Main Content

Generate Signals on Both Analog and Digital Channels

This example shows how to generate signals when the DataAcquisition contains both analog and digital channels.

Discover NI devices connected to your system and find the ID for the NI 6255.

d = 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-6363" "USB-6363" [1×1 daq.ni.DeviceInfo]

Create a DataAcquisition and add two digital output lines from port0onDev1.

d = daq("ni"); addoutput(d,"Dev1","Port0/Line0:1","Digital")

Add an analog output channel fromDev1, then view all channels.

addoutput(d,'Dev1',0,'Voltage') d.Channels
ans = Index Type Device Channel Measurement Type Range Name _____ _____ ______ _____________ _____________________ __________________ __________________ 1 "dio" "Dev1" "port0/line0" "OutputOnly" "n/a" "Dev1_port0/line0" 2 "dio" "Dev1" "port0/line1" "OutputOnly" "n/a" "Dev1_port0/line1" 3 "ao" "Dev1" "ao0" "Voltage (SingleEnd)" "-10 to +10 Volts" "Dev1_ao0"

Output a single scan of data on both the digital and analog channels.

write(d, [decimalToBinaryVector(2), 1.23])