Intro: LED Flickering Torch
Starting in 2009 for Halloween, we needed a realistic looking flickering light effect that would mimic an actual fire torch, but not use real flame.
I'd also been wanting to experiment with using AVR Microcontrollers for some time, and this seemed like a good opportunity to get started.
The controller design is such that it can be used for many other things in the future, so it is massive overkill, but I will present that here as well.
Step 1: The Controller Design Schematic
The controller is based on an ATMega324P in a 44 pin TQFP package. The schematic was drawn in gEDA's gschem tool. Looking at the schematic which is attached in both PNG and in gEDA/gschem format.
An RGB common anode LED is connected at CONN2, this is a 3W model from Everlight that I found surplus. Each segment of this LED can handle 3W so it was necessary to drive the cathodes with power transistors Q4,A5, and Q6. This particular AVR was chosen since it brings out 3 PWM channels of the internal timers to pins. This allows independent brightness control of the R,G, and B color channels.
Both an ISP header (J9) and JTAG (J12) are brought out for programming and debugging. Only the ISP header is required, but I wanted to experiment with JTAG as well.
The CPU (U1) is clocked by a 20MHz crystal, X1.
The board is powered by 5V, with the option of a 12V pass-through at a later time.
Other functions that are not needed for this purpose include U2 a ULN2803A high power buffer for driving other loads from Port A of the CPU, as well as 3 channels that can drive relays at 12 V on J2, J3, and J4. The other timer outputs that are not used are pinned out on J8 and J11 to eventually control servo-motors. General Purpose IO (GPIO) is provided on J5, J7 and J10.
Step 2: The Controller Design Layout
The schematic described previously was layed out in the opensource board design program called PCB. Renderings of the layout are attached, as is the actual layout
Most of the components are surface mount, and I had a solder stencil made by the nice folks at Pololu http://www.pololu.com/catalog/product/446.
The board is a 2 layer board that was fabbed by http://www.apcircuits.com/ in Calgary, Canada.
Of the 2 attached images, one is rendered to look like an actual board with soldermask, and the other is the "cad" view used during the layout.
Step 3: Controller Assembly
To assemble the board, I taped the bare board down to my desk, and used the solder stencil and an old plastic hotel card key to screen a layer of solder paste onto the board.
You can see this in the second photo where the pads look less shiny (that is the solderpaste covering the pads). The components were hand placed with tweezers.
The reflow soldering was accomplished with a hotplate covered with a scrap piece of aluminum to give a flat surface. Any shorts were fixed by hand with a soldering iron.
There are many references for how to do SMT soldering at home.
One thing I would probably not do again is use 0402 sized parts with out a microscope for more accurate placement. I would probably switch to 0603 next time.
Step 4: Controller Software
The key differences are that this one uses an RGB LED and 3 hardware PWM timers, for minimum SW overhead.
The idea was that if the pseudo-random flickering didn't look natural, the CPU has plenty of extra room to handle a more complex model of candle behavior.
The RGB LED was chosen for several reasons over a single color LED.
- It's hard to find orange / yellow LEDs at high brightness
- Most firelight is not constant color, if you look close a dimmer fire has a darker, more red color, and I wanted to try to mimic that.
- I wanted to use this project for other things in the future.
The full code is attached. I had been trying to implement a more complex fading between colors, but ran out of time to finish it. That is commented out in the attached code
The code starts in main() by initializing the PWM registers, and then doing a quick self test of the LED.
The function set_rgb() takes the R,G,B values and sets the PWM registers accordingly.
The main loop then starts a LFSR and flickers between 2 different color values.
Step 5: Final Assmbly
Since I made a few of these, I wanted to find an efficient way of mounting them as torches that would work well.
I hit upon the idea from my friend Steve at work, who does complex christmas light displays of using EMT electrical conduit used as a pole (it's basically rigid galvanized pipe).
a small electrical conduit box provides the housing, and a compression connector mates the pole to the conduit box.
a couple coats of black spray paint gives a more neutral look.
A cone with frills was cut out of paper to give a flame like effect.
A video is attached here as well, but due to the extreme brightness it does not show up as well as it does in person.
Note this LED was a SMT part that needed a small daughter board. A Luxeon star that comes mounted on it's own board will work just fine as well.
Step 6: Final Notes
- use of gEDA as an open source cad toolchain. I did have access to a high end commercial tool at work, but then my designs would be locked into that cad tool forever, if my company changed tools, or I lost access to that tool for any reason, I would not be able to edit my designs.
- SMT Soldering for hobby projects, not using resources at work.
- AVR programming.
More small-scale, I would suggest not using 0402 components unless you have access to a good binocular microscope or magnifying visor.
These torch LEDs were used in our halloween decorations for 2009, but were not featured in that instructable. https://www.instructables.com/id/Halloween-2009-Fire-breathing-dragon-with-artic/ One of them was used as the "fire" part of the fire breathing dragon.
Thanks for your time.