HP8591E Spectrum Analyzer: Capturing Screen Images Therefrom

While I’m thinking about instrument screen shots, this is the script for my Hewlett-Packard 8591E Spectrum Analyzer.

You’ll need C-Kermit, ImageMagick, and hp2xx for this one, too.

The cable must cross-connect RTS/CTS for hardware flow control.

Set the spectrum analyzer to

  • print-to-plotter
  • 19200 b/s (limited by USB-to-RS-232 converter)
  • One plot per page

Turning menus off doesn’t seem to have any effect on screen captures from the serial port, so the script crops off that part of the image.

Copy-n-paste the following text into a file (gethp8591), make it executable (chmod u+x gethp8591), and run it with a file name (./gethp8591 test).

Unlike the (well, my) 54602 ‘scope, the 8591 responds to serial commands just like the Fine Manual says. So before you run this script, make sure the screen shows what you want.

#!/usr/bin/kermit +
# Fetches screen shot from HP8591E spectrum analyzer
# 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

# Tell it what size to plot
echo Triggering plot output...
output plot 0,0,60000,40000;

log session "\%1.hgl"

# Wait for end of data stream
input 400 SP;

echo ... HPGL data captured

close session
close

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

run hp2xx -m png -c 143 "\%1.hgl"

echo Cropping and resizing
run mogrify -crop "515x395+0+0!" "\%1.png"
run mogrify -density 300 -resize 200% "\%1.png"

echo Finished!

exit 0

Here’s a picture of the FM broadcast band, as seen from the Basement Laboratory. The marker looks a bit off from 104.7 MHz, but that’s a combination of broad span and skinny peaks.

Spectrum Analyzer Screen Capture
Spectrum Analyzer Screen Capture