PDA

View Full Version : pic18f driving usb printers



ephesus
- 25th July 2005, 16:54
hi,
I am a beginner to USB,
I need some info about interfacing USB printers.
I feel better now after reading all "USB 2.0 specifications","USB device class definition for printing devices" and USB threads in forum. A few questions,

-is a pic18f able to drive USB printers as a host using pbp2.46 USB statements?
-how about page description language -PDL-?
-how to send a standard A4 text page from pic18f to printers -hp,canon,xerox etc.-?
-do all USB printers accept a standart text format or variations needed for different manufacturers?

My application is a kind of Guard Tour System including a portable recorder and ibuttons or rfid tags
for security checkpoints. it works well with the interface software on pc or directly reports to rs232 printers.
Thanks to picbasic pro.
Now planning to upgrade to USB printers.

Thank you very much...

mister_e
- 26th July 2005, 00:02
As i know, a PIC can't drive a Printer. You'll need something like those ALFAT chips.

See this link
http://www.picbasic.co.uk/forum/showthread.php?t=2102

ephesus
- 26th July 2005, 11:07
Steve,
Yes, there are many interface chips like FTDI's and usb onchip microcontrollers and many adapter solutions. I really wonder if an ascii
text page based printer driver for any of brands -HP,Canon..- could be written by pbp for 18F family usb pics.
Thanks

Serkan

mister_e
- 26th July 2005, 17:48
PIC are not design to handle external USB device. They are design to work as an external USB device... well, that's the simplest explanation i found.

Dwayne
- 26th July 2005, 17:54
Hello ephesis,

E>> I really wonder if an ascii text page based printer driver for any of brands -HP,Canon..- could be written by pbp for 18F family usb pics. <<

Yes, very easily done...IF ( I say IF) your printer accepts standard ASCII codes...with BUILT IN FONTS. Most printers do not anymore... your Dot Matrix printers will. I know that the HP1200 will work, and it can be driven by the USB. But when you start messing with printers that do not have built in fonts... you complicate things tremendously for the PIC. Quite a few of the Centronix Printers will have built in fonts.. and sometimes the Centronix printers can be driven by the USB ports.

Dwayne (either that, I misunderstood your question).

NavMicroSystems
- 26th July 2005, 18:57
Dwayne,

I think the question was:
is it possible to drive a printer by a PIC via USB?

not:
which printer models do have built in fonts?

Dwayne
- 26th July 2005, 19:17
Hello Ralph,


I think the question was:
is it possible to drive a printer by a PIC via USB?

not:
which printer models do have built in fonts?



My answer would be yes...*only* if the printer has built in Fonts, and you use standard ASCII to print with to your USB port.
If it doesn't have built in fonts, you are shooting yourself in the foot.

Most printers that I know of (That have built in fonts) will accept ASCII data, just like your LCD. (Especially the Dot Matrix). But if they do not have the built in fonts, you will have a tremendous amount of overhead to create and use the fonts. Which IMO is out of the question for the PICs.

I was probably unclear...sorry.

Dwayne

NavMicroSystems
- 26th July 2005, 19:30
Yes, very easily done...IF ( I say IF) your printer accepts standard ASCII codes...with BUILT IN FONTS.

Ok, let's assume the target printer has built in fonts.

Do you have a working code example?


Yes, very easily done...

come on, it's easy, share the code...

;-)

Dwayne
- 26th July 2005, 20:10
Sending standard ASCII code to the PORTB, just like your LCD.

ASCII in ASCII out...like a ASCII delimited file.

PSUEDO CODE

InputData var byte
Output Var byte

Loop:

Read Inputdata (whether you use SERIN or any other input data method)
Portb=Inputdata
toggle your datapin to send your ASCII byte.

goto Loop

Made one of these programs many years ago to test printers in DOS format...

If you take a look at a OLD printer control manual, you will see that Line feeds are Decimal 10... I think top of page was Decimal 12 contolling similar to the LCD...

Either I am misunderstanding something, or we are not on the same frequency at this very minute <g> Maybe I should go back to bed? <g>

DWayne

NavMicroSystems
- 26th July 2005, 22:43
Dwayne,


Either I am misunderstanding something, or we are not on the same frequency at this very minute...
let's try to get you back on track...

of course, driving a standard parallel (or serial) printer requires only a few lines of PBP code.

But here we are talking about USB

