Giving commands parallel to the A-D converter (National Instruments) and the axes (PI).
1 view (last 30 days)
Show older comments
Is there a possibility, to send commands simultaneous to this two connected devices?
I am using a GUI. If I push the first checkbox, this code will run:
while(get(hObject,'Value'))
set(handles.X_POS,'String',num2str( eval(sprintf('%.4f',handles.Controller1.qPOS('1'))) )); %%request for the exact position of axis
pause(0.1);
end
and if I push the second box, that code starts:
while(get(hObject,'Value'))
[data,time] = handles.s.startForeground; %%request for voltage-datas of the last second (A-D converter)
pause(0.1);
end
If I push both checkboxes, one code stops directly.
So I would like to run it simulataneous.
Thank you in advance.
2 Comments
Walter Roberson
on 12 Nov 2019
eval() is single threaded only. You should probably use the round() function instead.
Walter Roberson
on 12 Nov 2019
Are the controllers both connected to the same device, or are they connect to different devices? And do you have access to the Parallel Computing Toolbox?
If they are connected to different device and you do have the Parallel Computing Toolbox then you can do what you are talking about, run the code simulatenously. It won't be the best of ideas, but it is possible, and sometimes people are unwilling to accept other solutions that do not involve the code running literally simultaneously.
Better would be to use timer function callbacks. You might only need one callback, especially if you switch to background operations instead of foreground operations.
Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!