PDA

View Full Version : RS232 to Parallel Printer Converter



Squibcakes
- 21st January 2004, 00:06
Has any one attempted this one or know a site with info about it?

bitmaniac
- 21st January 2004, 11:37
HI! I don't know if this is what you want but give it a try

THANKS HARRISON PHAM ,for the codding!

'Serial to Parallel Printer Converter for Generic Printers
'By: Harrison Pham March 30, 2003
'---------------------------------------------------
'PIC: 16F84 at 4mhz
'
' PIC Printer (DB25 Connector)
' Pin A1 Pin 16 (Init)
' Pin A0 Pin 1 (strobe)
' Pin B0 Pin 2
' Pin B1 Pin 3
' Pin B2 Pin 4
' Pin B3 Pin 5
' Pin B4 Pin 6
' Pin B5 Pin 7
' Pin B6 Pin 8
' Pin B7 Pin 9
' Pin 17 to gnd (Printer Select)
' *Pin 14 to gnd (if needed for autofeed feature)*
' Pin 18 to gnd (gnd)
'----------------------------------------------------
init con A1
strobe con A0
char var byte
trisb = $00 'set portb to all outputs

high init 'clear init line
high strobe 'clear the strobe line
portb = %11111111 'put all data lines high
pause 1000 'pause for a second

low init 'init the printer
pause 500 'pause 500mill seconds to let printer init
high init 'clear the line

main:
serin A2,N9600,[char] 'get characters with serial
if char = 13 then 'if detected a cr then insert cr and lf
PortB = 10 'lf
low strobe 'tell printer to read in byte
pauseus 200 'wait 200usec for printer to read in byte
high strobe 'clear the strobe
PortB = 13 'cr
low strobe
pauseus 200
high strobe
endif
portb = char 'set portb to the char byte
low strobe
pauseus 200
high strobe
goto main

Squibcakes
- 22nd January 2004, 00:59
Thanks Mate. just what I was after.. I shall give it a try.

Cheers

Squibcakes
- 26th January 2004, 23:18
Gave this example a try and can confirm that the code does work, however,

I woud recomend that Pin 18 not be tied to gound as some printers have a 5 volt supply on it.

For my application, I found that I needed to use the -BUSY signal so that all chars could be printed and increased the delay to 500... I used this code..

pauseus 500 'wait 200usec for printer to read in byte
high strobe 'clear the strobe
GOSUB READY



READY:
IF BUSY = 0 THEN RETURN
GOTO READY

Thanks again for the code....

JosueCas
- 19th September 2006, 15:18
Hi!!.
I was trying this code with an EPSON printer.
I am almost there but it seems nothing is being printed until the buffer of the printer is full. Is there any special character that needs to be send in order to execute the printing?

Jerson
- 19th September 2006, 17:04
if it is an inkjet printer, this is normal behaviour. To print what is in the buffer, send a Form Feed character (FF - ^L I think)

Jerson

Josuetas
- 19th September 2006, 17:11
Although it was not an inkjet printer, this matrix printer executes printing after a line feed (10).

I was just trying to print dots for a plot :)

The code works great, very simple and nice ;)

Thanks.