Global TMW:
Login  |  Register          Free Newsletter Subscription
Subscribe
Email
Print
Reprint
Learn RSS

Program instruments with Tcl

Martin Rowe, Senior Technical Editor -- Test & Measurement World, 8/1/2003

Tcl script
Ron Simonson, a product engineer at Analog Devices'  (www.analog.com) Design Center in Beaverton, OR, often had to make the same types of measurements for different tests. Rather than spend time with front-panel setups, Simonson wanted to automate the instrument setups with a language that works with both Windows and Linux. Thanks to other engineers and the open-source software movement, he now uses the Tcl

A free programming interface lets you control IEEE 488 instruments from the Tcl scripting language.

scripting language to configure instruments from either operating system over the IEEE 488 bus.

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
  1. Rowe, Martin, "Scripts automate communications test," Test & Measurement World, June 2001. p. 43. www.tmworld.com/archives.
Email
Print
Reprint
Learn RSS

Talkback

We would love your feedback!

Post a comment

» VIEW ALL TALKBACK THREADS

Related Content

Related Content

 

By This Author

Sponsored Links



 
Advertisement
SPONSORED LINKS

More Content

  • Blogs
  • Podcasts

Blogs

  • Rick Nelson
    TAKING THE MEASURE

    July 1, 2008
    S-parameters are so yesterday
    Textbook amplifiers operate in linear mode and are easy to analyze. Unfortunately, it’s often ...
    More
  • Martin Rowe
    Rowe's and Columns

    May 28, 2008
    More on Bill and Dave
    In my January 11 posting, "Tell your Bill and Dave Stories," I asked if the HP Way still e...
    More
  • » VIEW ALL BLOGS RSS

Podcasts

Advertisements





NEWSLETTERS
Click on a title below to learn more.

Test Industry News (3 Times Per Month)
Machine-Vision & Inspection (Monthly)
Communications Test (Monthly)
Design, Test & Yield (Monthly)
Automotive, Aerospace & Defense (Monthly)
Instrumentation (Monthly)
Resource Center E-Alert (Monthly)
©2008 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy
Please visit these other Reed Business sites