Wednesday, January 05, 2011

Collaboration

Making fun little lighting projects is just one of my hobbies.  Interjecting my unsolicited opinion on the design of other people's projects is another.  My neighbors embarked on a basement remodel a while back and, like a moth to a light bulb, I fluttered about living vicariously through their ambitions.  I'm pretty sure doing something similar or anything more than hanging a well framed painting on the wall of my rented townhouse is some sort of lease violation. I said, "those are some nice shelves".  They said, "thanks".  I said, "you know what would look cool".  They said, "do it".  They have obviously read my blog.

The shelves are 16" cubed, built into the wall, made out of sheet rock and painted white.  I wanted to light'em up and I knew just what to do.  The trick was finding a RGB LED worthy of the job.  DealExtreme is a tad sketchy and based out of China but pretty much my only bet for 3W RGB's at anything close to a reasonable price.

The construction of the circuit board was pretty straight forward with only one notable addition.  Along with the 3.3V power supply, LED driver chips (CAT4103), and obligatory PIC micro-controller (PIC18F2510), I used a Lantronix XPORT Ethernet to Serial module to accept commands from any network attached device.  It was agreed that I would leave all the software design up to the neighbors.  After all, they are the professionals.  My board reads in a command packet, writes the LED intensity registers and creates a pulse width modulated (PWM) signal to update the RGB LED drivers.  When I design any board, I like to make it as versatile as possible in the event I decide to add any features after the fact.  There are only 7 shelves but I built the board with 12 drivers just in case.  Two boards can also be stacked to drive a total of 24 RGB LED's as you can see in the picture below.  Turns out we'd need all 24 but I'll tell you more about that later.


So I finished the hardware, installed my custom firmware and performed the least amount of testing it took to convince myself that there was a chance it could work.  My neighbor Mark was designing his visualization software in parallel with only a loose discussion of what the command packet should look like to go by.  The idea was to get together once each part was done and spend way too much time debugging the inevitable problems. That is until it worked right out of the gate.  Sometimes the lighting of a single indicator LED can stir up a bevy of emotions in the average geek... imagine the lighting of an entire bank of shelves.  I'll have to admit, Mark's software is pretty impressive. My favorite part is the connection with iTunes.  While a song is playing, it gathers frequency information on the fly and displays it on the shelves in a variety of ways. Check out the video at the bottom to get a better idea of what I'm talking about.

If working solo, I may have called it a project and moved on.  However, the neighbors had a vision and a suspicion that I wouldn't leave them hanging.  They installed 20 overhead can lights in the drop ceiling and four wall sconces in the theater section.  24 extra LED's huh, yikes!


The hardware wasn't a big deal cause it was pretty much done already.  LED installation and firmware development... Now that was a bit tricky. The room lighting was already wired up for 120Vac so the LED's had to be installed in such a way that proper light diffusion was achieved within the housing and the housing itself wasn't altered in a severe way.  The blue socket protection cap provided as close to a perfect solution as we were going to get. The cap was meant to fit snugly into the existing light socket so I just mounted the LED to that and attached a strain relief on the side. Neat and tidy.



So for the ceiling and walls, that is 24 RGB LED's which makes 72 (24x3) discrete sources of light.  To drive each LED at different intensity levels, I switch them on an off at a set frequency and vary the percent at which each LED is on during a cycle period.  If it's on half the time, it appears to be half as bright as a LED that is continually shining.  For this project I chose a refresh frequency of 60Hz with 32 levels of intensity.  Therefore, I have to update each of the 72 LED's 32 times every 1/60th of a second.  In other words, I have 520 microseconds to update 72 LED's.  With a 16MHz oscillator, the instruction cycle on my micro-controller is 250nS. So, the update period divided by the instruction cycle time divided by the number of LEDs gives me a total of 26 instructions to preform everything needed to decide whether a given LED needs to be on or off.   I ended up needing 22.  Just squeaked it in there after a bunch of tweaking and a little luck. 






The shelves and ceiling have a refresh rate of 30Hz and can generate over 30 thousand colors per pixel.  A pixel is a single shelf or can light in this case.  Not bad for a few bucks and hours of spare time. Best part, Both the shelves and ceiling consume less than 50 Watts when fully lit. And less than 10 on average when in visualization mode.  That's around the power draw of an incandescent night light.  Saving the planet one disco basement at a time.

I'm pretty psyched about this install.   I mean, it's what I'm really passionate about and, if I could toot my own horn for second, I may actually be getting kind of good at it.  What do you think?

Here are more videos for your viewing pleasure.  Thanks Mark.