Create DataAcquisition Interface
R2026bThis example shows how to create a DataAcquisition
interface object and add channels to acquire and generate data. You can also configure
the DataAcquisition object with the channel properties needed for your
operations.
Find Devices Based on Vendor
View all the available NI devices on your system using the daqlist
function.
daqlist("ni") 2×4 table
DeviceID Description Model DeviceInfo
________ ___________________________________ __________ _______________________
"Dev2" "National Instruments(TM) USB-6509" "USB-6509" [1×1 daq.ni.DeviceInfo]
"Dev3" "National Instruments(TM) USB-6211" "USB-6211" [1×1 daq.ni.DeviceInfo]Create DataAcquisition Object
Create a DataAcquisition object d for a NI device
using the daq
function.
d = daq("ni")DataAcquisition using National Instruments(TM) hardware:
Running: 0
Rate: 1000
NumScansAvailable: 0
NumScansAcquired: 0
NumScansQueued: 0
NumScansOutputByHardware: 0
RateLimit: []After you create a DataAcquisition object, add channels using the
addinput and
addoutput
functions.
Add Channels to DataAcquisition Object
Add an analog input channel, and view the DataAcquisition channel
list:
addinput(d,"Dev3","ai0","Voltage") d.Channels
Index Type Device Channel Measurement Type Range Name TEDS Enabled
_____ ____ ______ _______ ________________ __________________ __________ ____________
1 "ai" "Dev3" "ai0" "Voltage (Diff)" "-10 to +10 Volts" "Dev3_ai0" "false"Change Channel Properties
Change the TerminalConfig channel property to
'SingleEnded', and view the updated configuration. For more
information, see Channel Properties.
d.Channels.TerminalConfig = "SingleEnded";
d.Channels Index Type Device Channel Measurement Type Range Name TEDS Enabled
_____ ____ ______ _______ _____________________ __________________ __________ ____________
1 "ai" "Dev3" "ai0" "Voltage (SingleEnd)" "-10 to +10 Volts" "Dev3_ai0" "false"