Main Content
Acquire Digital Data in Hexadecimal Values
This example shows how to acquire digital data using four channels on an NI 6255.
Discover devices connected to your system and find the ID for the NI 6255.
dev = daqlist
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-6363" "USB-6363" [1×1 daq.ni.DeviceInfo]
Create a DataAcquisition and add four digital input lines from port
0
on Dev1
.
d = daq("ni"); addinput(d,"Dev1","Port0/Line0:3","Digital"); d.Channels
ans = 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" 3 "dio" "Dev1" "port0/line2" "InputOnly" "n/a" "Dev1_port0/line2" 4 "dio" "Dev1" "port0/line3" "InputOnly" "n/a" "Dev1_port0/line3"
Acquire digital data in hexadecimal values.
hData = binaryVectorToHex(read(d,"OutputFormat","Matrix"))
hData = 'C'