Tools for Developing LXI Systems

With more LXI hardware coming to market and engineers taking a closer look at this technology, questions from developers and system integrators also involve software issues: What tools are available to help me program an LXI system, and how do they differ? For example, what debug facilities are at my disposal?

Several vendors—most notably Agilent Technologies, Data Translation, The MathWorks, and National Instruments—have adapted their application development environments to support LXI system development. Are there significant differences?

Well, today not every one supports all LXI instrument classes, not all accommodate both IVI-COM and IVI-C drivers, and some require that you purchase advanced versions or extra modules to gain LXI access. You aren’t limited to these tools if you, instead, program LXI instruments directly with SCPI commands.

When working with familiar development environments, programming an LXI instrument isn’t considerably different than programming other classes of instruments. In fact, it’s possible to create hybrid systems that combine LXI instruments with those using other bus or backplane schemes.

For MATLAB

In MATLAB, you can work with graphical tools, but most development is done from the command line. With many programming environments, you work directly with vendor-supplied IVI drivers, but to run them in MATLAB, you must first create a MATLAB IVI driver that acts as a wrapper for the IVI-COM or IVI-C driver which must remain installed on the system.

You can either download a preconfigured MATLAB instrument driver from the MATLAB Central File Exchange at mathworks.com/matlabcentral or create it using the command-line function makemid. To customize the new driver, open it in the MATLAB Instrument Driver Editor (midedit) where you can create, delete, modify, and rename properties, functions, or groups; add M-code around instrument commands for analysis; and create, connect, and disconnect code.

Once the MATLAB IVI instrument driver is created, you next create a device object using the icdevice command. icdevice is part of the Instrument Control Toolbox, an add-on module necessary to interface MATLAB to external instruments.

MATLAB works with every VISA implementation that The MathWorks can find. Several years ago when VISA didn’t have good discovery utilities, the company wrote its own utility that works within MATLAB for VXI-11.2. But with the new discovery mechanisms in LXI 1.2, there seems to be little need for the company to do a Bonjour version of its own discovery utility unless some bugs appear in the VISA implementations.

To get information from a discovery table into MATLAB, use instrhwinfo, a command that gets all the details VISA can provide including information about instruments on the network. This information is automatically loaded into the MATLAB environment, and you can gain access to it using other command-line functions.

The Instrument Control Toolbox provides a MATLAB-friendly way to communicate with instruments such as through IVI drivers. Within it, you can issue the tmtool command to bring up the Test & Measurement Tool to configure and control resources such as instruments, drivers, and interfaces without writing MATLAB script (Figure 1). This tool allows you to detect available hardware and drivers, connect to an instrument or device, configure instrument or device settings, read and write data, automatically generate MATLAB script, visualize acquired data, and export acquired data to the MATLAB environment.

Figure 1. Test & Measurement Tool in MATLABCourtesy of The Mathworks

Once you have become familiar with the instruments using that toolbox, you typically proceed to application development by writing a script in M-code. Since MATLAB is an interpreted language that also serves as a debug tool, at any time you can send a command to examine data going to the instruments and review their responses without the need to compile a program. You also have a command history and can edit that file to create a final script with the desired commands.

If desired, you then can compile it with a separate product to create an .EXE or a .DLL. However, according to Tom Gaudette, a development manager at The Mathworks, most users prefer to stay in the MATLAB environment for its interactivity and debugging capabilities.

If an IVI driver supports Class A and Class B as well as Class C operation, these capabilities are mapped into MATLAB. For instance, within MATLAB it is possible to send an LXI trigger by issuing a command over the TCP/IP link available in the Instrument Control Toolbox. You can work with low-level SCPI commands to set up triggers or use the IVI driver. Once the instrument is looking for the trigger, you can generate the trigger using straight TCP/IP commands, even outside the instrument driver if desired.

Some instruments that integrate PC capabilities now come with MATLAB connectivity preinstalled. This makes it possible to do scripting directly on the instrument and removes any issues with bus latency or network traffic. You don’t transfer a full waveform to a host PC but rather perform the filtering/analysis on the instrument itself and then send only high-level results to the host. As yet, LXI instruments with MATLAB preinstalled are not on the market.

