This demo explores general device object information and device object creation. Instrument Control Toolbox device objects provide a common interface for communicating with instruments using instrument drivers.
Device objects use MATLAB instrument drivers to determine the properties and functions associated with an instrument. MATLAB instrument drivers also specify how to communicate with the instrument to set and get those properties, and how to execute the functions.
Instrument Control Toolbox device object supports three MATLAB instrument driver types.
Type Description
==== ===========
interface Uses Instrument Control Toolbox interface objects
VXIplug&play Uses VXIplug&play drivers
IVI Uses IVI driversMATLAB interface instrument drivers use Instrument Control Toolbox interface objects to communicate with instruments. The MATLAB instrument driver acts a wrapper around the instrument-specific commands used by the interface object.
MATLAB VXIplug&play instrument drivers use industry-standard VXIplug&play drivers to communicate with instruments. The MATLAB instrument driver acts a wrapper around the functions in the VXIplug&play driver.
MATLAB IVI instrument drivers use industry-standard IVI-C or IVI-COM drivers to communicate with instruments. The MATLAB instrument driver acts a wrapper around the functions in the IVI driver.
The Instrument Control Toolbox ships with a set of example drivers. Additional drivers can be downloaded from the File Exchange area on MATLAB Central. The MAKEMID and MIDEDIT functions can be used to create new drivers and modify existing ones.
To begin, create a device object using a MATLAB interface instrument driver. This example uses a driver for the Tektronix TDS210 oscilloscope that ships with the toolbox. The oscilloscope is connected to a Measurement Computing GPIB board having a board index of 0, and is located at primary address 2. First, create the interface object using the ICDEVICE function.
>> g = gpib('mcc', 0, 2);Next, create a device object that will use the interface object and the Tektronix TDS210 driver.
>> d = icdevice('tektronix_tds210.mdd', g)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: closedYou may also use industry-standard drivers, such as VXIplug&play and IVI drivers, with device objects. To use one of these drivers, you must first create a MATLAB instrument driver for the underlying VXIplug&play or IVI driver. In this example, MAKEMID is used to create the MATLAB instrument driver for a VXIplug&play driver installed on the machine.
>> makemid('tktds5k', 'tktds5k_matlab_driver');The above command will create a new MATLAB VXIplug&play instrument driver, tktds5k_matlab_driver.mdd in the current directory, using the functions found in the VXIplug&play driver, tktds5k.
Next, create a device object using the MATLAB VXIplug&play instrument driver. In this example, the instrument location is identified by its VISA resource name, GPIB0::2::INSTR.
>> d = icdevice('tktds5k_matlab_driver', 'GPIB0::2::INSTR')Instrument Device Object Using Driver : tktds5k
Instrument Information
Type: VXIPnPInstrument
Manufacturer: Tektronix
Model: TDS5xxx Series Oscilloscope Driver Information
DriverType: MATLAB VXIplug&play
DriverName: tktds5k
DriverVersion: 1.0 Communication State
Status: closedBefore you can get or set properties, or invoke functions on the object, you must connect the object to the instrument using the CONNECT function. If the object was successfully connected, its Status property is automatically configured to open.
>> connect(d);
To view and update the object's properties, use the GET and SET functions, respectively.
>> get(d) ConfirmationFcn = DriverName = tektronix_tds210.mdd DriverType = MATLAB interface object InstrumentModel = Interface = [1x1 gpib] LogicalName = GPIB0-5 Name = scope-tektronix_tds210 ObjectVisibility = on RsrcName = Status = open Tag = Timeout = 10 Type = scope UserData = []
SCOPE specific properties: Acquisition = [1x1 icacquisition] Calibration = [1x1 iccalibration] Channel = [1x2 icchannel] Cursor = [1x1 iccursor] Display = [1x1 icdisplay] Language = english Math = ch1 - ch2 Measurement = [1x5 icmeasurement] ResponseHeaderState = off System = [1x1 icsystem] Trigger = [1x1 ictrigger] VerboseEnabled = off Waveform = [1x1 icwaveform]
For information on invoking device object methods, see Invoking Device Object Methods.
When you are finished with the device object, disconnect it from the instrument, remove it from memory, and remove it from the workspace.
>> disconnect(d); >> delete(d); >> clear d
If the device object used a MATLAB interface instrument driver and an associated interface object, it may be appropriate to remove the interface object from memory, and remove it from the workspace as well.
>> delete(g); >> clear g