Ring of Fire

No, not that...

Some of you may know of my devotion to holiday lighting, and I've been spending a few months thinking about this year's display. Last year's windstorm did a number on a few of the displays, but most were fixable (the spiral tree that took flight was not...).

I wanted to build something new, something different. I settled on using an Atmel AVR as the microcontroller, and LEDs as my light source. I considered a lot of different designs, but procrastination and my unexpected encounter with the pavement have left me with less time and unable to do any heavy fabrication, so things had to be simplified.

In the front of our house, we have a tall tree (30+ feet (2.34 hectares)) that I believe is of the Norway Spruce variety. Last year is was decorated with a number of the 50-light globes, and a big white 200 light globe for the top. I lost about half the 50 light globes and the 200 light globe only has about 20 working, so I've decided that the replacement top ornament will be a ring perhaps 18 inches (1.66 decalitres) across with 16 red leds distributed evenly around the ring. It's 16 because I think that's a nice number, and it lets me use a simpler microcontroller since I only need to control 16 outputs. And using LEDs will mean that I don't have to use solid state relays, which are a bit pricey...

Hence "ring of fire"

Here's the part slist:

  • Atmel AVR ATTiny861 (8K Flash, 512 bytes EEPROM, 512 bytes (!) SRAM, 16 I/O pins, 20 MHz)
  • 20 LTL911VESKA LED (LITEON)
  • 20 2n3904 transtors
  • 20 43 ohm resistors
  • 20 10K resistors
  • 20 100K resistors
  • 1 100uF capacitor
  • 1 waterproof box

I chose the 861 mostly because it had 16 pins, and at $3, what's not to like?

The LEDs are designed for sign and signal applications. They run at 70mA rather than the 20mA most LEDs use, and they have a wide viewing angle (ie the light is spread out rather than going straight ahead). The 43 ohm resistors will go in series with the leds to get that 70mA at 2V on the LEDs from the 5V power supply.

The transistors and 10K/100K will be used to switch the LEDs off and on. The AVR can sink 20mA of current, which is a fair amount, but not enough for the LEDs, and even at 20mA it couldn't drive them all at once.

I think I have a 5V power supply that will work. The LEDs pull 2.24 watts when they are all on, but unfortunately at 5V the 42 ohm resistors will pull 3.36 watts, which puts me up near 6 watts.  If I drop down to 3.3V, 20 ohm resistors would give me 65 mA, and that would mean 2.08 watts for the LEDs but only 1.35 watts for the resistors, so I could get by with a 4 watt supply.

The AVR will run on anything from 1.8V to 5.5 V, though it won't be quite as fast at the lower voltages.

Software is in two stages.

The first stage will be a simple table-based animation system. I've built it a few times before, and last night I built a simple simulator in winforms. That will get it up and running.

The second stage will be to add dimming to all the LEDs. That requires doing PWM on every channel, and I'm not sure that there is enough horsepower to do that in the AVR.

To do flicker-free dimming will require an update frequency of around 100Hz - the dimmest setting would have a brief spike of "on" every 10 mS. That period would need to be divided by the number of light levels - to do 256 would mean that the code would have to update the output state about every 40 microseconds. That's roughly every 750 clock cycles at 20MHz, which seems possible but difficult.

On the other hand, 64 levels would increase that to 3000 clocks, and 16 levels to 12000 clocks, so it looks like some sort of dimming is doable. It helps that the table-driven code doesn't use a lot of resources.

All my previous projects have been written in assembler, but I've decided to use CodeVisionAVR as the development environment, which gets me a C compiler and IDE.

I'll post other updates as things progress...