Now Reading
Faux Parallel Printer – A Parallel Port Visitors Capturing Instrument

Faux Parallel Printer – A Parallel Port Visitors Capturing Instrument

2023-01-25 00:31:29

My previous blog post
contained a screenshot of an Advantest R3273 spectrum analyzer that I took by holding
my iPhone in entrance of the display screen:

Screenshot of a spectrum analyzer

Utilizing a digital camera works, in fact, nevertheless it doesn’t look very… skilled?

Right here’s one other one from my
TDS 420A blog posts:

Screenshot of TDS 420A oscilloscope

This one seems even worse, as a result of the CRT hasn’t been tuned fairly proper and the picture is
rotated a little bit bit.

What I need is a bit-for-bit hard-copy of what’s proven on the display screen, like this:

Bitmap of screenshot of an R3273 spectrum analyzer

or this:

Bitmap screenshot of a TDS 420A oscilloscope

Significantly better!

It’s straightforward to avoid wasting screenshots on fashionable gear. On my day by day driver Siglent oscilloscope, the simplest
approach is to simply insert a USB stick and press “Print”, however you can too do it by scripting some
SCPI commands
over a USB or Ethernet connection:

Screenshot of a Siglent oscilloscope
(Click on to enlarge)

It’s not so easy for outdated gear. The TDS 420A and the R3273 have a GPIB interface
that can be utilized to obtain uncooked measurement knowledge, however not the display screen contents, menus and all included.
Nevertheless, they do have a floppy drive to avoid wasting screenshots, and there’s an old-fashioned parallel port
to ship a screenshot straight to a printer.

I purchased a floppy drive on Amazon for $19 and spent an extra $18 for a pack of 10 3 1/2 HD floppy disks,
solely to find that the floppy drives on each devices have been damaged. Perhaps that’s simply to
be anticipated from gear that’s 20 to 30 years outdated…

Floppy drive

So the one interface left is the parallel printer port. Which made me assume: “What if I seize
the printer knowledge and convert it right into a bitmap on my PC?” And thus a brand new challenge was born!

I’m definitely not the primary one to consider this.
For £90, round $110, Retro-Printer
claims to do precisely what I need.

Retro-Printer solution

It’s a Raspberry Pi hat that plugs into, nicely, a Raspberry
Pi which is okay when you’ve got one laying in a drawer someplace, in any other case it’s one other $100+
in at the moment’s loopy market. Retro-Printer has been in existence for some time and so they have devoted
software program to again it, some open source, some not.
I didn’t check it, however if you’d like one thing that’s an actual product as an alternative of a fast weekend hack,
it’s in all probability the choice with the best likelihood of success.

Nonetheless, it’s a little bit an excessive amount of for what’s, in my case, a non-essential gadget that I’ll use solely
a couple of instances per 12 months.

I asked for feedback on Twitter
and obtained plenty of helpful pointers.

Rue Mohr created one by soldering a connector and an
Atmega on perfboard. It seems actually neat:

Rue's parallel port capturing tool - top

He additionally shared his Parallel2Serial repo on GitHub
with the Atmega firmware.

There are different initiatives on the market, however if you google for phrases equivalent to “parallel port to usb”,
they drown in a sea of “USB to parallel port” outcomes!

Protocol

The parallel printer port and related
protocol was initially outlined by Centronics approach again
in 1970 for his or her Mannequin 101 printer.
The Vintage Technology Digital Archive nonetheless has the
specification and interface information
for it.

Centronics Protocol

The diagram exhibits how a BUSY sign will get asserted by the printer when it’s doing sure lengthy
length actions such a line or a paper feed, however the sign is frankly a bit redundant, as
we will quickly see.

Both approach, these are the alerts that actively take part in knowledge transactions:

