Arduino Controlled Epson Tm T88p Printer
The EPSON TM-T88P is a parallel controlled printer. It came to be in my possession after going along to a kind of computer jumble sale 5 quid got me this:
Centronics Handsake
It turns out there are a number of ways to communicate with printers and the Epson supports a number of these methods. I decided to go with the Centronics standard AKA Compatibility Mode since its about as basic as you can get. Heres a diagram from the excellent http://www.beyondlogic.org
Centronics Handshake Diagram from beyondlogic.org
Think of the handshake as; you wait for the printer to be free (busy low) enter the number you want to send (set the 8 bits of your byte on the data lines) then pull the send lever old cash register style (strobe low wait stobe high). Its not a partuclay dificult concept but I found the diagram hard to understand becuase for some reason I thought it had to be more complicated than it actualy was.
Wiring Up
Nothing too complex here the table below show the Socket to Arduino linkup:
Socket | Arduino | ||
---|---|---|---|
Pin | Name | Pin | pinMode |
1 | Strobe | 13 | OUTPUT |
2 | D0 | 2 | OUTPUT |
3 | D1 | 3 | OUTPUT |
4 | D2 | 4 | OUTPUT |
5 | D3 | 5 | OUTPUT |
6 | D4 | 6 | OUTPUT |
7 | D5 | 7 | OUTPUT |
8 | D6 | 8 | OUTPUT |
9 | D7 | 9 | OUTPUT |
10 | ACK | 10 | INPUT |
11 | BUSY | 11 | INPUT |
25 | GND | GND | n/a |
You only need to wire up one of the ground lines since they will all be connected to ground in the printer anyway (lazy method) ! :)
Programming
Its worth pointing out at this stage that you might want to make up some kind of parallel port debuger so you can get an idea of whats actualy happening at a low level and that your program is producing the expected output.
First lets setup the pins as in the table above we will also setup a serial connection so we can do debugging.
To start with we can actual simplify the handsake further by ignoring the ACK since BUSY should always go low when we are OK to send more data. With this in mind we end up with 3 main steps:
- Wait for not busy
- Set Data
- Strobe
For the wait not busy function i decided to go with a simple poll, every 100 iterations it prints a ‘.’ so we can see in the terminal if its got stuck.
Strobe function is nice and simple. Suposidly you can have any value greater than 0.5 microseconds for the strobe and it will work. To keep it simple i just went with 1ms.
Setting the datalines we use i+2 as the first bit is written to pin 2 etc.
Now we use all these functions to send a byte to the printer
Finaly we can make a small program to print somthing. Its worth making sure things only happen once… you dont want your printer spewing paper while you try and turn it off!
Add the following global:
Then quick and dirty hello world:
We now end up with something that looks like this:
Thats all for now in a future post (hopefully!) I will be looking at more advanced printing.