Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 23rd July 2008, 11:14 PM   (permalink)
Default Printers and uC

Is there anyway to connect a uC like PIC(any) to a printer and perform a print? or would that be to difficult?
AtomSoft is online now  
Reply With Quote
Old 23rd July 2008, 11:31 PM   (permalink)
Default

If it's connected through the parallel port it would be easy enough and you should find examples on the net.
colin mac is offline  
Reply With Quote
Old 23rd July 2008, 11:33 PM   (permalink)
Default

Quote:
Originally Posted by AtomSoft View Post
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 by 3v0; 24th July 2008 at 05:06 AM. Reason: Changed 15-20 to 15
3v0 is online now  
Reply With Quote
Old 24th July 2008, 12:14 AM   (permalink)
Default

wow that sux to here that. i guess hyper terminal on xp or something will have to do.
AtomSoft is online now  
Reply With Quote
Old 24th July 2008, 04:24 AM   (permalink)
Default

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)
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Reply With Quote
Old 24th July 2008, 05:05 AM   (permalink)
Default

Quote:
Originally Posted by Sceadwian View Post
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.
3v0 is online now  
Reply With Quote
Old 24th July 2008, 10:08 AM   (permalink)
Default

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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 24th July 2008, 11:53 AM   (permalink)
Default

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!
UTMonkey is offline  
Reply With Quote
Old 24th July 2008, 12:13 PM   (permalink)
Default

Quote:
Originally Posted by UTMonkey View Post
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.
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 24th July 2008, 12:17 PM   (permalink)
Default

True, though most printers appear to accept PCL3.

It would be an interesting project though.

Mark
UTMonkey is offline  
Reply With Quote
Old 24th July 2008, 01:31 PM   (permalink)
Default

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.
AtomSoft is online now  
Reply With Quote
Old 24th July 2008, 01:50 PM   (permalink)
Default

Quote:
Originally Posted by AtomSoft View Post
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).
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 24th July 2008, 01:58 PM   (permalink)
Default

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 Nigel Goodwin; 24th July 2008 at 02:13 PM.
AtomSoft is online now  
Reply With Quote
Old 24th July 2008, 02:05 PM   (permalink)
Default

Quote:
Originally Posted by AtomSoft View Post
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.?
__________________
Eric
"Good enough is Perfect"

PIC tutorials:
Gramo's: www.digital-diy.net/
Bill's: www.blueroomelectronics.com/
ericgibbs is offline  
Reply With Quote
Old 24th July 2008, 03:04 PM   (permalink)
Default

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.
AtomSoft is online now  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Two Stepper controllers from Epson printers Parre86 Datasheet/Parts Requests 0 4th February 2008 08:20 PM



All times are GMT. The time now is 11:12 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.