For Measure Foundry

Now move on to some familiar codeless development environments, starting with Measure Foundry. This software has no built-in discovery mechanism, but when working with commonly available tools, you set up an alias, which then appears automatically in Measure Foundry. Alternatively, you can use an IP address directly so discovery is not mandatory.

In its present implementation, Measure Foundry supports only Class C instruments, but Data Translation is planning to add support for Class A and Class B instruments for a future release. Also, Measure Foundry works only with IVI-COM.

“The LXI standard says that software must support one or the other, said Tim Ludy, product marketing manager at Data Translation. But any new development in the last five years will have COM and C only for legacy applications.”

To ease programming, Measure Foundry presents all IVI commands as property pages to eliminate command-line programming. With the Instrument Socket component, you can access an instrument’s property pages and configure its initial properties, which you can change at runtime using other controlling objects.

A socket connection is required for each instrument being accessed. For instance, you drag a component onto the form, such as the Function Generator component, and then select the IVI device driver from the pull-down menu to associate this box with the socket connection.

For program debugging, Measure Foundry captures and displays every event among objects. You also can set filters to see what one component does in conjunction with another component. If you have NI or Agilent VISA installed, you can look at Measure Foundry’s IVI-COM object. Just open NI VISA, for instance, to see details such as the number of characters in a message.

On the application side, Measure Foundry offers the VISA Script Component, which has a VISA Assistant. With it you can send any command, even those outside the IVI structure for a particular instrument class, which makes it easy to access an instrument’s unique capabilities.

With Measure Foundry, the standard way to program LXI instruments using property pages and no coding is with the Professional Version, a requirement for installing either the Instrument Pak or Advanced Instrument Pak, both of which add objects to access the IVI-COM interface through property pages. The Instrument Pak supports four basic instrument classes: function generator, scope, DMM, and power supply. The Advanced Instrument Pak adds other types including RF generators, spectrum analyzers, power meters, and switches. However, if you don’t mind programming with SCPI calls in a script, you can work with the base version of Measure Foundry by using the VISA object.

For VEE Pro

A key to working with Agilent VEE is to first install the Agilent IO Library Suite. During installation, the software dynamically identifies smart defaults based on hardware and previously installed software. After installation, the software automatically discovers instruments connected to the PC, then configures and verifies the interfaces independent of the hardware or software application being used.

Also during installation, the software checks for the presence of other I/O software on the PC. If it finds another vendor’s VISA libraries, such as those from NI, it automatically installs them in a side-by-side mode that allows you to work with existing I/O software and the Agilent software together in a multivendor system.

The VISA Open Report module identifies conflicts between Agilent VISA and NI-VISA. Once it detects a conflict, VISA Open Report gives instructions on how to fix the problem. To support hybrid systems, the IO Library is compatible with any instruments connected over GPIB, USB, RS-232, and LAN.

With Agilent VEE Pro, the software can load drivers automatically for a specific instrument. VEE can find whether an IVI-COM driver is installed in the computer and then configure it. VEE does not support IVI-C drivers. No extra modules are required to support LXI; VEE only needs the modules provided by the IO Library that control any instrument interface or bus.

In VEE, you go to the Instrument Manager to create a simulated instrument and set its properties including a link to the corresponding IVI-COM driver. Next, you create an instance of that driver in your workspace.

Specifically, to automatically configure an IVI-COM driver for an instrument, start the Instrument Manager. In Auto Discovery, click Find Instruments. Select the instrument for which you want to configure drivers, then in Auto Discovery click Configure Drivers. You also can do this work manually.

In either case, to access the To/From IVI-COM object, bring up the Instrument Manager from the I/O menu. Select an instrument, then in Create I/O Object select IVI-COM Driver. In addition, you can use an IVI-COM driver with a class-compliant interface in much the same way.

