Simple PIC USB Interface

Jump To:
USB Theory: USB Device
           The USB device is whatever you want to make. It could be a printer, webcam, keyboard or microphone. The USB device is wholly at the mercy of the USB host. It is in all respects, an electric slave. It cannot do anything without the USB Hosts' approval and passthrough.

USB Power For Your Device

           As noted in the USB specifications section, all USB revisions have a power +5v and ground signal built into the connector and cables. This means that any USB device you build, can be powered by the USB host! The limitation was noted that the maximum current draw per USB channel is 500mA (900mA for USB 3.0), which is a lot of current for a digital device. There's not too much more to say about this, beyond being aware that using USB means no need for external power supplies or batteries for the device you are designing.

Four Main Types of USB Device Communication

Isochronous Transfers
           This type of data communication is for real-time, high bandwidth devices like webcams or streaming audio. The USB Host garuntees a specific data-rate will always be available to the USB device that needs this type of communication. Data loss is possible, however unlikely.
Bulk Transfers
           The bulk transfer type of communication is typically reserved for large file transfer like to a USB memory stick or external harddrive storage. This transfer type does not set any garunteed speed for through-put, so it can be seen as a low-priority communication type for large/long communications.
Interrupt Transfers
           Interrupt driven transfers are meant for devices where low latency and fast response times are necessary. These devices, like a USB mouse or keyboard, do not send much information to the USB Host, but rely on high speed transfers in order to fully-function.
Control Transfers
           The last type of transfer is used in a similar way to the interrupt transfer. Control transfers are typically short commands looking for a status response from a device or host.

Human-Interface Device - Interrupt Driven Communication

           This tutorial will focusing on creating the HID type of USB interface which typically uses either the interrupt or control transfer communication method. The software developed will be able to utilize either method of communication. By definition the Human-Interface USB Device should be something that is taking input and giving output. Our device will primarily be giving input to the USB Host in the form of small data packets. This will allow the Laptop computer to then translate the input into something that can be output onto the LCD screen back to the user to confirm that the USB I/O is working properly.