Title Path Description
nSTROBE To Printer A low pulse signifies that there’s legitimate knowledge on D[7:0]. This pulse may be as brief as 500ns.
D[7:0] To Printer The information that’s transmitted to the printer. The information is legitimate when nSTROBE is low.
BUSY To Host Inform the host that the printer is busy and that it ought to wait with sending the subsequent knowledge.
nACK To Host A low pulse tells the host that the present knowledge has been processed.

Right here is parallel port visitors between the spectrum analyzer and the faux printer:

Parallel port transactions on a R3273
nSTROBE: yellow, BUSY: purple, nACK: cyan

There’s 22uS between every transaction, good for a knowledge charge of round 350kbits/s, however most devices
don’t come near that.

I created a check firmware for faux printer that by no means asserts BUSY. It really works simply the identical, displaying
that the R3272 in all probability ignores BUSY and easily waits for an end-of-transaction nACK pulse:

Parallel port transactions on a R3273 without using BUSY

Along with the alerts which might be used for the precise knowledge switch, the parallel port has a bunch of
largely static management and standing alerts:

Title Path Worth Description
nINIT To Printer 1 A damaging pulse resets the printer to its default state.
nSELINT To Printer 0 A low worth tells the printer {that a} host is current and powered on.
nAUTOF To Printer 1 No strict definition. A low worth is used to perfrom issues like printer auto-feed or another motion.
SEL To Host 1 A excessive worth signifies {that a} printer is current.
PE To Host 0 Brief for Paper Error. A excessive worth signifies that the printer can’t print at the moment.
nERROR To Host 1 A low worth signifies that the printer has encountered some type of error.

For a easy visitors capturing instrument, you’ll be able to ignore the the three alerts which might be going to the printer and
you’ll be able to tie the alerts that return to the host to the listed static values.

The parallel printer port was initially solely used for low velocity printer communication, nevertheless it was later upgraded to
help increased switch speeds and even bidirectional knowledge communication. These extensions are described
within the IEEE 1284 specification which defines totally different modes: compatibility mode, nibble mode, byte mode,
enhanced parallel port (EPP), and prolonged functionality port (ECP), the place compatibility mode is the unique
protocol.

After powering up, all printers begin out in compatibility mode. They change to a unique mode via
a protocol negotiation course of.

For our functions, we are able to ignore all these superior modes and keep on with compatibility mode.

Connectors

The host virtually at all times makes use of a DB-25 connector:

DB-25 pinout

Supply: Wikipedia, (c) Andrew Buck

The printer aspect has a 36-pin Centronics connector:

Centronics connector

Supply: Wikipedia, (c) Michael Krahe

Right here’s a government abstract of the faux printer options and design choices:

  • DB-25 connector on a PCB that plugs straight into the instrument
  • USB performing as serial port to transmit captured knowledge to the PC
  • Raspberry Pico as microcontroller

DB-25 as an alternative of Centronics Connector

The Retro-Printer resolution has a Centronics port, similar to an actual printer. I’m utilizing
DB-25 connector as an alternative. The reason being value and, IMO, comfort. On Digikey,
the DB-25 connector is $1.60 versus $7.10 for the Centronics one. And when you
use the Centronics connector, you want a cumbersome DB-25 to Centronics cable too,
good for an extra $12! And now you’ve gotten 2 cables to cope with: the printer cable
and the USB cable from the faux printer again to your PC.

Raspberry Pico

You’ll be able to see by taking a look at Rue’s design {that a} faux parallel printer may be quite simple.
It is advisable have:

  • a parallel interface that may cope with 5V signalling in transmit and obtain route
  • logic to reliably seize the 8-bit knowledge and cling to the parallel port protocol
  • a solution to interface with the PC. USB is the apparent alternative right here.

At the moment, you employ a microcontroller for stuff like this. Rue had an Atmel in his element field,
which is nice as a result of it has USB gadget interface and 5V succesful IOs proper out of the field.

