Introduction: Adding USB to Circuits With Open Source

Adding USB to control/monitor/interact with circuits from a PC via USB is easy.

Just follow these steps - it uses open hardware (just a single chip - a microcontroller), or alternatively you can use a pre-built StartUSB board from MikroElektronika.

Both methods are outlined, and full source code is available for the microcontroller and the PC app. No USB driver needed, it uses 'USB HID'. For schematics, check out the startUSB documentation if you exactly want to replicate the board.

There is not a lot to it (just the microcontroller, USB connector, crystal and a few other typical bits).

Step 1: Overview

Step 2: Obtain a Board (or a Bare PIC18F2550 Microcontroller + Programmer)

Step 3: Get Software From MikroElektronika Site

Get it from here:

(About half-way down the page)

Step 4: Download and Install Development Software

Go to Microchip site to get MPLAB X IDE and XC8 Compiler

Install them.

Step 5: Get Source Code for the Microcontroller

Go to Element14 and download the usbtest source code attached to this blog post.

Step 6: Unzip Source Code and Open It in MPLAB X

Step 7: Only Do This If You're Using a Bare PIC18F2550 Microcontroller

This step is only if you're using a blank PIC microcontroller and a PIC programer. In this case, you're not using a bootloader and so this setting needs to be removed (the setting is needed to be present for the StartUSB board which has a bootloader).

If you're using StartUSB then skip this step.

Step 8: Compile the Source Code

Step 9: Program the Microcontroller (skip This Step If You're Using a StartUSB Board)

Step 10: Drag-and-Drop Programming of StartUSB Board (skip This Step If You're Using a Bare Microcontroller)

Step 11: Download MLA File Which Contains Source and Executable for the PC Application

Step 12: Run the PC Application, See the Control Capability in Action

Step 13: Optionally Modify the Source Code and Recompile to Add More Control Pins

Step 14: Thank You

That's it!

See Element14 website(click here) for a text description of all of these steps, and any discussion.