フィルターのクリア

online analysis on background data, ni card analog input

2 ビュー (過去 30 日間)
Ehsan
Ehsan 2019 年 1 月 14 日
編集済み: Ehsan 2019 年 1 月 24 日
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

回答 (1 件)

Kenny Shu
Kenny Shu 2019 年 1 月 23 日
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 件のコメント
Ehsan
Ehsan 2019 年 1 月 23 日
編集済み: Ehsan 2019 年 1 月 24 日
this doesn't work in the continuous mode.
s2.IsContinunous = true;

サインインしてコメントする。

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by