ephesus
- 27th July 2005, 10:50
ralph,
Right, we're talking how to drive USB printers especially inkjet or
laser ones for contiued models. Simply to print a complete ascii A4 page.
First we need some specifications of thoose printers, if available standart
page languages or easiest way to do. Then creating a driver software using pbp USB in/out statements.
Regards

Serkan

Luciano
- 27th July 2005, 11:31
Hi Serkan,

I understand you are currently using a printer with a serial port.

A simple solution could be a DOS compatible printer with a centronics parallel port.

Some low cost printer are GDI printer only. (Windows host-based printers).
These printes will not work if connected to a DOS based PC or microcontroller.

For a quick test, boot the PC from DOS and type the DOS internal command:

DIR *.* > PRN

(Make sure the parallel port is set as "Normal" in PC BIOS).

If you see the output on paper the printer understands "text only".

If the first test is OK, then try to see if the printer supports the
Epson Escape Codes or the Hewlett-Packard PCL commands.


Interface to your portable recorder:

Using a PIC, build a serial to parallel converter. The centronics pin 18 of
the printer will supply the necessary current for the PIC inside the converter.

See this link about PIN 18, search text "VCC (aka SLCT)".
http://nemesis.lonestar.org/reference/computers/interfaces/centronics.html

This solution is compatible with the current version of your portable recorder.


Best regards,

Luciano

ephesus
- 27th July 2005, 14:40
Hi Luciano,
I think this topic will be closed by the way that you submitted.
Yes, I'd better to built a serial/parallel converter to drive commonly used, low cost parallel printers.
So we'll never use a pic18f as a host.
Thanks yo very much.

Serkan

Dwayne
- 27th July 2005, 14:52
Hello Serkan,

Serkan>>Right, we're talking how to drive USB printers especially inkjet or
laser ones for contiued models. Simply to print a complete ascii A4 page.
First we need some specifications of thoose printers, if available standart
page languages or easiest way to do. Then creating a driver software using pbp USB in/out statements.<<

This will probably not happen... overhead and stuff is too great...As you have already said and I have said...you will have to create fonts and the works...Each printer is different... same brand printers are sometimes somewhat compatible.

Your only hope relys upon the printer having its own built in fonts. usually by rule of thumb, if it has its own built in fonts, it can do pure ASCII input/output....Like the matrix printers.

Dwayne

bot402
- 27th July 2005, 16:21
Microcontroller USB implementation is peripheral only. In order to control a Printer or any other USB device requires a HOST.

The only thing that a host and a peripheral has in common is the name USB. They are totally different things and are not interchangeable.

So the bottom line is you cannot control a USB printer from a PICmicro unless you interface using a host peripheral such as ones supplied by Cypress or Philips etc. These are not simple devices to control and a knowledge of programming and USB is required. There is also the USBWIZ with its simple interface, but this may be overkill.

mister_e
- 27th July 2005, 16:44
This is what i thought. Thanks Bot402 for confirmation of my First. (http://www.picbasic.co.uk/forum/showpost.php?p=10788&postcount=2) and Second post (http://www.picbasic.co.uk/forum/showpost.php?p=10824&postcount=4)

But your explanation is much better than mine :)

ephesus
- 29th July 2005, 08:20
"Microcontroller USB implementation is peripheral only.",bot402,
it's clear to understand..
Thanks friends..
Serkan

maheshmurty
- 21st March 2012, 18:04
I wanted to ask then what is USB OTG. I read some articles over the web & came to know that USB OTG helps an embedded device to configure both as a device / host. So can't we do anything with it?

Demon
- 22nd March 2012, 02:07
Until Microchip (and probably PBP) announce they support USB on the go specification for 16F and 18F, our PICs will remain USB slaves and won't be able to act as USB masters.


Only the host can schedule the configuration and data transfers over the link. The devices cannot initiate data transfers, they only respond to requests given by a host. OTG introduces the concept that a device can perform both the master and slave roles
http://en.wikipedia.org/wiki/USB_On-The-Go

Look at the PIC 24F family of products, they have OTG specs.


PIC24FJ256DA210
Universal Serial Bus Features:
• USB v2.0 On-The-Go (OTG) Compliant
• Dual Role Capable – Can act as either Host or Peripheral
• Low-Speed (1.5 Mbps) and Full-Speed (12 Mbps) USB Operation in Host mode
• Full-Speed USB Operation in Device mode


Robert