Description

After working on the Matrix Medallion, I ran across a couple of articles on "Charlieplexing", it looked interesting, so I wanted to give it a try.

One project in the back of my mind was trying to capture the essence of a jar of fire flies. I'd seen several projects around the internet that were built on LARGE jars, I wanted to represent it in miniature, almost like a 'ship in a bottle'. The stumbling block had always been trying to fit the number of wires required to do traditional multiplexing into a small jar. I figured 3 or 4 wires was about all I could hope to reasonably work with in such a confined space. That's when I stumbled across Charlieplexing.

I was wanting to drive 6 or 7 small 0603 size LED "fire flies". Traditional multiplexing would require at least 5 wires, (2 rows & 3 columns) However, Charlieplexing uses tri-state logic so 3 wires can drive 6 LED's. Note that this does not come for free. With Charlieplexing, you can only drive a single LED at a time and the control logic is a bit more complicated because you have to control 3 states of each output pin, hi, low, and High-Z.

This is what the total circuit looks like. In order to control the LED's you need to follow a state table similar to this:

A0A1A2LED
LHZ#1
HLZ#2
ZLH#3
ZHL#4
HZL#5
LZH#6

There are serious limitations to what you can do with Charlieplexing. For example, you can only switch on 1 LED at a time (where as with traditional multiplexing a whole row is switched on at once), this means you need a higher refresh rate and the effective brightness may be reduced due to the reduced duty-cycle for each LED. In a normal 3x2 multiplex matrix, each LED is on 1/2 the display cycle time (50% each row). However with Charlieplexing, those same LED's are only on for 1/6 the display cycle time.

You will also find that the wiring and software driver complexity increases greatly as each LED is added to the Charlieplexed matrix. In addition you'll run into issues if all your LED's do not have the same forward voltage as certain states may then turn on unwanted LED's. However, I found Charlieplexing to be quite useful in this specific case. It's definitely something useful to keep in your bag of tricks.


Usage

Assembly

There isn't much assembly wise, just the ATTINY26L, 6 SMD LED's, one capacitor, 3 wires and the CR2032 battery holder, that's it! No circuit board, just solder everything together and mount it inside an appropriate container. However, I've got a few tricks to make things easier.

Here's the bottle I used. Start by drawing on a piece of paper, a rectangle about the size of the inside of your bottle. Use pencil so you can erase it later. This sketch will help you layout your 6 LED's. The rectangle should be just about the width of the mouth of the bottle. The length should match the length of your bottle.
Here's the little 0603 SMD LED's I used as Fire Flies, they're the same used in the Matrix Medallion) and they have a little green arrow on the underside. When you lay out the LED's for soldering, you'll be lining up with those green arrows.
Draw yourself a little outline for how you want your LED's laid out. It's not important which is anode or cathode, just that you have the LED's laid out in pairs. When you lay out the LED's for soldering, line up those green arrows with the arrows on your sketch. Note that You'll have 2 longer wires on the outside edges and 1 shorter wire toward the inside.
Now, over your sketch, Mark where you want your LED's to be placed and where the wires should go. To create a more life like display, don't just place the LED's right over the rectangle, move'em around a bit as in this picture. If you want, erase the rectangle so it's a little clearer where the LEDs and wires should go. Once you've got the layout done, cover the sketch with double-sided sticky tape.
Use tweezers and stick the LED's on top of your sketch (solder side up), use your arrow drawing to properly align the LED's. You want to make sure you have opposite pairs of LED's on each pair of wires. Important! that double-sided sticky tape will be your third hand when attaching the wires, so make sure the LED's are firmly stuck. Press'em down a bit if you need to.
You'll need some really fine wire for connecting your LED's. I just stripped some multistrand wire and pulled out the individual strands.
Take the first strand of wire, press it down onto the sticky tape over the first LED. Spot solder the wire to one tab of the LED.
Continue with the same process, bend the wire toward the next LED, spot solder, and continue...
Work this way until you have all 3 wires soldered to the 6 LED's.
Once the LED wiring is complete, carefully remove the wire/LED assembly from the sticky tape. Visually inspect your solder connections, you will probably have to redo one or two after you pull the assembly from the tape. Use a multimeter to verify all your connections.
Carefully insert your wire/LED assembly into the bottle. You may need to bend some of the wire to fit within the bottle, that's ok, just make sure you don't short out any wires.
On what will be the back side of the bottle, carefully arrange the 3 wires as they exit the bottle. Keep them aligned but away from each other. Use a bottle stopper or a bit of hot-melt glue to keep the wires in place and away from each other.
Solder the capacitor to the back of the battery clip, then solder the CPU to the capacitor. The CPU doesn't need to be glued in, the soldered connections are sufficient to hold everything in place.
Finally carefully solder the 3 wires from the bottle to A0/A1/A2 on the ATTiny26L. Orient the wires so that when you mount battery/cpu assembly on the bottle that you do not short out any of the wiring.
Use a piece of double sided tape to attach the battery/cpu to the bottle. For the prototype, I placed the battery/cpu on the back of the bottle, but for better stability, future versions will probably have the battery/cpu mounted on the bottom of the bottle.
Programming

I use a USBTinyISP from LadyAda.net. It works just fine, however you need an adapter to program the SOIC ATTiny26L out of socket. You can see what I used here.

All source code is written for WinAVR C compiler. It's a simple infinite loop that bit-bangs a PWM output to each of the 6 LED's. Cycle times are random. Each time you re-apply power, new random patters are chosen, so if you don't like the resulting pattern, try power cycling again!


Download

The simple circuit diagram is shown at the top of the page. There's not much to it!

FireFly source code.

If you want to try your hand at the FireFly bottle, I do have some of the LED's and bottles left. I can also supply a pre-programmed SOIC ATTiny26L, just drop me a note at