FlexRadio 5000 and contesting
Choosing a radio for remote operation

Making USB connected PIC projects easy!

All my previous PIC projects that required external communication used an RS-232 serial port – RS-232 is ubiquitous, easy to debug and inexpensive. But most PCs have always been limited to one or two serial ports and adding extra ports, even as USB serial adaptors, isn't a low cost proposition!

Mulling over the idea of a USB connected tuning knob for the "Mk II" project I started to climb the inevitable learning curve of getting a USB connected PIC connected (and communicating!) to the PC. The idea of crawling my way through the roughly 600 pages of the USB spec wasn't particularly atrracive!

Some research with Google quickly showed a number of promising ways to short cut the learning process:

Just before leaving for Christmas vacation, I downloaded a copy of the PIC PACK library and its examples onto my lap top. Travel delays provided ample time to start browsing through the code.

I also ordered a Futurelec PIC18F4550 based development board as basis for development when I got back. The board is very reasonably priced, uses a socketed 40 pin DIP version of the 18F4550 and is a great platform for developing new designs. The company is based in Thailand and as a result, it took a couple of weeks for the board to show up. The board is very similar to the Microchip PICDEM FS board but easier to use for prototyping purposes.

The PIC PACK library includes a demonstration of the USB stack that implements a USB Communications Device Class – aka, something that looks like a COM port to the host. After reading through the code, I decided that this would be a good place to start getting my feet wet with USB.

After a few debugging efforts to re-target the demo to my FutureLec board, this was more like diving in the deep end than dipping a toe in the water! I resolved a couple of issues with the configuration register settings on the PIC18, plugged the board USB port into my PC and was instantly greeted by the Windows Hardware Wizard asking to install a newly detected piece of hardware.

Ian Harris has done a spectacular job with the USB device support – it has a fully interrupt driven USB stack, has several worked examples that show how to configure the different configuration vectors that USB uses for device enumeration – the process of figuring out the device capabilities and host driver support for a newly discovered USB device. Ian also provides links to the relevant sections of the USB specification embedded at relevant places in the code. All this with a "do what you like with this software" license.

Excellent work Ian!

I quickly had my USB framework up and running – installed as a USB compatible COM port under Windows, using a standard Microsoft USB driver and communicating with the PIC via Hyperterminal.

My next step was to build a prototype of the hardware for the Mk II tuning knob and attach it to the Futurelec board. Here's a picture of the completed prototype – complete with ribbon cables to connect to the PIC port lines on the Futurelec board.

The large knob (from a Collins KWM-380 no less!) sits on top of a mechanical shaft encoder which has an integral push switch – not unlike the volume control used in modern car radios. This particular encoder has 20 pulses per revolution and no mechanical detents – this providing a smooth tuning experience! Best of all, the prices is right – a little over $3 in 1 off quantities! You can just see the three LEDs peeking out above the knob itself – these provide visual feedback of the different operating modes for the knob.

In the next post, I'll describe the how the encoder is handled by the PIC and turned into a tuning knob for a FlexRadio via CAT commands on the PC.

Comments

The comments to this entry are closed.