Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Solutions Academia Support User Community Company
spacer spacer spacer spacer spacer spacer

 

Instrument Control Toolbox 2.9

Introduction to Device Objects

Contents

Introduction

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.

MATLAB® Instrument Drivers

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 drivers

MATLAB 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.

Creating a Device Object

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 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('ni', 0, 2);

Next, create a device object that will use the interface object and the Tektronix TDS210 driver.

d1 = 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:             closed

You 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('age364xa', 'age364xa_matlab_driver');

The above command will create a new MATLAB VXIplug&play instrument driver, age364xa_matlab_driver.mdd in the current directory, using the functions found in the VXIplug&play driver, age364xa.

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.

d2 = icdevice('age364xa_matlab_driver', 'GPIB0::2::INSTR')
   Instrument Device Object Using Driver : Age364xa

   Instrument Information
      Type:               VXIPnPInstrument
      Manufacturer:       Agilent Technologies
      Model:              Agilent Technologies E364XA

   Driver Information
      DriverType:         MATLAB VXIplug&play
      DriverName:         Age364xa
      DriverVersion:      1.0

   Communication State
      Status:             closed

Connecting the Device Object to the Instrument

Before 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(d1);

Viewing and Updating Device Object Properties

To view and update the object's properties, use the GET and SET functions, respectively.

get(d1)
    ConfirmationFcn =
    DriverName = tektronix_tds210.mdd
    DriverType = MATLAB interface object
    InstrumentModel = TEKTRONIX,TDS 2024,0,CF:91.1CT FV:v4.06 TDS2CM:CMV:v1.
04
    Interface = [1x1 gpib]
    LogicalName = GPIB0-2
    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 = on
    Waveform = [1x1 icwaveform]

For information on invoking device object methods, see Invoking Device Object Methods.

Cleanup

When you are finished with the device object, disconnect it from the instrument, remove it from memory, and remove it from the workspace.

disconnect([d1 d2]);
delete([d1 d2]);
clear d1 d2

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
Contact sales
Trial software
E-mail this page

Get Pricing and
Licensing Options