views:

1360

answers:

3

This is a bit of an odd/specific question, but I'm having no luck, so maybe someone can help. I'm trying to build a microprinter using an Arduino and an Epson TM-T88II receipt/POS printer. The printer uses the 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 (RS232) 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 a newbie at 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.

+1  A: 

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?

starblue
For the communication settings, I'm not sure at all. I think I may need to do some kind of handshaking, but I don't know how. Information from the printer self test:Baud rate: 9600 (that's what I'm using)Data bits: 8 bitsParity: noneStop bit: 1 bit or moreHandshaking: DTR/DSR
Adam Endicott
+1  A: 

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 bits, parity etc.

Douglas Anderson
+3  A: 

Are you using an RS-232 transceiver? The arduino outputs 0 and 5V for serial, while the printer uses -12 and 12v 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.

Adam Davis