online analysis on background data, ni card analog input

2 visualizaciones (últimos 30 días)
Ehsan
Ehsan el 14 de En. de 2019
Editada: Ehsan el 24 de En. de 2019
Hi,
I am trying to get access to a global variable that is updated in the listener function of a ''DataAvialable'' event, relating to the startbackground for NI card analog input.
It seems that neigther a global variable nor the "UserData" of the daq session object are not updated before stoping the background recording. Is there any way around this to get online access to a variable that is updated in the listener function while the recording is still running?
Thanks,
Ehsan

Respuestas (1)

Kenny Shu
Kenny Shu el 23 de En. de 2019
When the session's "UserData" variable is updated in the "DataAvailable" event callback, the result is immediately accessible from the workspace.
By setting up the listener as follows,
s1 = daq.createSession('ni');
s1.addAnalogOutputChannel('Dev1','ao1', 'Voltage');
s2 = daq.createSession('ni');
ch = s2.addAnalogInputChannel('Dev1','ai1', 'Voltage');
ch.TerminalConfig = 'SingleEnded';
s2.DurationInSeconds = 60;
lh = addlistener(s2, 'DataAvailable', @dataAvailableCallback);
s1.queueOutputData(linspace(0,10,30000)');
startBackground(s1)
startBackground(s2)
function dataAvailableCallback(src, event)
src.UserData = [src.UserData; event.Data];
end
you may access the live "UserData" while the acquisition continues in the background:
>> s2.UserData(end)
ans =
9.1314
  1 comentario
Ehsan
Ehsan el 23 de En. de 2019
Editada: Ehsan el 24 de En. de 2019
this doesn't work in the continuous mode.
s2.IsContinunous = true;

Iniciar sesión para comentar.

Categorías

Más información sobre Simultaneous and Synchronized Operations en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by