How to pause execution of push button until specific trigger received by NI device?
3 次查看(过去 30 天)
显示 更早的评论
I have a user interface (GUIDE) in which the user is supposed to press a push button to initiate analog output to NI devices:
NIao = daq.createSession('ni');
addAnalogOutputChannel(NIao, 'Dev1', ['ao', handles.laser.port], 'Voltage');
NIao.Rate = 1000;
warning('off', 'all')
In my setting, I need the user to press the push button and then I need the program to wait with the execution until it receives an input trigger from the NI device. I thought I could use startForeground(s) for the input from the NI device:
NIai=daq.createSession('ni');
addAnalogInputChannel(NIai,'Dev1',1,'Voltage');
NIai.Rate = 1000;
startForeground(NIai)
which would then block the following code, that is, the output, from being executed:
queueOutputData(NIao, handles.laser.laserAna);
NIao.startBackground();
However, I am not sure how to define the session operation as "complete" since I need it to wait for a certain input (trigger) from the NI device, that is, a reduction in voltage to ~ 0 V. But perhaps waitfor would also be a work around?
Thank you in advance.
3 个评论
Walter Roberson
2017-6-11
Could you post your adjusted code, as an example for others? (It would make sense to post it as an Answer to your own Question)
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!