Start DataAcquisition background operation
start( starts the DataAcquisition interface
background operation. When the input acquisition and output generation begin depends on
channel configuration and preloaded output data:
If the DataAcquisition has only input channels, the acquisition begins immediately, collecting scan data, which you can access later with the
readfunction. The default scan duration is 1 second.
If the DataAcquisition interface has only output channels, generation begins immediately if data is already queued with the
preloadfunction. If no data is queued, output begins when data is made available with
If the DataAcquisition has both input and output channels, the input acquisition begins and ends at the same time as the output generation, resulting in the same number of scans.
start( starts the background
operation running continuously. If there is data already available from the
preload function, output generation begins immediately along with
acquisition on any input channels. Otherwise, acquisition begins when you execute
write. The operation continues until you call
stop. As output scan data is generated or input scan data is
acquired, you might need to call
while the DataAcquisition is still running.
start( starts the background
operation, generating periodic output in a repeating loop of the output scan data. If there
is data already available from the
preload function, output generation
begins immediately along with acquisition on any input channels. Otherwise, generation and
acquisition begin when you execute
write. The operation continues until
stop. If input scan data is being acquired, you might need to
read while the DataAcquisition is still running.
starts the background input acquisition to run for a finite span of time, specified as
either a duration or a number of scans. If the DataAcquisition has any output channels, the
start occurs but the duration specification is ignored.
Read Data from a Background Acquisition
When a background acquisition is initiated with the
start function, use
read to import the
d = daq("ni"); ch = addinput(d,"Dev1",1:2,"Voltage") start(d,"NumScans",5)
Background operation has started. Background operation will stop after 0.005 s. To read acquired scans, use read.
scanData = read(d,"all")
scanData = 5×2 timetable Time Dev1_ai1 Dev1_ai2 _________ ________ ________ 0 sec 0.012466 0.023977 0.001 sec 0.019373 0.023319 0.002 sec 0.021017 0.02299 0.003 sec 0.021346 0.02299 0.004 sec 0.022661 0.023648
Generate a Repeating Signal in the Background
Define and preload data for device output, then start output generation to repeat in the background while MATLAB continues.
d = daq("ni"); addoutput(d,"Dev1",1,"Voltage"); signalData = sin((1:1000)*2*pi/1000); preload(d,signalData') % Column of data for one channel start(d,"RepeatOutput") % Device output now repeated while MATLAB continues. stop(d)
span — Length of background operation
duration | double
Length of background operation, specified as a duration or double. For
"Duration" specify a duration type; for
"NumScans" specify a double for the number of scans. The default is
Introduced in R2020a
- Generate Signals in the Background
- Generate Signals in the Background Continuously
- Generate Continuous and Background Signals Using NI Devices
- Acquire Continuous and Background Data Using NI Devices
- Log Analog Input Data to a File Using NI Devices
- Communicate with I2C Devices and Analyze Bus Signals Using Digital IO
- Generate Pulse Width Modulated Signals Using NI Devices
- Acquire Continuous Audio Data
- Create an Echometer Using Audio Measurements
- Acquire Data from Two Devices at Different Rates