usb 6008 to acquire signal online

2 vues (au cours des 30 derniers jours)
mado
mado le 28 Jan 2014
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 commentaires
Walter Roberson
Walter Roberson le 28 Jan 2014
What is the question? Are you encountering an error?
mado
mado le 28 Jan 2014
Modifié(e) : mado le 28 Jan 2014
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.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 28 Jan 2014
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.

Catégories

En savoir plus sur Simultaneous and Synchronized Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by