In addition there is a single LED and a single push switch to represent the input and output devices.
The device includes an ICSP header (In Circuit Serial Programming) and a USB type B connection. In the following circuit diagram you can see the minimum configuration for a usable USB device. To begin with we need to build a USB device to communicate with. Please note that all of the host screenshots are taken from a Windows 7 machine, if you need to find the same/similar thing on an older Windows box please head over to Google where you will find plenty of information about where the items are on your WindowsME machine.
Also make sure you have MPLAB, Microchip C18 for the PIC18F and Microsoft Visual Studio 2010 express installed. If you want to follow along with this article I suggest you scroll down to the bottom and download the accompanying software. To keep the cost and difficulty as low as possible I will concentrate on breadboard construction of the hardware using few components, the PIC18F firmware will be based on (the freely available) MPLAB and Microchip C18 compiler, the Windows software will be created using Microsoft Visual C# 2010 express (which is also free to download).Īlthough this article is based around the PIC18F4550 microcontroller you can easily substitute this for the smaller and cheaper PIC18F2550 which is code compatible with the larger 4550. Using this the basic principals of 2-way USB communication will be made clear allowing you to progress onto more complex projects. The device will allow you to control a LED from Windows and also see the status of a push-switch on the device. As always I welcome your feedback and suggestions in the comments.įor this article we’re going to stick to a fairly basic USB device. This should provide a smoother path from this basic tutorial to more complex projects. Update: I have updated this article to use the Microchip C18 compiler and to be based around my latest USB framework libraries for both the PIC and Windows ().
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. 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 advent of Windows 7 you need an expensive Microsoft validation certification to create custom USB drivers (without it most users cannot even install your software).
In this article I will show 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. After looking at projects such as my Atari Joystick USB Adaptor and C64 VICE Front-End there seems to be a demand for more information on how to ‘hack your own’. I get a number of emails every month asking about creating USB devices using the PIC18F microcontroller. 2.4 Understanding the firmware source code.2.3 Installing and building the firmware source code.these) that can be interfaced directly to an embedded processor usig only a uart. There are also some usb-serial chips (eg. These will deal with the hard work of usb and the data acquisition and give you a nice programming interface to use in your application. Take a look at some of the offerings from National Instruments. If all you are interested in is being able to measure voltages on a usb device (and writing the code isn't important) there are many products out there that will do that for you.
For windows driver development I can recommend this book by Oney.īut I'd investigate the libusb option in preference to the driver development in both cases.ītw. Investigate this book by Rubini for linux development. If you must do some kernel development (either Windows or Linux) then C is pretty well the only option you have. (edit 3: Ilya points out in the comment that Jungo is also available for Linux) Again, this moves the usb software into user space rather than requiring Windows kernel development. If libusb isn't going to suit your needs and you're developing for Windows you should have a look at the software that Jungo provides. If you can I would suggest using a library like libusb, as kris and Jon Cage have suggested.