HP 54602B Oscilloscope: Capturing Screen Images Therefrom

Back in the early 90s I bought a Hewlett Packard 54602B digital oscilloscope: 150 MHz bandwidth, 4 channels. By and large, a fine piece of gear that’s been worth every penny.

Over the objections of the HP sales force, I got the HP 54651A RS-232 interface rather than the HP 54650A HPIB (aka GPIB, aka IEEE-488) interface. Reasoning: I’d need a matching interface on the PC side and PC architecture is anything but stable. Turns out that was a good decision, as you’ll realize if you count up the number of different buses since those days and factor in the cost of an IEEE-488 interface for each iteration. RS-232 is slow and not well-suited for complex arrays of test gear, but mostly I needed the scope for screen shots to go with my Circuit Cellar columns.

Here’s how that works…

Configure the scope by poking the RS-232 softkey in Print/Utility:

  • Connect to: HP Plot
  • Factors: On (this is absolutely vital)
  • Resolution: High
  • Baud Rate: 19200 (yes, “baud rate” is an oxymoron)
  • Handshake: DTR

Now the scope will dump HPGL to what it thinks is a plotter, so the trick is to make the PC look like a plotter. Turns out that’s not particularly difficult.

Despite the name, DTR handshaking does not use the scope’s DTR pin. The relevant manual section looks like this (click the thumbnail for full-size image):

HP54602B Oscilloscope Serial Port Pin Functions

HP54602B Oscilloscope Serial Port Pin Functions

So DTR remains high and the flow-control signaling actually uses the RTS/CTS pins. The cable I’ve been is basically a null modem connection with the appropriate gender on each end:

PC RS-232 HP 54602B Oscilloscope
9-pin F Signal 25-pin M Signal
1 DCD 20 DTR
2 RxD 2 TxD
3 TxD 3 RxD
also-> 8 DCD
5 Gnd 7 GND
6 DSR 20 DTR
9 RI n/c


  • PC 1 and 6 <- scope 20
  • PC 4 -> scope 6 and 8

I wired the cable like that mostly because I have a lifetime supply of nice 9-conductor shielded cable lying around. You could connect the scope’s DTR to its own DSR and DCD pins, apply similar trickery on the PC end, and everybody would be perfectly happy with 5-conductor cable, maybe even 4-conductor if you ran the ground through the shield.

Using XON/XOFF flow control seems to not work well, although I admit to not trying too hard to figure it out.

These days, I use a USB-to-RS-232 converter with the now-standard 9-pin connector. The port identifier may be nearly anything after udev/hotplug has its way with the hardware, but it usually works out to /dev/ttyUSB0.

The script requires C-Kermit (likely the ckermit package), ImageMagick, sed, and hp2xx (yes, spelled exactly like that), all of which should be packages in your favorite Linux distro. Haven’t a clue how this might work with Windows.

With all that in hand, copy-n-paste the following text into a file (I used gethp54602, for lack of anything more original), make it executable (chmod u+x gethp54602) and run it with a file name (./gethp54602 test). Poke the Print Screen softkey on the scope and settle back for a bit. The scope can’t keep up a steady flow of data at 19200 b/s, so the whole affair takes a minute or three for the 50-ish kB of text in a dual-trace image.

You’ll end up with three files:

  • test.hgl — raw HPGL text from the ‘scope
  • test.eps — raster conversion from HPGL
  • test.png — bitmapped screen-capture image

The magic script…

#!/usr/bin/kermit +
# Fetches screen shot from HP54602B oscilloscope
# Presumes it's set up for plotter output...
# Converts HPGL to PNG image

set modem none
set line /dev/ttyUSB0
set speed 19200
set flow rts/cts
set carrier-watch off

# Make sure we have a param
if not defined \%1 ask \%1 {File name? }

set input echo off
set input buffer-length 200000

# Wait for PRINT button to send the plot
echo Set HP54602B for HP Plotter, FACTORS OFF, 19200, DTR
echo Press PRINT SCREEN button on HP54602B...

log session "\%1.hgl"

# Wait for final character
input 480 \x03

close session

echo Converting HPGL in
echo --\%1.hgl
echo to PNG in
echo --\%1.png

# Without factors
#run hp2xx -m png -a 1.762 -h 91 -c 14 "\%1.hgl"
#run mogrify -density 300 -resize 200% "\%1.png"

# With factors
run sed '/lb/!d' "\%1.hgl" &gt; "\%1-1.hgl"
run hp2xx -q -m eps -r 270 -a 0.447 -d 300 -w 130 -c 14 -p 34 -f "\%1.eps" "\%1-1.hgl"
run rm "\%1-1.hgl"
run convert -density 300 -resize 675x452+2+2 "\%1.eps" "\%1.png"

echo Finished!
exit 0

