Controlling GPIB instruments from LabVIEW with GPIBEE

Overview

This page builds a small VI that opens an instrument through GPIBEE, asks it *IDN?, then loops a number of DC voltage readings into a table with timestamps. It is the same thing the Octave and Excel VBA examples do, built with the standard VISA palette functions and nothing else.

It takes about ten to fifteen minutes once LabVIEW and NI-VISA are installed. There is no scripting, no toolkit and no workaround anywhere in it.

Unlike the other tutorials here, this one has no file to download. That is deliberate, and explained below.

A standard VISA resource

The important thing to know before you start: GPIBEE is a fully VXI-11 compliant instrument. VXI-11 is the standard protocol that LAN instruments have spoken for decades, and the adapter implements it properly rather than approximating it. It is checked against a conformance test suite of our own, described in How GPIBee is tested.

What that means in practice is simple. To LabVIEW, GPIBEE is an ordinary VISA resource, no different from a LAN instrument by any other manufacturer. It shows up in Measurement & Automation Explorer like one. You wire it into the same VISA Open, VISA Write, VISA Read and VISA Close nodes you would use for anything else.

So there is:

  • No driver of ours to install. NI-VISA is all the software you need.
  • No LabVIEW plug-in, toolkit or instrument driver specific to this adapter.
  • No GPIB interface board. The adapter is on the network, so nothing goes in a PCI slot.

That is also how it works out in practice. Several users already run GPIBEE under LabVIEW, in benches that previously used other GPIB hardware, and what comes back is consistently the same: it drops straight in. The existing VIs keep working against the new resource name, and nothing else has to change.

The practical consequence is that every LabVIEW article, book and forum post about talking to a VISA instrument applies to this one unchanged. This page exists to give somebody new to VISA in LabVIEW a running start, not because the adapter needs special handling.

Why there is no ready-made VI

Every other tutorial here ships a project you can download. This one does not, for two separate reasons, and it seems more useful to say so plainly than to quietly leave the download button off.

A VI is not text. The other examples are ordinary source files, .c, .pas, .bas, .m, .cs. You can open them in any editor, read every line and check what they do before running anything. A .vi is a proprietary binary file that only LabVIEW itself can write or open. There is nothing to read, and nothing we could hand you that you could inspect the way you can inspect the rest of this example set.

Licensing. The free Community Edition of LabVIEW is licensed for non-commercial use. Building a VI with it to ship as part of the documentation of a product we sell falls outside those terms, so we do not do it. Using it yourself, on your own machine, to follow this guide and try the adapter is a different matter and is exactly what that edition is for. NI publish their own clarification of what the licence does and does not cover, linked at the foot of this page.

The honest answer, then, is a build guide rather than a binary we cannot verify or properly license. The steps below use only standard palette functions, so nothing here depends on our having built it for you.

Prerequisites

  • A GPIBEE, with an instrument on the GPIB bus.
  • LabVIEW. Any reasonably current version. The free Community Edition is fine for trying this out, subject to its non-commercial terms.
  • NI-VISA. This is a separate download from LabVIEW and is not bundled with it. Install it first, so the VISA palette is populated and instruments appear in Measurement & Automation Explorer.

If VISA itself is new to you, our Installing & Using a VISA tutorial explains what it is and walks through an install screen by screen. It uses R&S VISA as its example, but the ideas are the same for NI-VISA, and it is worth twenty minutes before you start wiring anything.

Your resource name

Everything below hangs off one string:

VISA resource name
TCPIP0::192.168.3.2::inst0,4::INSTR

Read it as two parts. 192.168.3.2 is the IP address of your GPIBEE, and the 4 at the end of inst0,4 is the GPIB address of the instrument on the bus. Both come from the adapter's own web interface, which shows its address and can scan the bus for you.

Get the punctuation exactly right:the device name is inst0,4, lowercase, with a comma and no spaces. A malformed device name fails at VISA Open with the same unhelpful error as an unplugged adapter, and it is the single most common reason a first attempt does not connect.

1. The front panel

Create a new VI with File → New VI. On the front panel, drop these from the Controls palette:

Drop thisFromWhat it is for
VISA resource name controlI/O → Instr I/O → VISA Resource NameName it VISA resource. Type your resource name into it as the default value.
Numeric controlNumeric → Numeric ControlName it Reading count, default 10. How many measurements to take.
String indicatorString & Path → String IndicatorName it IDN response. Where the instrument's identity appears.
Table indicatorArray, Matrix & Cluster → TableName it Readings. Two columns: timestamp and value.

Arrange them however you like. Layout has no effect on behaviour.

2. Open the session

Switch to the block diagram with Ctrl+E. The VISA functions live under Instrument I/O → VISA. Palette layout shifts between LabVIEW versions, so if you do not see it, type "VISA" into the search box at the top of the palette window.

Drop a VISA Open node and wire the front panel's VISA resource control into its resource name input.

Then drop a VISA Property Node immediately after it, and wire VISA Open's resource name output into it. Right-click the property node and set two properties, using Add Element to get the second row:

