Using an IVI-COM Instrument Driver in LabVIEW

Updated Oct 31, 2023

Environment

Software

  • LabVIEW

Driver

  • IVI Compliance Package

An instrument driver is a set of software routines that control a programmable instrument. Each routine corresponds to a programmatic operation such as configuring, reading from, writing to, and triggering the instrument. Instrument drivers simplify instrument control and reduce test program development time by eliminating the need to learn the programming protocol for each instrument.
 

IVI-COM is one of several instrument driver technologies that you can use with LabVIEW. The IVI Foundation defines two architectures for IVI drivers: IVI-C, which is based on ANSI C, and IVI-COM, which is based on Microsoft COM technology. For information on the differences between IVI-C and IVI-COM drivers, refer to the IVI Architecture document.

In general, a driver with a customized LabVIEW interface is easiest to use in LabVIEW. LabVIEW Plug and Play and IVI-C drivers with LabVIEW wrappers are available on the Instrument Driver Network. You should consider all driver choices available, and choose the driver that best fits your needs.

In some cases, a driver with a simple LabVIEW interface is unavailable. In those cases, you can program the COM objects directly with LabVIEW’s ActiveX functions.
 

This document describes how to use Agilent's IVI-COM driver for the 34401A DMM in a simple LabVIEW application. Use these instructions as a guideline for using other IVI-COM drivers in LabVIEW.

Installing Software

Refer to the instrument driver Readme file for detailed software requirements. The installation steps described in this document are based on the software requirements for the Agilent 34401A IVI-COM driver.
 

Complete the following steps to install the required software on your system:

  1. Install LabVIEW.

  2. Install NI device drivers from either the NI Device Driver CD or Drivers and Updates on ni.com

 

  1. NI-488.2, if a NI GPIB interface is used

  2. NI-VISA, for VISA-COM support

  3. IVI Compliance Package, for the IVI Shared Components

  1. Install Agilent IVI-COM Components, required for older Agilent IVI-COM drivers.

  2. Install Agilent IO Libraries Suite, required by Agilent IVI-COM drivers. For compatibility with NI GPIB interface cards, install version 14.0 of the Agilent IO Libraries Suite. Agilent IO Libraries Suite version 14.0 is not the most current version of the IO Libraries Suite, but later versions of the Agilent IO Libraries Suite are not compatible with NI GPIB interface cards.

  3. Install Agilent IVI-COM Driver for the 34401A DMM.
     

Note: If the IVI-COM driver installs a .NET Primary Interop Assembly, you need to install the Microsoft .NET Framework.

Note: If you have already installed Agilent IO Libraries Suite version 14.1, you may have to uninstall/reinstall or repair all the Agilent components to use Agilent IO Libraries Suite version 14.0.
 

Using IVI-COM Drivers in LabVIEW

Because an IVI-COM driver is an ActiveX-enabled technology, use the LabVIEW ActiveX functions to access IVI-COM properties and methods in LabVIEW. Complete the following steps to create a simple LabVIEW IVI-COM application.
 

  1. Launch LabVIEW and create a new VI.

  2. Open the ActiveX palette and place the Automation Open function on the block diagram.

  3. Right-click the function and select Select ActiveX Class>>Browse from the shortcut menu. A dialog box appears, shown in Figure 1.

Figure 1: Selecting a Type Library in ActiveX Class Browser
 

  1. From the Type Library pull-down menu, select the IVI-COM driver. The Type Library list contains the type libraries for all the registered ActiveX servers on the system in alphabetical order. This list can be long, so you might need to browse for keywords that match the driver, such as the vendor name or "IVI". If you cannot find the driver in this list, use the Browse button to select the driver DLL in the IVI\Bin directory.

  2. After you select the type library, the Objects list contains all the IVI-COM objects and interfaces associated with the driver. Place a checkmark in the Show Creatable Objects Only check-box to display only objects that you can create. IVI-COM drivers have one creatable object and multiple interfaces.

  3. Select the interface with which you want to start. For IVI-COM drivers, select the interface which defines the Initialize method. This is typically the first interface in the list.

  4. Click the OK button to return to the block diagram after you have selected the type library, object, and interface. The block diagram should now appear similar to Figure 2. Figure 2 shows the type library, object and interface selection for the Agilent 34401 IVI-COM instrument driver.

     

Figure 2: Automation Open and type library refnum
 

  1. Select View>>Class Browser to display the Class Browser dialog box.
     

    1. From the Object library pull-down menu, select ActiveX>>Select Type Libraries to display the Select Type Libraries dialog box, shown in Figure 3. Select the same type library you selected for the Automation Open refnum. You will see a list of properties and methods supported by the Agilent 34401 IVI-COM driver, shown in Figure 3.

    2. Select the Initialize method and click the Create button to attach the Initialize method to the mouse cursor. Click on the block diagram to place the Initialize method on the diagram.

    3. Wire the Initialize method to the Automation Open function, shown in Figure 5.
       

Figure 3: Using the Class Browser

 

  1. The Initialize method establishes communication with the instrument. The ResourceName parameter of the Initialize method, shown in Figure 4, is the VISA I/O address for the instrument. You can view a list of resource names connected to the instrument by selecting the pull-down menu in a VISA I/O Name control. Alternatively, refer to Measurement & Automation Explorer (MAX) for assistance on VISA resources.

 

Figure 4: Automation Open and Initialize method
 

  1. To access operations other than Initialize and Close, use the Class Browser window to navigate to the desired operation. Dottable properties have a blue glyph next to the property name. Dotted properties are a shorthand alternative to cascading multiple Property Nodes that return interface references needed for wiring properties and methods specific to a given interface. For example, to create a dottable property to enable autorange on the DMM for DC voltage measurements, double-click on Properties>>DCVoltage. The class interface changes and a new set of properties and methods are now selectable, shown in Figure 5.
     

    1. Select Properties>>AutoRange and click the Create button to drop the AutoRange property on the block diagram, shown in Figure 6.

       

Figure 5: Selecting a dotted property

 

 


Figure 6: Using dotted properties and methods
 

Additional Information

You should close references to all ActiveX sessions and interfaces when you are finished using them. In Figure 6, notice that the sessions to the DCVoltage interface and to the driver session are closed after they are used.

To access help for an interface, property, or method, right-click on the node and select Help For <property or method name> from the shortcut menu. An example of how to access the help for the Initialize method is shown in Figure 7.
 

Figure 7: Selecting help for Initialize method


LabVIEW context help is also available for IVI-COM interfaces, properties, and methods. Figure 8 shows the Context Help window for the AutoRange property.
 

Figure 8: Viewing context help for AutoRange property


Links to complete examples demonstrating how to execute the Measurement method and read the measured value are provided at the end of this document.
 

IVI-COM drivers use the variant data type to pass array data. To convert variant data into a LabVIEW data type, use the Variant to Data function located in the ActiveX palette. Refer to the instrument driver help to determine the array data type. Figure 9 demonstrates how to convert variant data from an IVI-COM driver to a double precision array. More details about the Variant to Data function can be found in the LabVIEW Help.

Figure 9: Converting variant data to an array