I need to use a shift register to light 8 LEDs simultanously. The register is CMOS so it can only power one LED at a time safely (total current sink around 20mA). I need multiple LEDs to be on at the same time.

My solution is to use PWM with a 5V microcontroller. The LEDs have a forward voltage drop of 3.6V and a 20mA current requirement.

I connect each LED to an output pin of the shift register.

Since I have 8 LEDs to pulsate individually, the maximum duty cycle per LED is 12.5% (100%/8, because only one LED can be on at a time).

So my question is, is there anything I can do to get full brightness from all the LEDs? For example, if I set the clock cycle of the PWM is fast enough? Or if I boost the voltage from the PWM output?

Can you change parts? They make power shift registers which would happily light all of your LEDs at once...

Otherwise, if your shift registers can only supply a total of 20mA spread among all of the pins, you're simply not going to make 8 LEDs with an average of 2.5mA look like they're all getting 20mA.

As to which frequency would be best, anything above the flicker-resolving limits of the human eye. Some folks can see flicker as high as 120 Hz or so, so go 200Hz or higher to be safe. I generally use about 1kHz.

--------------------

"Sometimes I can't tell the difference between thinking and being quiet, but I'll try."

Your best bet might be to simply add a driver transistor after the chip to increase maximum current capability. A single 2N2222 or 2N3904 would have more than enough current handling capability to light all of the LEDs at once. There are hundreds of other transistor types that would work as well, including many MOSFETs or IGBJTs.

--------------------

Trouble rather the tiger in his lair, than the sage among his books.For to you, kings & armies are things mighty & enduring.To him, mere toys of the moment, to be overturned at the flick of a finger.

What I meant in my original post is that my micro controller code will cycle through the LEDs one at a time. For example, if all of the LEDs need to be on, I will turn on 1 led, then turn it off, turn the next one on, turn it off etc for all leds, To take advantage of persistence of vision.

I don't want to use transistors or a special LED power driver because they increase the cost much more (in my design this is the cheapest way). Im just wondering of its possible.

1) use two shift registers: you can matrix the leds and each shift register + 3 pins form 11 columns and another shift register + 3 pins form 11 rows for a total of 121 leds. those shift registers would be daisy-chained so they take 2 pins -> a total of 8 io pins;2) use three shift registers: you can daisy-chain all shift registers together - and split their coverage so you have a (8+4) x (8+4) = 12x12 matrix, controlling up to 144 leds. this requires two io pins (hc164) or three io pins (hc595).

just two examples.

if speed isn't the most concern, you can also use a r/c network to further reduce the number of pins.

edit: in either of those cases, the leds can be pulsed, independently, from 0% duty cycle to 100% duty cycle (near 100% with hc164 and 100% with hc595 but you use three pins).

74HC supply current max is 70mA, so you could run up to 3 LEDs at full power and one at half, or all at just under half current, or if the average number of LEDs lit at any given time is around half, I wouldn't even worry about it.

HC logic is pretty robust stuff and won't burn out very fast if you're just lighting LEDs.

Incidentially, when calculating the LED's series resistor, remember to subtract about 50-100 ohms for the gate's effective output resistance.

As for lighting a total of 100, presumably in arbitrary patterns, you have your choice of serial (chain of shift registers, such as the 74HC595 mentioned above), parallel (since you have 8 I/O lines available, though you still need one for WR, and ideally 4 address lines as well), or some combination (e.g., shared CLK and WR lines, with 6 separate data lines for 6 serial chains; average shift register length 16.7 bits)

If you don't need absolute highest bandwidth or brightness, you can matrix it into, say, 16 x 8, using only 24 bits of registers (shift or otherwise). You then have to increment the column bit so you're only driving one set of LEDs at a time; you also need a transistor driver to supply the columns (since 16 LEDs draw a maximum of 320mA, which no gate will supply by itself).

Tim

--------------------

Answering questions is a tricky subject to practice. Not due to the difficulty of formulating or locating answers, but due to the human inability of asking the right questions; a skill that, were one to possess, would put them in the "answering" category.

Let me rephrase the question - what is the cheapest component cost way to light 100 LEDs, at 5V with a microcontroller that has only 8 I/O pins?

The cheapest way would be to spend $0.75 more and get a micro with more I/O pins, and then charlieplex your LEDs.

