LWN.net Logo

Control instrumentation devices with PyVISA

PyVISA is a cross-platform Python package that has been written by Torsten Bronger:

The PyVISA package enables you to control all kinds of measurement equipment through various busses (GPIB, RS232, USB) with Python programs.

PyVISA is used to interface with electronic devices that adhere to the VISA specification. VISA is defined by the Interchangeable Virtual Instrument (IVI) Foundation, and is used to create a standardized interface to a variety of instrumentation control buses. Electronic devices such as voltmeters, oscilloscopes, temperature sensors, power supplies, motors and much more can be accessed by VISA.

PyVISA includes the vpp43 VISA library implementation, which deals with the low-level VISA functions. PyVISA can work with a number of adapters such as those from National Instruments, Agilent, and Tektronix.

Assuming one has the required hardware and driver installed, the software appears to be fairly easy to use. The PyVISA manual has some simple and more complex examples for performing data acquisition from Python. More complex applications, such as pyvLab, an open-source instrumentation control and display program, have been built around PyVISA.

Version 1.1 of PyVISA was recently announced: "Yesterday I released version 1.1, which works much better together with older VISA implementations. Moreover, we finally have reports from Linux users. They successfully used PyVISA with Linux + NI/Tektronix GPIB hardware."

PyVISA looks to be an important tool for those who wish to perform instrumentation control functions from a Linux machine.


(Log in to post comments)

Control instrumentation devices with PyVISA

Posted Nov 30, 2006 4:55 UTC (Thu) by moxfyre (subscriber, #13847) [Link]

I *love* PyVISA!!! I'm a physics graduate student and do all of my data acquisition coding under Cygwin (Unix-like shell for Windows).

At first I used the Perl GPIB packages for data acquisition, and while they work fine, they are a *pain* to get installed properly. Had to figure out how to statically link them against the National Instruments GPIB DLLs, although the Makefiles thought the system should be looking for Unix libs since Cygwin is Unix-like. Took me hours.

A couple of months ago, I learned Python and found PyVISA. It's such a snap to install... just do "easy_install pyvisa" and then create a .pyvisarc file with a pointer to your VISA DLL. PyVISA will dynamically load that library and use it to interface with your devices.

Once you've got it going, you can just do something like:
inst = visa.instrument("gpib::24")
idn = visa.ask("*idn?")

Couldn't be easier!!!

Copyright © 2006, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds