Assessing the use of IVI drivers in your test system: Determining when IVI is the right choice Application Note

If software reuse and system “portability” are important to your organization, it may be to your advan- tage to use IVI drivers in present and future test systems. This is especially true if you are making the shift from GPIB-based control to LAN and LXI: All LXI-compliant instruments include an IVI driver.

To help you decide if IVI drivers are • Choices in Much of the material in this applica- right for your system, this applica- • Why use an instrument driver? tion note has been leveraged from the tion note provides an overview of • Benefits of using an IVI driver IVI Foundation’s IVI Getting Started the technology, presents additional Guide. Sections taken directly from considerations, and describes the • IVI driver classes the Getting Started Guide are marked tradeoffs. The note includes eight • Requirements to use an IVI driver in italics. That document is available major sections: • Tradeoffs and limitations of IVI as a PDF from the IVI Foundation drivers Web site at www.ivifoundation.org. • Steps to getting started • Using IVI drivers in Visual Basic .NET or Visual C# Choices in instrument control

There are four choices available for SCPI provides fine-level instrument providing computer-based control of control through a consistent, test- A quick look at SCPI most instruments: focused command set. However, it can be complicated to use with more Beginning in 1989, a group of • Standard Commands for complex instruments where it may instrument manufacturers devel- Programmable Instrumentation seem like programming a computer (SCPI) in assembly language. SCPI carries oped Standard Commands for • A program- or language-specific three other important considerations: Programmable Instrumentation driver (e.g., a LabVIEW driver) (SCPI). This defined a set of • It is not dependent on the operat- • A proprietary driver (supplied with ing system or programming lan- commands for controlling many vendors’ instruments) guage so is highly portable among instruments using ASCII test systems. • An open driver such as IVI characters, providing some basic • It defines common functions, so is Each of these carries a set of standardization and consistency generally portable among instru- tradeoffs. For example, choosing a to the commands used to control ments. proprietary or program-specific driver instruments. For example, when may result in very tight integration • It does not require a certain set of you want to measure a DC volt- with any provided tools or programs; functions, so some calls may not however, this comes at the expense be implemented on similar instru- age, the standard SCPI command of test system portability. You may ments. is “MEASURE:VOLTAGE:DC?.” also be confronted with a com- In many cases, SCPI is a suitable mon problem: the available set of and sufficient choice. However, instrument drivers doesn’t match drivers provide extended capabilities your desired (or required) list of that simplify instrument control and instruments. We’ll talk about the reduce programming time. tradeoffs in using an IVI driver in a later section.

SCPI control is one of the most popular methods of programmatically controlling instruments. These com- mands work on instruments that have implemented an appropriate SCPI command set and also contain an on-board command parser, typically implemented through a microproces- sor or state machine. This specifically means that SCPI control will not work on most register-based devices housed in a cardcage (e.g., neither VXI nor PXI architectures).

2 Why use an Benefi ts of using an instrument driver? IVI driver

