usb 6008 to acquire signal online

조회 수: 3 (최근 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 CenterFile Exchange에서 Simultaneous and Synchronized Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by