Monday, August 2, 2010

Make Your Own USB Device using PIC18F4550

If you are looking to learn how to make your own USB device, this tutorial is perfect to start. Here you will see how to breadboard a simple USB generic HID device, creating the PIC18F firmware and finally creating the Windows interface for the device which will allow you to control a LED from the PC and read the state of a push-button from the device. Using the built in drivers for generic HID devices provides a simple method of creating Windows and Linux compatible devices and also makes the creation of both firmware and software far simpler. Since the HID standard does not require custom drivers you will not need to get a certificate for your driver, also both Windows and Linux have built-in libraries to help you communicate.


This project will allow you to control a LED from Windows and also see the status of a push-switch on the device. Using this the basic principals of 2-way USB communication will be made clear allowing you to progress onto more complex projects. The circuit is made on a breadboard and the PIC18F firmware will be based on (the freely available) MPLAB and Hitech C compiler, the Windows software will be created using Microsoft Visual C++ 2008 express (which is also free to download).

Make sure you have MPLAB, HiTech C for the PIC18F and Microsoft Visual Studio 2008 express installed before doing this project.
Circuit Diagram (Source:http://www.waitingforfriday.com/images/thumb/e/ee/Generic_HID_USB_Device.png/600px-Generic_HID_USB_Device.png)


The circuit is very simple. The PIC18F4550 will be 'bus powered'; this means that the device will draw its power from the USB host (your PC) so no power regulation is required. The 470nF capacitor (C3) is required so the PIC can operate the internal USB circuitry (it helps with regulating the USB voltages required by the on-board USB interface in the PIC). The ICSP header allows you to connect a PIC programmer, I suggest using the inexpensive PICkit2 programmer, however other ICSP compatible programmers should work just fine. The 20Mhz clock is required for USB applications. This allows the PIC to use PLL which ups the clock speed to the required 48Mhz necessary for USB communication.


1 comments:

Pieterjan said...

I don't see a hex-file or something to program the microcontroller.
Before you can use a microcontroller, you have to tell him what he should do in certain situations.
In USB programming, you have 5 things to tell:
- how does the circuit on the board look like -> OK
- which code should the microcontroller execute -> Not OK
- How do I program the microcontroller easily -> Not OK
- How do I make a driver/dll-file to communicate with the USB-device -> Not OK
- How do I implement the driver/dll-file into a developpement program like visual basic - C# etc. -> Not OK

I don't know how i should make a usb device. That's why i'm looking it up and arrive here. But I don't learn anything with reading this.
Greetz pieterjan

Post a Comment