To understand the benefits of IVI Before IVI drivers, there was a stan- This level of commonality—or drivers, we need to start by defining dard framework called VXIplug&play interoperability—was the motivation instrument drivers in general and drivers. This specification defined a behind the development of IVI drivers. describing why they are useful. An standard dynamic-link library (.dll) The specifications define an open instrument driver is a set of software interface; however, did not provide driver architecture, a set of instru- routines that controls a program- for interchangeability among similar ment classes, and shared software mable instrument. Each routine cor- types of instruments. In fact, the nor- components. Together these provide responds to a programmatic operation mal syntax of a VXIplug&play driver consistency and ease of use, as such as configuring, writing to, read- discouraged inter-vendor operability well as the crucial elements needed ing from, or triggering the instrument. because the keywords contained ven- for advanced features. IVI drivers Instrument drivers simplify instrument dor names. Furthermore, the standard also support instrument simulation, control and reduce test program did not define standard keywords for automatic range checking and state development time by eliminating common actions. For instance, one caching. These capabilities provide the need to learn the programming vendor may use “read” while another several benefits: protocol for each instrument. may use “get” as the syntax for acquiring a measured value from an • Instrument simulation enables Although you must be syntactically instrument. program development and debug- correct in all calls to an instrument ging even when an instrument is driver, making calls to a subroutine in In contrast, the IVI standard defines not available. This is particularly your preferred programming language the concept of an “instrument class.” useful when you are waiting for the is less error prone. This is especially For any type or “class” of instru- test hardware to arrive or if several true if you are using a language that ment, common functions have been people must share expensive test supports the Intellisense capabil- defined. Using digital multimeters resources. ity, which presents valid syntax (DMMs) as an example, the IVI driver • Automatic range checking can choices as you type each command. for every DMM from any vendor eliminate unnecessary program- An instrument driver such as IVI uses the measurement command ming errors. integrates more tightly with your IviDmmMeasurement.Read. Once you programming language than will SCPI learn to program the IVI-specified • State caching is optionally imple- calls through the VISA I/O library. commands for the instrument class, mented within the driver. This you can use any vendor’s instrument capability can accelerate the exe- If you’ve been programming instru- without relearning the commands. cution of certain test programs by ments without using a driver, then Commands that are common to all making only the minimum changes you are probably well acquainted drivers, such as Initialize and Close, to the state of an instrument. with the chore of hunting through are identical for every instrument Eliminating unnecessary instrument the programming guide while looking class. This commonality ensures resets, range changes or other similar for the right SCPI command and its portability across test systems and functions can further accelerate the exact syntax. You’ve also been deal- lets you spend less time searching execution of measurement functions. ing with an I/O library to format and through help files or programming an send strings, and then embedding instrument—and leaves more time response strings into variables. Let’s for your primary job. take a look at some advantages of IVI drivers.

3 IVI driver classes Tradeoffs and limitations of IVI drivers

The IVI Foundation has created IVI provide the same consistency and The various companies that defined class specifications that define a benefits described above for an IVI the IVI standard tried to minimize the common set of capabilities for drivers driver, but are specific to a device tradeoffs in using an IVI driver. Even for eight instrument classes (Table 1). so lack interchangeability across so, there five key considerations you vendors. should keep in mind: Class IVI driver • An IVI driver may or may not Digital multimeter IviDmm take full advantage of the speed Oscilloscope IviScope capabilities of an instrument. Arbitrary waveform/ IviFgen Requirements to use function generator an IVI driver • An IVI driver will seldom imple- DC power supply IviDCPwr ment the entire feature set of an Switch IviSwitch The primary gating item is the avail- instrument. Power meter IviPwrMeter ability of a specific IVI driver for the • IVI drivers are not available Spectrum analyzer IviSpecAn instrument you want to control. If for all commercially available RF signal generator IviRFSigGen such a driver is available, it must be installed on the controlling computer instruments. Table 1. The IVI standard includes eight along with four other essential items: • The two types of IVI drivers, IVI-C instrument classes. and IVI-COM (Common Object ® • An appropriate Microsoft operat- Model) (see sidebar), mean that ing system and certain operating- you will need to choose one or the In addition to the existing class system services. drivers, there are six other classes in other. To make an informed choice, development as this paper is being • An appropriate programming it’s useful to understand the ben- written. The timer/counter and language. efits and tradeoffs of each type. AC power classes are directed at • An appropriate I/O library. • Your system must meet the general-purpose instruments while requirements outlined in the upconverter, downconverter, digitizer, • IVI shared components code. previous section and arb (baseband) classes are being With these items all in place, you are Let’s expand on the first three points. developed as part of the synthetic ready to proceed. instruments program spearheaded by the US military.

