Data Acquisition Toolbox | ![]() ![]() |
Creating a Device Object
Device objects are the toolbox components you use to access your hardware device. They provide a gateway to the functionality of your hardware, and allow you to control the behavior of your data acquisition application. Each device object is associated with a specific hardware subsystem.
To create a device object, you call M-file functions called object creation functions (or object constructors). These M-files are implemented using the object-oriented programming capabilities provided by MATLAB, which are described in MATLAB Classes and Objects in the Help browser. The device object creation functions are listed below.
Function |
Description |
analoginput |
Create an analog input object. |
analogoutput |
Create an analog output object. |
digitalio |
Create a digital I/O object. |
Before you can create a device object, the associated hardware driver adaptor must be registered. Adaptor registration occurs automatically. However, if for some reason an adaptor is not automatically registered, then you must do so manually with the daqregister
function. Refer to Registering the Hardware Driver Adaptor for more information.
You can find out how to create device objects for a particular vendor and subsystem with the ObjectConstructorName
field of the daqhwinfo
function. For example, to find out how to create an analog input object for an installed National Instruments board, you supply the appropriate adaptor name to daqhwinfo
.
out = daqhwinfo('nidaq'); out.ObjectConstructorName(:) ans = 'analoginput('nidaq',1)' 'analogoutput('nidaq',1)' 'digitalio('nidaq',1)'
The constructor syntax tells you that you must supply the adaptor name and the hardware ID to the analoginput
function
The association between device objects and hardware subsystems is shown below.
![]() | Overview | Creating an Array of Device Objects | ![]() |