In this article I will tell you how to interface with a GOULD 4094 digital storage oscilloscope without proprietary software, i.e. using only Linux command line tools and the open source scripting language PERL.
If you don’t have exactly the same model … I suppose the 4090, 4092, 4072A, 4074A have very similar commands, it’s worth a try, I guess.
In the download section I provide a link to the software I wrote. It’s just a small PERL script that should run on any linux machine with the necessary PERL modules / command line tools (nothing fancy) installed.
A friend of mine has some connections to a company that needed to get rid of old lab equipment. He asked me if I could use a digital storage oscilloscope. I probably replied something like “hell yes”, because you don’t find something like that lying around on the street every day.
My friend told me that it was “big”. I understood what he meant when he dropped by my place and I had this huge box standing around:
It’s a GOULD 4094, 200MHz digital storage oscilloscope with four input channels. From what I can tell It is from the year 1990 or so.
All the features that you expect from a good scope are there: switching between AC/DC coupling, switch input impedance between 50 Ohms and 1M, setting trigger levels and delays, you can even set two different time bases (horizontal scaling) A and B and switch for each of the four input channels between these two timebases independently. When you freeze a curve with the hold button or by setting a trigger, you can “walk around” the curve with a cursor and read the momentary voltage level. You even can set the display intensity for the traces and the alphanumeric output separately.
It got a mathematical signal processor that lets you sum/subtract channels and calculate the FFT of the input signal, or apply a lowpass/highpass filter. The funniest feature is the built-in graph plotter, which seems to be still working, despite the fact that the ink in the plotting pens is long gone dry.
Despite its grey bulkiness I suppose that in 1990 this must have been a luxury scope. And today – it’s good enough for me 😀
The manual that came with it claims that the scope has digital interfacing options … that may be interesting. I didn’t want to put my hopes up too high, but maybe … given IF I would manage to connect this thing to my PC somehow, could I dump the trace storage and make a plot on my computer? I’m doing all my everyday work, my AVR coding and flashing, PCB design and numeric calculations on Linux. So it would be nice if I could talk to the scope using only open source/Linux software …
Interfacing – electronics
Looking at the backside of the scope I found some intimidating looking connectors:
GPIB, RS423 and misc I/O. Hmm … not what I was hoping to find, which would have been a plain simple RS232 (D-Sub 9) connector.
The manual claims that the RS423 port (D-Sub 25 connector) is a a serial interface. It even provides a pinout of the connector. Furthermore it says that RS423 is in many ways compatible to RS232, just the logic levels are different. RS232 is -12V -> HI, 12V -> LO whereas RS423 alternates between -6V and 6V. That is not so bad. Most USB2Serial converters don’t output the full +/-12V logic levels anyway, they are more like +/-7V.
So I got myself one of these USB converters:
I was already scratching together some cables and leftover D-Sub connectors to build me a custom adapter cable when I found an old modem cable (DB9 Female to DB25 Male Standard RS-232 Modem Cable) that used to connect my 56k Modem to my desktop PC some 10 years ago. Fortunately the pin configuration of the cable was just perfect for linking my USB2Serial converter to the scope, I only use the lines RX, TX and Signal GND anyway.
Interfacing – protocol
In the scope’s menu I set the serial interface to 9600 baud, no handshake. In a linux console I opened my favourite serial terminal emulator “picocom” to see whether the scope would talk to me (alternatives to “picocom” would be “minicom” or “screen”).
micha@TM8371 $ picocom -b 9600 /dev/ttyUSB0 ? ?HELLO GOULD,4094,2.00 ?
Now I tried some of the commands that were listed in the manual. There are quite a lot of commands 😀
Above you saw the reaction to the “HELLO” command. It replies by printing its name and the firmware version (I suppose).
To control the basic parameters of the scope I found the following commands quite useful:
HSA (prints the current horizontal scaling in sec/div)
HSA=100E-3 (set horizontal scaling to 100 ms per division, timebase A)
HSB=100E-3 (set horizontal scaling to 100 ms per division, timebase B)
VS1=100E-3 (set vertical scaling to 100 mV per division, channel 1)
… and so on … they are nicely documented in the manual …
So you see, once you know the keywords the setting and reading of settings is pretty straightforward, just use the proper SI unit and decimal power.
The most powerful command is probably:
TRC1A ( trace recall channel 1 timebase A)
which prints out the contents of the oscilloscope’s trace memory, a sequence of 1008 signed 1 byte integers ( numbers from -127 to +127). That is pretty cool.
Before I forget: when you issue a command via the serial line, the scope’s control buttons will be locked while the bottom line of the scope’s screen says “RS423 remote”. You can break the lock by pressing the “Abort” button underneath the screen.
So I can talk to the scope now, and it talks back at me. Very satisfying. But yet tiresome and impractical. If I want to use the scope to take data in an everyday lab work context then I need a tool that issues the necessary commands automatically, waits for the answers and processes the received data until it has a form that I can comfortably work with later on.
I chose to handle the scope with the same tools that we use to talk to lab equipment at work: Writing a perl script which uses the libdevice-serialport-perl library to handle serial communication.
I do not want to go into details here. Those of you who are into PERL, you look at the source code anyhow if you are interested. For those of you who just want to use the script, here is a summary of ho to use it:
First perform the steps listed in the Download + Installation section at the bottom of this page.
Open a linux terminal, then go to the directory where you stored the script:
make the script executable:
chmod +x dsocmd.pl
now you can call the script and pass it an oscilloscope command, like “HELLO”:
(pasted from my bash console)
micha@TM8371 gould_4094DSO $ ./dsocmd.pl -c HELLO sending command HELLO DSO received command HELLO received answer: GOULD,4094,2.00
If you don’t want the debug info, i.e. the pure scope answer, then use the quiet option:
micha@TM8371 gould_4094DSO $ ./dsocmd.pl -c HELLO -q GOULD,4094,2.00
If you want to specify a non-standard hardware interface and baudrate you can do this via the “-tty” and “-baud” options:
./dsocmd.pl -c YOUR_COMMAND -baud 9600 -tty /dev/ttyUSB3
What about making a “screenshot” of the scope? I wrote a little subroutine for that. Call this function with:
./dsocmd.pl -plot [-show] [-pdf]
The data transfer takes up to 20 seconds. If you add the option “-show” then a ghostview (gv) window will be opened and show the screenshot. If you add “-pdf” the plot will be saved in pdf format, by default output will saved as eps format.
The “plot” sub calls the “PLOT” function of the scope, which in turn will send the screen content to the PC encoded in HPGL, a HP printer/plotter language. My script now calls hp2xx, an gnu/linux command line tool, that is able to convert the HPGL file to an .eps (encapsulated post script) which is a vector graphic format that can be opened with most linux document viewers or graphics editors. The generated eps file is stored in the “plot” folder in the current directory (will be created if doesn’t exist). If “-pdf” is added to the command options, the eps file will directly be converted to a pdf file, with the help of “epstopdf”, another command line tool which is part of the package “texlive-font-utils”.
Okay making screenshots and saving them as vector graphics is pretty awesome. But how about reading out the numeric data of a specific trace from the scope’s storage?
I wrote another subroutine for that:
./dsocmd.pl -capture 1A [-show] [-pdf]
This will read the trace data from channel 1A ( or 2B , or 3A …) and write it to a .dat file in the “capture” folder which will be created if it does not already exist in the current directory. At the same time, the received data will be piped to gnuplot, which will create a png image or a pdf file when “-pdf” is set. “-show” will cause a viewer to open the latest plot.
The dat file contains two columns of numbers, separated by a tabulator. The left column contains the relative time in seconds, while the right column contains the voltage amplitude of the captured signal in volts at this very point in time.
The file format is perfectly suited for reading the data in with numeric tools like Gnuplot, Octave/Matlab/SciLab or LibreOffice Calc, etc…
Please let me know if you try/manage to interface with your GOULD DSO. It helps to know that I don’t write my articles in vain, in any case I do expect the exact opposite of a large audience 😀
Download + “Installation”
before you run the script, make sure you have the following software packages installed:
- libdevice-serialport-perl [ for serial communication, mandatory ]
- hp2xx [ for hpgl -> eps conversion ]
- texlive-font-utils [contains “epstopdf”, for eps -> pdf conversion ]
- gnuplot [ for plots of downloaded traces ]
On a Debian/Ubuntu/Mint Linux you can install all that by typing this into your console:
sudo apt-get install libdevice-serialport-perl hp2xx texlive-font-utils gnuplot
Make sure your user can access the serial interface. Therefore “user” has to be member of the “dialout” group. You can achieve this by simply typing:
sudo usermod -a -G dialout user
Subsequently user has to log out and in again, so the changes become effective.
Now get the script from [here], OR download it directly in the command line:
git clone firstname.lastname@example.org:acidbourbon/dsocmd.git cd dsocmd
make the script it executable:
chmod +x dsocmd.pl