I select a Raspberry Pico as a result of:

  • I had a pair laying round
  • at round $5 a chunk, they’re low-cost sufficient
  • they’re staightforward to program and to program for
  • they’re obtainable all over the place in excessive quantity: no points with element scarcity!

The Raspberry Pico is bulkier than smaller options with the identical RP2040 silicon,
such because the Seeed Studio XIAO RP2040,
however in my ultimate PCB design that doesn’t make a sensible distinction. And the Pico is the
reference implementation which needs to be obtainable for so long as the RP2040 exists.

As a substitute of a Pico, you can too use a Pico W. The boards are pin appropriate in any case. A wi-fi interface
may be helpful when the again aspect of your oscilloscope is tough to succeed in, however you’d nonetheless want
a USB cable to energy the board as a result of there isn’t a +5V pin on the parallel port itself.

Stage Shifter

Since a Raspberry Pico doesn’t have 5V tolerant IOs, a number of buffer ICs are required for degree shifting.

My preliminary design used 3 generic SN74LVC8T245PW 8-bit
transceivers that value $1.65 a chunk on Digikey. Solely as soon as that PCB format was accomplished did I test if
by any likelihood there was a buffer IC that’s particularly designed for the parallel port. There was, in fact:
the 74LVC161284 is that chip, and it’s
yours for under $2.08.

74LVC161284 logic diagram

In case you have been holding monitor, there are a complete of 17 parallel port sign listed within the earlier part.
Consequently, the 74LVC161284 has 17 primary alerts as nicely, getting into the correct route. Because the
chip can help the later IEEE 1284 protocols, the IOs for the databus are bidirectional.

You’ll be able to ignore the PERI_LOGIC and HOST_LOGIC feed-through alerts: they aren’t used.

Resistors and Caps

The service manual of a Sharp AR-PK11 laser copier/printer
accommodates the complete schematics and makes use of an 74LVC161284. Helpful to test what sort of surrounding
elements are utilized in an actual implementation:

Sharp AR-PK11 schematic with 74LVC161284
(Click on to enlarge)

The schematic has 22 Ohm resistors on every of the 17 alerts to dampen reflections on the cable.
These are in all probability overkill on a design that doesn’t have a cable, however I added them anyway. Similar
factor for 17 100pF capacitors, which I added to the design and the PCB however didn’t solder on the
precise board.

Prepared for Full IEEE-1284 Assist

For a minimal parallel printer emulation, you’ll be able to safely ignore the nINIT, nAUTOF, and nSELIN alerts
which might be coming from the host, and the nERROR, PE, and SEL alerts that from the printer again
to the host may be strapped to a hard and fast worth.

However by connecting all of those alerts to the Raspberry Pico, you keep the choice to help
IEE-1284 mode which might be extra than simply compatibility mode.

Check Pins

Whereas designing the PCB, I wasn’t 100% positive how totally different devices would behave, and I wished
to guarantee that it’d be straightforward to seize the bus alerts with a logic analyzer. I’m completely happy that
I did, it’s a type of issues that makes your life so much simpler!

The primary model of the PCB was designed with KiCAD 6. You could find the complete design database
within the fake_parallel_printer repo on GitHub.

The schematic is about as simple as you’ll be able to think about.

Fake Printer Schematic v1
(Click on to enlarge)

And right here’s the PCB:

Fake Printer v1 PCB

For as soon as I didn’t make any errors: the board labored positive.

Nevertheless, after every little thing was full, there have been 2 issues that bugged me:

  • the shape issue isn’t sensible

    It’s approach too lengthy, especialy when you issue within the USB cable that’s protruding within the again.
    Area on the lab bench is usually at a premium and shouldn’t be wasted.

    Fake Printer sticking out

  • the PCB makes use of 4 layers for no good purpose by any means.

I created a second PCB model that fixes these 2 points:

Fake Printer v2 PCB

On this model, the Raspberry Pico is mounted on the backside of the PCB, on the
different aspect of the remainder of the elements.

