Object-oriented programming examples for the GPIB (IEEE-488) bus

From EDM2
Jump to: navigation, search

by Stefan Zollner

Lab equipment such as digital voltmeters, temperature controllers, stepper motors, counters, etc. often can be controlled with a computer using a GPIB bus (also called IEEE-488 or HP-IB bus). Some ancient computer disk drives (Commodore C64 or HP-150) were also controlled with a GPIB bus.

What you need

  • A GPIB interface card (such as an AT-GPIB/TNT card from National Instruments) to plug into the motherboard of your computer.
  • Drivers for the card, sometimes (but not always) available from the manufacturer of the card. Before you buy a card, make sure that the manufacturer offers drivers for your version of the operating system and is willing to support it (fix bugs, if you find them).
  • GPIB cables. (See restrictions on the length of cables).
  • Some general introduction to the GPIB bus and its control commands. This is sometimes included in the documentation for the GPIB interface card. There are also two very good articles on the GPIB bus some time ago in the journal Computers in Physics (your local university library should have this journal). A quick tutorial can also be found in the 1996 Instrumental Reference and Control Catalog from National Instruments. (Other vendors may have similar offerings.)
  • Optional: A GPIB analyzer in case something does not work the way you want it. Unfortunately, Hewlett-Packard no longer manufactures GPIB analyzers the way they used to. I am not aware of any other analyzers from other companies. National Instruments offers a software solution, but it only runs on DOS/WIN-based systems. (Since Microsoft dropped OS/2 as an operating system, National Instruments has not announced new products for OS/2. They are very half-hearted in the support of the OS/2 products they still sell. A support engineer once told me: "If 99% of our customers buy DOS-based products, you have to understand that 99% of my expertise is in this area.")

List of Programming Examples

  • constants and structure definitions (include file) - GPIB.H
  • class definitions (include file) - GPIBCLASS.HPP
  • Source code for the DLL - GPIB.CPP
  • Compiled (object) file - gpib.obj
  • GPIB.DLL dynamic link library
  • GPIB.LIB include library
  • GPIB.DEF linker definition file
  • NICODE.H is only available from National Instruments (as part of the OS/2 driver for AT-GPIB/TNT)
  • GPIB.ZIP. Contains everything (except NI drivers)

Programming tools you need

I use the following programming tools to write software for controlling my GPIB devices:

  • VisualAge C++ for OS/2 (version 3.0) with CSDs.
  • Include files for your GPIB driver (such as at at-gpib\c\nicode.h from National Instruments).
  • Borland's resource workshop (part of Borland C/C++ compiler for OS/2, version 1.5) for creating nice dialog windows.

DISCLAIMER: This sample code is for your information only. Do not attempt to use this code on your equipment without first inspecting the source code and making sure it does what you want. This code is supplied as is without warranty or liability of any kind. Most of the brand names on this page are registered trademarks. Ames Laboratory or the author have no connection with National Instruments.

Note: This code is part of a larger program which I use for controlling my experiment. Some sections of the code have been removed to make the code stand-alone. Therefore, I am not sure, if this code will run without errors on your machine. I am not too concerned about this, since you are not supposed to run this code anyway. INSTEAD, THIS CODE IS INTENDED TO SERVE AS AN EXAMPLE, what type of things you can do using GPIB drivers on an OS/2 machine.