usb 6008 to acquire signal online

2 ビュー (過去 30 日間)
mado
mado 2014 年 1 月 28 日
回答済み: Walter Roberson 2014 年 1 月 28 日
i am using usb 6008 to acquire signal using this code and i want to use the signal in a process in m file while reading
%%get connected devices
d = daq.getDevices
%create session
s = daq.createSession('ni')
%add analog channel s.addAnalogInputChannel('ID',channel num, 'measurement type')
s.addAnalogInputChannel('dev1','ai0', 'Voltage')
% set rate of scan 4 scans/second , run for 30 seconds
s.Rate=1000;
s.DurationInSeconds=30;
v= s.Channels(1);
set(v)
%_____________________________
v.TerminalConfig = ' Differential';
v.Coupling = ' DC';
%start continuous aquisition and plot
h = s.addlistener('DataAvailable', @(src,event) plot(event.TimeStamps, event.Data));
s.NotifyWhenDataAvailableExceeds = 200;
s.startBackground()
s.wait()
delete (h)
h = s.addlistener('DataAvailable', @storedata);s.NotifyWhenDataAvailableExceeds = 200;
s.startBackground()
  2 件のコメント
Walter Roberson
Walter Roberson 2014 年 1 月 28 日
What is the question? Are you encountering an error?
mado
mado 2014 年 1 月 28 日
編集済み: mado 2014 年 1 月 28 日
there is no error , i want to use the signal in a process in m file while reading . on this status now i got the data after finishing reading .this code can't give results for other operations before finishing reading.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 1 月 28 日
The addlistener calls show you how you can proceed, with two examples given. The first is for the case where you want to plot as you go along, and the second is for the case where you want to store the data as you go along. You could use a different listener that did whatever you needed to do.
The s.wait() is the call that results in the command line waiting until s.DurationInSeconds worth of data has been plotted. If that wait is not there then the data will be served up by the listener calls starting any time after s.startBackground is called. If you let the duration of collecting be infinite then you can go ahead and make whatever calls you need, with the listener called as s.NotifyWhenDataAvailableExceeds measurements become available.

カテゴリ

Help Center および File ExchangeSimultaneous and Synchronized Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by