Here’s a sample of what pops out; it’s the scope’s own calibrator waveform, nothing exciting, but you get the general idea.

Screen Capture of Calibrator Signal

Screen Capture of Calibrator Signal

The commented-out section labeled “Without Factors” converts the format you get with Factors Off. Turns out that there’s no unique ending string without factors, which puts a real crimp in getting the data. The advantage is that the HPGL converts directly to PNG and looks good. The only way I’ve found to capture the scope data is to just time out after a while.

With Factors On, however, the image data has a unique ending character (ASCII ETX, 0x03) after the label text, but the layout is rotated to plot in landscape mode. A direct conversion to PNG looks awful, perhaps because hp2xx must do software character generation, and I eventually figured out that making a bank shot off EPS vector format produced much better results.

However, hp2xx dutifully renders the text into the EPS image, but it doesn’t inject a carriage return after each linefeed: the text dribbles off to the far right of the actual screen image. To fix that, the sed editor hacks off the label text following the lb command. Mercifully, hp2xx doesn’t choke on the incomplete command.

And then convert does its usual magic. The image size is just right to drop into my Circuit Cellar columns; you may want something different for your purposes.

[Update: The PNG has an alpha channel that selects only the traces, so the background color depends on where you put it. A small tweak is there.]

For reasons that I absolutely do not understand, I cannot control the oscilloscope through the serial interface. The scope sends data to the PC just fine and I can get the scope to complain about the character format if I send truly bogus junk (like, mismatching the baud settings), but it simply will not respond to commands. Maybe the interface is broken or, more likely, I’m screwing something up. Hasn’t been a problem, though, for my simple needs.

