Giving commands parallel to the A-D converter (National Instruments) and the axes (PI).

1 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2019-11-12
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by