Advertisements

Archive for December 31st, 2009

HP54602 Oscilloscope Trace Conversion Tweakage

The script (writeups there and there) I use to convert the HPGL screen dumps from my HP54602 into PNG images produced a transparent background. I put the files into an OpenOffice mockup of my Circuit Cellar columns and the background turns white, so I figured it worked OK.

Turns out that the workflow at Circuit Cellar Galactic HQ turns the background black. A bit of digging showed that the ImageMagick convert program produced an alpha channel that selected only the traces and left everything else unselected. Why that produces white here and black there is a mystery, but there’s no point in putting up with such nonsense.

Another wrestling match produced this revision (the two changed lines are highlighted), which has no alpha channel and a white background. That ought to simplify things: an image shouldn’t depend on where it’s dropped to look right.

#!/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 ON, 19200, DTR
echo Press PRINT SCREEN button on HP54602B...

log session "\%1.hgl"

# Factors On
input 480 \x03

close session
close

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

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

# Factors On
run sed '/lb/!d' "\%1.hgl" > "\%1-1.hgl"
run hp2xx -q -m eps -r 270 -a 0.447 -c 14 -f "\%1.eps" "\%1-1.hgl"
run rm "\%1-1.hgl"
run convert "\%1.eps" -alpha off -resize 675x452 "\%1.png"

echo Finished!

exit 0
Advertisements

Leave a comment