Acquire Non-Clocked Digital Data
This example shows how to read digital data using two channels on an NI USB-6255
Discover NI devices connected to your system and find the ID for the NI 6255:
dev = daqlist("ni")
dev = 3×4 table DeviceID Description Model DeviceInfo ________ ___________________________________ __________ _______________________ "Dev1" "National Instruments(TM) USB-6255" "USB-6255" [1×1 daq.ni.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 a DataAcquisition object and add two input lines from port
0
on Dev1
:
d = daq("ni"); ch = addinput(d,"Dev1","Port0/Line0:1","Digital")
ch = Index Type Device Channel Measurement Type Range Name _____ _____ ______ _____________ ________________ _____ __________________ 1 "dio" "Dev1" "port0/line0" "InputOnly" "n/a" "Dev1_port0/line0" 2 "dio" "Dev1" "port0/line1" "InputOnly" "n/a" "Dev1_port0/line1"
Acquire a single scan of digital data from both channels:
data = read(d,"OutputFormat","Matrix")
data = 1 0