Finally, you can use an IVI-COM session that is defined in the IVI Config Store and contains resource information about the instrument. You can do so with or without a class-compliant interface.

For advanced Class A and Class B capabilities, VEE can access two APIs that are part of Agilent’s IO libraries: the LXI Event Manager and an LXI Precision Time Protocol (PTP) Manager. The Event Manager allows you to programmatically send and listen for LXI event messages. The PTP Manager provides tools for controlling and monitoring the IEEE 1588 PTP clocks.

For debugging, you can use the Watch Window tool to view variables and data values on terminals. In addition, the IO Monitor tool integrated in VEE lets you monitor communications such as to view commands going to an LXI instrument and its responses.

For LabVIEW

LabVIEW supports the full range of LXI drivers and others: IVI-COM, IVI-C, LabVIEW Plug and Play, VXIplug&play, C DLLs, and direct I/O so you can write to Ethernet devices with direct SCPI commands. NI’s philosophy is that the best instrument drivers for an environment are designed specifically for that environment, in this case LabVIEW Plug and Play drivers with source code and calls to SCPI. When using LabVIEW to write a driver, you can peel away software layers, see the SCPI calls into VISA, and use it as is or modify a driver, such as to remove extraneous calls to improve efficiency.

Although it can be done, LabVIEW Plug and Play drivers are not readily transportable to other programming environments. As for the availability of prewritten drivers, Alex McCarthy, senior product manager for VXI and instrument control, added that LabVIEW is the only development environment where the end users write most of the instrument drivers, and very often the one you need already is written.

“The strength of the NI user community has a major impact on the number and quality of our instrument drivers,” Mr. McCarthy said. “Compared to other vendors, we have many end users who help us refine our driver technology, help drive our own prolific instrument-driver development, and develop their own instrument drivers to donate to the community.”

When installing IVI drivers, all the components that support IVI-COM and IVI-C come as part of the LabVIEW installation. Instrument drivers are installed separately, regardless of type.

LabVIEW has an Instrument Driver Finder utility that assists you in locating drivers for the instruments. From within LabVIEW, you can go to IDNet and automatically pull down any drivers you want. In programming instruments, you have access to VIs for Class A and Class B instruments and all their functionality as well as Class C units.

For instrument discovery, NI supplies a utility with LabVIEW called Measurement and Automation eXplorer (MAX), a configuration utility that helps separate LXI hardware from LXI software. In MAX, you can discover devices on the network, open Web pages, perform instrument configuration over the Web, and set up aliases that later ease test-system programming (Figure 2).

Figure 2. LabVIEW Program for LXI Control (bottom) and the Associated User Interface (top)Courtesy of National Instruments

One strength of LabVIEW is its capability to work with multiple bus systems to facilitate building hybrid test systems. Not only does it support virtually every type of test hardware, but NI also sells the PCI-1588 and the PXI-6682 cards that synchronize 1588-based instruments.

Under LabVIEW, an LXI system can combine the functions of LXI Class B with non-LXI 1588 instruments as if they were all Class B. The PCI-1588 also allows for the synchronization of non-1588 devices such as traditional instruments. An RTSI bus interface synchronizes other PCI boards in the same PC; the PXI-6882 does the same for PXI systems.

In debugging phases, NI Spy included with LabVIEW is a useful utility. This tool monitors instrument I/O communications while an application runs, and it also can log commands sent over any instrument bus. Sometimes these commands are not immediately obvious, especially when using high-level IVI or Plug and Play drivers that provide function calls translated into instrument-specific commands.

But with NI Spy, which acts as a software bus analyzer, you can see the SCPI command sent to the instrument and the responses. NI Spy only works when using NI software, and you’ll see VISA calls only if you use NI-VISA.

LabVIEW now supports multicore processors. While LabVIEW users cannot dictate task partitioning, they can set task priorities. For instance, you could try to dedicate all LXI bus traffic to one processor and leave the other cores free to run the LabVIEW VIs for processing and display.

Finally, LabVIEW runs on Linux, making it the only high-level program development environment for LXI under that OS. NI-VISA also supports Linux, so you can run LabVIEW Plug and Play drivers or VISA calls directly from a LabVIEW block diagram.

