Project PicUSB: PIC<-->RF<-->PIC<-->USB<-->PC
by MatheusLPS
Hello people of the forum! How are you? So, I have good news for those who enjoy a microcontroller and do not know turn it on PC through USB. The problems are over!
OBS 1: This is a project that a made 1 year before and decided to share with you. First because I want to share and I saw a reply today on youtube from
Kam on this video:
http://www.youtube.com/watch?v=cJq-PlkIb0wI believe he is also interested in the subject.
OBS 2: I am from Brazil and english is not my mother language. Sorry for any mistake.
OBS 3: The coments on the images was writen in portuguese, that is my language. I am too lazy to recoment in english... :d
OBS 4: All the images are clickable to a large version.
Attention:
This project is not aimed at those completely new to the world of microcontrollers. You need a certain degree of knowledge to be able to go over the problems that may occur. And remember: "Uncle GOOGLE is there to remedy the most questions!"
So, I am developing a project in college where I need to use a microcontroller and connect it somehow to my computer to view information. This pre-project aims to introduce the concept of how to make the data exchange between a microcontroller and a computer via USB.
Specification of component used (USB)
Currently ports like RS232, serial, and other are no longer used, because they are considered outdated. The USB protocol takes advantage as regards the speed of information transfer and the ease of connection to the system, although this feature is quite complex as regards the control software. Much of this work is to make the PC recognizes a valid USB device.
Methodology
At first there was the idea of using the computer's parallel port to communicate with the PIC, however, considering that a notebook does not have such a connection, it was decided to examine other alternatives. Faced with this limitation it employed the USB components and microcontrollers to remedy the problem.
Was used as a methodology the textbook USB Complete Third Edition, Everything You Need to Develop Custom USB Peripherals by Jan Axelson writing. It is noticed that the book is the bible for those who want to start using USB, contains many examples and source code.
Unfortunately this is not the case, even wanting to do something new, do not want to reinvent the wheel. The USB protocol already exists for a while, just wanna know how it's done something more superficial. And the book covers subject matter that we decided not to seek.
Starting from the initial proposal, it was an intense search to find material that would unite the elements PIC, USB and CCS Compiler which is already being used. Unfortunately, the material on the subject is scarce, even more of a theme so specific. Luckily it was found in an internet forum that helped in determining the type of PIC to use.
It was with great difficulty that I found a forum in Spanish, which helped me a lot:
http://www.todopic.com.ar/foros/index.php?PHPSESSID=4c610a6d668ecb0594cd26c5419195dc&topic=2260.0This guy built a protocol in 2005 that helped me understand how a simple PIC can be connected to the PC.
He placed at the disposal of all your files with source code so that all people could benefit from. It was with this intention that I decided to post my experience so others do not have as much difficulty as I had in doing the project. Since the idea to the stage that I am, there were 2 months of research.
Block diagram of the Initial Project
The diagram can be seen in the image below:

As you can see above, the aim of the project is to control a car via the computer, built with two servo motors. This car can send various information such as: temperature, relative humidity and so on.
In this post I will give only an idea of the project, later on, I will give more detailed information about the construction of both hardware and software that was the trickiest part.
Tools Required
In this part I will quote the necessary software for the project to be executed.
Microsoft Visual C # 2010 Express: The author used the 2005 Express, however, that all the functions added work, you need the 2010 Express. It's free!
Pic C Compiler: Is the CCS. I used this because I'm used to and the bibliography found also wore it. I DO NOT KNOW USE other compilers!
Proteus ISIS: To test our project, we need a simulator. And that I recommend.
32bit Operating System: The Proteus USB drivers do not work on 64bit systems. And the PIC USB drivers do not. I use windows 7 64 bit and did not want to install another OS just to test the circuits. Then I used a virtual machine resource. I installed XP SP3 and Windows 7 32bit and it ran smoothly.
EDIT: Later, I was able to use 64bits operation system.....
How It Works
At first I have a PIC connected to the computer and some leds connected to the microcontroller to test.
The PIC circuit is as follows:

It is noticed that the hardware part is quiet, few components.
There is a pic of the left that is connected to PC via USB, the PIC on the right pic is on the car. Realize that they are connected only by one wire, simulating an RF connection via RS232. The LCD is just as debugger to certify that the information is coming.
We have to turn it on PC and it should be recognized as a USB device:

In the photo above, I started testing with a 18F2550. Now I have an 18F4550 and it works!
Now you must create an object-oriented software that controls our PIC. This is done in Microsoft Visual C # 2010 Express.
As a test, I made a program based on the J1M, author of the original structure. This program turns on / off LED red, blue, read the temperature using an LM35 and shows in a graph. Ahhh, I left in the program a function that takes two integers, send them to the PIC and the PIC returns the sum. Result is shown on the screen.
Screenshot of Sofware:

Pictured above is a screenshot of the system running on Windows XP installed on a virtual machine. In windows 7 worked well!
I will not post the source code of software for a while because it will overload the post.
More info is coming....