MATLAB: Error message not connected

serial motor connected

Hellow, im working with two motors for a project and they are connected via the Control instrument toolbox. Now i have used it in my gui, so the motor connect before the figure is shown. So in the function density_CreateFcn. But know, there must be a fault message when the gui starts and the motors arent connected properly. Anyone who has experience with this? Thx in advance

Best Answer

t = serial(...) % Try to open the connections.
u = serial(...)
try
fopen(...)
catch
errordlg('First Motor not connected properly.', 'Connect Error');
end
try
fopen(...)
catch
errordlg('Second Motor not connected properly.', 'Connect Error');
end
Now you should put a pushbutton on the GUI which has the same above code in the callback. Perhaps one pushbutton for each motor.
Related Question