TCP/IP functions are available for a low-level approach. You can make direct SCPI calls just like under Windows. And while the IVI Foundation has drivers only for Windows, you can run IVI-C drivers under Linux even though they’re no longer official IVI drivers in a technical sense. But, said Brian Powell, LabVIEW R&D, in general, well-written drivers won’t need to be modified, only in rare cases where compilers are picky.

Direct Programming With SCPI

The capability to run under Linux is increasingly important. A survey by Agilent roughly a year ago revealed that about 50% of their customers, including those using Windows, are not using instrument drivers and instead program their instruments directly with SCPI commands. They appreciate the higher degree of control and flexibility offered by direct SCPI programming. Also, many instrument vendors haven’t developed IVI drivers for Linux, which the IVI Consortium defines only under Windows (Figure 3).

Figure 3. Programming an LXI Instrument Within Linux Using SCPI CommandsCourtesy of Agilent Technologies

An important aspect of SCPI and direct I/O programming under Linux is portability across the many variants. Commercial software tool vendors usually support the top two or three distributions but won’t guarantee support for the hundreds of Linux distributions available. Consequently, using open-source programming tools such as the GNU tool chain and direct I/O programming is the only way to achieve true portability.

Some engineers insist on using Linux and will go to great lengths to do so. They don’t care if there are no drivers. Development is more complex, but these engineers have complete control and a deep understanding of the system. Using open-source tools, they also get the rights to adapt and recompile their environment, and they are totally independent of revision changes that come about with Windows.

“This is especially important for areas such as aerospace and defense where applications can sometimes serve for 30 to 40 years and engineers are reluctant to use XP or Vista in such a system,” said Stefan Kopp, sales development expert for Agilent. Especially for support for specific I/O interfaces, the open-source paradigm is very powerful. “Chances are that someone in the world has already solved your problem. You then can get the source code and port it to your system,” he concluded.

A number of commercial VISAs are available for Linux, but they are distributed in binary format and typically supported on a limited number of popular distributions such as RedHat. In contrast, with direct I/O programming, you make API calls directly into the OS to run the Ethernet controller and LXI instruments. Especially for Ethernet, this is fairly easy to do. There is a different API for every I/O interface while VISA offers a common abstraction layer for all of its supported interfaces.

LXI instruments typically use VXI-11 based on RPC or TCP for remote control. Both protocols are available through standard OS calls.

By definition, LXI uses VXI-11 for instrument identification. You can perform a discovery by sending a broadcast and then querying the identification strings of the instruments found via VXI-11. From there on, you can use either VXI-11 or TCP to do regular instrument programming beyond the initial instrument identification.

Most Agilent instruments can do both VXI-11 and TCP communications, and direct TCP removes several layers of overhead. According to Agilent’s Mr. Kopp, there could be a significant performance increase depending on the application and average packet size, but the boost can be up to 100% or more. With VXI-11, each SCPI command is implemented through several back-and-forth TCP transactions. If you’re dealing with large waveforms, the overhead is less significant. But if you’re doing many individual transactions such as opening and closing relays, there will be a significant improvement moving to direct TCP communication.

Finally, for debugging, you use any plain-vanilla Ethernet analysis tools including Wireshark.

About the Author

Paul G. Schreier, editor of LXI ConneXion, is a technical journalist and marketing consultant working in Zurich, Switzerland. He was the founding editor of Personal Engineering & Instrumentation News, served as chief editor of EDN Magazine, and has since written articles in countless technical magazines. Mr. Schreier earned a B.S.E.E. and a B.A. in humanities from the University of Notre Dame and an M.S. in engineering management from Northeastern University. e-mail: [email protected]

For More Information
on the IVI-based
Hello-Instrument Program
www.rsleads.com/815-176

on using Linux to control
LXI Instruments
www.rsleads.com/815-177

on papers describing IVI drivers
and how to work with them
www.rsleads.com/815-178

July 2008

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!