Getting Started with IVI Drivers

Introduction

You need to install IVI® drivers and shared components before you can use them in MATLAB®. See Requirements below for more information. You can use an IVI driver in MATLAB in two different ways. The syntax for each method differs vastly. Please refer to the MathWorks IVI Web page for more information. After installing the necessary components, you can:

  • Create and use a MATLAB IVI instrument driver as described in MATLAB® IVI Instrument Driver. Here, you create a MATLAB IVI instrument driver with .mdd extension using an IVI driver.

  • Use a MATLAB IVI wrapper as described in Using MATLAB® IVI Wrappers. Here, MATLAB wraps the IVI driver. You can then use this wrapper with the Instrument Control Toolbox™ software. This allows interchangeability and is the preferred method if you are working with class-compliant drivers.

    You can use the MATLAB IVI Wrappers provided with the Instrument Control Toolbox software with IVI drivers of the same class. Supported IVI driver classes are:

    • IviACPwr

    • IviCounter

    • IviDCPwr

    • IviDigitizer

    • IviDmm

    • IviDownconverter

    • IviFgen

    • IviPwrMeter

    • IviUpconverter

    • IviRFSigGen

    • IviScope

    • IviSpecAn

    • IviSwtch

    You can also use MATLAB IVI wrappers provided by an instrument vendor that has built in MATLAB support. Refer to the vendor documentation for more information about using these drivers in MATLAB.

With the MATLAB IVI instrument driver, you construct a device object, which you use to communicate with your instrument. With the MATLAB IVI wrapper, you communicate with the instrument by directly accessing elements of the driver class.

Requirements to Work with MATLAB

Before you use IVI drivers in MATLAB, install:

  • VISA

  • IVI Shared components

  • Required IVI drivers

Verifying VISA

Most IVI drivers require you to install VISA libraries on your system. The driver installer software specifies certain VISA or other connectivity requirements.

To determine proper configuration of the necessary version of VISA on your system, at the MATLAB Command Window, type:

instrhwinfo visa
ans = 
    InstalledAdaptors: {'agilent'}
       JarFileVersion: 'Version 2.8.0''

The cell array returned for InstalledAdaptors indicates the type of VISA software installed. A 1-by-0 cell array indicates that your system does not have VISA installed. Possible InstalledAdaptors values are agilent, tek, and ni.

To install VISA, check the software installation disk provided with your instrument. This disk can include VISA along with the IVI driver for the instrument. You can also download VISA from the Web site of the instrument manufacturer.

An instrument driver can have other software requirements in addition to or instead of VISA. Consult the driver documentation. The installer software itself can specify these requirements.

Verifying IVI Shared Components

Many driver elements are common to a wide variety of instruments and not contained in the driver itself. You install them separately as shared components. Sharing components keeps the drivers as small and interchangeable as possible. You can use instrhwinfo to determine whether you installed shared components on your system.

instrhwinfo ('ivi')
ans = 
.
.
.
ConfigurationServerVersion: '1.6.0.10124'
  MasterConfigurationStore: 'C:\Program Files\IVI\Data\IviConfigurationStore.xml'
               IVIRootPath: 'C:\Program Files\IVI\'

ConfigurationServerVersion, MasterConfigurationStore, and IVIRootPath all convey information related to installed shared components. ConfigurationServerVersion indicates whether you installed IVI shared components. If its value is an empty string, then you have not installed shared components.

Verifying IVI Drivers

The instrument manufacturer usually provides the specific IVI driver, either on an installation disk or as a Web download. Required VISA software and IVI shared components could also come with the driver.

You can use instrhwinfo to find information on installed IVI drivers and shared components.

instrhwinfo ('ivi')
ans = 
              LogicalNames: {'MainScope', 'FuncGen'}
                ProgramIDs: {'TekScope.TekScope','Agilent33250'}
                   Modules: {'ag3325b', 'hpe363xa'}
ConfigurationServerVersion: '1.6.0.10124'
  MasterConfigurationStore: 'C:\Program Files\IVI\Data\
                             IviConfigurationStore.xml'
               IVIRootPath: 'C:\Program Files\IVI\'

Logical names are associated with particular IVI drivers, but they do not necessarily imply that the drivers are currently installed. You can install drivers that do not have a LogicalName property set yet, or drivers whose LogicalName was removed.

Alternatively, use the Test & Measurement Tool to view the installation of IVI drivers and the setup of the IVI configuration store. Open the tool by typing:

tmtool

Expand the Instrument Drivers node and click IVI. Click the Software Modules tab. (For information on the other IVI driver tabs and settings in the Test & Measurement Tool, see IVI Configuration Store.)

Creating Shared Libraries or Standalone Applications When Using IVI-C or VXI

When using IVI-C or VXI Plug&Play drivers, executing your code will generate additional file(s) in the folder specified by executing the following code at the MATLAB prompt:

sprintf('%s',[tempdir 'ICTDeploymentFiles'])

On all supported platforms, a file with the name MATLABPrototypeFor<driverName>.m is generated, where <driverName> the name of the IVI-C or VXI Plug&Play driver. With 64-bit MATLAB on Windows®, a second file by the name <driverName>_thunk_pcwin64.dll is generated. When creating your deployed application or shared library, manually include these generated files. For more information on including additional files refer to the MATLAB Compiler documentation.

MATLAB IVI Instrument Driver

Using a MATLAB IVI Instrument Driver

To use an IVI driver with a device object, you need a MATLAB IVI instrument driver based upon the information in the original IVI driver. The MATLAB IVI instrument driver, whether modified or not, acts as a wrapper to the IVI driver. These drivers, however, do not support interchangeability. You can download or create the MATLAB IVI instrument driver.

Creating a MATLAB IVI Instrument Driver with makemid

