Linux Drivers for Tektronix Oscilloscopes and Arbitrary Function Generators

Using the VXI-11 RPC Protocol over Ethernet

Steve D. Sharples

Last code update: 17 August 2009, current version: 1.04.
Website updated: 3 September 2008

Related links:
VXI11 Ethernet Protocol for Linux. You'll need this for these drivers to work.
Linux Drivers for Agilent Infiniium Oscilloscopes
TCP/IP Control of a LeCroy DSO with Linux
Random links:
Hardware Linux/open source drivers | Eagle PCB -> PCBTrain Export Mini How-To | Eagle PCB -> LPKF Milling Machine Mini-How-To | strip_nl: newline (CR) stripper | Agfa Snapscan 310 Scanner with Linux | Linux on a Dell Latitude CP M233XT | Installing PCI230/PCI260 Comedi driver on a RedHat 9 system (PDF) | The steve (a new unit of measurement) | Applied Optics Group at EEE, University of Nottingham (who we are)

Skip to the end...

Here's a link to a tarball of the latest source: tek.tar.gz. Once you've untarred it, have a gander at the README.txt file. You might also want to have a quick butchers at the CHANGELOG.txt file.
You will also need the VXI11 Protocol for Linux (including my vxi11_user libraries).

For those in a real hurry, check out the 60 second quick download and installation instructions.

Introduction

This is a collection of source code that will allow you to talk to Tektronix oscilloscopes and arbitrary function generators (AFGs), via the VXI11 Protocol for Linux. It uses my own vxi11_user libraries, built on top of the VXI11 RPC protocol itself. To compile and run this code, you will also need the vxi11.tar.gz tarball. It consists of a user library (tek_user.c), with a range of functions that perform many of the common tasks that you might want to do with your scope/AFG, including (at the time of writing) grabbing traces from the scope, loading and saving settings, uploading waveforms to your AFG etc; and a handful of simple command line utilities that will allow you to do these things. You can use these as templates to writing your own applications, and I'd be interested in any that you develop!

Description of the Linux tek code

This collection of source code consists of:

1. library/tek_user.c (and library/tek_user.h)

These are (fairly) friendly user libraries. You can "open" and "close" your scope, load and save the setup, set up the scope for waveform capture, grab data, work out how many points your data will be, etc. There is not an exhaustive list of all the different things you might want to do (there is no function for "set the acquisition mode to peak detect" for instance) but the code in the functions provided show you how to write functions for this kind of thing if you so desire. Most things can be achieved very easily via direct commands; so rather than writing a function to set peak detection mode, you would just use vxi11_send(clink, "ACQ:MODE PEAK"); for instance. Have a browse through the library, you'll see what I mean.

So most of the guts of the library is about setting up the scope for acquisition, working out how many bytes of data you're going to get, acquiring the data, and so on. In this respect, there is a certain amount of personalisation that you may not necessarily agree with and may want to change (which of course you can do, it's all open source!). For instance, by default, the acquisition memory on Tektronix scopes may contain a longer time period's-worth of information than is displayed on the screen. I personally find this concept confusing to work with, and so the library functions are written such that the time period of data that you get always corresponds to what you see on the screen.

2. utils/tgetwf/tgetwf.c

This is a command line utility for grabbing a trace from the scope. After you've compiled the source code, type ./tgetwf to see how to use it. For historical reasons, we have our own data format for scope trace data. Each trace consists of a trace.wf file that contains the binary data, and a trace.wfi text file that contains the waveform info. We then use a very cheesy Matlab script, loadwf.m to load the data into Matlab. The wfi file does not contain all the information that Tektronix's own "preamble" information contains; on the other hand, you can have multiple traces in the same wf file. So whether you use this format, or modify it, is up to you. The utility is well commented, and so you should be able to adapt it to suit your own purposes, should you wish.

3. utils/tek_load_save_setup/tek_save_setup.c

Saves the current Tektronix Scope Setup to a ".tss" file, for future use.

4. utils/tek_load_save_setup/tek_load_setup.c

Loads an Tektronix Scope Setup (".tss") file, and sends it to the scope.

5. loadwf.m

A cheesy Matlab script for loading the trace.wf/trace.wfi files generated by the tgetwf utility. This script (and the wfi file format) has been hacked and bodged over more than six years and several generations of digital scopes by several manufacturers, so it isn't very pretty!

6. utils/tek_afg_upload_arb/tek_afg_upload_arb.c

Loads an arbitrary waveform into a Tek AFG3252 (and possibly others in this range).

7. make_sim_signal.m

A cheesy Matlab script for generating an arbitrary waveform.

8. utils/tek_afg/tek_afg.c

Utility that allows you to set a few of the waveform parameters from the command line, such as turning channels on and off, changing the peak-peak voltage, frequency or phase. Also allows you to send an arbitrary command to the Tek AFG (or in fact to any VXI11 instrument).

9. Makefile

Type "make" to compile the source above. Type "make clean" to remove old object files and the old executables. Type "make install" to copy the utilities to /usr/local/bin/

There are also individual Makefiles in the tgetwf, tek_load_save_setup, tek_afg and tek_afg_upload_arb directories.

10. README.txt

Contains instructions on how to compile the source against the vxi11 code; and some other info.

11. CHANGELOG.txt

Text file containing information about the changes between all the different versions.

12. GNU General Public License

Fairly obvious. All programs, source, readme files etc are covered by this license. In brief:

These programs are free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

These programs are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with these programs; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

60 Second Quick Download and Installation Instructions

This is all in the readme, but then it's nice to cut and paste sometimes...:

wget http://optics.eee.nottingham.ac.uk/vxi11/source/vxi11.tar.gz
tar -xvzf vxi11.tar.gz
cd vxi11
make
Everthing ok so far? Want to see if you can talk to your scope (or any VXI11 instrument)?
./vxi11_cmd your.inst.ip.addr
*IDN?
q
Let's carry on...:
cd ..
wget http://optics.eee.nottingham.ac.uk/tek/source/tek.tar.gz
tar -xvzf tek.tar.gz
cd tek_X.XX
(where X.XX is the current version number)
make
Everything ok? Want to try and grab a trace?
cd utils/tgetwf
./tgetwf -ip your.inst.ip.addr -f test -c 1
(Binary data is in test.wf, waveform info is in test.wfi. Use the Matlab script loadwf.m to load into Matlab.)

Links to the source

Here's a link to a tarball of the source: tek.tar.gz

This produces a "tek" directory containing the tek_user.c and tek_user.h library; a utils directory containing tgetwf.c, tek_save_setup.c, tek_load_setup.c, tek_afg_upload_arb.c and tek_afg.c utilities; and loadwf.m, a Matlab script for reading the files produced by tgetwf.

There is also a Makefile, a README.txt file, a CHANGELOG.txt file, and a copy of the GNU General Public License. To extract the tarball, use tar -xvzf tek.tar.gz . Then have a look at the README.txt file for compiling instructions.

Please read the disclaimer about warranty, etc etc.

All the files, including previous versions, are available for viewing or downloading here.

All trademarks and copyrights are acknowledged.