Python is becoming more established for scientific data analysis and processing, but what python instrument control options are there?
For me the benchmark instrument control software has to be LabView. It’s incredibly expensive and certainly has it’s quirks, but I’ve found that it can often make interfacing with hardware relatively painless.
I’ve recently been exploring alternatives to Matlab for scientific analysis and processing, so I was curious to see what the state of affairs was for python instrument control.
Read about my 3 Python Alternatives to Matlab.
My Requirements For Instrument Control
For me any python instrument control package would need:
- Standard hardware interfacing (E.g. GPIB, RS232, USB)
- NIDAQ interfacing
- Ability to easily build a virtual rack
- Easy live plotting of data
The most important of these of course is the ability to interface with the measurement hardware, so let’s see what python instrument control packages are available.
In a future post I’ll investigate the options for completely replacing LabVIEW with python.
Python Instrument Control Packages
The most important part of any python instrument control software has to be the packages for interfacing with the measurement equipment itself.
Thankfully there are a couple of fairly well maintained python packages that cover most of your interfacing needs.
PyVISA allows python to relatively painlessly interface with:
This example (taken from the PyVISA documentation) communicates with a Keithley multimeter on GPIB address 12:
>>> import visa >>> rm = visa.ResourceManager() >>> rm.list_resources() ('ASRL1::INSTR', 'ASRL2::INSTR', 'GPIB0::12::INSTR') >>> inst = rm.open_resource('GPIB0::12::INSTR') >>> print(inst.query("*IDN?"))
PyVISA seems to be an active, regularly updated package with fairly good documentation page. Unfortunately the VISA architecture does not include the popular NIDAQ card interface. For that we need PyDAQmx (below).
Thankfully there is an additional package, PyDAQmx, which acts as a wrapper to the NI-DAQ driver and allows your python scripts to communicate with the the DAQ card.