2009-12-25

240 LED Animated Christmas Tree

While shopping in Big-W at Warringah Mall I noticed in the Christmas Light section several bags of LED light extension strings intended for a modular light system they no longer stock. They were marked as 120 LEDs in two circuits of 60 LEDs each. No transformer or driver circuits just plugs at each end for daisy chaining. There were only a few left in various states of packaging distress and marked down to about $17. I picked up one and took it to a price check point, it scanned at $8.20... Naturally I went back and grabbed the remaining 7 assorted packs. Most of them weren't even labelled as to their colouring. Upon getting them home some tinkering with the bench PSU identified 4 blue sets, and one each of green, white, and multi-coloured (red/green, blue/orange).

The strings have a forward drop of about 28 volts at 50 mA, brightness is compressing at that point, suggesting they are wired as 4 parallel strings of 15 LEDs per circuit. The anode is common, allowing easy open drain/collector switching. The LEDs themselves are high efficiency/ultra-bright units, encapsulated in a milky defusing material with a conical invagination centred on the chip to scatter light in all directions - ideal for the application. The strings terminate in keyed 3-pin plugs with threaded closures, male on one end, female on the other.

At a bit of a loss as to what to do with such a large number of LEDs connected up in a fairly limiting manner, I decided to build a simple 4-channel Christmas Tree as an initial project.

Hardware

A frame was created by tie-wrapping some 6 mm timber dowelling together. Barely adequate for the fairly large structure, it was heavily triangularised to stiffen it, at least in two directions. It is still really only suitable for bracing against a wall. To this structure two sets of lights were tie-wrapped. The green set twice around the edges to form the basic isosceles triangle of the tree and the multi-coloured set zig-zaged across the body to fill the central void.

The power supply and control board was thrown together on doughnut board with the wiring pencil. It is so simple I didn't even prototype it.

PWM Controller Board for the 240 LED Xmas Tree.

A 24 volt AC plug-pack transformer supplies the power to the system, it is rectified by a bridge rectifier composed of 4 1N4007s and smoothed by a 100 uF capacitor. The main supply rail is almost exactly 35 volts unloaded. To supply the Atmel ATtiny13 MCU a 5 volt rail is regulated using a LM7805 (and a few 100 nF capacitors). The LM7805 can't handle the raw 35 volt rail, so two 9v2 Zener diodes drop about 18 volts off it feed the regulator with a more suitable voltage. (The regulator is overkill, I could have used a 5v1 Zener and resistor - but the regulator was like all the other parts just sitting in the junkbox ready to use.) Five channels are supported by the hardware, each with a 2N7000 open-drain current sink. Each MOSFET gate has a 10 kΩ pull-down to define the gate voltage with the MCU out of the circuit or tri-stated (e.g. at reset). Each drain line has a 180 Ohm resistor to protect the MOSFET and limit the current through the LED strings (in a short-circuit condition the 2N7000s should survive the 195 mA indefinitely - they are rated at 200 mA continuous in saturation - and nicely this resistor value gives a LED string current of 38 mA which is also quite acceptable). Of course the 7 watts in the resistors under a short will fry them, but they should survive transient shorts or fail-high and open the short - fusible devices would be more ideal. The MCU port B directly drives the MOSFET gates and their pull-downs, the associated RC constants are quite acceptable for PWM control.

Software

The software is vaguely related to the Star and Tree projects, but is 4-channel, and supports PWM for brightness control unlike the digital Tree and Star projects. Like the Star it executes a byte-coded program to control the animation of the channels. The global display state is 8-bits per channel and there is an plesiochronous ramp/fade thread and associated joining instruction. The single interrupt timer drives the ramp/fade and instruction state machines through independent global speed variables. Unlike the Star there is support for more than 1 level of loop nesting and two kinds of looping constructs (this was intended for the Star but is currently unimplemented - similarly the nibble-packed instructions designed for the Tree but also unimplemented there were built into this project). Most surprisingly the code fits in a Tiny13 (just) with enough space for some display scripting.

More work on the display scripting is required. I may also use the 5th channel to drive an additional string, perhaps a Star for the top of the tree.

Leave a comment on this article.

Updates

2009-12-28: 4-channel PWM Tree Emulator
A web-based emulator for the 240 LED Christmas Tree project.