PropertySet it to
Timeout ValueA constant 3000, in milliseconds. Three seconds, the same as the other examples here. Raise it if you trigger long measurements.
Termination CharacterA constant 10, which is the line feed byte. It sits under Serial Settings in the property list, but it applies to VISA sessions generally and not only to serial ones.
Termination Character EnableA constant TRUE. This is what makes VISA Read stop at the newline the instrument sends at the end of its answer.
Termination is what catches people out:if reads are not told where an answer ends, they wait for the full byte count and then report a timeout, even though the reply arrived immediately. The symptom is distinctive: writes work perfectly and every read times out. Setting the two termination properties above fixes it for nearly every SCPI instrument.

The two wires that run through everything

This is the part that looks strange if LabVIEW is new to you, and it is worth understanding once rather than copying blindly.

The session is a wire, not a global. Every VISA node you add has to be physically threaded onto that wire, left to right, in the order you want things to happen. Nothing is implicit. The same goes for the error cluster: chain each node's error output into the next node's error input, all the way along.

Those two wires are how LabVIEW knows the order of operations and how a failure anywhere gets carried to the end instead of being silently swallowed. They also double as a correctness check while you build: the Run arrow stays broken until every wire is connected end to end.

3. Query *IDN?

Drop a VISA Write node after the property node, threading both wires through. Right-click its write buffer input, create a constant, and type *IDN?\n into it.

Turn on backslash codes:a LabVIEW string constant treats \n as two literal characters, a backslash and an n, unless you right-click the constant and enable '\' Codes Display. Do that, or the instrument receives a command that makes no sense to it and answers nothing.

Then drop a VISA Read node right after, wires threaded through again, with a constant 256 as the byte count. That is plenty for an identity string. Wire its output to the IDN response indicator.

That is a complete conversation already. If you stopped here, added a VISA Close and ran it, you would see your instrument identify itself.

4. Loop the readings

Drop a For Loop after the VISA Read, and wire the Reading count control into the count terminal, the small N in its top left corner.

Wire the session and error wires in through the loop border. LabVIEW creates tunnels for them automatically. Inside the loop:

  • A VISA Write with the constant MEAS:VOLT:DC?\n, backslash codes enabled again.
  • A VISA Read after it, byte count 256, wired the same way as before.
  • A Get Date/Time String node from Programming → Timing, to timestamp each reading.
  • A Build Array from Programming → Array, combining the timestamp and the reading into a two element array. That is one row of the table.

Wire that row to the loop's output tunnel. A For Loop indexes its output automatically, so each pass appends a row and what leaves the loop is a two dimensional array of strings. Wire it to the Readings table indicator.

Finally, bring the session and error wires back out of the loop border, heading for the close in the next step.

5. Close and handle errors

Drop a VISA Close node after the loop and wire the session into it. Closing matters: the adapter holds the link open otherwise, and the next run can find the instrument busy.

Then drop a Simple Error Handler from Dialog & User Interface as the very last node, and wire the accumulated error output into it. It stays silent when nothing went wrong and pops one dialog when something did, wherever along the chain it happened.

At this point every VISA node on the diagram should sit on two unbroken wires running left to right, the session and the error cluster, with no dangling ends.

6. Run it

Save the VI, check the resource name on the front panel, and press Ctrl+R.

The identity string appears once, and the table fills with as many timestamped readings as you asked for. If you see the identity string, every link in the chain works: LabVIEW reached NI-VISA, VISA reached the GPIBEE over the network, and the adapter reached the instrument over GPIB.

Where to go next

What you have built is the shape of every VISA program there is: open, configure, write, read, close, with errors carried alongside. Everything more elaborate is a variation on it. Swapping MEAS:VOLT:DC? for another SCPI command is enough to point the same VI at a different measurement or a different instrument.

Because the adapter is a plain VISA resource, NI's own instrument drivers work with it too. If there is a LabVIEW driver for your instrument, you can usually hand it this resource name and skip the wiring above entirely.

Stuck on a step?If a palette item is somewhere else in your LabVIEW version, or a wire will not connect, write to support@gpibee.com with what LabVIEW is telling you. It also helps us keep this page accurate across versions.

Troubleshooting

ProblemSolution
The Run arrow stays broken A wire is not connected end to end. Click the broken arrow and LabVIEW lists every fault with a jump to it.
VISA Open fails with 0xBFFF0011 Resource not found. The GPIBEE is not reachable at that IP, or no instrument answers at that GPIB address. Confirm the IP in a browser, then use the GPIB scan in the web interface.
Writes work, every read times out Read termination. Check both Termination Character and its Enable in the property node from step 2.
The instrument does not answer at all Look at the command constant. If '\' Codes Display is off, you sent a literal backslash and an n instead of a newline.
The adapter does not appear in Measurement & Automation Explorer It may be on a different subnet, where automatic discovery does not reach. You can always type the resource name in by hand; discovery is a convenience, not a requirement.
The table shows one row, or nothing The row array is being wired past the loop border rather than into an indexing output tunnel. Right-click the tunnel and check it is set to index, not to keep the last value.
Long measurements fail, short ones work The timeout is shorter than the measurement. Raise the Timeout Value past the longest operation you trigger.
Prefer to write code?The same instrument, the same protocol, in Python, C#, C, Object Pascal, Excel VBA and GNU Octave, each with a project you can download.