Main Content

DataAcquisition

Interface to data acquisition device

Since R2020a

Description

The DataAcquisition object provides access to the devices of a specified vendor.

Creation

Use the daq function to create a DataAcquisition object.

Properties

expand all

Automatically Synchronize DSA devices, specified as a logical true or false. Use this property to enable or disable automatic synchronization between DSA (PXI or PCI) devices in the same DataAcquisition. By default automatic synchronization capability is disabled.

Example: true

Data Types: logical

This property is read-only.

Device channels, returned as an array of channel objects. Create channels with the functions addinput, addoutput, and addbidirectional.

Example: addinput(d,…)

This property is read-only.

Device clock connections, returned as an array of clock objects. Create clocks with the addclock function.

Example: addclock(d,…)

This property is read-only.

Device digital trigger connections, returned as an array of DigitalTrigger objects. Use the addtigger function to add digital triggers to the DataAcquisition.

Example: addtrigger(d,…)

Time allowed for occurrence of digital trigger, specified as a numeric value in seconds or a duration.

Example: 30

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | duration

Callback function to call when error occurs, specified as a function handle.

Example: @mycleanup

Data Types: function_handle

Control whether to log data to TDMS file, specified as true or false (default).

Example: dq.LogToDisk = true

Data Types: logical

Write mode for logging to TDMS file, specified as a string or character vector. The following values are supported:

  • "append" — Append data to existing file. Old data is retained; new data comes after old data in a new channel group.

  • "overwrite" — Overwrite existing file with new data. Old data is lost.

  • "new" — Create a new file. If the file already exists, an error occurs.

Example: dq.LogFileMode = "overwrite"

Data Types: char | string

Name of TDMS file to log data to, specified as a string or character vector. The default file name is of the format "recording_YYYYMMDD-HHMMSS.tdms".

Example: dq.LogFileName = "MyDataFile_2.tdms"

Data Types: char | string

This property is read-only.

Number of digital triggers remaining in run, returned as a double.

Example: 1

Data Types: double

Number of digital triggers per DataAcquisition run, returned as a double.

Example: 2

Data Types: double

This property is read-only.

Number of data scans acquired in background operation since the last start, returned as a uint64 value. This value is reset each time start is called, and does not reflect whether the scans have been read into MATLAB.

Example: 1000

Data Types: uint64

This property is read-only.

Number of data scans available for reading, returned as a uint64 value. These scans have been acquired by the device input channels in a background operation, but have not yet been read into MATLAB. The value decreases with each call to read; and is reset by a call to start.

Example: 1000

Data Types: uint64

This property is read-only.

Number of scans generated as device output, returned as a uint64 value.

Example: 1024

Data Types: uint64

This property is read-only.

Number of scans queued to the device output channels, returned as a uint64 value.

Example: 4000

Data Types: uint64

Data scan rate, specified as a numeric value of samples per second.

Example: 44100

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

This property is read-only.

Lower and upper scan rate limits, returned as a 1-by-2 vector of doubles indicating minimum and maximum allowed scan rates in samples per second. The scan rate limits depend on the hardware and its configurations. In devices that multiplex channels to a converter, the rate limit is impacted by the number of channels you use. For more information, see Sampling.

Example: [8000 192000]

Data Types: double

This property is read-only.

DataAcquisition running indication, returned as true or false.

Example: true

Data Types: logical

Callback function to execute when scans are available from the input channels, specified as a function handle

Example: @read

Data Types: function_handle

Number of acquired scans to trigger ScansAvailableFcn, specified as a numeric value. The function handle specified in ScansAvailableFcn executes every time ScansAvailableFcnCount scans are acquired from the input channels.

Example: 8000

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Callback function to execute when scan data is required for device output channels, specified as a function handle.

Example: @write

Data Types: function_handle

Number of queued scans to trigger ScansRequiredFcn, specified as a numeric value or "auto". The function handle specified in ScansRequiredFcn executes when NumScansQueued drops below the value specified in this property. If this is set to "auto", the value resets to a default.

Example: 2000

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | char | string

Custom data, specified as any MATLAB® data type and format.

Example: datetime('now')

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string | struct | table | cell | function_handle | categorical | datetime | duration | calendarDuration | fi

This property is read-only.

Data acquisition hardware vendor information, returned as a vendor object with the following properties:

ID
FullName
AdaptorVersion
DriverVersion
IsOperational

This object is the same as the corresponding vendor object returned by the daqvendorlist function.

This property is read-only.

Digital trigger waiting indication, returned as a logical.

Example: true

Data Types: logical

Object Functions

addinputAdd input channel to device interface
readRead data acquired by hardware
readwriteSimultaneously read and write device channel data
startStart DataAcquisition background operation
stopStop background operation
removechannelRemove channel from device interface
flushFlush DataAcquisition input and output buffers
writeWrite output scans to hardware channels
preloadQueue scan data for device output
addoutputAdd output channel to device interface
addbidirectionalAdd digital bidirectional channel to device interface
resetcountersReset hardware scan count for all counter inputs
addclockAdd clock connection to device interface
removeclockRemove clock from device interface
addtriggerAdd trigger connection to device interface
removetriggerRemove trigger from device interface

Examples

collapse all

Create and configure a DataAcquisition object for interfacing with National Instruments™ devices.

d = daq("ni")
d.Rate = 20000;

Version History

Introduced in R2020a

See Also

Functions