Data Acquisition Toolbox | ![]() ![]() |
Adding Lines to a Digital I/O Object
After creating the digital I/O (DIO) object, you must add lines to it. As shown by the figure in Adding Channels or Lines, you can think of a device object as a container for lines. The collection of lines contained by the DIO object is referred to as a line group. A line group consists of a mapping between hardware line IDs and MATLAB indices (see below).
When adding lines to a DIO object, you must follow these rules:
You add lines to a digital I/O object with the addline
function. addline
requires the device object, at least one hardware line ID, and the direction (input or output) of each added line as input arguments. You can optionally specify port IDs, descriptive line names, and an output argument. For example, to add eight output lines from port 0 to the device object dio
created in the preceding section:
The output argument hwlines
is a line object that reflects the line group contained by dio
. You can display the class of hwlines
with the whos
command.
whos hwlines Name Size Bytes Class hwlines 8x1 536 dioline object Grand total is 13 elements using 536 bytes
You can use hwlines
to easily access lines. For example, you can configure or return property values for one or more lines. As described in Referencing Individual Hardware Lines, you can also access lines with the Line
property.
Once you add lines to a DIO object, the properties listed below are automatically assigned values. These properties provide descriptive information about the lines based on their class type and ID.
Property Name |
Description |
HwLine |
Specify the hardware line ID. |
Index |
Indicate the MATLAB index of a hardware line. |
Parent |
Indicate the parent (device object) of a line. |
Type |
Indicate a line. |
You can display the values of these properties for chans
with the get
function.
get(hwlines,{'HwLine','Index','Parent','Type'}) ans = [0] [1] [1x1 digitalio] 'Line' [1] [2] [1x1 digitalio] 'Line' [2] [3] [1x1 digitalio] 'Line' [3] [4] [1x1 digitalio] 'Line' [4] [5] [1x1 digitalio] 'Line' [5] [6] [1x1 digitalio] 'Line' [6] [7] [1x1 digitalio] 'Line' [7] [8] [1x1 digitalio] 'Line'
![]() | The Parallel Port | Line and Port Characteristics | ![]() |