Memo to Self: One of these days, eBay will have a 54652B serial/parallel interface that might work better.


  1. #1 by John Brown on 2009-11-21 - 12:00

    HI. I’m a novice. Know little about electronics and nothing about Oscilloscopes. However, I want to measure power that my generator is producing and convert it back to torque so I can determine how much torque my home made water turbine is producing. On Wednesday, my buddy calls me and tells me he just bought an RV van at a university auction. It had a HP 54602B oscilloscope, 150 Mhz, rack system with zip drive. So, I want to use the scope and hook it to the generator. My turbine will activate the generator through a gear box. I know it takes 165 ft lbs of torque to overcome inertia in the system. Thus, if I can measure power out in kilowatts I could convert back to HP and Torque produced. But, another friend of mine said that won’t work. I have to separate out the differnt power components using an oscilloscope or a power factor meter. Then, I could us some math and determine “real torque”.

    So, your little program above, can I use that to hook the HP to my laptop? Can I capture the screen over time, review the images, extract the data that I will need to accomplish my goal?

    My name is John Brown, my email is my phone is 660-888-8693. Thank You

    • #2 by Ed on 2009-11-21 - 13:45

      You’ll need a serial interface on the back of the ‘scope, after which my script should get you pretty close to the goalpost.

      The script creates a nice screen shot, but that’s not what you want for data analysis. The ‘scope can compute all manner of waveform measurements and hand you a single number, rather than a trace; you’ll spend some quality time with the Fine (Programmer’s) Manual before you get all that working.

      But you don’t need an oscilloscope to measure a water turbine’s output power…

      power = torque x RPM

      Connect the generator to a honkin’ big resistive load, measure the voltage across it, and compute the power: (voltage squared) / resistance. That’s a sort of crude dynamometer and there are other ways to get it done, but that’s quick and easy, which makes up for a lot.

      Aim a tachometer at the generator spindle and measure the shaft RPM.

      Then: torque = power / RPM


      Now, admittedly, that gives only the output power from the generator to the load, with all the losses bottled up between the generator and the turbine… but if your losses are that large, then you have other problems.

  2. #3 by Marc on 2010-04-17 - 10:23


    I have the same scope and want to use the script, but I am struggling with Ubuntu 9.10… It seems like ckermit is not able to configure the COM port (I use an old laptop with a “real” comport and changed the port in the script to ttyS0). If you have a link with some help it’d be greatly appreceated. Maybe I should go back to the NetBSD I had on my SUN way back, a pain to configure, but at least I always knew what I had done :-(

    Best regards


    • #4 by Ed on 2010-04-17 - 12:15

      It seems like ckermit is not able to configure the COM port

      I’d be more suspicious of the cable or the ‘scope setup, because configuring serial ports is what kermit does for a living.

      Make sure all the handshaking signals go where they should and the voltage levels make sense. Use a breakout box to verify that the various signals have the right values.

      You can fire up minicom and drive the ‘scope directly from the keyboard to verify that the hardware is working for the configuration settings you want. If that works and kermit doesn’t, then it’s something truly obscure.

      Other than that, I’m afraid I don’t have any suggestions…

      • #5 by Marc on 2010-04-17 - 13:26

        shame on me… it all behaved as if the port wasn’t there I realized, and that’s what it was – or better wasn’t. I had it disabled in the BIOS ages ago. So do a “dmesg|grep tty” and see if /dev/ttyS0 is actually detected first if you try this.

        Anyway, I can capture the plot with a terminal proggy now, but whith your script, it stops after just a few lines. Have to do some debugging later when the kids are in bed.

        Thanks for your help! Sometimes it’s good if someone tells you “go check the cable”, I have been out of the hardware business for a little now, feel like a bloody beginner again ;-)



        • #6 by Ed on 2010-04-17 - 13:33

          feel like a bloody beginner again

          They say that’s the best way to keep your brain from rotting out, but I must admit it’d be nice to feel like I knew something for sure… just once in a while, not all the time, mind you…

          I have a few other notes on that ‘scope script; search for 54602 and you should find them.

          It’s all downhill from here…

  3. #7 by Marc on 2010-04-17 - 14:53

    Just realized that I seem to have the serial/parallel interface fitted. Maybe that’s the difference that made trouble with the script. I’ll post my solution when I found it.


  4. #8 by Marc on 2010-05-11 - 02:46

    Back after reading (a tiny part of) the CKermit manual and doing some tests…

    The CR/LF problem does not come from the scope, but from CKermit. Just insert “set session-log binary” to get rid of it. CKermit defaults to text mode, where it automagically replaces the scopes CR/LF to UNIX-style.

    With the serial/parallel interface card, at least with my scope, I get a date/time stamp, an ETX (\x03), then the plot, the factors, then another ETX. so, I had to add another “input 480 \x03” right after the first.

    After that, I went for another post processing, since I am more after some kind of “lab report” than just the screen copy, so I leave the factors in, do some text resizing to make it pretty, and get a one-page EPS with time and setup info by replacing the last part of your script with

    # With factors – lab report style

    # replace text size in hpgl file
    run sed -e s/sr.6,1.2/sr1.2,.7/g \%1.hgl > \%1_1.hgl

    # generate eps from hpgl
    run hp2xx -q -m eps -r270 -a 0.5 \%1_1.hgl -f \%1.eps

    # delete temp file
    run rm \%1_1.hgl

    echo Finished!
    exit 0

    • #9 by Ed on 2010-05-11 - 07:07

      With the serial/parallel interface card, at least with my scope

      So the output is the same, only different, with a different interface board: who’d’a thunk it?

      I’m pretty sure my scope doesn’t know the time of day, so perhaps that’s a function of the S/P interface.

      Nice work; if I ever pick up one of those boards, I’ll blend in your changes…


      • #10 by adrian on 2011-10-10 - 10:30

        Thank you very much Ed and Marc. After days of trying to get the (windows 3.1?) Benchlink software running in wine, i finally found your script. After adding the lines with another “input 480 \x03″ and binary-mode and fixing a html-escaping thing (&gt in the sed-line) it finally worked!

        • #11 by Ed on 2011-10-10 - 10:33


          Glad to help… now we’ll both remember how to do it.

  5. #12 by Jon on 2011-11-03 - 09:22

    Do you now if it’s possible to get the scope to basically continuously stream trace/signal data out the serial port? IE: just send me raw bytes representing the waveform on the screen. I have an HP 54601A with a 54651A RS-232 module just like you have. I do not have the manual for the RS-232 module and wish I did. I haven’t found any manuals on eBay and Agilent doesn’t have it on their site like they do for the 54658A measurement/storage module. Any tips on where to find a module manual for the RS-232 module would also be greatly appreciated. I’d prefer a digital copy if at all possible.

    • #13 by Ed on 2011-11-03 - 10:09

      continuously stream trace/signal data out the serial port?

      Haven’t a clue, although RS-232 bandwidth wouldn’t be up to the task for anything other than the slowest possible sweeps. There’s also the question of how it would deal with multiple traces.

      Oscilloscope architecture is “take a measurement according to the current setup, then tell me about it” rather than “behave like a data acquisition module”.

      In theory, you can get a dump of the raw trace values from the screen, but I’ve never done that because I can’t (figure out how to) send commands to the ‘scope… [sigh]

      the manual for the RS-232 module

      As nearly as I can tell, there’s nothing much to know about the hardware modules, because the ‘scope contains all the command parsing logic. The one-page “interface module manual” I have pretty much says “plug it in and it works”…

  1. HP8591E Spectrum Analyzer: Capturing Screen Images Therefrom « The Smell of Molten Projects in the Morning
  2. HP54602 Oscilloscope Trace Conversion Tweakage « The Smell of Molten Projects in the Morning
  3. Marlin Firmware: Stepper Interrupt Timing | The Smell of Molten Projects in the Morning