| Data Acquisition Toolbox | ![]() |
Creating a Digital I/O Object
You create a digital I/O object with the digitalio function. digitalio accepts the adaptor name and the hardware device ID as input arguments. For a list of supported adaptors, refer to The Hardware Driver Adaptor. The device ID refers to the number associated with your board when it is installed. Some vendors refer to the device ID as the device number or the board number. Use the daqhwinfo function to determine the available adaptors and device IDs.
Each digital I/O object is associated with one board and one digital I/O subsystem. For example, to create a digital I/O object associated with a National Instruments board with device ID 1
dio = digitalio('nidaq',1);
The digital I/O object dio now exists in the MATLAB workspace. You can display the class of dio with the whos command.
whos dio Name Size Bytes Class dio 1x1 1308 digitalio object Grand total is 40 elements using 1308 bytes
Once the digital I/O object is created, the properties listed below are automatically assigned values. These general purpose properties provide descriptive information about the object based on its class type and adaptor.
| Property Name |
Description |
Name |
Specify a descriptive name for the device object. |
Type |
Indicate the device object type. |
You can display the values of these properties for dio with the get function.
get(dio,{'Name','Type'})
ans =
'nidaq1-DIO' 'Digital IO
| Digital Input/Output | Adding Lines to a Digital I/O Object | ![]() |