Drivings LED with limited pins

Mar 10, 2014 61 Replies

The OP has 17 I/Os available and needs 2 for an 8 bit shift register's serial data and data clock inputs. Using a single 8 bit register with bus driver outputs will allow him to source/sink 8 LEDs, which leaves him with 15 I/Os on the SoC for the rest of the LEDs. 8 LEDs fed from the shift register, plus 15 from the SoC is 23, so the simplest solution for a quasi-static display which can address any or all LEDs in the array would seem to be something like an HC575 (less than 60 cents in onesies from Digi-Key) plus the current limiting resistors.

--- Since the OP has 17 I/Os available and needs two for the shift register's serial data and data clock inputs, he'll have 15 left over which he can use to drive the LEDs directly.

Those 15, configured as outputs and added to the shift register's 8 outputs is 23 which - with the current-limiting resistors - comes out to exactly what the OP says he needs.

The _single_ shift register needed, BTW, should be an HC374 in order to eliminate the latch clock, which the 595 needs, and supply the serial bus-driver rated outputs which the 595 lacks.

Charlieplexing:

formatting link

-Harold Hills

A simple solution might be three 74LS138 chips. No multiplexing needed.

What you haven't touched on is that for apparently equal brightness, the current through any LED in the array must be at least 23 times that for an identical LED run static. For a 20mA LED, then, that comes to some 460mA at about a 5% duty cycle; a no-no, I believe. Also, assuming a 5V supply, 2V LEDs, and two 0.3V Vce(sat) drops for the row and column drivers leaves 2.4V to be dropped across the current limiting resistor with 460mA through it. That's about 5.2 ohms which, with 460mA through it equals about 1.1 watts. But, since a single resistor can only carry current for 5/23rds of the time, the maximum dissipation falls to 240 milliwatts. Not too shabby, but I think that 23-fold increase in the current through the LED is going to hurt. John Fields

drive one out of eight a time. 74x259 instead of 74x138 would work.

Dipl.-Inform(FH) Peter Heitzer, peter.heitzer@rz.uni-regensburg.de HTML mails will be forwarded to /dev/null.

I was assuming that the OP only needed to light one at a time. I very well could be wrong...

On a sunny day (11 Mar 2014 14:09:00 GMT) it happened "Peter Heitzer" wrote in :

How about 15 pins for LEDs, and one I2C PCF8574 I/O expander on pin 16 and 17 driving 8 more LEDs, makes 23. If you are lucky you already have I2C somehere, and then have 2 pins free for other things. One chip.

Den tirsdag den 11. marts 2014 16.12.05 UTC+1 skrev Jan Panteltje:

esign challenge is that I only have about 17 pins

al interface (spi/i2c) and then send over data to toggle

on a second microcontroller.

d 17 driving 8 more LEDs, makes 23.

for other things.

two resistors, three pins and two of these:

formatting link

4286441

-Lasse

On a sunny day (Tue, 11 Mar 2014 09:45:28 -0700 (PDT)) it happened Lasse Langwadt Christensen wrote in :

Yes that is nice, and cheap too :-)

These are the same idea (LED drivers with built-in shift registers), but alive and well. People have reported driving 1000 LEDs from 3 pins with a fast uC. I have some, but haven't had a chance to use them yet:

The Magic of NeoPixels

formatting link

$8 - Breadboard-friendly RGB Smart NeoPixel - Pack of 4

formatting link

$17 - Adafruit NeoPixel Digital RGB LED Weatherproof Strip 30 LED -1m - WHITE

formatting link

Enjoy...

Frank McKenney

It is an interesting thing that the highways through the West seem to always miss the most delightful places, and those most worth seeing. One can travel through Arizona or Nevada on the highways and never realize that there are such places as the White Mountain country of Arizona or many of the finest sights in Nevada. The same is true of half a dozen other western states. Highways are built where it is easiest, and such routes do not take one into the forests and canyons except where they cannot be avoided, -- Louis L'Amour / The Sackett Companion

design challenge is that I only have about 17 pins available on my SoC.

tal interface (spi/i2c) and then send over data to toggle the appropriate p ins?

t on a second microcontroller.

t any one time (a opposed to toggling any one of 23) but it would only use

10 lines for a 5x5 matrix. You'd connect the anode pins of groups of five L EDs together to a common current-limiting resistor, and connect each of the five resistors back to five PNP open collectors, any one of which (but onl y one) could be turned on to connect to - say - +5V.

five different anode groups) would be connected together to one of five com mon NPN collectors, any one of which (but only one) could be turned on to c onnect to the

0V rail.

True. But obvious, but I was talking about using the multiplexed approach t o turn on one LED out of the 23, rather than potentially turning on all 23 in sequence.

Only if you want to run the 20mA LED at it's maximum brightness. In many ca ses a LED can be an adequate indicator at 5% of maximum brightness, and - a t least for some LEDs - the limit on pulsed peak current can be higher than the limit on the sustained current. I once used a LED as a stroboscope, at it's pulsed current limit of 80mA. It wasn't very bright, but it was brigh t enough.

