CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Interfacing a Barcode Reader Through Usb with Pic18f4550
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
altanonat



Joined: 07 Feb 2011
Posts: 21
Location: Turkey

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

Interfacing a Barcode Reader Through Usb with Pic18f4550
PostPosted: Mon Feb 21, 2011 7:12 am     Reply with quote

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.
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Mon Feb 21, 2011 9:30 am     Reply with quote

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
altanonat



Joined: 07 Feb 2011
Posts: 21
Location: Turkey

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Mon Feb 21, 2011 9:51 am     Reply with quote

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?
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Feb 21, 2011 10:17 am     Reply with quote

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
altanonat



Joined: 07 Feb 2011
Posts: 21
Location: Turkey

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Tue Feb 22, 2011 3:57 am     Reply with quote

Can a usb to rs232 converter be a solution?
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue Feb 22, 2011 6:43 am     Reply with quote

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
altanonat



Joined: 07 Feb 2011
Posts: 21
Location: Turkey

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Tue Feb 22, 2011 6:52 am     Reply with quote

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.
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue Feb 22, 2011 8:06 am     Reply with quote

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
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 22, 2011 8:09 am     Reply with quote

Go the easy way, use RS232 ! intstead of the Useless Serial Bus !!
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue Feb 22, 2011 8:43 am     Reply with quote

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
altanonat



Joined: 07 Feb 2011
Posts: 21
Location: Turkey

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Tue Feb 22, 2011 8:54 am     Reply with quote

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?
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Feb 22, 2011 9:49 am     Reply with quote

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
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Tue Feb 22, 2011 10:25 am     Reply with quote

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
altanonat



Joined: 07 Feb 2011
Posts: 21
Location: Turkey

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Tue Feb 22, 2011 12:24 pm     Reply with quote

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.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 22, 2011 1:10 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group