| Data Acquisition Toolbox™ | ![]() |
| On this page… |
|---|
You create a digital I/O (DIO) object with the digitalio function. digitalio accepts the adaptor name and the hardware device ID as input arguments. For parallel ports, the device ID is the port label (LPT1, LPT2, or LPT3). For data acquisition boards, the device ID refers to the number associated with the board when it is installed. Note that some vendors refer to the device ID as the device number or the board number. When using NI-DAQmx, this is usually a string such as 'Dev1'.) Use the daqhwinfo function to determine the available adaptors and device IDs.
Each DIO object is associated with one parallel port or one subsystem. For example, to create a DIO object associated with a National Instruments board:
dio = digitalio('nidaq','Dev1');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 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.
Table 8-1. Descriptive Digital I/O Properties
Property Name | Description |
|---|---|
Indicate the device object type. | |
Specify a descriptive name for the device object. |
You can display the values of these properties for dio with the get function.
get(dio,{'Name','Type'})
ans =
'nidaq1-DIO' 'Digital IO'The PC supports up to three parallel ports that are assigned the labels LPT1, LPT2, and LPT3. You can use any of these standard ports as long as they use the usual base addresses, which are (in hex) 378, 278, and 3BC, respectively. The port labels and addresses are typically configured through the PC's BIOS. Additional ports, or standard ports not assigned the usual base addresses, are not accessible by the toolbox.
Most PCs that support the MATLAB software will include a single parallel port with label LPT1 and base address 378. To create a DIO object for this port,
parport = digitalio('parallel','LPT1');Note The parallel port is not locked by the MATLAB workspace. Therefore, other applications or other instances of the MATLAB application can access the same parallel port, which can result in a conflict. |
Accessing the individual pins of the parallel port under Windows 2000 and Windows XP is a privileged operation. The Data Acquisition Toolbox software installs a driver called winio.sys that provides access to the parallel port pins. Normally, only users with administrator privileges can do this.
To allow users without administrator privileges to use the parallel port from the Data Acquisition Toolbox software:
At the MATLAB Command Window, type
daqhwinfo('parallel');On the desktop, select My Computer and right-click. Choose Properties from the menu that appears.
In the dialog box that appears, click the Hardware tab, and click the Device Manager button.
In the window that appears, select View > Show Hidden Devices, and expand the Non-Plug and Play Drivers item in the list.
Find the WINIO item near the bottom of the list. Double-click it, and click the Driver tab in the window that appears.
Expand the Startup Type drop-down list and change the entry from Demand to Boot. This causes the WINIO driver to start up every time the machine is rebooted.
Close all the open windows, including MATLAB, and restart your machine.
Users with standard or power-user privileges can now access the parallel port pins.
Note The Parallel adaptor will be deprecated in a future version of the toolbox. If you create a Data Acquisition Toolbox™ object for 'parallel' in R2008b, you will receive a warning stating that this adaptor will be removed in a future release. See the supported hardware page at www.mathworks.com/products/daq/supportedio.html for more information. |
![]() | Digital Input/Output | Adding Lines to a Digital I/O Object | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |