DataAcquisition
Interface to data acquisition device
Description
The DataAcquisition
object provides access to the devices of a
specified vendor.
Creation
Use the daq
function to
create a DataAcquisition
object.
Properties
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. The default value is 1/10 the rate and the lower limit is 1/20 the rate of the
corresponding DataAcquisition
object.
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.
The default value is 1/2 the rate and the lower limit is 1/20 the rate of the
corresponding DataAcquisition
object. If this property is set to
"auto"
, it resets to the default value.
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
addinput | Add input channel to device interface |
read | Read data acquired by hardware |
readwrite | Simultaneously read and write device channel data |
start | Start DataAcquisition background operation |
stop | Stop background operation |
removechannel | Remove channel from device interface |
flush | Flush DataAcquisition input and output buffers |
write | Write output scans to hardware channels |
preload | Queue scan data for device output |
addoutput | Add output channel to device interface |
addbidirectional | Add digital bidirectional channel to device interface |
resetcounters | Reset hardware scan count for all counter inputs |
addclock | Add clock connection to device interface |
removeclock | Remove clock from device interface |
addtrigger | Add trigger connection to device interface |
removetrigger | Remove trigger from device interface |
Examples
Create and configure a DataAcquisition
object for
interfacing with National Instruments™ devices.
d = daq("ni")
d.Rate = 20000;
Version History
Introduced in R2020a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)