Documentation Center

  • Trial Software
  • Product Updates

digitalio

Create digital I/O object

Syntax

DIO = digitalio('adaptor',ID)

    Note:   You cannot use the legacy interface on 64–bit MATLAB®. See Session-Based Interface to acquire and generate data.

Arguments

'adaptor'

The hardware driver adaptor name. The supported adaptors are advantech, mcc, nidaq, and parallel.

ID

The hardware device identifier.

DIO

The digital I/O object.

Description

DIO = digitalio('adaptor',ID) creates the digital I/O object DIO for the specified adaptor and for the hardware device with device identifier ID. ID can be specified as an integer or a string.

    Notes   The Traditional NI-DAQ adaptor will be deprecated in a future version of the toolbox. If you create a Data Acquisition Toolbox™ object for Traditional NI-DAQ adaptor beginning in R2008b, you will receive a warning stating that this adaptor will be removed in a future release.

    The Parallel adaptor will be deprecated in a future version of the toolbox. If you create a Data Acquisition Toolbox™ object for 'parallel' beginning 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.

Properties

Common Properties

LineContain hardware lines added to device object
NameSpecify descriptive name for the channel
RunningIndicate whether device object is running
TagSpecify device object label
TimerFcnSpecify callback function to execute when predefined time period passes
TimerPeriodSpecify time period between timer events
TypeIndicate device object type, channel, or line
UserDataStore data to associate with device object

Line Properties

DirectionSpecify whether line is for input or output
HwLineSpecify hardware line ID
IndexMATLAB index of hardware channel or line
LineNameSpecify descriptive line name
ParentIndicate parent (device object) of channel or line
PortSpecify port ID
TypeIndicate device object type, channel, or line

Examples

Create a digital I/O object for a National Instruments® device defined as 'Dev1'.

DIO = digitalio('nidaq','Dev1');

Create a digital I/O object for a Measurement Computing™ device defined as '1'.

DIO = digitalio('mcc','1');

Create a digital I/O object for parallel port LPT1.

DIO = digitalio('parallel','LPT1');

More About

expand all

Tips

More About Creating Digital I/O Objects

  • When a digital I/O object is created, it does not contain any hardware lines. To execute the device object, hardware lines must be added with the addline function.

  • You can create multiple digital I/O objects that are associated with a particular digital I/O subsystem. However, you can execute only one of these digital I/O objects at a time for the generation of timing events.

  • The digital I/O object exists in the data acquisition engine and in the MATLAB workspace. If you create a copy of the device object, it references the original device object in the engine.

  • The Name property is automatically assigned a descriptive name that is produced by concatenating adaptor, ID, and -DIO. You can change this name at any time.

    Note:   When you create a digital input or output object, it consumes system resources. To avoid this issue, make sure that you do not create objects in a loop. If you must create objects in a loop, make sure you delete them within the loop.

The Parallel Port Adaptor

The toolbox provides basic DIO capabilities through the parallel port. The PC supports up to three parallel ports that are assigned the labels LPT1, LPT2, and LPT3. You can use only these ports. If you add additional ports to your system, or if the standard ports do not use the default memory resources, they will not be accessible by the toolbox. For more information about the parallel port, refer to Parallel Port Characteristics.

More About the Hardware Device Identifier

When data acquisition devices are installed, they are assigned a unique number, which identifies the device in software. The device identifier is typically assigned automatically and can usually be manually changed using a vendor-supplied device configuration utility. National Instruments refers to this number as the device number.

There are two ways you can determine the ID for a particular device:

  • Type daqhwinfo('adaptor').

  • Open the vendor-supplied device configuration utility.

See Also

| |

Was this topic helpful?