| Contents | Index |
| On this page… |
|---|
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, g.
d = icdevice('tektronix_tds210', g);You can use the whos command to display the size and class of d.
whos d Name Size Bytes Class d 1x1 652 icdevice object Grand total is 22 elements using 652 bytes
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 icdevice constructor.
You can display the current values of all properties for d with the get command.
get(d)
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 disp or display function.
The display summary for device object d is given below.
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: openYou can also display summary information via the Workspace browser by right-clicking a device object and selecting Display Summary from the context menu.
The command-line function makemid creates a MATLAB instrument driver from a VXIplug&play, IVI-C, or IVI-COM driver, saving the new driver in a file on disk. The syntax is
makemid('driver','filename')where driver is the original VXIplug&play, IVI-C, or IVI-COM driver name (identified by instrhwinfo or the Test & Measurement Tool), and filename is the file containing the newly created MATLAB instrument driver. See the makemid reference 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.
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 icdevice.
For example, if the driver is created from a VXIplug&play, IVI-C, or directly from an IVI-COM driver,
obj = icdevice('ConvertedDriver.mdd','GPIB0::2::INSTR')If the driver is created from an IVI-COM logical name,
obj = icdevice('ConvertedDriver.mdd')Now that you have created the device object, you can connect it to the instrument with the connect function. To connect the device object, d, created in the last example, use the following command:
connect(d);
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 object or instrument. To have the instrument updated to the object's property values, the connect function from the previous example would be
connect(d, 'instrument');
If connect is successful, the device object's status property is set to open; otherwise it remains as closed. You can check the status of this property with the get function or by looking at the object display.
get(d, 'status')
ans =
open
![]() | Device Objects | Communicating with Instruments | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |