Program instruments with Tcl
Martin Rowe, Senior Technical Editor -- Test & Measurement World, 8/1/2003
| Tcl script |
![]() |
|
A free programming interface lets you control IEEE 488 instruments from the Tcl scripting language. |
Tcl is an extensible open-source scripting language. Many data-communications test instruments contain Tcl and language extensions to automate test setups within an instrument (Ref. 1), but Simonson needed to get Tcl to control his test equipment through an IEEE 488 interface.
Ian Dees, a software engineer at Anritsu (Richardson, TX; www.us.anritsu.com), faced a similar problem, so he wrote "GPIB-Tcl", a Tcl extension that adds programming commands for Tcl to communicate with IEEE 488 cards from National Instruments (Austin, TX, www.ni.com). Dees says that GPIB-Tcl should work with any IEEE 488 card that uses the NI driver functions. You can download the GPIB-Tcl extension for Windows or Linux free of charge at http://gpib-tcl.sf.net.
To use Tcl with an IEEE 488 card, you need a Tcl engine, the GPIB-Tcl language extension, and the driver supplied with the card (see figure). You can download any of several Tcl engines from the Internet. Simonson uses a Tcl engine from ActiveState (www.activestate.com/Products/ActiveTcl).
Once you install a Tcl engine, you can write scripts that the engine will interpret and run. After you download GPIB-Tcl, you can unzip the files and follow the install instructions, or you can use a Tcl script written by Simonson's colleague Cary Renzema that automates the installation. Dees includes Renzema's script in the zip file that contains GPIB-Tcl.
The commands that GPIB-Tcl adds to Tcl let you initialize any instrument, write data and commands to the instrument, and read data from the instrument. When you read data from an instrument, the "gpib read" command lets you select ASCII, binary, or mixed mode. In ASCII mode, the command returns data as printable characters. If you select "binary," the command returns the instrument's response in hexadecimal format. In "mixed" mode, the command returns all printable characters in ASCII format and all nonprintable characters (such as returns) in hexadecimal format.
This article contains a GPIB-Tcl programming example that Renzema wrote that includes a sample input file from Simonson. The input file contains commands for controlling a Keithley Instruments (Cleveland, OH; www.keithley.com) Model 619 electrometer, Model 220 programmable current source, and Model 230 programmable voltage source, as well as a Tektronix (Beaverton, OR; www.tektronix.com) TDS3032 oscilloscope.
| Reference |
|



















