Introduction: Open Source Microchip LED / PWM Driver Project
This instructable fully describes building a PWM driver to control four LEDs from one small Microchip 12F609 board.
The original design was called the "Kemper LED Lamp" and I sold a few lamps to several brave folks through my web site. However, I've come to discover selling small quantities to a few folks is a major pain in the backside. Hand soldering these together and then selling them at $4 bucks each is no way to make money.
So, I'm going Open Source baby. I'm hoping that more people can enjoy these wonderful little lamp drivers. I've put in way too much work for these little gems to sit idle on the shelf and not get used.
With the information I'm providing here, you should be able to program your own Microchip 12F609 micro, connect a couple LEDs, and have your PC command some LED action.
For reference, here are links to my prior Kemper LED instructables:
Those two links have a bunch of information that cover the lamp design in detail. There are even a couple video demos in those instructables that, I think at least, are cool too.
Note, if anything new comes up you can always check my web site at:
Step 1: Hardware Design
The hardware is painfully simple. The micro drives four outputs and receives / sends commands on the fifth. Couldn't get much simpler.
Eventually, I ended up with a board design that is 20mm x 15mm. To keep the cost down I used CAMtastic to array the lamp boards onto a larger board. I arrayed the lamp boards using a grid of 8 x 8 with a 0.055" gutter between each lamp. The gutter makes it easy to cut the lamps apart with my cheap-o bandsaw.
Step 2: Software Design
Programming the 12F609 separates the men from the boys. While the hardware may be super simple, the software is not. I spent weeks (OK, maybe two) pouring over this stuff. The code below has been highly optimized just for this application. There is practically no RAM or ROM leftover to spare. In fact, I ran out of RAM many many times and had to ether drop functionality or look for more optimizations.
The 12F609 does not have a UART. So, receiving new commands while maintaining the PWM channels became my nightmare. The PWM channels must be maintained even while a new character is being received. The human eye is just so good at seeing the smallest blip emanating from an LED.
Receiving a new character using software is no big deal. But, receiving characters while updating PWM outputs is. The trick is to update the LED output channels while waiting for the next bit on the comm link. In effect, it's multitasking, and getting it all working was a major hassle. Simply impossible without a LSA (logic state analyzer). I used one output pin as a debug pin. I'd toggle the pin on certain events and watch for it on my LSA. Using this trick, I could watch each bit being received by my code.
OK, OK, enough already. Below you can find the source files that do all the magic. I'm publishing them in the hopes that others can learn from my efforts. There really is some good code in there.
Instead of describing all the software in detail, the comments in the code should explain most stuff. Remember, when in doubt "Use the force - view the source." I added a bunch more comments to the code in an attempt to make it more readable. I hope you'll agree that it is, indeed, readable.
Update: May 16th, 2012
Below is a Zip attachment which has 32 hex files within. Each hex file is the same except for the hard-coded node number. So, to flash node #1 use file "1.hex" to program the micro.
This should help folks who do not have access to the CCS C Compiler.
Step 3: Datasheet
Attached to this step is the datasheet that goes along with the project. The datasheet does a good job of documenting each protocol command.
Well, that's it. Hope you find some good uses for the Kemper LED Lamp.