From time to time, a project idea is born fully formed. This was one of those. As happens from time to time, I blame this whole project on Adafruit.
Maybe I’d better start at the beginning. One of the organs I maintain is at Appalachian State University, in Boone NC.
She’s a rather stately animal, is she not? (Since you asked, no, not all organs are female, but this one is. That said, you should never anthropomorphize instruments; they hate that.) The fellow who runs the organ studio at ASU is a most excellent co-conspirator for projects which involve Good Fun. For example, the school hosts a Halloween Monster Concert every year with audience sing-alongs, costume contests, spooky decorations and the whole bit. It’s become a school institution, and they pack the house every year.
Now there is a small stream of interesting parts for which I have no immediate application which nevertheless flow across my lab bench to be tested because you never know what you may need at some point, and I’m an irrepressible tinker. One of these was the Adafruit breakout board for the PCA9685 which is an IC by NXP which generates PWM signals for driving servos and fading LEDs. Their description page for the product had something which stuck in my brain…
“You can even chain up 62 breakouts to control up to 992 PWM outputs (which we would really like to see since it would be glorious)”
So there was a little gremlin in my brain saying “We need to do a gigantic LED project!” and then all at once, it came to me. The organ needs theatrical lighting effects for Halloween. The problem is, the organ is nearly three stories tall, lighting it up would require a lot of LEDs.
Enter : A lot of LEDs. Sixteen full 5 meter reels of 5050 package RGB LEDs. So we have 1152 watts of LED strip here, how are we going to break it up? Let’s make it simple : One controllable output zone (which is to say, three PWM outputs, Red-Green-Blue) per reel.
So that makes three PCA9685 breakouts, 48 output transistors, a mess of wiring; in short this is not going on a breadboard, or even perfboard. We needed a purpose made board, and because this is Halloween, it should be spooky.
At this point, a schematic would be pretty much redundant. At center you’ve got an Atmega644P, then three PCA9685, a little power supply, and a boatload of STP16NF06 power MOSFETs on the output side. Spooky squiggly traces optional.
Now there is one more issue to consider: current. 1152 watts is a lot, and it’s more than is any fun to deal with on a PCB. That much current switching at these frequencies also starts to resemble a lousy radio transmitter for noise, so I don’t deal with much of the current on the board. You might assume that because an LED strip has four pins (Anode, R, G, B) that these four pin wiring connectors attach to them directly, but that’s actually not so. The source pins of each group of three output transistors are tied together with a big fat trace and brought out on one of those pins to a wire, and it joins the common anode wire from the LED strip and they go down to the power supply as discrete wires. Like so…
This keeps the big currents almost entirely off the board, which is a Good Thing.
The strips themselves have their own attendant problems. We decided to stick them, doubled up, onto 4′ long sticks of flat moulding we got for cheap at the home improvement store.
There is, actually, NO time efficient way to tie the strips together, you just have to solder wires. Bummer, Drag. It took forever.
PROTIP : if you’re doing a project like this, you should only get the waterproof strip if you need it to be waterproof. cleaning the silicone gook off the pads of the waterproof stuff is no fun, also it STINKS when they warm up.
Next question : Where do you get 1152 watts of decent 12VDC? Well you can get it out of PC Power Supplies, but you need to be Very Choosy. Good modern PC power supplies above 600 Watts frequently drive one massive 12V rail from which the other voltages in a PC are all derived, this is the kind you want. you DON’T want the kind which is all regulated off the 5V rail. We used a pair of Corsair TX750 V2 – they stayed within 3% of the stated voltage regardless of load. Highly recommended!
PROTIP : Four conductor thermostat wire is great for wiring up LED strips. Four conductors at sufficient gauge to support a whole 5M reel on each one. Much cheaper than the stuff sold specifically for the job, and shielded!
During testing, we were afraid we wouldn’t have enough light output. It’s difficult to gauge such things in very different rooms.
The software was pretty straight forward, the system is controlled over serial link, a command is the destination value for each channel followed by the number of frames it should take to fade to that color. The Atmega proccesses frames at a pre-determined rate by polling the clock. The arduino Map function saved me a ton of coding time working out the intermediate values in the fades.
Stuff that Broke :
The original plan had been to run the serial through an Xbee radio to control it from out in the auditorium someplace, or in the booth. As it turns out, the switching noise from all that PWM completely swamped the radio, reducing its effective range to about 9 inches. In a pinch for time, I hardwired the serial line with an FTDI Buddy, left the Macbook in the organ, and remote controlled it with the iPad over an ad-hoc wireless network. Apparently those radios are a lot more robust than XBees. Good to know.
The adhesive on the backs of the LED strips is kinda crap. If the cable pulls on them, at all, they’ll peel right up. This was the cause of much heartbreak.
Don’t cheap out on connectors. Just…Really, Don’t.
So, on the Big day, things wen’t pretty well.
The first cue is with the house lights up, and even against that competition, the system looks pretty damn cool. But when the house lights went down, that’s when things got Properly Sexy.
About six cues into the concert, after the picture you see here was when the system became totally unresponsive. The remote control link was working fine, but the PCB was no longer responding to serial commands.
It pays to be able to keep calm and analytical during these moments and quietly troubleshoot while people wonder why the lights have stopped changing. So here’s the other Thing That Broke.
The serial protocol is totally fragile. This is pure sloppiness on my part, I was in a hurry. It waits for 49 bytes, reads them all, parses them into a command and then goes on with business. This, as you’ve probably already guessed, is prone to going out of sync if, say, noise causes an extra byte to go down the wire. Suddenly it gets stuck part-way into a frame waiting for the rest.
I strongly suspected this is what had gone wrong. I didn’t have a remote reset, so what to do? Well I closed the serial port on my control application and fired up a straight serial terminal and typed the same letter repeatedly every quarter second or so and watched the lights. Once the out-of-sync command buffer filled up to 49 bytes of my typed-in letters, the lights changed (mostly to gray, since I’d been repeating the same character) and I could restart the control app and take control of the system back. This was a clever bit of problem solving, but it should never have been necessary. If you’re going to make something controlled over serial, you should implement a proper protocol with a checksum and the capacity to bail out of a packet which is obviously malformed and start over again. Lesson learned.
So what about next year?
Well this design worked pretty well, but it has serious weak spots. I think, all things being equal, I’d want a more distributed system. In the future I think I’ll make small cards which solder directly onto the strips and decode/pwm/power each strip off a common power and RS485 signal chain. An ATTINY2313 would be more than sufficient for this job. You could feed the board 12V and serial and assign each one a unique number. This would at least keep troubles segregated, which in an application like this is probably for the best. Probably a bit more expensive, probably a lot more reliable. Certainly more straightforward to wire up!
Next year, I think we need twice as many LEDs. Maybe a bit more.