Parallel printing with a 20m2 picaxe

captnemo

New Member
I was wondering if someone could give me a hand with a program. What I have is 40 character (page width), parallel input, kiosk printer. it's been around since 1995.
The only usable signal lines are the eight data bits and a strobe line. I have no problem sending text to the printer and it indeed prints it out. The problem I'm having is figuring out how to send a line or form feed. I don't see how the printer know's the difference between a text character and a command. If I sent "hello" to the printer the picaxe program puts each character on the buss and strobes it out. Well, since a command may consist of three characters and each one has to be sent separately . How does the printer know it's a command and not just text. Sending text or commands to an LCD display is easy, since the RS line is either high or low to designate whats on the buss is either a command or text. Where as, this printer only has a strobe line. The printer does do an automatic carriage return after a full line.
I've been all over the internet and it's all about sending data to a serial printers, anything other than that is a about desktops talking to old parallel printers.
Anybody have any ideas or experience with this. All I need is a code snippet that I can understand and I'll be all set.

Attached is my program. I stripped it from and LCD program and modified it. It works as far as printing text goes. There is more printer information in the program.

P.S. I know I can just send out a couple of blank 40 character messages to get the real text up out of the print head where it can be read, but I'd rather do it right.
 

Attachments

neiltechspec

Senior Member
What happens if you send it a hex 0D and a hex 0A (cr + lf).

Looking at the spec for Zebra kiosk printers, a form feed is a hex 0C.
 
Last edited:

AllyCat

Senior Member
Hi,
The only usable signal lines are the eight data bits and a strobe line.
The "traditional" PC Parallel Interface was called "Centronics", but that used a 36-pin connector with 8 parallel bits, but numerous additional lines, not just Strobe , but Busy, Ack, Paper End, etc... Was your printer intended for (or supplied with) some specific commercial application or product?

So, as Neil Says, I can only suggest you try the ASCII "Control" (non-printable) characters between 0 (zero) and 31 decimal ($1F Hex), in particular 13 decimal ("Carriage Return") and 10 ("Line Feed"). Others might be relevant such as Form Feed, etc., and possibly "Escape" to initiate a sequence of control bytes.

Cheers, Alan.
 

captnemo

New Member
No. It didn't come with any software. Although this model is for a parallel connection the manual only discussed serial communications. I tried to send all the commands in decimal and hex with no response and I tried to print only 10 characters instead of the usual test of forty and the printer didn't budge. I think you are right about the ESC, as other printers seem to use that to signify a command. Thank for the info.
 

captnemo

New Member
I'll try to send both commands. Going by the internet, I guess no one has connected a parallel printer (kiosk printer)to a picaxe before. It's no big deal, as I have no pressing projects, its just that they have been lying around for 10 or 15 years and I hate to see them wasted. Thanks for your help.
 

papaof2

Senior Member
If all else fails, there are parallel printer driver chips. Anyone remember the ZX80 or ZX81? I built a parallel printer interface from that computer to a pretty generic dot matrix printer. I'm a software guy, but hardware is sometimes needed ;-)

You shoud be able to set the 8 data pins to whatever states are needed for the character to be sent, then pulse the strobe line - but you might need a logic analyzer or a multi-trace scope to verify the timing. Some parallel printers are more forgiving of the timing than others...
 

westaust55

Moderator
If you advise the make and model of the printer that may help folks provide an answer with more information.

whether serial or parallel interface, those older printers used in-line control codes.
Data for printing was accumulated in a buffer until either:
1. The buffer was full, or
2. A print control code was sent

In general, all fort required a carriage return (13 or $0D) to be sent to initiate printing.
Then depending upon printer settings or it’s internal program
A line feed to advance the paper could be:
1. Automatic, or
2. Require you to send a Line Feed character (10 or $0A)

there may also be a form feed control implemented to move the paper a given distance. FF code is 12 or $0C
 

captnemo

