Printers and uC

Status
Not open for further replies.

AtomSoft

Well-Known Member
Is there anyway to connect a uC like PIC(any) to a printer and perform a print? or would that be to difficult?
 
If it's connected through the parallel port it would be easy enough and you should find examples on the net.
 
Is there anyway to connect a uC like PIC(any) to a printer and perform a print? or would that be to difficult?
It depends.
If you have a serial port printer it is very easy.
If you have a parallel printer it is still easy but you either need a lot of pins or use a shift register (my choice).
If you have a USB only printer then the job is more difficult. The last time I checked PICs would only act as slaves. Maybe that has changed, you would need to check or have a body who knows will squeak up.

Now for the kicker. If you actually want to print anything you have to find a printer that can print ASCII. Many/most of the printer sold today create the page image on the PC and dump it to the printer. This became popular maybe 15 years ago. So if you can latch on to an older printer.. A sure sign is that the printer takes font cartridges. As in the original HP Deskjet. There are actually a few of these around. They were built well. Mostly the friction pads that picked up the paper from the tray wore out.
 
Last edited:
Atomsoft, if it's a parallel printer it's actually really easy, all you need are 9 connections, 1 for each data bit and 1 for the strobe. Set the data bits, turn the strobe pin on and wait a small period of time and then set it low again. Each strobe pulse will cause the printer to read in the data pins. USB is however a different story. If a printer has a serial connection it likley has a parallel one as well (though not always)
 
True but not if the printer depends on the PC to compose the page. Most of the inexpensive printers sold in theh past 15 years do this. When they first came out they were called windows printers.
 
Yes, almost no modern printers will work, you need either an old printer, or a very expensive one - old dot-matrix printers are a good option. The last non-Windows printer I had was an HP Deskjet 500 - which cost an absolute fortune.
 
You could learn PCL and send your datastream that way.

Last time I tinkered with a printing application it goes something like this.

1. Application to OS print subsystem
2. OS subsystem creates a printing metafile
3. The driver of the printer takes the metafile an puts it into something the printer understands.

So you "could" learn a bit of PCL and fire that at the printer directly, PCL is relatively old but still understood by most printers.

A sample datastream looks like this.

Code:
%!PS
/minidict 45 dict def minidict begin
/inch {72 mul} def
/ld {load def} def
/gs /gsave ld   /gr /grestore ld        /gray {gs setgray fill gr} def
/li /lineto ld  /rl /rlineto ld         /ct /curveto ld/set {gs setlinewidth st gr} def
/mt /moveto ld  /tr /translate ld       /np /newpath ld /cp /closepath ld
/st /stroke ld  /rp /repeat ld          /ro /rotate ld  /rt /rmoveto ld
/box {np mt rl rl rl cp set} def        /circle {np arc set} def
/newline {tm lg sub /tm exch def lm tm mt} def
/centre {dup stringwidth pop 2 div linewidth 2 div exch sub lm add tm mt} def
/right {dup stringwidth pop rm exch sub tm mt} def      /r {right n} def
/s /show ld     /n {show newline} def /L {newline} def
/c {centre n} def       /kern {0 rmoveto} def /k {kern} def
/F {findfont exch scalefont setfont} def
/w /widthshow load def  /h {0 32} def
/textbox {/lm 0 def /bm 0 def /rm 7 inch def /tm 0 inch def /lg 12 def lm tm moveto} def
/page {gsave 50 72 translate textbox} def
/close {grestore showpage end} def
/end


gs 0.75 inch 10.50 inch tr textbox
10 /Helvetica F
(Hello World) n
grestore

The top segment of code does the upfront stuff leaving the last "paragraph" of code to do something useful i.e. say "Hello World" 10.5 inches UP the page and 0.75 inches from the left.

Hope this is useful

Mark

p.s. USB = I don't think so!
 

PCL was mainly HP printers (and plotters), but in any case modern ones still need a PC as well, because they don't have enough processing power inside to allow them to work without one.
 
im glad i can give at least a project idea. I wont be taking this on becuase too advanced for me i guess and wont fit project needs. I wanted to make a project that would print info contain in eeprom but formatted like eeprom will contain date/time info and other things.

But i might as well have it dump the info to a terminal and print it there.
 

If you've got a dot-matrix printer it should be simple to do, and EPE did just such a project a few years back - if I remember correctly they used an Epson dot-matrix printer?.

But like many of the members here, I come from an age long before Windows printers - my first printer was actually a Tandy (Radio Shack) one that printed on 4 inch rolls of paper using 4 little coloured ball-point pens. I originally used it on a 6502 based Tangerine computer purely in machine code (not even assembler!), eventually moving to single pass assembler, then dual pass assembler, and eventually Microsoft BASIC and even Forth.

The little printers were really amazing, you could print 80 characters wide text on a 4 inch roll, or draw any graphics you wanted - essentially you could switch between the four coloured pens, the pens moved left to right, and the paper moved up and down - in this way it could draw anything you wanted, it wasn't a dot based system (more a plotter than a printer).
 
sounds cool but if my project was to ever hit mainstream (for sale) then it would need to be a general printer needed. Or i would have to sell with printer and if printer isnt widely available or is to costly then it would effect sales.

In which case you would need to make it require a PC and printer driver to make it work.

Even if it was 20-30 years ago, you would still have needed to provide printer drivers (in your application) for all different supported printers.

Windows has really spoiled everyone, the printer manufacturer provides a Windows printer driver and everything works - even back in the PC DOS days every single application had to provide their own printer drivers for supported printers. You could use most printers in a crude text only way though, as they generally mostly provided a simple text only mode, based on the original Centronics standard.
 
Last edited by a moderator:
sounds cool but if my project was to ever hit mainstream (for sale) then it would need to be a general printer needed. Or i would have to sell with printer and if printer isnt widely available or is to costly then it would effect sales.

hi atom,
Exactly what do you plan to print.?
 
well it was meant in general but lets say for example my im making my alarm and want it to print out the info every time an alarm goes off but on command print out entire eeprom info.
 
Last edited:
Sounds cool but google isnt my friend today lol not much info. Maybe because it searches based on you previous searches and i just get canon and some other non related to strip stuff
 
Hi AtomSoft,
What you're talking about might not be that difficult. You could very easily use one of the smaller thermal printers (eg Epson TM88). This printer uses a language called ESC/P (same as the epson dot matrix) . You can usually put these printers in a mode where there will simply print the ascii being sent to them.

If the printer is not in this mode, it will only print when it gets certain commands.

Try installing one of these printers in windows and then in the driver, under ports, set it to print to a file. Create a simple TXT document and print with this printer, You will be prompted for a filename. Enter whatever you like and then open the file with notepad,wordpad, word etc. What you see in the file is what the printer requires. Google 'ESC/P programmers manual' and the info the file will then make more sense to you. Using this method, you could print to virtually any printer (you just have send it commands it understands). RS232 would probably be the easiest from the Pic.
Hope this helps.
 
Last edited:
seems promising and very well documented. I might have to look into this. Ill see if a store around is going out of business and is selling anything similar that uses ESC/P. Ill be sure to lug around my itouch for web lookup purposes.
 
If you're just looking for basic output you can always get a cheap dot matrix from a thrift store, I bought the last three we've used at work for less than 10 dollars. Epson printer codes for bold/italic and various other text modification are well documented. They can be used for low end graphics at well, but not if you need high resolution or accuracy. Many line printers like you'll find in old register equipment or what not will have serial input line printers in them which can often just be fed standard ascii text.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…