

CCS also provides a Windows driver for the PC that creates a virtual COM port that you can open in Matlab, Hyperterminal, or any other RS232-capable program and use to talk to the PIC. The CCS compiler has a CDC library that provides functions like usb_cdc_getc or usb_cdc_putc that work over USB exactly like regular getc and putc work over RS232. Probably the simplest thing to do is use a preexisting software library that makes the USB connection look like an RS232 connection. On the software side you have some choices.

The ground line of course connects to ground.Īdditionally pin 18 on the PIC, called Vusb, should have a capacitor to ground. On the 18f4550, the D+ line connects to pin RC5 and the D- line to pin RC4. The exact protocol is complicated and you probably don't need to know the details. D+ (green) and D- (white): data is transmitted on these lines.GND (black): ground make sure you do connect this to your PIC's ground.If your PIC is self-powered, though, make sure you don't connect the two +5V sources or bad things may happen. +5V (red): the host (computer) provides up to 500mA of current at 5V that you can use for power.If you cut open a USB cable, the colors will also tell you which wire is which: USB connectors have four leads the pictures on Wikipedia show which is which on standard connectors. Wikipedia has a detailed and informative page on USB. It's enough to know what wires to hook up and what software libraries to include in your code. USB is a pretty complex protocol with a long specification, but it's not necessary to understand every part of it to use it.
