Start background operations
When you use
startBackground(s) with analog
input channels, the operation uses the
to deliver the acquired data. This event is fired periodically while
an acquisition is in progress. For more information, see Event and Listener Concepts (MATLAB).
When you add analog output channels to the session, you must
queueOutputData() before calling
During a continuous generation, the
is fired periodically to request additional data to be queued to the
DataRequired for more information.
By default, the
IsContinuous property is
false and the operation stops automatically.
If you have set it to
stop to stop background
block MATLAB execution until a background operation is complete.
Create an acquisition session and add a channel before
you use this method. See
If your session has analog input channels, you must
DataAvailable event to receive the acquired
data in a background acquisition.
If your session has analog output channels and is
continuous, you can use a
DataRequired event to
queue additional data during background generations.
reduce the latency associated with startup and to preallocate resources.
ErrorOccurred event to display
errors during an operation.
Create a session and add a listener. Use the listener callback function to access the acquired data.
s = daq.createSession('ni'); addAnalogInputChannel(s,'cDAQ1Mod1','ai0','Voltage'); lh = addlistener(s,'DataAvailable',@plotData); function plotData(src,event) plot(event.TimeStamps,event.Data) end
Start the session and perform other MATLAB® operations.
Perform other MATLAB operations.
For a continuous background generation, add a listener event to queue additional data to be output.
s = daq.createSession('ni'); addAnalogOutputChannel(s,'cDAQ1Mod2',0,'Voltage'); s.IsContinuous = true; s.Rate=10000; data=linspace(-1,1,5000)'; lh = addlistener(s,'DataRequired', ... @(src,event) src.queueOutputData(data)); queueOutputData(s,data) startBackground(s);
Perform other MATLAB operations during the generation.
s— Data acquisition session
Data acquisition session, specified as a session object. Create
the session object using
Use the data acquisition session for acquisition and generation operations.
Create one session per vendor and use that vendor session to perform
all data acquisition operations.