Creating and Connecting Device Objects
Device Objects for MATLAB Interface Drivers
Create a MATLAB® device object to communicate with a Tektronix® TDS 210 Oscilloscope. To communicate with the scope you will use a National Instruments™ GPIB controller.
First create an interface object for the GPIB hardware. The following command creates a GPIB object for a National Instruments GPIB board at index 0 with an instrument at primary address 1.
g = gpib('ni',0,1);
Now that you have created the interface object, you can construct a device object that uses it. The command to use is
icdevice. You need to supply the name of the instrument driver,
tektronix_tds210, and the interface object created for the GPIB controller,
d = icdevice('tektronix_tds210', g);
You can use the
whos command to display the
size and class of
whos d Name Size Bytes Class d 1x1 652 icdevice object Grand total is 22 elements using 652 bytes
Device Object Properties
A device object has a set of base properties and a set of properties
defined by the driver. All device objects have the same base properties,
regardless of the driver being used. The driver properties are defined
by the driver specified in the
Device Object Display
Device objects provide you with a convenient display that summarizes important object information. You can invoke the display in these ways:
Type the name of the device object at the command line.
Exclude the semicolon when creating the device object.
Exclude the semicolon when configuring properties using dot notation.
Pass the object to the
display summary for device object
Instrument Device Object Using Driver : tektronix_tds210.mdd Instrument Information Type: Oscilloscope Manufacturer: Tektronix Model: TDS210 Driver Information DriverType: MATLAB interface object DriverName: tektronix_tds210.mdd DriverVersion: 1.0 Communication State Status: open
You can also display summary information via the Workspace browser by right-clicking a device object and selecting Display Summary from the context menu.
Device Objects for VXIplug&play and IVI Drivers
Creating the MATLAB Instrument Driver
The command-line function
a MATLAB instrument driver from a VXIplug&play or
IVI-C driver, saving the new driver in a file on disk. The syntax
driver is the original VXIplug&play or
IVI-C driver name (identified by
the Test & Measurement Tool), and
the file containing the newly created MATLAB instrument driver.
page for a full description of the function and all its options.
You can open the new driver in the MATLAB Instrument Driver Editor, and then modify and save it as required.
Creating the Device Object
After you create the MATLAB instrument driver by conversion,
you create the device object with the filename of the new driver as
an argument for
For example, if the driver is created from a VXIplug&play or IVI-C driver,
obj = icdevice('ConvertedDriver.mdd','GPIB0::2::INSTR')
Connecting the Device Object
Now that you have created the device object, you can connect
it to the instrument with the
To connect the device object,
d, created in the
last example, use the following command:
By default, the property settings are updated to reflect the
current state of the instrument. You can modify the instrument settings
to reflect the device object's property values by passing an optional
update parameter to
connect. The update parameter
can be either
To have the instrument updated to the object's property values, the
from the previous example would be
connect is successful, the device object's
status property is set to
open; otherwise it remains
closed. You can check the status of this property
get function or
by looking at the object display.
d.status ans = open