Lab::Measurement: New lightweight backends for VXI-11 and USB-TMC

The Lab::Measurement project provides Open Source control of Test & Measurement devices with Perl. This post introduces the new Test & Measurement back end modules Lab::VXI11 and USB::TMC. Both VXI-11 and USBTMC are open standards and are supported by most modern T & M devices. They were developed as alternatives to the legacy GPIB (General Purpose Interface Bus). The main purpose of GPIB is to transfer text messages between the measurement PC and an automated measurement device, such as a digital multimeter. Beyond that, it defines various control commands for device triggering, setting end-of-message characters, reading a status byte and much more. VXI-11 and USBTMC provide a high degree of backwards compatibility with these features.

The photo shows the rear panel of an Agilent 34410A digital multimeter. While it is a small and (relatively) cheap device, it supports four different automation standards (GPIB, USBTMC, VXI-11, raw TCP sockets). This is why I used it for most of my testing.


Now, let me tell you some details about the VXI-11 and USBTMC protocols and how we implement them with Perl.


VXI-11 is a TCP/IP protocol based on the Open Network Computing (ONC) Remote Procedure Call (RPC). ONC RPC allows a client to call C-functions provided by a server and handles the serialization of the function's argument list. ONC RPC was developed by Sun Microsystems for their Network File System.

The VXI-11 specification defines several RPCs to perform read/write and control commands (like device clear) with the instrument.
To perform the RPCs, Lab::VXI11 uses Sun's ONC RPC library (sunrpc), which is part of libc on all major Unix platforms. We used the rpcgen program provided by sunrpc to parse the RPCL (remote procedure call language) contained in the VXI-11 spec. This creates C source and header files which define the client functions. XS does the rest.

The USBTMC protocol is directly based on the USB 2.0 specification. For read and write operations it uses bulk transfers, which are designed to move larger blocks of data with high bandwidth. Error checking is performed in hardware.
Control operations, like device clear, are performed with control requests. Control requests are also used to access device information like the serial number, which uniquely identifies a device together with the vendor and product ids (For the Agilent DMM on the photo, the serial number is printed on the rear panel: "MY47000419").

The implementation of USB::TMC was inspired by the Python module python-ivi/python-usbtmc. Namely, it uses the libusb-1.0 library which provides cross-platform user-space access to the USB. The Perl interface to libusb-1.0 is provided by USB::LibUSB.

Leave a comment

About simon reinhardt

user-pic I use Perl for experimental physics. PhD student at Institute for experimental and applied physics, Uni Regensburg.