Main Content

start

Start DataAcquisition background operation

Description

example

start(d)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 thereadfunction. The default scan duration is 1 second.

  • If the DataAcquisition interface has only output channels, generation begins immediately if data is already queued with thepreloadfunction. If no data is queued, output begins when data is made available withwritefunction.

  • 如果DataAcquisition同时具有输入和输出通道,则输入采集与输出生成同时开始和结束,从而导致相同数量的扫描。

start(d,"Continuous")启动背景操作连续运行。如果已经有数据preloadfunction, output generation begins immediately along with acquisition on any input channels. Otherwise, acquisition begins when you executewrite. The operation continues until you callstop. As output scan data is generated or input scan data is acquired, you might need to callwrite或者readwhile the DataAcquisition is still running.

start(d,"RepeatOutput")starts the background operation, generating periodic output in a repeating loop of the output scan data. If there is data already available from thepreloadfunction, output generation begins immediately along with acquisition on any input channels. Otherwise, generation and acquisition begin when you executewrite. The operation continues until you callstop. If input scan data is being acquired, you might need to callreadwhile the DataAcquisition is still running.

start(d,“期间”,span)或者start(d,"NumScans",span)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.

Examples

collapse all

When a background acquisition is initiated with thestart功能,使用read导入数据。

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,“全部”)
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

为设备输出定义和预加载数据,然后开始在MATLAB继续时在后台重复输出生成。

d = daq("ni"); addoutput(d,"Dev1",1,"Voltage"); signalData = sin((1:1000)*2*pi/1000); preload(d,signalData')% Column of data for one channelstart(d,"RepeatOutput")% Device output now repeated while MATLAB continues.stop(d)

Input Arguments

collapse all

DataAcquisition接口, specified as aDataAcquisitionobject, created using thedaqfunction.

Example:d = daq()

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 1 second.

Example:seconds(5)

Data Types:double|duration

Version History

Introduced in R2020a

See Also

Functions