Powered by Invision Power Board


Forum Rules Forum Rules (Please read before posting)
  Reply to this topicStart new topicStart Poll

> Clock Cycle Requirement For Leds, to get close to full brightness
teaman
Posted: October 30, 2011 11:40 am
Reply to this postQuote Post


Member
****

Group: Trusted Members
Posts: 162
Member No.: 6,030
Joined: August 17, 2006




Hi

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?

Any help appreciated, thanks!
PMEmail Poster
Top
millwood
Posted: October 30, 2011 05:36 pm
Reply to this postQuote Post


Forum Addict ++
*******

Group: Trusted Members
Posts: 1,823
Member No.: 25,377
Joined: July 26, 2009




it is not entirely clear what you are trying to do.

if you connect the led(s) to one output pin on the shift register, you will be able to get a duty cycle from 0% - 100% (inclusive if you use hc595, and near that if you use hc164).

and individual pins may have different duty cycles, but all the leds connected to the same pin will have the same duty cycle (obviously).
PMEmail Poster
Top
telomere
Posted: October 30, 2011 05:45 pm
Reply to this postQuote Post


Forum Addict ++
*******

Group: Spamminator Taskforce
Posts: 4,300
Member No.: 9,502
Joined: May 18, 2007




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."
PMEmail Poster
Top
tekwiz
Posted: October 30, 2011 09:08 pm
Reply to this postQuote Post


Forum Addict ++
Group Icon

Group: Moderators
Posts: 28,711
Member No.: 5,746
Joined: July 24, 2006




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.

Fortuna favet fortibus.
PMEmail Poster
Top
teaman
Posted: October 31, 2011 02:00 am
Reply to this postQuote Post


Member
****

Group: Trusted Members
Posts: 162
Member No.: 6,030
Joined: August 17, 2006




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.

This video seems to do it: http://www.youtube.com/watch?v=WlfD1bFekmI
PMEmail Poster
Top
millwood
Posted: October 31, 2011 02:17 am
Reply to this postQuote Post


Forum Addict ++
*******

Group: Trusted Members
Posts: 1,823
Member No.: 25,377
Joined: July 26, 2009




the purpose of using a shift register is so that you do NOT turn on 1 led at a time. a shift register allows you to turn on (or off) multiple leds at a time.

PMEmail Poster
Top
draget
Posted: October 31, 2011 04:32 am
Reply to this postQuote Post


Forum Addict ++
*******

Group: Cleanup Taskforce
Posts: 6,101
Member No.: 1,770
Joined: December 31, 2004




QUOTE (millwood @ October 31, 2011 10:17 am)
the purpose of using a shift register is so that you do NOT turn on 1 led at a time. a shift register allows you to turn on (or off) multiple leds at a time.

Push one bit in and just keep clocking it along and loop and you get the desired single LED effect.....
PMEmail PosterUsers Website
Top
teaman
Posted: October 31, 2011 01:39 pm
Reply to this postQuote Post


Member
****

Group: Trusted Members
Posts: 162
Member No.: 6,030
Joined: August 17, 2006




QUOTE (millwood @ October 31, 2011 02:17 am)
the purpose of using a shift register is so that you do NOT turn on 1 led at a time. a shift register allows you to turn on (or off) multiple leds at a time.

I think there is a misunderstanding in my question sorry. The shift register is required so I only need to use a few control pins on the micro controller (instead of 8 inputs).

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?
PMEmail Poster
Top
millwood
Posted: October 31, 2011 01:52 pm
Reply to this postQuote Post


Forum Addict ++
*******

Group: Trusted Members
Posts: 1,823
Member No.: 25,377
Joined: July 26, 2009




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


again, that will depend on what you meant by "control". the cheapest would be to use a transistor and tie the 100 LEDs together. only 1 pin is required.

if you are talking about controlling 100 LEDs independently, that's a separate question.
PMEmail Poster
Top
millwood
Posted: October 31, 2011 02:10 pm
Reply to this postQuote Post


Forum Addict ++
*******

Group: Trusted Members
Posts: 1,823
Member No.: 25,377
Joined: July 26, 2009




assume that you want to control 100 leds independently:

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).
PMEmail Poster
Top
Sch3mat1c
Posted: October 31, 2011 03:07 pm
Reply to this postQuote Post


Forum Addict ++
Group Icon

Group: Moderators
Posts: 19,588
Member No.: 73
Joined: July 24, 2002




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.
PMEmail PosterUsers Website
Top
telomere
Posted: October 31, 2011 04:33 pm
Reply to this postQuote Post


Forum Addict ++
*******

Group: Spamminator Taskforce
Posts: 4,300
Member No.: 9,502
Joined: May 18, 2007




QUOTE (teaman @ October 31, 2011 05:39 am)
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."
PMEmail Poster
Top
teaman
Posted: October 31, 2011 05:15 pm
Reply to this postQuote Post


Member
****

Group: Trusted Members
Posts: 162
Member No.: 6,030
Joined: August 17, 2006




QUOTE (Sch3mat1c @ October 31, 2011 03:07 pm)
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.)
PMEmail Poster
Top
telomere
Posted: October 31, 2011 07:30 pm
Reply to this postQuote Post


Forum Addict ++
*******

Group: Spamminator Taskforce
Posts: 4,300
Member No.: 9,502
Joined: May 18, 2007




QUOTE (teaman @ October 31, 2011 09:15 am)
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."
PMEmail Poster
Top
tekwiz
Posted: October 31, 2011 09:13 pm
Reply to this postQuote Post


Forum Addict ++
Group Icon

Group: Moderators
Posts: 28,711
Member No.: 5,746
Joined: July 24, 2006




QUOTE (telomere @ October 31, 2011 10:30 am)
QUOTE (teaman @ October 31, 2011 09:15 am)
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.

Fortuna favet fortibus.
PMEmail Poster
Top
teaman
Posted: November 09, 2011 08:19 am
Reply to this postQuote Post


Member
****

Group: Trusted Members
Posts: 162
Member No.: 6,030
Joined: August 17, 2006




Thank you guys, this answered all my questions! And has pushed me in the right direction. biggrin.gif
PMEmail Poster
Top
Gorgon
Posted: November 09, 2011 10:09 am
Reply to this postQuote Post


Forum Addict ++
*******

Group: Trusted Members
Posts: 3,009
Member No.: 3,861
Joined: December 18, 2005




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 laugh.gif


TOK wink.gif


--------------------
Light travels faster than sound. That's why some people appear bright until they speak!
PMEmail Poster
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 


:: support us ::




ElectronicsSkin by DutchDork & The-Force