Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Epson receipt printer to print from Arduino

I'm trying to build a microprinter using an Arduino and an Epson TM-T88II receipt/POS printer. The printer uses the Epson Esc/POS system, but I can't get it to do anything at all from the Arduino. I'm doing things like:

#include <SoftwareSerial.h>

#define out_pin 3
#define in_pin 2
SoftwareSerial printer = SoftwareSerial(in_pin, out_pin);

void setup()
{
    pinMode(in_pin, INPUT);
    pinMode(out_pin, OUTPUT);
    printer.begin(9600);

    delay(1000);

    printer.print(0x1B, BYTE);
    printer.print('@'); // ESC(HEX 1B) @ is supposed to initialize the printer
    printer.print("hello world");
    printer.print(0xA, BYTE); // print buffer and line feed
}

I just can't get the printer to respond at all. The printer powers up and prints its self test just fine. It's a serial (RS-232) printer, and I'm connecting it to the Arduino through a MAX233 chip. I've checked and rechecked my connections through the chip, which I think are right based on a friend who has a similar setup working. I read somewhere that the TM-T88 printers need null-modem serial cables, so I bought an adapter, and that didn't seem to make any difference.

I'm new to electronics, so I'm completely stumped. I just want to get it to print something, so I can get to the fun part - the programming :). Any thoughts on things to test/try? I can give more detail on wiring or anything else, just didn't want this to get TOO long.

like image 766
Adam Endicott Avatar asked Mar 02 '09 16:03

Adam Endicott


3 Answers

Are you using an RS-232 transceiver? The Arduino outputs 0 and 5 V for serial, while the printer uses -12 and 12 V for serial. You should use a MAX232 or similar device to get the correct physical interface. (You might be able to cheat if you invert the serial port on the Arduino, but that might not work, and it's more trouble when just getting started.)

Once that's taken care of, the RTS and DTR may be your problem. You should be able to change the DIP-switch settings on the printer and turn off flow control altogether, or switch it to software flow control.

Also, you may need to send both line feed and carriage return.

However, once all that's done it should print just fine, even without any reset commands. Send a bunch of ASCII characters and line feed/carriage returns, and it'll spit it all out.

You can ignore the RX line (on the Arduino side, TX on the printer side) for now - just send it data until you figure out the wiring, level conversion, flow control, etc.

like image 148
Adam Davis Avatar answered Oct 31 '22 00:10

Adam Davis


You could check whether you can communicate with a PC, both from the Arduino and to the printer.

I would use an oscilloscope to see if the serial signals come out of the Arduino and the MAX as they should, but then you probably don't have one.

Are you sure the communication settings are correct? You set the baud rate to 9600, but what about data bits, parity, stop bits? What about the control lines?

like image 43
starblue Avatar answered Oct 31 '22 00:10

starblue


I'd hook another PC instead of the printer to the other end of the serial cable and run telnet or PuTTY on that system to make sure you are communicating out and actually talking through the serial port. If so, you could use the same solution to send data to the printer to confirm all settings such as number of data bits, parity, etc.

like image 38
Douglas Anderson Avatar answered Oct 30 '22 23:10

Douglas Anderson