Serial to parallel the hard way

      5 Comments on Serial to parallel the hard way

I kind of miss making hard copies of my program listings on a dot matrix printer. There’s something contemplative and satisfying about waiting for the printer to finish its buzzing and chattering so that you can pore over the code and find that bug.

Also, printouts on continuous listing paper with holes down the sides feel like real computing. It almost makes you want to put on a short-sleeved white shirt with pocket protector, dark tie and thick-rimmed glasses.

Now, you can buy USB-to-parallel adapters – I have one. I never could get the damn drivers to work, though. And most drivers that are designed for dot-matrix printers seem to assume that you want to treat any output as a graphic. Frankly, there’s already too much PostScript in the world.

I want to be able to send stuff to the printer from a program character-by-character.

Return of the Epson

I already have the printer (currently under repair). It was the first printer I ever bought, back in 1982 or 1983, and cost me far more money than I could afford. Even after it was replaced as my main printer – first by an improbably loud daisywheel device and then by an Epson laser printer that I ‘acquired’ in my role as a product reviewer, it continued to see service for niche applications.

Chief among these was as a label printer for my library of 35mm colour transparencies. I maintained a database of my slides, built using the Eagle database package from Emerald Bay (a kind of friendlier knock-off of dBase) and it was far easier to print labels programmatically to the dot matrix than it was to mess with sheets of labels on the laser. That’s the kind of functionality I miss.

The plan

So here’s the plan. I want to use a Raspberry Pi as a print server. Quite how it will do this is currently unclear – it might just monitor a shared folder for files and, if it finds one, prints it and then moves it to a ‘done’ folder. That’s as far as my thinking has gone on that side.

I could try to hook up the Pi’s GPIO pins to a DB25 socket and control the printer that way, but I want something more flexible and a little less blowy-uppy. So, an interface card of some kind.

The breakout board.

I’ve already taken a small step in this direction. As part of my experimenting with the Eagle and KiCad EDA packages, I produced a design for a card that essentially just breaks out the connections from a DB25 socket, with the data lines being controlled by a shift register to reduce the number of pins needed on the Pi. At the time of writing, I’m still waiting for the fabbed boards to arrive from China.

But that was just to keep things simple for the purposes of learning KiCad and Eagle, and it doesn’t really address what I want from this project. So here’s where I’m heading with this:

  • An AVR ATMEGA328P microcontroller will handle communications with the Raspberry Pi (or any other device) via a TTL serial connection.
  • The AVR will set the data lines on the printer port via a 74HC595 shift register.
  • The AVR will set or read the other signals (strobe, busy etc) via a buffer chip – a 74HC541.
  • A resistor divider and jumper headers will allow the TX pin from the AVR to send signals at either 5V or 3.3V levels. The board as a whole will operate at 5V but should be able to cope (I think) with incoming serial data at 3.3V.
  • I’m going to have three LEDs on the board controlled by the AVR to provide status information.
  • I’m considering adding eight LEDs to show the data being sent over the data lines because … blinkenlights.
  • There’ll be an ISP header on the board to program the AVR in situ.

So far, the schematic looks like this (click to enlarge):

If any experienced electronics engineers have advice, feel free to share. After all, I’m a novice at this.

The resulting board would be usable with anything that can send over serial – Raspberry Pi, BeagleBone, Teensy, Arduino, even my iMac.

But I need a name … the working title has been SmartParallel, but that’s boring. Given that I want this to drive my dot matrix printer, and that, with my level of electronics knowledge and experience this is probably a foolish venture, I think I’ll go with DottyMatrix. [UPDATE: Nah! I went back to SmartParallel.]



5 thoughts on “Serial to parallel the hard way

  1. Bart Claes

    Nice project! As a programmer, personally I would have done it differently, just buy an arduino with sufficient gpio pins to cover all of the used db25 pins (12 or so, the rest is ground?). Simply solder a cable between the arduino header connector and the db25. Then bitbang the gpios respecting the timing of the parallel protocol. Let us know your progress!

    1. Machina Post author

      Yeah, that was my initial instinct too. In fact, it’s not far off what I’m doing – I’m just putting the ‘Arduino’ on the board. The ATMEGA328P probably has just enough GPIOs to do the job directly. But I wanted to make a board as a learning process – I even intend to use mostly SMD components. And the buffering afforded by the shift register and buffer chip will, I think, offer a measure of protection.

  2. Lenore Underwood

    First of all have you had to make any changes from the schematic on the actual prototype interface to get it to run? Usually I end up missing a connection or needing to add a pullup/pulldown resistor. 🙂

    Also you indicated on the virtual printer you had to connect to specific pins on the ATMEGA328 in order to emulate a real printer. Does the actual interface also have to have specific pins connected or are you free to group/assign different ports/pins to the chips and DB25 connector?

    1. Machina Post author

      The device is pretty simple, so the schematic and breadboard prototype are largely in agreement. I might experiment with what needs pullups when I get back into this project. As for specific pins, I’m not sure what comment you’re referring to: off the top of my head I don’t think it matters a great deal which GPIO deals with which printer interface line.

      1. Lenore Underwood

        Thank you. 🙂

        The reason I asked is that I plan to use the interface schematic as a starting point for building my own interface board. I’ll be using a different AVR and needed to know if specific pins were needed. That way I know what pins I have available for other features. Or not….. 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.