It is common for instruments within a specific class to provide IVI class- Types of IVI drivers compliant drivers to additionally provide functions beyond the defined To support all popular programming languages and development environ- IVI Class definition. There may be two ments, IVI drivers provide either an IVI-C or an IVI-COM application reasons for this: Either the capability programming interface (API). Driver developers may provide either or both is not common to all instruments of interfaces, as well as wrapper interfaces optimized for specific develop- the class or because the instrument ment environments. offers a level of control that is more Although the functionality is similar, IVI-C drivers are optimized for use in refined than what the class defines. ANSI C development environments while IVI-COM drivers are optimized IVI defines “custom drivers,” which for environments that support COM. IVI-C drivers extend the VXIplug&play are used for instruments that are not driver specification and their usage is similar. IVI-COM drivers provide easy members of a class. For example, access to instrument functionality through methods and properties. IVI-C there is not a class definition for drivers may require more active management of driver versions to ensure network analyzers, so those drivers compatibility. must be custom. Custom drivers All IVI drivers communicate with the instrument through an I/O library. We recommend using the Virtual Instrument Software Architecture (VISA) library, a widely used standard library for communicating with instruments from a personal computer.

4 An IVI driver may or may not take IVI drivers are not available for all 4. Download and install the appropri- full advantage of speed capabilities: instruments: It isn’t practical for ate IVI driver for any instruments Instrument drivers are generally instrument manufacturers to create you will be controlling. These written for a general user and may drivers for all past models. IVI drivers are commonly available at the include extra code such as range are available for most new instru- vendor’s Web site. For Agilent checking to ensure proper operation. ments and many popular older ones, instruments, see www.agilent. If you are operating an instrument but you should verify driver availabil- com/find/drivers. The IVI within well-known parameters, you ity before beginning a project. Foundation Web site also has can often program a more concise set links to many instrument vendor of instrument commands than those sites. Note that occasionally driv- provided by the driver. Additionally, ers will unload into multiple files. many drivers are built to maximize Getting started When you reference the driver programming compatibility across (see below), you should choose interfaces (e.g., GPIB, LAN and USB) The following 10 steps will help the files you need based on the and may use compatibility modes you prepare your system using IVI functionality you require. that do not take full advantage of instrument drivers. instrument speed. On the other hand, 5. Determine the VISA address 1. Choose a programming language. some drivers incorporate state cach- string. We’ll show examples for VB .NET ing, which eliminates unnecessary and Visual C. For other languages, 6. Reference the driver or load driver steps and accelerates operation. As a see the Getting Started Guide files. result, it is very difficult to know if a available from the IVI Foundation driver will provide the fastest possible 7. Create an instance of the driver if Web site. www.ivifoundation.org/ execution. Often, advanced program- your development environment is mers will use a driver for most instru- 2. Install the I/O libraries. Agilent using COM. ment functions, then will selectively I/O libraries are available at no 8. Create a variable to represent your tune their code (e.g., by using SCPI charge to Agilent customers. See instrument(s). calls or direct register operations) for www.agilent.com/find/iolib time-critical operations. to download the latest version. 9. Initialize the instrument(s). An IVI driver may not implement 3. Download and install the IVI 10. Write your test program. Be sure the entire feature set: A simple shared components. These are any instruments are closed before DMM may have only 25 commands, available from vendor Web sites exiting your program as this frees whereas a more complex instrument or directly from the IVI Foundation any system resources reserved for may have hundreds. You can imagine Web site those devices. how expensive it is to write an intel- ligent driver that anticipates all the possible permutations of instrument setup, triggering, sourcing and mea- surement. That’s why you’ll seldom see a driver that covers every com- mand in an instrument. Instrument manufacturers take their best guess at the commands you are likely to use and craft the driver accordingly. For most users, the commands available in the driver will cover their program- ming needs. Advanced users may be disappointed in the functionality of some drivers and might consider other alternatives.

5 Using IVI drivers in Visual Basic .NET or Visual C#

Let’s start with Microsoft Visual Studio®, which is a popular develop- ment environment. The procedures for Visual C# and Visual Basic .NET are very similar. Start by installing the required software from the list above: operating system, Visual Studio with appropriate compiler, I/O libraries, IVI shared components and any IVI instrument drivers. We recommend using the IVI-COM driver in Visual Studio whenever available.

