The HP5454xx family of digital storage scopes are pretty capable tools, with the high end of the family offering 4 channels with 2GS/S sample rate and 500MHz bandwidth. Their memory depth could be better, but the 32K samples per channel is definitely adequate for what I need.

Looking through the programmers manual for the 545xx scopes, all of the front panel controls can be accessed through the external interface. There are also a few functions that are only accessible through the external interface. Writing a complete interface package for this scope would be a very large task. I am not interested in developing a fully automated test system with the scope, just getting the sample data from the scope with a few minimal functions to ease the acquisition process.

A few years ago, I wrote a tool ( #HP5454x Screen Capture  ) that connects to the serial port on the scope and emulates an HP Laserjet printer enough to capture a PCL file which can be converted to other formats readily. As a result, the scope serial port is in use. This leaves the GPIB interface as the choice for controlling the scope. One added advantage of using the GPIB interface is that I can start the print download on the scope without getting up and walking across the room to push the "PRINT" button on the scope.

When the GPIB interface is in use to control the scope, the front panel is disabled.  It is frustrating to have to go through the two button sequence on the front panel to put the scope in local mode every time you want to change the configuration from the front panel. This program is designed to execute one or two commands and then turn the control back to the front panel. This method works well for the way I use the scope. Sitting in front of the scope, manually set the scope up and get it to capture the image as I want it. The PC is on another desk, so I can move to the PC and run multiple scan and capture steps to get the data that I want.

Commands supported by this tool are:
     RUN
     STOP
     MODE AUTO/TRIG/SINGLE
     FMT_WORD
     FMT_BYTE
     GET_DATA outfilename.csv
     WAIT_MS delay_MS
     FREE_BUS
     PRINT_START
     GET_ERRORS
     GET_IDN
     COUPLING 1/2/3/4 DC/DC50/AC
     SetSerial 0123456789

RUN Start the scope acquisition in whatever MODE it is set to. I normally use MODE SINGLE for acquisition. In MODE SINGLE, the scope captures one full set of data and goes back to STOP.

STOP Don't acquire any more data. This is basically an idle mode.

MODE This is the "TRIGGER MODE" and "RUN MODE" controls for the scope. AUTO just loops continuously, acquiring data and refreshing the screen as fast as it can. TRIG is the triggered sweep mode and the scope will sit in the run state waiting for the trigger condition to be satisfied and then it will acquire new data and go back to waiting for the next trigger event. SINGLE is like the TRIG mode, in that it will wait for a trigger condition before acquiring a set of data and then go to stop mode when it is complete. Either TRIG or SINGLE will give the most stable and predictable image on the screen and in the captured data. The SINGLE mode has the advantage that if you want to print a copy of the screen in addition to downloading the data, both will have the same information.

FMT_BYTE and FMT_WORD Selects the format for the data transfer from the scope. BYTE mode is slightly faster, but WORD mode data looks a lot better. In BYTE mode, there are 7 bits of data and the sign. In WORD mode, there are 14 bits of data and the sign. FMT_BYTE or FMT_WORD must be issued before the data to download is captured. Once an acquisition run is done, you cannot change the output format without corrupting the data.

GET_DATA Requests sample data from every channel that is enabled and builds a .csv output file with 5 columns. Column 1 is the time for each sample, columns 2 through 5 are the voltage values for each channel. If a channel is not active when the data is acquired, the column for that channel will be empty. The number of samples defaults to 512, but can be set in the HORIZONTAL menu on the scope to powers of 2 up to 32K. The number of lines of data in the output file will match the number of samples (+1). Note that the screen shows a 500 sample window into the capture data regardless of how many samples are captured.

WAIT_MS It is possible to have multiple commands on the command line and it may be necessary to wait some amount of time between them. This command is how you do that. The parameter for WAIT_MS is in integer milliSeconds. This command does not talk to the scope, it is just a local sleep command.

FREE_BUS If the program exits unexpectedly, it may not release the GPIB bus and return the scope to LOCAL mode. This command will take care of this.

PRINT_START Starts the print process on the scope. In use, you should start the hp_dump program in another window prior to issuing this command.

GET_ERRORS Queries the scope for any error messages. Sending bad parameter values or communication problems can generate errors and this is how you examine that information.

GET_IDN Retrieves the scope model, serial number and firmware revision information. Also useful for testing communication with the scope. If there are non-printable characters in the data, the result will be a hex/ASCII dump of the data, otherwise it will be formatted per the HP54542 Programming Manual. The only reason there should be non-printable characters in the data is that the memory battery in the scope has been changed without refreshing the serial number.

COUPLING Selects the input coupling on any channel. This command was put in because a scope that I am working on is having problems with the LED indicators for the 50 Ohm mode and was needed for troubleshooting

SetSerial Allows setting the serial number value for the scope in the battery backed memory. It accepts a 10 character value, which is the same format as the serial number shown on the sticker on the back of the scope. This is useful because the battery that keeps the memory alive lasts about 10 years, and when it goes dead, the scope stops working and the serial number information in the memory is lost. It is fairly easy to change the battery and re-calibrate the scope. This command allows putting the serial number back into the battery backed memory. The calibration protection switch must be set to "Unprotected" for this command to work.

This program was developed on a Fedora Linux system using the open source Linux-GPIB library to handle communication with the GPIB adapter. The Linux-GPIB API is very similar to the National Instruments C library API. It would not be difficult to port this program to build with National Instruments GPIB library and run under windows. The code for the WAIT_MS is the only really Linux specific code and would need to be re-written to port this to windows. The rest is generic ANSI C. I have had good luck with the MINGW/MSYS tool chain for command line driven code on windows.

July 28, 2022 Tried to get the National Instruments driver to link with the MINGW/MSYS output, and could not. Something has changed, because this used to work. Tested with the 32 bit version of MINGW/MSYS. No Joy.

Code for this project is released under the BSD license.

This is "tool code". I have been using it for a month or so and not seen problems, but there are almost certainly bugs in it. The top level parser architecture works for small command sets, but becomes unreadable as the number of commands increases. If I were adding more commands, I would change the parser architecture to one that is more readable for larger command sets.

Compiling and linking this tool requires the Linux-GPIB include file and .so file to be installed to succeed. You must have the Linux-GPIB library (availible from Sourceforge and other places) installed before attempting to build this code. The Fedora repository has Linux-GPIB in it. There are good directions in the Linux-GPIB download to build and install Linux-GPIB. To build HP54542_ctl, create a convenient directory for the source like ~/HP54542_ctl and un-tar the .tgz file in that directory. Type make from withing the source directory and the build should complete. You will probably want to move the executable into a directory in your path like ~/bin.
  [HP54542_ctl]$ tar -xvf HP54542_ctl_6_21_2022.tgz

  [HP54542_ctl]$ make

  [HP54542_ctl]$ make HP54542_Print

  [HP54542_ctl]$ cp HP54542_ctl ~/bin

  [HP54542_ctl]$ cp HP54542_Print ~/bin

There is also a single function executable called HP54542_Print that will start the print process with no parameters beyond a possible -D address.

The Linux-GPIB library supports many different hardware interfaces from several vendors. All of the supported interfaces use the same set of calls, so no changes are needed in the top level software based on the specific interface used. The supported interface list can be found on the Linux-GPIB web site: https://linux-gpib.sourceforge.io/doc_html/supported-hardware.html

Using HP54542_ctl:
The HP Default GPIB address for the 5454xx scopes is 7 and the code defaults to that using value. Unless you have changed the GPIB address in the scope, you don't need to use the -d address option to supply a GPIB address.

To see a list of supported commands:

[HP54542_ctl]$ HP54542_ctl

Usage: HP54542_ctl [-d dev_addr] CMD1 [arg1] [CMD2]...
 where CMDn [argn] is one of:
     RUN
     STOP
     MODE AUTO/TRIG/SINGLE
     GET_IDN
     GET_ERRORS
     FMT_WORD
     FMT_BYTE
     GET_DATA outfilename.csv
     WAIT_MS delay_MS
     FREE_BUS
     PRINT_START
     COUPLING 1/2/3/4 DC/DC50/AC
     SetSerial 0123456789

The configuration options (starting with - ) must all
be before the first command on the command line.

To capture a few sets of data: From the scope front panel, set the scope up to trigger reliably where you want it to, set the number of samples and sample rate desired. Set the sweep time to capture the portion of the waveform that you want. The vertical position of each trace doesn't matter in the captured data, traces can overlay each other without problems. In this example, the command line prompt is: [scope_data]$ so just type the stuff starting at HP54542_ctl.
From the PC:

[scope_data]$ HP54542_ctl
[scope_data]$ HP54542_ctl stop
[scope_data]$ HP54542_ctl fmt_word
[scope_data]$ HP54542_ctl mode single
[scope_data]$ HP54542_ctl run
[scope_data]$ HP54542_ctl get_data sample10MS_Run_1.csv
[scope_data]$ HP54542_ctl run
[scope_data]$ HP54542_ctl get_data sample10MS_Run_2.csv
[scope_data]$ HP54542_ctl run
[scope_data]$ HP54542_ctl get_data sample10MS_Run_3.csv

The first line shows the list of possible commands. This is not needed if you remember the commands.
The second line stops the acquisition.
The third line sets the data transfer format to WORD.
Lines 4 and 5 acquire a set of data and transfer it to a file named: sample10MS_Run_1.csv
Subsequent run, get_data lines repeat the acquisition and store operations.

To Capture an image of the scope screen using the hp_dump program, the printer stuff in the utility menu on the scope must be configured correctly for hp_dump. The program hp_dump is another project that I have posted: #HP5454x Screen Capture .
Start the data transfer from HP54542_ctl:

[scope_data]$ hp_dump sample10MS_Run_3.pcl
[scope_data]$ HP54542_ctl print_start

You could replace the HP54542_ctl print_start command with HP54542_Print and get the same result.  

To set the serial number in the battery backed memory:

[HP54542_ctl]$ HP54542_ctl setserial US353001xx get_errors
[HP54542_ctl]$ HP54542_ctl get_idn

The first line sets the serial number in the scope and asks for any errors. Assuming that there were no errors, the second line displays the new serial number information. If there were errors, check that the calibration protect switch is in the "Unprotected" position. The first line shows the use of two commands on a command line.