Data communication between microcontriller and PC using USB protocol

Thread Starter

HMD

Joined Jan 24, 2015
14
Hi everybody

I want to make a communication between microcontroller ( i.e. AVR microcontrollers ) and PC ( with windows OS ) using USB protocol . but i don't know how.
I know that I should do these steps :
1 - design the appropriate circuit on the microcontroller side
2 - applying the required changes on the PC side ( or even write a program in C , C++ etc if needed )
3 - programming the microcontroller with appropriate design in order to communicate with PC
I know nothing about these steps . Can anyone please help me? Does anyone know helpful references for this purpose? I'd really appreciate your help.
 

Papabravo

Joined Feb 24, 2006
21,159
I would start with the USB 2.0 specification which can be downloaded at no cost.
http://www.usb.org/developers/docs/usb20_docs/

Next I would purchase a low cost USB packet analyzer
http://www.totalphase.com/products/beagle-usb12/

The start of the development process is to successfully negotiate your configuration with the windows PC. This is the most challenging and difficult part of the process. You need to be prepared to repair your Windows Registry when this process goes wrong as it inevitably will.

Purchase a copy of Jan Axelson's book USB Complete
https://books.google.com/books/abou...urce=kp_read_button&hl=en#v=onepage&q&f=false

That should keep you occupied for a while.
 
Last edited:

RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Hi everybody

I want to make a communication between microcontroller ( i.e. AVR microcontrollers ) and PC ( with windows OS ) using USB protocol . but i don't know how.
I know that I should do these steps :
1 - design the appropriate circuit on the microcontroller side
2 - applying the required changes on the PC side ( or even write a program in C , C++ etc if needed )
3 - programming the microcontroller with appropriate design in order to communicate with PC
I know nothing about these steps . Can anyone please help me? Does anyone know helpful references for this purpose? I'd really appreciate your help.
I have done not written code of UART myself.
if you want i can give you pi16f877a and usb ttl
 

Thread Starter

HMD

Joined Jan 24, 2015
14
I have done not written code of UART myself.
if you want i can give you pi16f877a and usb ttl
Dear RRITESK KAKKAR

No thank you. I've lots of projects to do with USB in future. So it's better to get familiar with USB at first and currently I know almost nothing about it.
So thanks again for your help.
 

ScottWang

Joined Aug 23, 2012
7,397
Dear ScottWang

Using serial ports , is much easier. but they are not common in today's computers.
I think I should study more about USB protocol . The references which Papabravo introduced are enough . but thanks anyway for your help.
If you want to study the formal USB protocol, I won't stop you, but you need to know is that it is harder more than you can think, what I suggested was that you using the series port but it was through the USB port, so I'm not suggest you to use the old RS232 series port, if you look into the linked page to check the code as I suggested then you will know what I mean.

That is what we called false USB.
 

John P

Joined Oct 14, 2008
2,025
This is extremely easy to do if you use the FTDI interface chips. These accept USB on one side and communicate with the processor's UART on the other. Meanwhile, on the PC side the FTDI chip automatically creates a pseudo- serial port which your software can talk to. It's as if your PC had one of those extinct RS232 ports, as seen by both the PC and the processor. All you have to do is make the baud rates compatible.

There are processors available with USB built-in, but getting the code to run properly is a challenge.
 

ErnieM

Joined Apr 24, 2011
8,377
I would strongly advise not to write your own USB code for the micro. Go to the micro manufacturer's site and download their library for this. If they do not have such a library, and no third party has one, go back to step zero and select a different micro that has such available.

I use Microchip PIC devices and they have just such libraries available. My top choices are the com communication class, which makes your device appear as a virtual com port, and the drive class which gives the PC access to an SD card on my board.

I've had some practice at this but starting from the sample programs I can get a bare bones project up and running in a few hours. Disclaimer: I have yet to work my way thru the revised libraries so my work done with the older libs on the C18 compiler is what I know best.

Jan's book referenced in post #2 is excellent, as it her website. I would not waste time reading the standard.
 
Top