USB – Olsen 595 Translator

Overview

This project started as a learning experiment on the Microchip PIC 18F2550 (Datasheet - 6.74MB) with on-board USB. One of my recent interests has been computer-controlled Christmas lights. Most of the USB-to-parallel converters on the market don’t work with the commonly used Olsen 595 DIY Christmas light controller (see also Making an Olsen 595), so a translator for the ‘595 seemed like a good starter project.

The firmware for the PIC was written in Microchip’s free “student edition” C18 compiler. The project uses Microchip’s USB CDC class for the USB functions. While researching hardware designs, I ran across the USB Bit-whacker by Brian Schmalz. Since the UBW is now being sold by SparkFun Electronics, I decided to make my design compatible with the UBW so people who didn’t want to build the hardware could use the UBW from SparkFun.

Hardware

I designed my hardware using the freeware version of Eagle. Since this was a learning exercise (and to reduce the number of holes to drill!), I chose to use surface mount resistors and a surface mount capacitor for Vusb from the PIC (don’t make the mistake I did and order a “0603” size cap!).

I was able to put all the traces on a single-sided design. Here’s the front side (complete with toner “silkscreen”) :

…and the copper side:

Here’s what the completed board looks like:

…and my wonderful soldering:

You can download the eagle files for my schematic and board if you are interested (note: I added the "J_PWR" jumper after I built the pictured hardware).

Software

The software for the project consists of the firmware that runs the PIC and a small VB.Net utility that sets the number of channels the translator expects.

Firmware

The firmware is built around the CDC class in Microchip’s USB framework. It’s described in AN956. Rather than start from scratch, I modified Brian's UBW Revision C firmware (see link above). I also used Brian's customized version of Microchip's bootloader compiled for the UBW’s switch configuration and 20 MHz resonator.

Here’s my source code, or just the hex file (for use with the bootloader).

PC Software

The VB project also makes use of a freely available component, in this case a RS-232 class from Microsoft. I used the free VB.Net Express Edition to modify the sample code.

Here’s the source code and the .exe file for the PC side.

Using the Translator

Loading the Firmware

First, build the hardware and get the bootloader working (or buy the SparkFun version…). If you build your own, you will need a PIC programmer to program the bootloader into the PIC the first time. From then on, you can use the USB link. To activate the bootloader over USB, hold down the “PGM” button and press and release the reset button. The RX LED will blink rapidly to show you it is ready to program.

When you first plug in the translator while it’s in bootloader mode, Windows will go through the new hardware found process. In bootloader mode, the PIC identifies itself as a PICDEM demo board. The driver is included with Microchip’s USB framework (in the "\Pc\MCHPUSB Driver\Release" directory). Once it’s recognized, you can use Microchip’s demo software (PDFSUSB.exe) to load the translator’s firmware.

PDFSUSB.exe is in the "\Pc\Pdfsusb" directory of the framework. If the driver loaded correctly, you’ll have a “PICDEM FS USB 0 (Boot)” option in the drop-down box that selects which “board” to program.

Configuring the Translator

Once you’ve loaded the translator firmware, the chip will identify itself as a CDC class device. Win XP and Windows 2000 come with a CDC class driver, and the .inf file that associates the PIC with that driver is also included with the Microchip USB framework (in the "\fw\Cdc\inf\win2k_winxp" directory). Once Windows recognizes the CDC class firmware, your system will show a new COM: port.

Next, use the channel set utility to tell the PIC how many channels to expect. No special prep is needed. With the translator plugged in, start the utility.

Select the virtual com port from the drop-down box, type in the number of channels you want to control, and click the “Program” button. If everything is working, the PIC will send back confirmation of the number of channels. The PIC stores the number of channels in EEPROM, so it will retain the channel setting even with the power off.

Connecting the Translator

On the ‘595 side, you can use a straight-through LAN cable if you are using the most common pin configuration:

  1. power
  2. NC
  3. ground
  4. NC
  5. strobe (latch for the ‘595)
  6. NC
  7. clock (shift clock for the ‘595)
  8. data

Otherwise, fabricate a cable that matches your hardware.

The '595 can draw power from the USB port if J_PWR is jumpered. The power from the USB port is limited to 100mA in this configuration. That’s enough for limited testing without SSRs connected, but you have to power the ‘595 from another source for real sequences (and probably just to do a lamp test!). The ground for the power supply and the translator must be tied together on pin 3 of the '595 cable.

A better solution is to use a 6N137 optoisolator on each of the three signal lines so that the USB ground (and ultimately your PC) isn't tied to the controller ground, which usually goes out into the uncontrolled environment of the yard. The opto-isolators could be integrated into a power supply for a robust power/isolation module.

Configuring the Control Software

That’s it for the hardware. If you’re using Vixen (and YOU SHOULD BE!), set up the Renard plug in for the virtual com: port that matches the USB (on my system it shows up as COM3:), and the same number of channels you set up on the translator. If you're not using Vixen, you're on your own, but the protocol is described in the source files.

Using the Translator

Once the translator is running, the USB LED blinks slowly to indicate that the USB link is configured. The "RX" LED blinks every time the translator receives data from the PC.

In translator mode, the "PGM" button toggles the lamp test.

The "ERR" LED is an error light. It will blink to indicate an out-of-sync conditionon the translator (for example, when you press the channel test button while a sequence is running). It will also come on if a buffer overun occurs.

What’s Next

Right now, the translator has enough memory for 1024 channels. With the standard Renard plug-in, Vixen sends an 8-bit illumination level and the PIC translates those values into an on or off state. This should be sufficient to run 128 channels, but I can't test it since I don't have 2 controllers. If the project catches on, someone could write a Vixen plug-in that sends native 8-bit on/off values to the PIC. That would accommodate even very high channel count setups (but I’ll need someone else to test that!). UPDATE (2/11/07): OK, so maybe I spoke to soon...I'm getting errors at 64 channels even with 50ms timing with the plugin set to 250K. More to follow...