New Member
Thank you for replying. The printer has no manufacturer, but can be set up to emulate a Citizen 560 or Epson ESC/POS. I've tried sending command codes to the printer but they are ignored. Also, the printer will not print unless all 40 characters are sent out. it will then print out the 40 characters and do a carriage routine. The chip is interesting, but what would be more interesting is how and what that chip is sending to the printer. Requiring a chip to talk to a parallel printer tells me that the program is to cumbersome to do in a picaxe alone. As far at the printer manual is concerned, it gives all the control codes required to run it as; itself, or a Citizen 560 or Epson. The only example they give, as far as programming commands goes, is for a serial printer, strange considering it has a parallel port. They do make the same printer in serial format. I guess they figured one manual for all.
I really find it hard to believe no one has attempted to do this. There is no info. on the internet about attempting to do this at all. Unless all the attempts were unsuccessful. I'll mess around with the printer again today and then trash it. As usual in a month or two, I'll come across some obscure article in a magazine titled "How to Control a 40 Character, Parallel Port, Kiosk Printer With a Picaxe." Of course, I could hook it up to the parallel port on my old XP and see what it's sending out to the printer, Hmmmm.
 

neiltechspec

Senior Member
If it has no manufacturer, who wrote the manual ???

frm015.pdf shows the code it uses.

The commands for parallel or serial should be the same, it's just the method of delivery.
 
Last edited:

captnemo

New Member
It has a manual. It's just a generic printer (see attached PDF).

And that's the whole problem "method of delivery." It would have been nice if picaxe had a "print" command for parallel printers.
I also tried to print upper case letters and numbers and other symbols. No dice. It only prints lower case.
 

Attachments

westaust55

Moderator
Looking for a Citizen manual online, closest I found was Citizen IDP-560RS for a 40 character/column wide dot matrix printer which is a serial comma version.
The manual at page 18 has the same control codes as folks have already mentioned:
10 for line feed
12 for form feed
13 for carriage return.
 

AllyCat

Senior Member
Hi,
It has a manual. It's just a generic printer (see attached PDF).
That manual does appear to describe the parallel interface (Centronics et al.) in sufficient detail. Basically, present an 8-bit parallel byte to the data lines and then pulse the Strobe low for > 1uS (no maximum values appear to be quoted). But it doesn't print until 16 characters have been presented OR a Carriage Return (13 / $0D) is sent. No need to send Line Feeds, but they should be ignored. Are you saying that that doesn't work? Lack of Upper Case (and Control characters) suggests that the Data 5 line might be faulty or disconnected.

Then there appears to be plenty more detail for the additional features (double-width font, etc.).

Cheers, Alan.
 
Last edited:

Technical

Technical Support
Staff member
As explained in the https://picaxe.com/docs/frm015.pdf file many parallel printers don't actually print until the form feed character is received ie they buffer up all the characters in internal memory and then dump out the whole page in one go once the FF character (12) is received.
 

captnemo

New Member
Allycat: This is the real problem, I don't know how to sent a carriage return or anything else to the display. Can you post how the command would be written in a picaxe program? I've tried so send the commands in every possible way in the picaxe program. As far as a data line being screwed up, it prints out the entire alphabet in lowercase which tells me all the data lines are working.

Technical: I understand that. I just don't know how to send the commands!
Can't someone just send me an example code, a snippet?
 

Technical

Technical Support
Staff member
A command is just a number, so in your initial example just use 'let pinsB=12' for form feed or 'let pinsB=13' for CR. Incidentally you have it incorrectly as 11 in your program.

Or just put the commands in the DATA line

data 20, ("abcdefgh",13,"ABCDEFGH",13)

ASCII characters (normal text) start at number 32, so "a" is number 97 and "A" is number 65. There is no magic, you just send a number between 1-254 for the different commands and characters. Note that if you type "a" in speech marks in the BASIC program the compiler will automatically convert that ascii text to the correct number, 97. http://web.alfredstate.edu/faculty/weimandn/miscellaneous/ascii/ascii_index.html
 