The schematic
of revision 2 has totally different pin assigments, and it has 1 further decoupling cap,
nevertheless it in any other case an identical. The firmware
automatically detects the PCB version
and adjusts the pin areas accordingly.

I haven’t despatched out revision 2 for manufacturing!

The firmware
is extraordinarily primary:

  • GPIO pin configuration
  • Interrupt to detect falling fringe of nSTOBE
  • Interrupt routine that:
    • asserts BUSY,
    • learn the info pins
    • ship the byte to the USB serial port
    • deassert BUSY
    • pulse nACK

That’s actually about it.

There’s additionally a debug operate that prints out the variety of
bytes acquired on the printer port, and a checksum. You set off
this functionatily by placing a jumper (or a button) between
GND and the JUMPER_PIN (see schematic) of the Raspberry Pico, however
you gained’t want to do that if all goes nicely.

Disclaimer: construct at your individual threat! This can be a passion challenge. It labored for
me, however there aren’t any ensures that it gained’t set the parallel port of your
costly gear on fireplace!

You’ll be able to construct a faux printer instrument for round $25.

Right here’s the fee breakdown of the faux printer instrument:

5 revision 2 PCBs at JLCPBC $2
JLCPCB International Direct Line Saver transport $7.25
All elements at DigiKey (cart) $11.17
DigiKey USPS Precedence Mail transport $5
Complete $25.42

Transport value accounts for ~50% of the whole, so you’ll be able to reduce down on that considerably
by organizing some type of group purchase.

I believe it’s greatest to solder the elements within the following order:

  1. 74LVC161284
  2. SMD Resistors and capacitors however not essentially all of them!
  3. DB-25 connector
  4. Raspberry Pico with non-obligatory pin-headers

74LVC161284

See Also

When you don’t have expertise with precision soldering, the toughest half by far
is soldering the 74LVC161284 with pins which have a 0.5mm pitch. I did issues the normal approach
with a fine-tipped soldering iron, making use of solder to every pin one-by-one, whereas utilizing a
microscope.

I’ve been instructed although that drag soldering is admittedly the best way to go. Right here’s a superb
demonstration of that:

I’ll attempt it on the subsequent revision.

Resistors and Capacitors

All resistors and caps are utilizing a 0603 HandSolder footprint. I discover this dimension the smallest
that I can solder confidently and not using a microscope.

You don’t should solder all of the resistors: when you’re actually in a rush, you’ll be able to drop
R14, R15 and R16 (for SELIN, nINIT, nAUTOF). The present Raspberry Pico firmware doesn’t use
these alerts.

It can save you your self extra work by not soldering any of the 17 100pF capacitors. I didn’t
and every little thing labored simply positive. The alerts regarded clear on the oscilloscope as nicely.

Raspberry Pico

You’ll be able to solder Raspberry Pico straight onto the PCB, however I at all times
use a pin header as spacer between the principle PCB and the Pico. This makes
it a lot simpler to attach an oscilloscope probe on the Pico pins in case
one thing doesn’t work fairly proper. When you don’t plan to do any firmware
modifications, there’s no want to make use of them.

The two 20-pin pin headers are usually not included within the DigiKey component cart!

Connector Debug Pin Header

Fake Printer with logic analyzer

J2 is one other 20-pin pin header that I added to have the ability to probe the alerts as
they’re current on the DB-25 connector. Similar factor as earlier than: no want so as to add this
when you don’t plan on making firmware modifications, and this one can at all times be added later.

This pin header can also be not a part of the DigiKey cart.

My revision 1 PCB seems like this after meeting:

Fake Printer v1 assembled

Programming the Raspberry Pico with the faux printer firmware is tremendous easy:

  • Unplug the USB cable
  • Press the BOOTSEL button
  • Plug within the USB cable
  • Launch the BOOTSEL button
  • Wait till a USB drive with the identify RPi-RP2 exhibits up in your PC
  • Drag the parallel2usb_hd_on.uf2
    file onto the RPi-RP2 USB drive.

