Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Interfacing USB with PIC

Status
Not open for further replies.

Pirasath

New Member
We, under-graduate guys,3rd year, have to do a project.We have selected our topic as Automatic Traffic control sysytem,where we going to use some type of USB device to capture the data. The problem we have is, processing this data using PIC microcontroller 16F877. Even though some chips available in the market that facilitates the above function, we have decided not to use those chips. We hav to design some kind of drivers to get things done. How can we do that.? Please help us regarding this.
 
Pirasath said:
We, under-graduate guys,3rd year, have to do a project.We have selected our topic as Automatic Traffic control sysytem,where we going to use some type of USB device to capture the data. The problem we have is, processing this data using PIC microcontroller 16F877. Even though some chips available in the market that facilitates the above function, we have decided not to use those chips. We hav to design some kind of drivers to get things done. How can we do that.? Please help us regarding this.

MicroChip have two series of chips with USB capability, the 16C745 (which is OTP), and the newer 18F series, some of which are USB compatible. The current issue of EPE magazine includes a 18F project using USB.

However, you should be aware that USB is FAR! more complicated than a simple serial connection - again, the EPE article would be helpful to you.

I'm also fairly puzzled as to why you've chosen USB?, it seems to give no advantages for your project?.
 
Nigel Goodwin said:
The current issue of EPE magazine includes a 18F project using USB.

MicroChip have two series of chips with USB capability, the 16C745 (which is OTP), and the newer 18F series, some of which are USB compatible. The current issue of EPE magazine includes a 18F project using USB.

Nigel,
Do you know what device the PIC appears as on the PC. Is it HID, serial port or something else. I'll have to see if I can get hold of a copy of EPE locally.

BTW, the 16C745 also comes as a windowed version. The code being 16C745JW.

Mike.
 
Pommie said:
Nigel Goodwin said:
The current issue of EPE magazine includes a 18F project using USB.

MicroChip have two series of chips with USB capability, the 16C745 (which is OTP), and the newer 18F series, some of which are USB compatible. The current issue of EPE magazine includes a 18F project using USB.

Nigel,
Do you know what device the PIC appears as on the PC. Is it HID, serial port or something else. I'll have to see if I can get hold of a copy of EPE locally.

The article explains the differences, but I think it's serial?, because the demo board is designed to provide an RS232 port.

BTW, the 16C745 also comes as a windowed version. The code being 16C745JW.

Yes I know, I've got one :lol: but they are VERY expensive, I got mine as a sample, before they stopped JW parts as samples!.

The 16C745 is USB 1.0, where the 18F examples are USB 2.0, and can be either 1.1MB or 12MB.
 
I suppose you will be wiring a Web Cam to the PIC.

The USB currently has 3 different speeds: Low Speed :1.5Mbps, Full Speed: 12Mbps and High Speed 480Mbps.

As far as the wiring is considered you can take a USB Connector, attach one end to the web cam, and at the other end separate out the wires. You should see the foll wires:

Green Color --- + Data
White------ -Data
Red ------ Vcc
Black ---- Ground

+Data and –Data form a differential system of data (to cancel the noise). Now you build a scheme so that you get your original data back ie Pulses wrt gnd. Remember that the data is in NRI-Z format.

The next part is a bit trick…You need to follow the USB protocol. Now USB uses packets for transferring of data. Every exchange is a 3 tier process…
1. Token Packet—Here the address of your device is given
2. Data Packet----Here the Actual Data is sent
3. Handshake Packet—Here the handshaking is done to complete the exchange

Note that both token and data packet are internally divided into sub field comprising of sync, packet identification & error check.

So now you have to choose your speed at both ends, assume your WebCam transferrs data at 9600 bps so in your MCU set the baud rate at 9600 bps and then use a logic scheme to seperate out each packet and in turn each sub packet . Then you can ultimately sort out your data.

Check out https://www.usb.org for more details.
 
Thankx Electrix and Nigel.. Atleast i got an idea where to start with.. I downloaded the USB 2.0 specification and now im going through that to get things cleared before start. Nigel, we using the WEBCAM to capture the images hence processing the data.. The cam we r using has USB interface. So we went with that. Also do we need to hav an external memory to work with data or stil we can use the EEPROM inside MCU... Im looking for further help from u all
 
Pirasath said:
Thankx Electrix and Nigel.. Atleast i got an idea where to start with.. I downloaded the USB 2.0 specification and now im going through that to get things cleared before start. Nigel, we using the WEBCAM to capture the images hence processing the data.. The cam we r using has USB interface. So we went with that. Also do we need to hav an external memory to work with data or stil we can use the EEPROM inside MCU... Im looking for further help from u all

PIC's generally have very little memory, although the 18F series are far larger than most, it really depends on the amount of space you need?. Check the memory space on the 18F series, NOT the program memory, but the GPR's (essentially the same as RAM).
 
Pirasath said:
Thankx Electrix and Nigel.. Atleast i got an idea where to start with.. I downloaded the USB 2.0 specification and now im going through that to get things cleared before start. Nigel, we using the WEBCAM to capture the images hence processing the data.. The cam we r using has USB interface. So we went with that. Also do we need to hav an external memory to work with data or stil we can use the EEPROM inside MCU... Im looking for further help from u all

Have you calculated your memory buffering needs to make sure this is possible with a PIC? Say you get a lowly 160x120 pixels per frame, and you somehow succeed in getting only 4 bits per pixel for color, that'd be 9600 bytes per *frame*, which is already 5 times more memory than what the biggest USB-enabled PIC18 has to offer in fast RAM.

What kind of processing will be done on the captured data?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top