[SOLVED] Connecting POS-Printer and Duemilanove

Hello everyone!

I'm currently working on a project, that is very similiar to the Microprinter by Tom Igoe. I have a little trouble with the interfacing of the printer and the arduino and hope you can help you.

This is my setup, as far, as a printer is involved:
I built a TTL-RS232-converter based on a MAX232N. It's inputs are hooked to pins 0+1. The outputs are connected to the inputs of a thermal receipt printer, namely an Able Systems Ap863-F. On the arduino there is some sketch using the Serial.print()-function to send some text to the printer.

And now to my problem: it just doesn't print anything! But that is somehow irrational. When I connect the serial output of the TTL-RS232-Converter to my pc's serial, i can read it out with HyperTerminal on Windows respectively MiniCom on Linux with the following setting:

[fixed]9600 bauds
8 data bits
1/2 stop bits (both work)
No parity[/fixed]

If I now unplug the cable coming from my pc from the arduino and plug it into the printer, then I can write some text and commands and everything is executed by the printer flawlessly (well, nearly, but this shouldn't be part of this thread :wink: ).

At first, I hooked the d-sub9-connector to the printer according to the documentation:

Printer D-SUB9
RxD Pin 2
TxD Pin 3
Busy Input(CTS&DSR) Pin 6 & 8
GND Pin 5

I guess, it has something to do with the flow control, so I also tried wiring it like this (inspired by this RS232-Tutorial):

Printer D-SUB9
RxD Pin 2
TxD Pin 3
Busy Input(CTS&DSR) Pin 6 & 8
GND Pin 5
Shortened Pins 1,4 & 6
Shortened Pins 7 & 8

I already disassemled the whole wiring, checked all connections and the soldering of the plugs twice and did some hours of researching the internet, but i can't really figure out, what exactly causes the problem. I really hope anybody of you could help me!
If you need some additional information on my information, just let me know.

Thank you very much in advance and kind regards,
Marc

The most common mistake is to assume something is a DTE when it's a DCE and vice versa. If you're into trying random things try swapping pins 2 and 3. It wouldn't hurt to put 100-1k series resistors on those lines just in case you get it wrong and the printer is sensitive about that kind of thing.

But I agree, posting the full schematic/wiring diagram would help us out in diagnosis.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

Thank you very much for your prompt and helpful responses, both of you. Sorry if my first post was a little brief, I will try do add some more information to it.
I don't really have a nice circuit diagramm, scribbled it by hand, and I don't think, that this will be very helpful. But I made a rough schematic, to explain my point, I hope it will help you. I might do some more detailed schematic, if it is needed.

Picture 1: Connection of arduino to a serial plug via MAX232N

Picture 2: Connection of Able System Ap863-F to a serial plug


So in the two pictures are the two parts of my setup, and if i plug this thing together, it should print something - which it doesn't. The oddness about it is, that when I connect the arduino-part with my computer, I can read out everything it prints (so I guess, that the MAX232 is wired correctly) and when I plug into the printer, I can print everything via a serial console. I also tried to switch Tx and Rx at one point of the circuit, like you suggested, RuggedCircuits, but it just doesn't help.

edit: I should also have explained, that the red and green wires in the second picture are indicating, where I shortcircuited the plug in reference to this tutorial.

I did some further research in the Programmer's Guide of the printer and this is, what I found:

The default serial interface format is 9,600 baud, 8 data bits, 1 or 2 stop bits, and no parity. Other
formats can be programmed into the printer at the factory or in the field, from the host. A setup
program, suitable for use with a PC, is available from Able Systems to simplify this process.

Serial data is expected on Rx in RS-232C format with -12V meaning 'mark' or logical '1', and +12V
meaning 'space' or logical '0', with reference to the common ground. The serial data output line, Tx,
transmits XON/XOFF and status information to the host at the same baud rate and format as the
serial data input. The hardware busy line, Busy, is true (nominally -12V) when busy.

Some host equipment use a constant space condition (+12V) to indicate a reset condition or wait
state. Some battery powered host equipment present the same output signal when they go to sleep.
By default the printer will interpret this condition as a repetitive receive error, and will print multiple '?'
characters to indicate the fault. If required, the printer may be set to ignore this condition.

The printer has a nominal 20k byte buffer which enables data to be received while previous lines are
being printed. The state of the data buffer is transmitted to the host as follows:
XOFF (13HEX) sent when buffer fills to 3/4 full;
XON (11HEX) sent when buffer empties to 1/4 full; and also after a controller reset.

The hardware busy line is set when 256 bytes of space remains; and incoming data are no longer
passed to the buffer (but may be processed) when 128 bytes remain. The hardware busy line goes
ready again when 384 bytes become free. Note that the buffer can become filled with non-printable
codes, in which case the controller will go busy.

The printer always transmits an XON character when it has woken up and is ready to receive data. It
always attempts to transmit an XOFF character to the host before going to sleep. It is not necessary
to select hardware or software handshaking. Both are active at all times.

I'm sending only a few bytes at one time to the printer, so I'm not in danger of overflowing the 20k-buffer. Shouldn't I then be able to just ignore the flow control? When I control the printer with my pc via HyperControl or minicom, I choose "None" as flow control, this is the only way to get it to work, anyway. Or am I taking something about flow control (or anything else) fundamentally wrong? I have put a lot of time into other parts of the project already (e.g. it makes use of an Adafruit Waveshield), so it would be a real pity if I don't get it to work. I would be very grateful for further suggestions.

I think the solution is simple, cross over the Rx/Tx wires at the Arduino. The T1In of the MAX232 is an INPUT, and it should be connected to the pin 1 OUTPUT of the AVR, and respectively for R1Out and Rx.

--
The Quick Shield: breakout all 28 pins to quick-connect terminals

Wow, you're answering really quick! Thank you very much.

Ok, I doublechecked it, and you're absolutely right, but the problem was the transfer of my doodled layout to the digital world. It's already wired this way. Here is my corrected version of Picture 1:

I also tried alternating the pins at this point, but the only effect is, that there is no more communication possible with the pc. Any other suggestions?

OK, your diagram shows a DCE, something that receives data on pin 3 and transmits on pin 2. Does this work with the PC?

And I don't know if your diagram omitted it, but the MAX232N should share the same ground as pin 5 and the Arduino.

Now, if the printer is also a DCE, then it too expects to receive data on pin 3, yet you have it showing as receiving data on pin 2. So either it's a DTE (like a PC), or your diagram is wrong, or.....

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

Whoohoooo, you hit the nail square on the head!!! ;D
I crossed over the Rx and Tx at the d-sub-plug in picture 1, and what should I say: it works!
And the best thing about it is, that it even makes sense to me now, because considering the whole electric path, there is a point sending data to another point that is receiving data. Thank you very much, Rugged Circuits, it would have taken me a few more days to stumble upon this bug. And in addition to this, I now understand the concept of DCE and DTE.

So, to close this thread: the last and now correct version of Picture 1:

I'm going to document the whole thing when it's fininshed over at my admittedly rarely used and so far not very filled up blog.