Simultaneous Video Display with continuous serial communication
显示 更早的评论
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 true
function 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 true
function 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
1 个评论
Mariam Castañeda
2016-7-15
Hi! I know this is a topic from 2013 but I have the same problem now lol. Do you found an answer? I'm pretty stressed right now because I cannot make the buttons of my GUI responds with a while that use the camera, the while cycled and the buttons never respond. Any solution I'll appreciate.
采纳的回答
更多回答(1 个)
1 个评论
David Tarkowski
2013-4-9
Did you use GUIDE to create your GUI? If so, you probably need to change the 'HandleVisibility' property for the figure to make it accessible from the FramesAcquiredFcn callback. You can see Doug's tutorial for more information.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Preview and Device Configuration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!