Hello,
I am currently developing software for a vision based SMT pick and place machine. I have made a GUI in MATLAB that has continous video display and is able to communicate to the stepper motors in the machine through serial commands. The problem I am having is that I am unable to have the video display running whilst communicating to the motion controller to move the stepper motors. The relevant sections of the code are as follows:
1) Video Display Function:
if truefunction startStopCamera_Callback(hObject, eventdata, handles) set(handles.vid,'FramesPerTrigger',1); set(handles.vid,'TriggerRepeat',Inf); triggerconfig(handles.vid, 'manual'); start(handles.vid); while 1 trigger(handles.vid); RGB = getdata(handles.vid,1); subimage(RGB); end end
2) Stepper Motor Serial Communication:
if truefunction AutoStart_Callback(hObject, eventdata, handles) s = serial(serial_port_string); % COM4
fopen(s); for w = 1:rows fprintf(s,Loaded_Data{w}); % Loaded_Data is array of coordinate
fprintf(s,'PD2000;'); % 2 sec time delay command
end fclose(s);end
The problem is me being unable to run both at the same time. Say I start the camera video display and then click the button which iterates through Loaded_Data to go to the specified coordinates, what happens is the camera stops updating, the motors move and after the for loop is finished the camera starts updating.
This is a big problem to me as I need to be able to see the pick and place machine video whilst the stepper motors are moving.
I bought the Parallel Toolbox yesterday hoping it would solve the problem and I have tried parfor but not sure if this is what I am looking for.
Your help would be really appreciated.
Kind Regards,
Mo
Best Answer