Add hardware lines to digital I/O object
lines = addline(obj,hwline,'direction')
lines = addline(obj,hwline,port,'direction')
lines = addline(obj,hwline,'direction','names')
lines = addline(obj,hwline,port,'direction','names')
Note: You cannot use the legacy interface on 64-bit MATLAB®. See Working with the Session-Based Interface to acquire and generate data on a 64-bit MATLAB.
A digital I/O object.
The numeric IDs of the hardware lines added to the device object. Any MATLAB vector syntax can be used.
The line directions can be In or Out, and can be specified as a single value or a cell array of values.
The numeric IDs of the digital I/O port.
A descriptive line name or cell array of descriptive line names.
A column vector of lines with the same length as hwline.
lines = addline(obj,hwline,'direction') adds the hardware lines specified by hwline to the digital I/O object obj. direction configures the lines for either input or output. lines is a row vector of lines.
lines = addline(obj,hwline,port,'direction','names') adds the hardware lines specified by hwline from the port specified by port to the digital I/O object obj. direction configures the lines for either input or output. names is a descriptive line name or cell array of descriptive line names.
You cannot configure lines independently on devices that use the NI-DAQmx adaptor. Refer to Line and Port Characteristics for more information about line configurable devices.
Create the digital I/O object dio and add the first four hardware lines (line IDs 0-3) from port 0.
dio = digitalio('nidaq','Dev1'); addline(dio,0:3,'in');
These lines are automatically assigned the indices 1-4. If you want to add the first four hardware lines to dio and assign descriptive names to the lines,
Note that you can use the makenames function to create a cell array of line names. You can add the first four hardware lines (line IDs 0-3) from port 1 to the existing line group.
The new lines are automatically assigned the indices 5-8.
The numeric values you supply for hwline depend on the hardware you access. For National Instruments® and Measurement Computing™ hardware, line IDs are "zero-based" (begin at zero).
You can add a line only once to a given digital I/O object.
Hardware line IDs are stored in the HwLine property and the associated MATLAB indices are stored in the Index property.
For a single call to addline, you can add multiple lines from one port or the same line ID from multiple ports. You cannot add multiple lines from multiple ports.
If a port ID is not explicitly referenced, lines are added first from port 0, then from port 1, and so on.
You can specify the line directions as a single value or a cell array of values. If a single direction is specified, then all added lines have that direction. If supported by the hardware, you can configure individual lines by supplying a cell array of directions.
Every hardware line contained by a device object has an associated MATLAB index that is used to reference the line. Index assignments are made automatically by addline and follow these rules:
If no hardware lines are contained by the device object, then the assigned indices automatically start at one and increase monotonically. If hardware lines have already been added to the device object, then the assigned indices automatically start at the next highest index value and increase monotonically.
The resulting indices begin at one and increase monotonically up to the size of the line group.
The first indexed line represents the least significant bit (LSB) and the highest indexed line represents the most significant bit (MSB).
You can assign hardware lines descriptive names, which are stored in the LineName property. Choosing a unique descriptive name can be a useful way to identify and reference lines. For a single call to addline, you can
Specify one line name that applies to all lines that are to be added
Specify a different name for each line to be added
If the number of names specified in a single addline call is more than one but differs from the number of lines to be added, then an error is returned. If a line is to be referenced by its name, then that name must not contain symbols. If you are naming a large number of lines, then the makenames function might be useful. If a line is not assigned a descriptive name, then it must be referenced by index.