The 460mA assumes that you need the maximum permissible current through the LED to make it visible. The eye's response is logarithmic, not linear and

2ma is often all you need, particularly with "high brightness" LED's.
Bill Sloman, Sydney

All,

Thank you so much for the awesome posts. Lots of good information and ideas.

I have been working on my schematic late last night and the update is that for the 23 LEDs I have exactly 2 free pins available to drives these. Turns out the I2C peripheral is on these pins (SDA / SCL).

Follow up questions:

1.) I2C Port expander

Looking at this part:

formatting link

I can sink 25 mA and also have enough pins to cover the 23 LEDs.

Looking at the datasheet it is not clear to me if the 25 mA sink is per pin or total sink current for all the pins together.

What are you thoughts on this? Any issues that you can think of?

2.) Power Supply issue.

I am powering my device with a CR2045 coin cell battery that will provide a voltage of 3.0V - 2.0V. I have added an LDO regulator to give me a fixed 2.1V. I did this because I am using the ADC on a microcontroller and wanted a fixed reference.

The I2C port expander operates in the range of 1.65 V - 5.5 V.

Should I give the I2c port expander the direct battery voltage or the regulated voltage?

To turn the LEDs off I should enable the i/o pin to be high impedance. Then when I put this low I should be able to sink 25 mA per pin. Right?

Thanks for you comments.

-Mike

On a sunny day (Tue, 11 Mar 2014 12:51:59 -0500) it happened Frnak McKenney wrote in :

I like this one, as i tcan (the ysay?) be driven by Raspberry"

formatting link

Still a bit expensive to hang 32 strips on the wall as wallpaper...

It is per output, but there is a limitation of 200mA total through ground. That's absolute maximum, so it would be a good idea not to get too close to that. If you went with 100mA you'd have 4mA per LED, which more than enough for a decent LED.

Button cells, as well as having limited capacity, also have pretty high internal impedance. AA cells might be a better choice.

Yes, of course, but regardless of what you do using TDM, you'll never get away from the need to increase the current through the driven LED over its static value in order to elicit that static brightness dynamically.

he design challenge is that I only have about 17 pins available on my SoC.

igital interface (spi/i2c) and then send over data to toggle the appropriat e pins?

ment on a second microcontroller.

n at any one time (a opposed to toggling any one of 23) but it would only u se 10 lines for a 5x5 matrix. You'd connect the anode pins of groups of fiv e LEDs together to a common current-limiting resistor, and connect each of the five resistors back to five PNP open collectors, any one of which (but only one) could be turned on to connect to - say - +5V.

he five different anode groups) would be connected together to one of five common NPN collectors, any one of which (but only one) could be turned on t o connect to the 0V rail.

turn on one LED out of the 23, rather than potentially turning on all 23 i n sequence.

If you could get away with only turning on one LED at time, it wouldn't be a problem.

You should have realised that I was mainly objecting to John Larkin's "14 p ins" for the multiplexed approach.

cases a LED can be an adequate indicator at 5% of maximum brightness, and

- at least for some LEDs - the limit on pulsed peak current can be higher t han the limit on the sustained current. I once used a LED as a stroboscope, at it's pulsed current limit of 80mA. It wasn't very bright, but it was br ight enough.

But it may not.

the LED to make it visible.

I don't know what misapprehension you thought that were correcting there, b ut you do seem to have missed the point that the 20ma is the maximum sustai ned current that you can put through the LED rather than any kind of recomm ended operating current. Many LEDs are a bit too bright when run at their m aximum sustained current

Don't be silly. What I said is inarguably correct, and entirely relevant. t he only weaseling going on here is your mindless enthusiasm for discovering stuff to carp about.

Since you haven't made any kind of argument in the first place, this may ev en be true.

Don't be any stupider than you have to be.

Twaddle. The eye integrates the photons hitting it. The integration period

- search on "flicker fusion frequency" - can be anything from 200msec in di m light to about 15msec in bright light. There are only three different lig ht-absorbing pigments in the eye, so it's all rather simpler than you seem to think.

I don't need to prove you wrong - you do it yourself far too often to make it necessary for me to produce a formal proof of error. You might educate y ourself by reading this link.

formatting link

Bill Sloman, Sydney

Clue: using N pins, one has available 2^N states. So all you need to use is 5 pins to control those 23 devices, leaving

9 unused states. I leave it to the student to fill in the details.

sign challenge is that I only have about 17 pins available on my SoC.

l interface (spi/i2c) and then send over data to toggle the appropriate pin s?

on a second microcontroller.

You need 5 pins to be able to select any one of these devices. Selection - on its own - isn't quite what the OP is asking for. He wants to "toggle" th e LEDs.

Admittedly, just selecting any one LED could serve to "toggle" it between " on" and "off" but since you don't know how they started up (or got reprogra mmed by a recent lightning strike) this isn't all that useful. Using one of the nine spare states as global reset - to turn them all off - would get a round that problem. Adding a sixth pin - so you could set the selected LED explicitly "on" or "off" - would make life easier.

Which usually means that the instructor hasn't thought about the details.

Bill Sloman, Sydney

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required