Methods for controlling LEDs

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi All -

I'm looking at a project that will require control over at least 15 bi-color LEDs, common anode type probably. For flexibility, they will be treated as two sets of 15 LEDs, all individually controlled. Need pwm control of brightness as well.

Size and parts cost are an issue, need to keep it small and cheap. Hrm - when is this ever NOT a requirement ? I can think of a few ways of doing this ...

1) Simple. An ATTiny2313 or similar, a couple of transistors/fets to act as switches and a couple of resistor packs. Two pins to switch Vcc via the fets to the common anodes, one for each set. 15 pins for the cathodes, via the resistor packs. Code is simple and straightforward.

2) Charlieplexing - basic. Need an AVR with 6 pins and 6 resistors. Basic charlieplexing isn't too tough, though the brightness pwm control complicates things a little. Might be able to do away with the resistors and rely on the AVR pin source limits, so it would just be the AVR and LEDs. Would this work ?

3) Charlieplexing - full Vcc. Need an AVR with 6 pins, 6 PNP and 6 NPN transistors and base resistors for them all. This would allow for full-on voltage/current through the LEDs to get best brightness. Nice if I can find NPN/PNP pairs in a single package along with appropriate resistor packs (or single resistors).

I like (2) best I think, if it will work. (3) would give best/brightest control over the LEDs, but has a lot of extra small parts. Not expensive, but fiddly.

Any ideas ?

Dean 94TT
"Life is just one damn thing after another" Elbert Hubbard (1856 - 1915)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chancy99 wrote:
Might be able to do away with the resistors and rely on the AVR pin source limits, so it would just be the AVR and LEDs. Would this work ?

What limits? the AVR will attempt to source as much current as it can, right to the point of self destruction. The stated limits are how much you can draw without damaging the part. So unless you can keep the current low enough, an the duty short enough not to damage anything... use a resistor on each I/O. This method will give you near full VCC swing (depending on how much current you draw), so you don't need external transistors. Only if they are high current LED's, should you need external drive transistors.

Note that both the LED, and AVR can handle much higher currents than the stated limits, for short periods of time.

As a starting point start with series resistors that are set so that the continuous current is the limit for the LED (note that each resistor will be 1/2 the desired value, as there will always be 2 in play at any moment, giving you the desired total). As you start to multiplex, you sill want to decrease this resistance in order to maintain the desired brightness. (you can calculate it as well, if you have the datasheet for your LED, there will be a table that shows the input current allowed vs pulse width and duty cycle)

Writing code is like having sex.... make one little mistake, and you're supporting it for life.