How to pause execution of push button until specific trigger received by NI device?

3 visualizaciones (últimos 30 días)
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 comentarios
Walter Roberson
Walter Roberson el 11 de Jun. de 2017
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)

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by