Main Content

addbidirectional

Add digital bidirectional channel to device interface

Since R2020a

Description

addbidirectional(d,deviceID,channelID,"Digital") adds the digital bidirectional channel channelID of device deviceID to the specified DataAcquisition interface, d.

The channel information is available from the DataAcquisition Channels property.

ch = addbidirectional(___) adds the channel and returns a channel object.

[ch,idx] = addbidirectional(___) adds the channel and also returns the channel index from the DataAcquisition interface. The channel index reflects only the sequence in which channels are added to the DataAcquisition; not to be confused with the device channel ID.

example

Examples

collapse all

Add bidirectional digital channels to a DataAcquisition, and use indices to view their settings.

d = daq("ni");
ch1 = addbidirectional(d,"Dev1","port0/line0","Digital");
[ch2,idx2] = addbidirectional(d,"Dev1","port0/line1","Digital");
d.Channels
    Index    Type     Device       Channel          Measurement Type        Range           Name       
    _____    _____    ______    _____________    _______________________    _____    __________________

      1      "dio"    "Dev1"    "port0/line0"    "Bidirectional (Input)"    "n/a"    "Dev1_port0/line0"
      2      "dio"    "Dev1"    "port0/line1"    "Bidirectional (Input)"    "n/a"    "Dev1_port0/line1"

Access one of the channel settings using its index.

d.Channels(idx2).ID
    'port0/line1'

Input Arguments

collapse all

DataAcquisition interface, specified as a DataAcquisition object, created using the daq function.

Example: d = daq()

Device ID specified as a character vector or string, as defined by the device vendor. Obtain the device ID by calling daqlist.

Example: "Dev1"

Data Types: char | string

Channel ID specified as a numeric value, character vector, or string; often indicating the physical location of the channel on the device. Supported values are specific to the vendor and device. You can add multiple channels by specifying the channel ID as a numeric vector, or a cell array of character vectors. The index returned for this channel in the DataAcquisition display indicates the position of this channel. This channel ID is not the same as channel index in the DataAcquisition: if you add a channel with ID 2 as the first channel in a DataAcquisition, the DataAcquisition channel index is 1.

Example: "port1/line1"

Data Types: char | string | numeric | cell

Output Arguments

collapse all

Channel, returned as a DigitalBidirectionalChannel object with the following properties as described in Channel Properties:

Device
Direction
ID
MeasurementType
Name

Channel index returned as a numeric value. With this index, you can access the array of the DataAcquisition Channels property.

Version History

Introduced in R2020a

See Also

Functions

Properties