The PyVISA package enables you to control all kinds of measurement equipment through various busses (GPIB, RS232, USB) with Python programs. As an example, reading self-identification from a Keithley Multimeter with GPIB number 12 is as easy as three lines of Python code:
import visa keithley = visa.instrument("GPIB::12") print keithley.ask("*IDN?")
(That’s the whole program; really!) It is tailored to work on both Windows and Linux, and with arbitrary adapters (e.g. National Instruments, Agilent, Tektronix, Stanford Research Systems). In order to achieve this, PyVISA relies on an external library file which is bundled with hardware and software of those vendors. (So only in rare cases you have to purchase it separately.)
PyVISA implements convenient and Pythonic programming in two layers:
PyVISA is free open-source software. The PyVISA project page contains the bug tracker and the download area.
Projects using PyVISA so far:
The programming of measurement instruments can be real pain. There are many different protocols, sent over many different interfaces and bus systems (GPIB, RS232, USB). For every programming language you want to use, you have to find libraries that support both your device and its bus system.
In order to ease this unfortunate situation, the VISA  specification was defined in the middle of the 90ies. Today VISA is implemented on all significant operating systems. A couple of vendors offer VISA libraries, partly with free download. These libraries work together with arbitrary peripherical devices, although they may be limited to certain interface devices, such as the vendor’s GPIB card.
|||Virtual Instrument Software Architecture|
The VISA specification has explicit bindings to Visual Basic, C, and G (LabVIEW’s graphical language). However, you can use VISA with any language capable of calling functions in a DLL. Python is such a language.
Python has a couple of features that make it very interesting for measurement controlling:
|||For example, you don’t need to care about the underlying operating system with all its peculiarities.|