Saturday, May 25, 2013

Learning how to operate GPIB buses with Labview

I'm currently engaged in a project which requires me to coordinate four separate pieces of hardware (two lasers, a stepper motor, and a photon counter). As is the case with all good experimental scientists educated in the 2000's, my first thought was to turn to Labview for making this happen.

However, I'm not terribly excited about this. I haven't actually programmed in Labview since my REU studies at the University of Colorado, Boulder, during which I made a visible grating-based spectrometer for working with lasers in vacuum systems. Since then, I've somehow managed to perform ALL of my experiments without automation and by writing down results in my lab notebook. I know that automated data acquisition can make my life easier, but my experiments have been relatively simple until now and learning Labview would have taken too much time.

Furthermore, I'm much more interested in using open-source software whenever I can (PyVISA is one such Python package which might help me). I don't ever want to be dependent upon possessing some company's latest toolbox or software version to do my research.

Despite all of this, I'm under a time-crunch with my current project and Labview is arguably the de facto standard for automation and measurement, so... here I go!

I first installed Labview 2012 on a Windows 7 system. There really wasn't any problem here; the software took a while to install, but it wasn't a big deal.

Following this, I quickly discovered that I needed to install the DAQmx software to get nearly all of my lab's previous VI's working. This wasn't a big deal either (it's free if you're registered with National Instruments), but I wonder why something that is apparently so important to Labview is left out of the installation. Some slight perusing on the NI community pages led me to find that since the 2012 version, NI changed up what is included from DAQmx with the base Labview install. I found an old repository for these now "missing" VI's, but it was pretty confusing to navigate.

Now, onto the GPIB control. I found an old NI PCI-GPIB controller card in one of our lab computers, removed it, and inserted it into the computer that I'm currently using. Windows recognized the card but didn't know what to do with it and Labview didn't know it existed. Fortunately, I found and downloaded the NI-488.2 driver, version 3.1.1 from NI's website and installed it without a hitch. After reboot, the card was recognized in NI's Measurement and Automation Explorer (MAX).

Now, I admit that getting the first device, a Stanford Research SR400 Photon Counter, was a breeze. I ran a GPIB cable from the PCI card to the SR400, and another one from the SR400 to my motion controller (of the two lasers, one is controlled via USB and the other via RS232). Both GPIB devices were recognized in MAX. This is what my MAX window looked like after clicking "Scan for Instruments" while having PCI-GPIB "GPIB0" selected in the left-most itemized list:


In this picture I had already renamed the devices in MAX. I could tell which was which by turning one off and rescanning. Most of this information is found on an NI community website: http://www.ni.com/gettingstarted/setuphardware/instrumentcontrol/gpibconnect.htm

One final note: after reading some discussions on the SR400, I found that this particular device is tricky to work with because it's so old. Fortunately, on this same discussion I found custom VI's for working with it from Paul Henning which have worked like a charm.

So far, I'm quite happy with how easy it was to get to this point. This was facilitated by software that worked seamlessly at finding the hardware and a strong user-base for getting specific hardware to work. I still anticipate having some difficulty with the actual programming and getting the instruments to work in sync, but that can't be helped so much.

Kudos to you, NI.