AllyCat

Senior Member
Hi,
As far as a data line being screwed up, it prints out the entire alphabet in lowercase which tells me all the data lines are working.
No, that's not correct. The ASCII character set divides the characters in binary groups, so if for example D5 is locked High (or possibly open circuit) then it can still display all the Lower Case Characters (96 - 127 = binary %011xxxxx). But it couldn't display the Capitals (64 - 95 = %010xxxxx) nor perhaps relevantly the Control Codes (0 - 31 = %000xxxxx).

The Printer interface may have only 9 input lines, but it appears to have a number of "Reply" lines, which you might be able to use to validate what's happening, possibly with a multimeter, a few LEDs or connections to pins on the PICaxe (and a SERTXD/DEBUG program).

A typical program could be quite similar to those used to drive the full 8-bit wide parallel LCDs or OLEDs, etc.). Untested, but something like:
Code:
#picaxe 20m2
#no_data
symbol strobe = c.0
High strobe
dirsB = 255
for b1 = 0 to 15
   lookup b1,("Hello World",CR,"1234"),pinsB
   pulsout strobe,10
next
Cheers, Alan.
 

westaust55

Moderator
Alan is highly likely on the “right track” as to the problem.
Try printing “aA” you may have to repeat that lower and upper case character pair 20 times
Do both characters print as “aa”?
If so then the data line 5 is held high - through open circuit, wrong connection or fault.
 

captnemo

New Member
Technical: Doing the let pinsB=12 did nothing and doing data 20, ("abcdefgh",13,"ABCDEFGH",13) only printed out the abcdefgh.
Alleycat: It printed out 'Hello World' and tha'ts as far as it got.

I'll check the data lines tomorrow.
 

captnemo

New Member
I replaced 'Hello World' with aAbBcCdDeE and it did indeed print out the lower and upper case letters, but that's as far as it got. I don't know if it did a carriage return. The text that's printed out is buried inside and you can't tell whats been printed till you do 4 or 5 linefeeds (thats what started this whole thing). It did not print out the 1234.
 

Buzby

Senior Member
Looking at that manual you posted, it looks like CR, LF, and FF use the same codes in any of the printer modes, so you should have no problem there.

The fact that you can print characters both upper and lower case means you have all the data lines correct.

All that is left is the program !.

Please post your latest code, and we'll sort it out together.

Cheers,

Buzby
 

AllyCat

Senior Member
Hi,
The fact that you can print characters both upper and lower case means you have all the data lines correct.
Not quite, the D6 line could be stuck high (and/or D7 low) since neither numbers nor control codes are confirmed yet, but it seems very unlikely. I (somewhat intentionally) inserted a CR between the "Hello World" and numbers, so only the letters could be expected on the first line (terminated by the CR). However, the numbers might have been expected on the next line, but perhaps not because there were less than 16 numbers and no CR. It needs a comprehensive sequence of test strings, including plenty of control codes, to see exactly how it behaves.

Cheers, Alan.
 

Buzby

Senior Member
.. Not quite, the D6 line could be stuck high (and/or D7 low) ...
Yes, you are right. It was late last night, I should have checked closer.

However, I'm fairly certain that we could determine the condition of the data lines if we had a lot of test code and results.

My gut feeling is that the wiring is correct, but the behaviour of the printer is not fully understood, and the test code is less than is needed.

I've used printers in the past where CR did just that, returning the carriage to the left edge, so the following text over-printed the existing. It could be that this printer needs a CR & LF to move to the left edge of the next line. It could also be that it needs a FF somewhere in the mix. Also, we don't know if the 'Busy' signal is being used, this printer might need specific time delays between instructions.

We need to see the code .
 

westaust55

Moderator
CaptNemo provided a Revision G of the printer manual from 1995 at post 1.
Here is a link to a Rev J from 2003 although at a glance now significant changes: 1000 SERIES PORT.PTR USER MAN. - Oatley Electronics (yumpu.com)