The command-line function makemid creates a MATLAB IVI instrument driver from an IVI driver, saving the new driver in a file on disk. The syntax is:

makemid('driver','filename')

driver is the original IVI driver name (identified by instrhwinfo or the Test & Measurement Tool), and filename is the MATLAB IVI instrument driver name. For driver use a Module name(for IVI-C), a ProgramID (for IVI-COM), or a LogicalNames value (for either IVI-C or IVI-COM). See the makemid reference page for full details on this function.

To customize the driver, open the new driver in the MATLAB Instrument Driver Editor, modify it as required, and save it.

    Tip   Do not uninstall the original IVI driver when you create a MATLAB IVI instrument driver based on an IVI driver. You need the IVI driver in order to use the new MATLAB IVI instrument driver.

    Note:   When you create a MATLAB IVI instrument driver without specifying an interface name, makemid uses the instrument-specific interface as the default interface.

Downloading a MATLAB IVI Instrument Driver

Go to the MATLAB Central Web site and search for an appropriate MATLAB IVI instrument driver for your instrument. You can look for wrappers using the instrument drivers tag in the File Exchange area.

To use the downloaded MATLAB IVI instrument driver, you also need the IVI driver for the installed instrument. Find this driver on the Web site of the instrument manufacturer.

Importing MATLAB IVI Instrument Drivers

You can import an IVI driver using the MATLAB Instrument Driver Editor, and create a MATLAB IVI instrument driver. Evaluate or set the functions and properties of the driver, and save the modified MATLAB IVI instrument driver for further use.

  1. Open the MATLAB Instrument Driver Editor by typing midedit.

  2. Select File > Import. The Import Driver dialog box opens.

  3. Select the IVI driver that you want to import, and click Import.

    The MATLAB Instrument Driver Editor loads the driver and displays its components.

With the MATLAB Instrument Driver Editor, you can do the following:

  • Create, delete, modify, and rename properties, functions, or groups.

  • Add code around instrument commands for analysis.

  • Add, create, connect, and disconnect code.

  • Save the driver as a MATLAB IVI instrument driver.

For more information, see MATLAB Instrument Driver Editor Overview.

    Tip   Do not uninstall the original IVI driver when you create a MATLAB IVI instrument driver based on an IVI driver. You need the IVI driver in order to use the new MATLAB IVI instrument driver.

Constructing Device Objects Using a MATLAB IVI Instrument Driver

Once you have the MATLAB IVI instrument driver, create the device object with the file name of the MATLAB IVI instrument driver as an argument for icdevice. The following examples show the creation of the MATLAB IVI instrument driver (all with .mdd extensions) and the construction of device objects to use them.

See the icdevice and makemid reference pages for full details on these functions.

In the following example, makemid uses a LogicalNames value to identify an IVI driver, then creates a MATLAB IVI instrument driver. Because LogicalNames is associated with a driver session and hardware asset, you do not need to pass a RsrcName to icdevice when constructing the device object.

makemid('MainScope','MainScope.mdd');
obj = icdevice('MainScope.mdd');

In the next example, makemid uses a ProgramID to reference an IVI-COM driver, then creates a MATLAB IVI instrument driver. The device object requires a RsrcName in addition to the file name of the MATLAB IVI instrument driver.

makemid('TekScope.TekScope','TekScopeML.mdd');
obj = icdevice('TekScopeML.mdd','GPIB0::13::INSTR');

In the next example, makemid uses a software Module to reference an IVI-C driver, then creates a MATLAB IVI instrument driver. The device object requires a RsrcName in addition to the file name of the MATLAB IVI instrument driver.

makemid('ag3325b','Ag3325bML.mdd');
obj = icdevice('Ag3325bML.mdd','ASRL1::INSTR');

In the next example, makemid creates a MATLAB IVI instrument driver based on the IVI-C class driver ivifgen. The device object uses the MATLAB IVI instrument driver file name and the logical name of the driver from the IVI configuration store.

makemid('ivifgen','FgenML.mdd');
obj = icdevice('FgenML.mdd','FuncGen');

Using MATLAB IVI Wrappers

MATLAB IVI wrappers work well with class-compliant drivers.

This example shows how to connect to an instrument and read a waveform using a MATLAB IVI Wrapper.

The instrument in this example is an Agilent Technologies®' MSO6014 mixed signal oscilloscope, with an Agilent546XX driver.

%Create the object
myScope = instrument.ivicom.IviScope('Agilent546XX.Agilent546XX');

%Connect to the instrument using the VISA resource string
myScope.Initialize('TCPIP0::xxx-xxxx.xxx.<yourdomain.com>::inst0::INSTR',false,
false,'simulate=false');

%Access the Measeurements Collection
myScopeMeasurements  = myScope.Measurements

%Configure measurement 1
myScopeMeasurements.AutoSetup;
name = myScopeMeasurements.Name(1);
myScopeMeasurement1 = myScopeMeasurements.Item(name);

%Access the Channels collection
myScopeChannels = myScope.Channels;

%Configure channel 1
name = myScopeChannels.Name(1);
myScopeChannel1=  myScopeChannels.Item(name)
myScopeChannel1.Enabled = 1;

%Configure a trigger
myScope.Trigger.Source = 'Channel1';
myScope.Trigger.Level = 1.0;
myScope.Trigger.Edge.Slope = 'IviScopeTriggerSlopePositive';

%Start the measurement and get the data
myScopeMeasurements.Initiate;
myWaveform = myScopeMeasurement1.FetchWaveform;

%Plot the data
plot(myWaveform);

%Close and delete the object
myScope.Close;
myScope.delete

Plot the Waveform Read Using the MATLAB IVI Wrapper

Was this topic helpful?