It may not be what you want to hear, but it is the cheapest. If you need to be able to pump 20mA into every LED at the same time, then use your existing shift registers, and source some inexpensive pass devices (BJT or MOSFET) for the outputs. ULN2803s would be easy, but you might do it a tiny bit cheaper with a ton of individual transistors & resistors, at the expense of much more design and build time and larger PCB.

Is this a one-off project, or are you planning on kitting this out?

--------------------

"Sometimes I can't tell the difference between thinking and being quiet, but I'll try."

If you don't need absolute highest bandwidth or brightness, you can matrix it into, say, 16 x 8, using only 24 bits of registers (shift or otherwise). You then have to increment the column bit so you're only driving one set of LEDs at a time; you also need a transistor driver to supply the columns (since 16 LEDs draw a maximum of 320mA, which no gate will supply by itself).

This is basically what I want to do. Let's say I have a matrix and I must switch between "lines" of LEDs. This is basically like PWM because an "on" LED actually switches between 0 and 5v rapidly.

Here's my confusion: Let's say I have 2 lines in the matrix. Doesn't this mean the maximum duty cycle is 50%? Which means the simulated analog voltage is 2.5v? What does this do to my LEDs and is there any way to get full brightness?

(This is a project that I am building for my own learning experience.)

Here's my confusion: Let's say I have 2 lines in the matrix. Doesn't this mean the maximum duty cycle is 50%? Which means the simulated analog voltage is 2.5v? What does this do to my LEDs and is there any way to get full brightness?

As you reduce the average current, of course the LEDs look dimmer, and there isn't really anything you about it.

Now, if you are astute, you will notice that while you mentioned "duty cycle", I mentioned "average current". While there are limits, as duty cycle lessens, you can increase peak current so that the average current stays the same.

As a rough example, instead of 20mA at 100% duty cycle, you can do 40mA at 50% duty cycle. Due to non-linearities in LED efficiency and other factors, it may not be precisely equal, but should be close enough for the human eye.

--------------------

"Sometimes I can't tell the difference between thinking and being quiet, but I'll try."

Here's my confusion: Let's say I have 2 lines in the matrix. Doesn't this mean the maximum duty cycle is 50%? Which means the simulated analog voltage is 2.5v? What does this do to my LEDs and is there any way to get full brightness?

As you reduce the average current, of course the LEDs look dimmer, and there isn't really anything you about it.

Now, if you are astute, you will notice that while you mentioned "duty cycle", I mentioned "average current". While there are limits, as duty cycle lessens, you can increase peak current so that the average current stays the same.

As a rough example, instead of 20mA at 100% duty cycle, you can do 40mA at 50% duty cycle. Due to non-linearities in LED efficiency and other factors, it may not be precisely equal, but should be close enough for the human eye.

But note that all LEDs have maximum allowable pulse currents, & most are not all that much more than their steady state current. I haven't seen any where the pulse current is more than 3X the steady state current, & this is for very short pulses.Having a look at a few LED datasheets will tell you more.In any case, you will need driver transistors, at least one for each row & column.This need not add much to the expense, as generic small signal transistors are cheaper than dirt...dozens to hundreds for a penny in large quantities. 2 or 3 cents apiece in hobbiest quantities(50-100pcs).

Because the app is so non critical, suitable transistors can also be salvaged from a wide variety of consumer electronic discards. There are few ordinary transistor types that won't work in this app. A small stereo receiver from the 80's or 90's will have more than enough for your project. All you need is a way to determine polarity, pinout, & the type...BJT, MOSFET, IGBJT, etc. This can be done with an ordinary DMM. In fact, some DMMs have transitor identification functions built in. Many boards also have the pinout marked next to the transistors, which also tells you what type of device it is.

--------------------

Trouble rather the tiger in his lair, than the sage among his books.For to you, kings & armies are things mighty & enduring.To him, mere toys of the moment, to be overturned at the flick of a finger.

If you want to drive a LED from an output supplying around 3-5mA, as most 74HC chips do, use a high intensity LED, and no PWM. There are LEDs with rated current at 2mA, instead of the 'normal' 20mA.

If you need to multiplex a matrix of diodes, it is easier to use a high intensity LED than a normal one. You still have to take care of the max current applied, and think of what happens if the microcontroller stop in an active condition. This happens you know

TOK

--------------------

Light travels faster than sound. That's why some people appear bright until they speak!