View previous topic :: View next topic |
Author |
Message |
altanonat
Joined: 07 Feb 2011 Posts: 21 Location: Turkey
|
Interfacing a Barcode Reader Through Usb with Pic18f4550 |
Posted: Mon Feb 21, 2011 7:12 am |
|
|
Hello all!
I am trying to interface a barcode reader with pic18f4550, which is an hid device, through usb connection. However I do not know where to start and I do not have any experience about USB. I have looked at examples, but nearly all of them are for interfacing a pic with pc.
First of all I think I need to setup a hid device driver into the pic18f4550, then using an interrupt I need to get a 11 byte string from barcode reader and put this string into an lcd.
I am waiting for your suggestions and advice.
Thank you in advance. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Mon Feb 21, 2011 9:30 am |
|
|
You won't.
Your device, is a _slave_ device.
So is the PIC.
There needs to be a master device, to carry out the transaction. The 4550 hardware can't do this.
Two possibilities:
1) Find a PIC supporting USB 'OTG'. This implies there is hardware support for a master. Then you need to write master software to handle the slave. Unfortunately none at present for CCS. There is a stack for the MicroChip compiler.
2) Add a USB host device, like the FTDI Vinculum. Disadvantage - another device. Advantage prewritten master code is available, and several people here have already interfaced this to the PIC.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
altanonat
Joined: 07 Feb 2011 Posts: 21 Location: Turkey
|
|
Posted: Mon Feb 21, 2011 9:51 am |
|
|
Ttelmah wrote: | You won't.
Your device, is a _slave_ device.
So is the PIC.
There needs to be a master device, to carry out the transaction. The 4550 hardware can't do this.
Two possibilities:
1) Find a PIC supporting USB 'OTG'. This implies there is hardware support for a master. Then you need to write master software to handle the slave. Unfortunately none at present for CCS. There is a stack for the MicroChip compiler.
2) Add a USB host device, like the FTDI Vinculum. Disadvantage - another device. Advantage prewritten master code is available, and several people here have already interfaced this to the PIC.
Best Wishes |
Thank you very much Ttelmah.
Do you know any other usb host controller other than Ftdi Vinculum, I have looked it for in Turkey however it will be impossible to find it in here. Or can there be other solution like using an usb to rs232 converter? |
|
![](templates/subSilver/images/spacer.gif) |
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Mon Feb 21, 2011 10:17 am |
|
|
You could look to a PIC with USB OTG which should work as a host.
I believe the PIC24's have this capability and the PIC32 definitely has this capability.
Cheers,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
![](templates/subSilver/images/spacer.gif) |
altanonat
Joined: 07 Feb 2011 Posts: 21 Location: Turkey
|
|
Posted: Tue Feb 22, 2011 3:57 am |
|
|
Can a usb to rs232 converter be a solution? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Feb 22, 2011 6:43 am |
|
|
Not really. This is another slave.
However if the barcode reader supports RS232, then the PIC can talk to this, with just a MAX232 buffer chip. Much easier.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
altanonat
Joined: 07 Feb 2011 Posts: 21 Location: Turkey
|
|
Posted: Tue Feb 22, 2011 6:52 am |
|
|
Ttelmah wrote: | Not really. This is another slave.
However if the barcode reader supports RS232, then the PIC can talk to this, with just a MAX232 buffer chip. Much easier.
Best Wishes |
I read the manual of barcode reader and it says that the barcode reader can communicate via RS232C, USB, WAND, PC/AT depending on the cable. It can be programmed via barcodes. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Feb 22, 2011 8:06 am |
|
|
In which case, get the RS232C cable for it, add a MAX232 to the PIC, and use RS232. Easier, and code size will be several KB smaller as well. :-)
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Tue Feb 22, 2011 8:09 am |
|
|
Go the easy way, use RS232 ! intstead of the Useless Serial Bus !! |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Feb 22, 2011 8:43 am |
|
|
In which case, get the RS232C cable for it, add a MAX232 to the PIC, and use RS232. Easier, and code size will be several KB smaller as well. :-)
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
altanonat
Joined: 07 Feb 2011 Posts: 21 Location: Turkey
|
|
Posted: Tue Feb 22, 2011 8:54 am |
|
|
Ttelmah wrote: | In which case, get the RS232C cable for it, add a MAX232 to the PIC, and use RS232. Easier, and code size will be several KB smaller as well. :-)
Best Wishes |
What is the difference between rs232c and rs232? Which converter Do I have to buy, usb to rs232 or usb to rs232c?
And one more question where will barcode reader get the power? There is a vcc connection pic for the usb, however there is not a vcc connection pin in rs232. Actually I do not have any experience with rs232 before. Is barcode reader get the power from max232? |
|
![](templates/subSilver/images/spacer.gif) |
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Tue Feb 22, 2011 9:49 am |
|
|
altanonat wrote: | Ttelmah wrote: | In which case, get the RS232C cable for it, add a MAX232 to the PIC, and use RS232. Easier, and code size will be several KB smaller as well. :-)
Best Wishes |
What is the difference between rs232c and rs232? Which converter Do I have to buy, usb to rs232 or usb to rs232c?
And one more question where will barcode reader get the power? There is a vcc connection pic for the usb, however there is not a vcc connection pin in rs232. Actually I do not have any experience with rs232 before. Is barcode reader get the power from max
232? |
So? Go on Wikipedia and look up RS232!! RS232 is the baseband building block of experimenters worldwide!
It's been around forever. It's easy to implement. USB has a whole extra set of abstraction on top of it. Why bother when it's not needed.
Keep Is Simple _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Feb 22, 2011 10:25 am |
|
|
It's 'historical'. RS232/CCITT C24, is the 'full' title. The _current_ standard, is actually RS232D. The changes in D, don't affect the signalling as such, but add things like loopback testing. Generally anything _properly_ calling itself 'RS232', will be compliant with RS232C. Unfortunately, there are a lot of interfaces 'purporting' to be 'RS232', that don't actually meet the signalling standards at all (a lot of laptop computers and USB interfaces, use a 'near working' subset of the voltages required....).
However I'm puzzled as to your question. You don't need a 'converter'. You need the cable for your barcode reader, that allows it to be interfaced with RS232. Then you just need the MAX232 (or equivalent) line driver, to allow this to connect to the PIC. No 'converter'. USB won't be involved at all.
The processor on the barcode reader, is almost certainly something like a PIC, and it detects the signals present on the cable to switch to different signalling modes (like modern keyboards, which connect directly to USB, or with an adapter plug, can connect to PS/2 ports - the adapter does nothing, except pull a line 'down' to tell the processor to switch to PS/2 signalling, rather than USB.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
altanonat
Joined: 07 Feb 2011 Posts: 21 Location: Turkey
|
|
Posted: Tue Feb 22, 2011 12:24 pm |
|
|
Ttelmah wrote: | It's 'historical'. RS232/CCITT C24, is the 'full' title. The _current_ standard, is actually RS232D. The changes in D, don't affect the signalling as such, but add things like loopback testing. Generally anything _properly_ calling itself 'RS232', will be compliant with RS232C. Unfortunately, there are a lot of interfaces 'purporting' to be 'RS232', that don't actually meet the signalling standards at all (a lot of laptop computers and USB interfaces, use a 'near working' subset of the voltages required....).
However I'm puzzled as to your question. You don't need a 'converter'. You need the cable for your barcode reader, that allows it to be interfaced with RS232. Then you just need the MAX232 (or equivalent) line driver, to allow this to connect to the PIC. No 'converter'. USB won't be involved at all.
The processor on the barcode reader, is almost certainly something like a PIC, and it detects the signals present on the cable to switch to different signalling modes (like modern keyboards, which connect directly to USB, or with an adapter plug, can connect to PS/2 ports - the adapter does nothing, except pull a line 'down' to tell the processor to switch to PS/2 signalling, rather than USB.
Best Wishes |
Actually my barcode reader only have a usb connection cable any other cable can not be connected as far as I see. However as I said before in users' manual it says that it is multi interface. I have given it in the link below.
http://www.bilkur.com/products/Z3010.htm
So Firstly I think I need a usb to rs232 converter cable to use it because the usb cable seems as it can not be plugged out. There is a programming sheet including a set of barcodes for programming the reader. I see a barcode for rs232c interface.
To sum up I have a barcode reader with usb connection, and so there is not a usb otg specification in pic18f4550, I have to use rs232 with this barcode reader. Firstly I need to convert usb to rs232 then I have to connect reader to the pic via max232 through rs232. My question is if I used usb cable, reader would got the power from usb' s vcc. However there is no vcc pin in rs232. Where can this reader get the power? From max232 or I need to plug it on an external power supply. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 22, 2011 1:10 pm |
|
|
How do you propose to make the USB-to-RS232 cable work as a USB host ?
All the cables that I have seen for sale, are USB slaves. They must
plug into a USB connector on a PC. The PC is the USB host. |
|
![](templates/subSilver/images/spacer.gif) |
|