Arduino Emulating Printer

Hello,

I have a number of hurdles I need to overcome on this project. We have a timing system that is designed to print out a timeslip via a receipt or docket printer. I want to use the arduino to emulate that printer and be able to read the timing information off the computer screen.

Notwithstanding my ability to actually get the handshaking correct, I wanted to know this;

There will be a byte constructed presumably of 1,0's, using 8 inputs on the arduino which will be either high or low.

My question is what do I then do with that byte to become readable - ie to convert that into a time or text? Do I need to use an ascii table of some sort? There will presumably be other characters such as linefeeds and tabs etc, so I will need to deal with them too.

Any help greatly appreciated - I'm very new to this stuff so please be kind.

Ashley

Okay so I found a binary to decimal converter. My question now is that some characters are only 6 bits long, but from what I understand the printer outputs in 8 bit. How do I convert from 8 bits down to 6? or am I way off the mark?

What is the format of the data going to the printer?

I would guess ASCII characters, if that's the case you have the data in a printable format already.

become readable

Readable by what?

time or text?

That all depends on what you need. It sounds like it's already in a text format, if that's what you want then job done. If not you have to convert it but that's easy as well.

other characters such as linefeeds and tabs etc

Normally you would want to strip these, you can use a lookup table if there are a lot of control characters used but if there's only a few then a case statement will sort them out.

We need to know exactly...

a) What format is the incoming data?
b) What format do you want the outgoing data to be?


Rob

I'm not sure what the format is, it would be an 8 bit serial connection I think

Human readable.

Graynomad:
What is the format of the data going to the printer?

I would guess ASCII characters, if that's the case you have the data in a printable format already.

become readable

Readable by what?

time or text?

That all depends on what you need. It sounds like it's already in a text format, if that's what you want then job done. If not you have to convert it but that's easy as well.

other characters such as linefeeds and tabs etc

Normally you would want to strip these, you can use a lookup table if there are a lot of control characters used but if there's only a few then a case statement will sort them out.

We need to know exactly...

a) What format is the incoming data?
b) What format do you want toe outgoing data to be?


Rob

So the printer is serial printing (presumably) ASCII characters which are "human readable" if sent to the right device.
The output has to be human readable.

It sounds like the job is done already :slight_smile:

Does "serial" mean RS232 or some other physical format?
Will you be disconnecting the printer or does that have to be working as well?
Human readable on what/where?

In the absence of any real data I don't know how to advise any more.


Rob

The timing device has a printer port like on the back of a computer, which a receipt printer would normally plug into. A DB25 Plug.

The club has never owned a printer and they are prohibitively expensive.

We are trying to get the output that would normally be sent to the printer to appear on a screen of some sort, ie a pc screen through the serial monitor.

Thank you for trying to help, I'm trying to provide as much info as I can, I'm not feeling well today and I'm a little cloudly.

Ash

A DB25 Plug.

Almost certainly RS232 then. RS232 uses +-12v levels that will kill your Arduino, so you will need to convert the voltage levels to 5v TTL levels. Easy enough but unless there's an existing shield that does this you'll have to knock up a small amount of hardware using a chip like the MAX232 or 202.

Even simpler, as you are only reading use a diode (to stop the negative voltage) and a voltage divider (to cut 12v down to 5v). If you do this the data will be inverted however Newsoftserial (NSS) can handle that.

Depending on how the device is wired the data will be on pin 2 or pin 3 of the DB25. Also connect the GND (pin 7 IIRC) to your Arduino's GND.

Having done that you can read the characters coming from the device. If you don't have documentation or a scope or a logic analyser (this will be a LOT easier if you can borrow one or the other) you'll have to use trial and error to get the bit rate and format.

I would start with 9600bps and 8N1 format. Read characters in using NSS and do

if (myNSS.available () > 0) {
   Serial.print (myNSS.read(), HEX);
}

to print out the bytes in HEX for analysis.

That's a start.


Rob

so it's not likely to be sending data as bytes on the d0-d7 pins?

Thank you so much for your help. I have found an rs232 shield available locally.

Ash

Umm, what d0-d7 pins?

I thought it was serial.

OK DB25 was used for parallel printers as well.

Back to square 1 :slight_smile:

I don't remember the Centronics format, I'll have to look it up.


Rob

Here's a pic of the Centronics printer protocol.

Presumably your gadget uses this but who knows.

Timing doesn't appear to be super fast.

Data is first applied on the Parallel Port pins 2 to 7. The host then checks to see if the printer is busy. i.e. the busy line should be low. The program then asserts the strobe, waits a minimum of 1uS, and then de-asserts the strobe. Data is normally read by the printer/peripheral on the rising edge of the strobe. The printer will indicate that it is busy processing data via the Busy line. Once the printer has accepted data, it will acknowledge the byte by a negative pulse about 5uS on the nAck line.

So you could probably do this in software although you only have a guaranteed 1uS to grab the data.

Unfortunately the Arduinos don't have 8 available pins on one port which doesn't help. Using a Mega would be easier.


Rob

Thanks Rob, I think this whole project is beyond me.

I really appreciate your help and time you've put in.

Thanks again.

Ash

Maybe just get a printer from a garage sale :slight_smile:

Have a search for "centronics to serial converter", you may find a gadget that already does the job. For example

Note that this only uses two chips.

It's not a real hard thing to do but does require some pretty tight programming.

Also, keep an eye on this thread

http://arduino.cc/forum/index.php/topic,74603.0.html

He is trying to read the data sent to an LCD but it's almost the same problem.


Rob

thanks again heaps, I really appreciate it. I will look around for a schematic or ready made circuit that might do the job.

Garage sale or auction might be the best bet, though.

Thanks heaps

Ash

I read the LCD thread you posted, and I think maybe I'm not dead yet!

I am going to try shifting the data in using a shift register and just converting the bytes to ascii.

It sounds simple but maybe I'm wrong, it's worth a shot though.

Ash

I am working on a similar project. What type of printer does you PC support? I mean the printer you use in you project. Cause many printers with DB25 port use parallel port to communicate and I was shitted by treating it as serial port. So you should really verify the communication protocol first. I have succeeded in resolving most of the problems so if you like we can discuss later