After one second, you’ll see the inexperienced LED on the Raspberry Pico blink twice. Achieved!

After plugging within the USB cable into your PC, there needs to be a brand new serial USB gadget.

Linux

On Linux, this gadget will present up as /dev/ttyACMx or /dev/ttyUSBx. The worth of x will
rely upon who many serial units there are lively in your PC. If there’s the one one, then
x will likely be 0.

When you’re unsure, run dmesg -w in a terminal window, and plug within the USB cable.

You’ll see one thing like this:

[1041048.447119] usb 1-7.1: new full-speed USB gadget quantity 26 utilizing xhci_hcd
[1041048.783246] usb 1-7.1: New USB gadget discovered, idVendor=2e8a, idProduct=000a, bcdDevice= 1.00
[1041048.783254] usb 1-7.1: New USB gadget strings: Mfr=1, Product=2, SerialNumber=3
[1041048.783257] usb 1-7.1: Product: Pico
[1041048.783260] usb 1-7.1: Producer: Raspberry Pi
[1041048.783262] usb 1-7.1: SerialNumber: E66038B713624535
[1041048.809753] cdc_acm 1-7.1:1.0: ttyACM0: USB ACM gadget     <<<<<<<

The final line exhibits the gadget identify.

Now you can seize all of the visitors on the parallel printer of your instrument with this command:

Home windows

After plugging within the USB cable, the gadget ought to pop up within the Home windows System Supervisor:

Windows Device Manager - USB serial device

The gadget identify on this case is COM4.

All that’s left now could be storing the captured knowledge in your PC.

Barebones seize on Linux

On Linux, it may be so simple as utilizing the next command line:

(stty -echo uncooked; cat > screenshot_0.prtcap) < /dev/ttyACM0

The captured knowledge will find yourself in screenshot_0.eps. If you have to seize a number of screenshots,
you’ll have to abort the command above after every screenshot, enhance the variety of the filename,
and begin it once more.

A print operation usually occurs within the background in your instrument, and there’s no clear indication
when it has accomplished. I merely test the scale of the screenshot_0.eps file with ll -r screenshot*
and abort the seize the file dimension stays fixed.

fake_printer.py

There’s a extra consumer pleasant approach with fake_printer.py,
which is a part of the fake_parallel_printer repo on GitHub.

It’s a Python script robotically splits print captures into totally different recordsdata when it sees the parallel
port going idle for a few seconds. It additionally offers suggestions about printer knowledge being acquired.

To make use of it, first make set up the Python pyserial module:

pip3 set up pyserial

After that, you’ll be able to run fake_printer.py. On the very minimal, you have to present the USB serial drive
identify:

On Linux:

./fake_printer.py --port=/dev/ttyACM0

or one Home windows:

./fake_printer.py --port=COM4

Right here’s the output on my display screen when capturing a TDS 420A screenshot:

tom@zen:~/initiatives/parallel2usb$ ./fake_printer.py -v -p /dev/ttyACM0
faux printer:
    verbose = True
    port    = /dev/ttyACM0
    timeout = 2
    prefix  = printer_capture_
    suffix  = prtcap
    web page nr = 0
Printer knowledge acquired. Creating printer seize file printer_capture_0.prtcap.
...............................................
48485 bytes acquired in 18s. (2634 bytes/s)
No printer knowledge acquired for two seconds. Closing printer seize file.

This weblog put up coated constructing and utilizing Faux Printer. The subsequent step is changing
captured printer knowledge to one thing usable, a bitmap or a PDF file. Relying
on the obtainable and chosen format, ESC/P, PCL, and so on, that course of may be fairly
painful. Will probably be convered in a future weblog put up.

When you can’t wait, you will discover the important thing factors in
Converting a Parallel Port Captured File.



Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top