Main Content

Generate Digital Output Using Decimal Data Across Multiple Lines

This example shows how to convert decimal data and output to two lines on an NI 6255.

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 port 0 on Dev1.

d = daq("ni");
addoutput(d,"Dev1","Port0/Line0:1","Digital");
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"

Convert the decimal number 2 to a binary vector, and generate that digital output value on the two lines.

write(d,decimalToBinaryVector(2))