Now at a PC and can see the manuals - no need for any guessing, it is all in the manual(s).

Only the CR (carriage return) is required - that is sending decimal 13 ($0D):
CR (0DH) Prints the current line and feeds one line. If CR and LF are sent, the LF is ignored to avoid a double feed.
On the receipt of the last printable character (e.g. 24 characters for the 1012), the printer will automatically print
the data in the buffer. If CR and LF are sent after this condition, they will be ignored.
Sending a LF (line feed) control - that is sending decimal 10 ($0A) is just an alternative:
Prints the current line and feeds one line. If LF and CR are sent, the CR is ignored to avoid a double feed.

Time for CaptNemo to try the Diagnostic mode to find out if the CR control command is being correctly received by the printer:
If a command is not carried out by the printer, it is possible to check for an incorrect control code
or character by initiating diagnostic mode.
Diagnostic Mode reveals control codes and characters sent to the printer. Characters 00H to 1FH
are translated to characters 40H to 5FH and underlined to indicate a control character.

EXAMPLE: HORIZONTAL TAB (O9H) = CTRL I Printed as I
CARRIAGE RETURN (ODH)= CTRL M - Printed as M
Normal characters are not underlined.
and (as the second step to perfom)
Diagnostic Mode
To enter diagnostic mode initiate self-test and keep the feed switch depressed until 'DIAGNOSTICMODE' is printed.
The power-on indicator will flash every two seconds.
I note that in the manual it has ODH but that shows the letter "O" (Oh :eek:) as opposed to the correct "0" (zero) - should be dec13 or $0D.


Finally as the first step to do
To perform a self-test press the power “ON” and “FEED” switch simultaneously and keep them depressed until the test starts.
[/quote]
 

westaust55

Moderator
Now looking at the parallel comms timing diagram in the manual there is a busy period that does not have a specified duration.
that could take some finite time to print the characters on a row and automatically advance to the next line.

So to jump ahead and modify Alan's code:

#picaxe 20m2
#no_data
symbol strobe = c.0
High strobe
dirsB = 255
for b1 = 0 to 11
lookup b1,("Hello World",CR),pinsB
pulsout strobe,10
next
PAUSE 100 ; if 100 does not allow printing of the second line increase this value
for b1 = 0 to 10
lookup b1,("0123456789",CR),pinsB
pulsout strobe,10
next

Ideally the way to go would be to monitor the Busy signal after each CR command until it returned to a low (0) state before sending more characters.
The Busy pin is pin 11 on the 25 way D plug.
That signal seemingly stays low until the next strobe signal is sent (whereas the Ack signal is only 10 us maximum duration and may be too fast for the PICAXE to see).

EDIT: fixed typos for future reference as mention below by CaptNemo
 
Last edited:

captnemo

New Member
Westaust55: I ran your program this morning. I had to put the CR inside the brackets and change the 15 to 10. Now, comes the interesting part.
It just printed out 'Hello World.' I incremented the PAUSE by 100 and kept increasing it until I got to 900, at which time it printed out
'Hello World' on the first line and '0123456789' on the second line. So you are right about using the busy signal. I'll have to hook that up.
Next question is, if CR is a carriage return, then is LF a line feed and is FF a form feed?
When I get this thing working, I'll put the wiring diagram and program on the forum. I'm assuming this would work for any 40 character printer except for the commands differences. I'll try some variable data on the second line.

Thanks for everyone's help. Now we all know how to do it.
 

captnemo

New Member
Well, it's printing. I'd like to thank the guy's on the forum. Alleycat, westaust, neiltechspec, papaof2, buzby and technical support for helping out.
I'm attaching the program for the printer and an LCD display (not connected to the printer), also a PDF of the printer hook up and an LCD hook up.
I'm posting them here, as I don't know where else to put them.

P.S. I did managed to figure out how to do a form feed on my own (I had to use the binary code, though).
 

Attachments

Top