When the device is connected to the computer, a Virtual COM Port (VCP) will be created. This is shown at the Device Manager Window under Ports(COM & LPT). In this case, COM5 was created when the PIC18F4550 was attached to the USB Port. It may be interesting to note that if you plug in your PIC in different USB ports, the
VCP created will be different.
Here, I modified the CDC firmware provided by Microchip and wrote a Visual Basic programme to communicate with the device. An important thing to note when using the firmware and this schematics is that... to PLACE REMARKS ON THE FOLLOWING 2 LINES AT USBCFG.H like this...
//#define USE_SELF_POWER_SENSE_IO
//#define USE_USB_BUS_SENSE_IO
if not the when you attach the PIC to the USB Port, it will disconnect itself immediately soon after!
The concept of baud rates, parity bits and flow control is not important in this method of RS232 emulation as most of these matters are taken care of by Windows XP's internal drivers. Therefore, the settings for MSComm for these properties can be omitted altogether. It will still work.The VB software controls the 2 LEDs connected at RD2 and RD3 besides reading the analog voltage of the potentiometer connected at RA0. The correct VCP has to selected before the software can communicate with the PIC18F4550.
One last thing is that, when you want to switch back to the bootloader mode, just hold on to S2 (Enter Boot) while tapping S1 (Reset). When the bootloader firmware in the PIC detects a HIGH on S2, it will enter Bootloader mode where you can use the PDFSUSB.EXE to programme, erase or to read the PIC via the USB Port. When I do this project, I first went thru the quick USB tutorial at the website above before writing the firmware to communicate with the VB software. I would advice you to do the same too. The next time, I will present the HID version of USB Communication. =)
Schematics: USB_USARTSchem.jpg
Microchip C18 modified CDC firmware : cdc.zip
Visual Basic 6 programme : usbusart.zip
No comments:
Post a Comment