An
Introduction to Instrument Programming in LabVIEW Using GPIB/IEEE-488
We assume that you have some background - however sparse - in programming.
In this lesson, we will examine how to communicate with an instrument using
LabVIEW and a GPIB (IEEE-488) connection. We will focus on the Fluke
Hydra Data Acquisition Unit (DAU), but what is covered here is applicable
to many other instruments. Note that LabVIEW is a copyrighted name
owned by the National Instruments Corporation, and that is the corporation
that sells LabVIEW. It is the most widely used programming environment
for instrument control although there is considerable instrument programming
done in C/C++ and Visual Basic. LabVIEW is a visual programming environment
(which means that you do not write sequential lines of code) and seems
to be uniquely matched to the ways of thinking and solving problems that
engineers and scientists commonly employ.
The first step in instrument programming is to reset the instrument under
program control in LabVIEW. What you need for that process is the
following.
-
First, you need to start
LabVIEW and generate a new "vi". LabVIEW files often have a "vi"
extension, and that stands for "Virtual Instrument". You are about
to embark on developing a virtual instrument that uses the Hydra DAU to
take the actual measurements. What you write in LabVIEW will be a
program that controls that process.
-
You need to know the GPIB
address for the instrument. In many cases - especially with more
recent instruments - the GPIB address will flash for a moment as the instrument
cycles through its startup procedure. In the case of the Hydra, you
need to set that address. Within our department, the standard
address is 3, and you will find most programs use that address.
-
Once you have that taken
care of, the Hydra should be ready to be accessed from within LabVIEW.
The
Hydra
In the lab, you will find that the numbered terminals for the Hydra have
been brought out to a connector block attached to the top of the Hydra.
Those terminals are shown below in the photo of the Hydra and we are referring
to the orange terminal blocks there.

In the example in this note, we will be taking a temperature measurement
from Channel 1 of the Hydra. That means that you should connect the
thermocouple leads to the Hydra.
-
Attach the red lead to
terminal #22.
-
Attach the other lead
to terminal #21.
WARNING: You cannot
take a temperature measurement from the front panel terminals (Channel
0). You might try, and you might even force the thermocouple wires
into those terminals, but it will not work!
Taking
a Temperature Measurement
Taking a temperature measurement is more complex than just resetting the
instrument. The steps you need to take are as follows (assuming that
the instrument has been reset). Here's the diagram for the vi.

Here's what you do in this vi.
-
Send the following commands
using the GPIB Write
block in LabView. In the diagram below, there are three GPIB Write
blocks. Note that each of them uses the same address (3) and the
same mode (3) as in the reset vi above. Here are the commands that
are sent to the instrument in each of the GPIB Write blocks.
-
FUNC 1,TEMP,K
- which sets the function on Channel 1 to be TEMP (TEMPerature
measurement) using a type K thermocouple.
-
*TRG
- which triggers a measurement when the instrument receives this command.
-
LAST? 1
- which requests the instrument to prepare the last measurement on Channel
1 for transmission to the computer.
-
In LabView you sequence
these commands by taking the error signal from each block and feeding it
to the next block. See the diagram reproduced below.
-
After setting up the instrument,
taking a measurement and preparing the data, you must get the instrument
to send the string to the computer. In LabView you use a GPIB
Read block. It's found in the same general
place as the GPIB Write block.
The vi above will take a single temperature measurement once the instrument
has been reset. That allows you to put the temperature mesurement
inside a loop and put the reset outside the loop. If you use this
in an application where speed is critical, you might also want to consider
putting the GPIB Write block that sets the channel and the measurement
type outside the loop, separating it from the rest of the operations above.