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.
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?
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?
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
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.
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.
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);
}
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.
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