To use a driver, you must first add a reference to it. After that, the follow- ing steps are recommended: Figure 1. A single instrument may include more than one driver. 1. Launch Visual Studio and start a new Console Application (in Visual C# or Basic). Keep any code gener- ated.

2. Select and . The Add Reference dialog box will appear.

3. Select the COM tab. Scroll to the IVI section (all IVI drivers begin with IVI) and select the type library for your chosen instrument(s). Any IVI drivers you have installed should appear in this list. Select the driver(s) and press . Note that you can add multiple drivers with one selection. Note also that a single instrument will sometimes contain more than one driver. See Figure 1 as an example.

6 4. Create an instance of each driver by adding a using statement to allow your program to access the driver. For an Agilent driver, type “using A” and Intellisense will show the available Agilent drivers (e.g., using Agilent.A will pop up the list of installed drivers). Put this directly beneath the other using statements in your code. See Figure 2 for an example of the Intellisense popup. Figure 2. Depending on the context, the 5. Initialize the instrument: Create a Intellisense popup window will show variable to represent your instru- available drivers or installed drivers. ment and set the initialization parameters.

For Visual Basic.NET: Conclusion a. Enforce type checking (Option Explicit On). The optimum choice of instrument b. Add Dim variables for the instru- control method depends on many ment and for the reading. factors. Today, IVI drivers are being shipped with more and more new 6. To view the functions and param- instruments—so it may be time to eters available in the instrument consider using them in your applica- driver, right-click the library in tion. The increasing availability of the References folder in Solution IVI drivers along with their tight Explorer and select View in Object integration with modern programming Browser. languages means that IVI drivers could be the best choice for your 7. You can now start writing the next test programming project. program to use the available instrument drivers.

8. When you are finished, be sure to close the session.

7 www.agilent.com www.agilent.com/fi nd/XXX

For more information on Agilent Agilent Email Updates Remove all doubt Technologies’ products, applications or services, please contact your local Agilent www.agilent.com/fi nd/emailupdates Our repair and calibration services offi ce. The complete list is available at: Get the latest information on the will get your equipment back to you, www.agilent.com/fi nd/contactus products and applications you select. performing like new, when prom- ised. You will get full value out of Americas

Agilent Direct your Agilent equipment through- Canada (877) 894-4414 out its lifetime. Your equipment Latin America 305 269 7500 www.agilent.com/fi nd/agilentdirect will be serviced by Agilent-trained United States (800) 829-4444 Quickly choose and use your test technicians using the latest factory equipment solutions with confi dence. calibration procedures, automated Asia Pacifi c repair diagnostics and genuine parts. Australia 1 800 629 485 You will always have the utmost China 800 810 0189 confi dence in your measurements. Hong Kong 800 938 693 www.lxistandard.org For information regarding self India 1 800 112 929 LXI is the LAN-based successor to maintenance of this product, please Japan 0120 (421) 345 GPIB, providing faster, more effi cient contact your Agilent offi ce. Korea 080 769 0800 connectivity. Agilent is a founding Malaysia 1 800 888 848 member of the LXI consortium. Agilent offers a wide range of ad- Singapore 1 800 375 8100 ditional expert test and measure- Taiwan 0800 047 866 ment services for your equipment, Thailand 1 800 226 008 Microsoft is a U.S. registered trademark of including initial start-up assistance, Microsoft Corporation. onsite education and training, as Europe & Middle East Visual Studio is a registered trademark of well as design, system integration, Austria 01 36027 71571 Microsoft Corporation in the United States and project management. Belgium 32 (0) 2 404 93 40 and/or other countries. Denmark 45 70 13 15 15 For more information on repair and Finland 358 (0) 10 855 2100 calibration services, go to: France 0825 010 700* *0.125 €/minute www.agilent.com/fi nd/removealldoubt Germany 07031 464 6333 Ireland 1890 924 204 Israel 972-3-9288-504/544 Italy 39 02 92 60 8484 Product specifi cations and descriptions Netherlands 31 (0) 20 547 2111 in this document subject to change Spain 34 (91) 631 3300 without notice. Sweden 0200-88 22 55 Switzerland 0800 80 53 53 United Kingdom 44 (0) 118 9276201 Other European Countries: www.agilent.com/fi nd/contactus Revised: October 1, 2008

© Agilent Technologies, Inc. 2008 Printed in USA, November 14, 2008 5990-3186EN