Page 1 of 18

"Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 4:59 am
by ian
Here's a challenge for you hacks.........
I need a battery operated very efficient(bordering on perfect) circuit for diving a LED but it has to be safe. Right now I'm using a PIC to control the a DC to DC converter voltage to a LED, but the LED "on" state is still controlled by a 2n3904 transistor. I intend to use a large enough resistor into the base of the transistor so that the current through the LED can only be a maximum of 30mA, then control the LED with PWM.
The transistor only creates a voltage drop of .1V allowing the DC to DC controller to be efficient. I need an average of 20mA through the LED but if the micro goes haywire I can't have the LED burning out so I need a max 30mA through the LED in a worst case scenario.
My concern is that the hfe of a 2n3904 transistor may vary so much that a design resistor producing a nominal 30mA may yield less than 20mA or more than 40mA depending on the hfe variance. Is that true? Are there transistors with "set" hfe's? Is there a better way to limit the current to 30 or so mA without creating a large voltage drop?

"Beauty is transitory" Spock

<small>[ December 02, 2005, 05:04 AM: Message edited by: ian ]</small>

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 5:32 am
by Dean Huster
In other words, what you DON'T want to do is limit the current to 30mA through a series resistor in the LED/transistor series circuit and then control the brightness down from there with PWM. You want the entire circuit to be as lossless as possible. Is that correct?


Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 5:53 am
by ian
Yes. I can't accurately control the current with the DC to DC converter because even small changes in voltage cause wide variances in current but........
First I limit the current to where the LED won't burn out but at a minimum of 20mA using the characteristics of a transistors hfe. Then I reduce the voltage of the DC to DC converter until the current just starts to drop. This creates the maximum voltage differential from the battery for the DC to DC converter. I leave the DC to DC voltage somewhat above the forward voltage drop "knee". Then I read the voltage from a small voltage dropping resistor and try to PWM the LED to approximate 20mA. So if I use a 5 ohm resistor to ground and I read .15V I know i've got 30mA, so I PWM it for 2/3 duty cycle approximating 20mA with almost no losses.
If I read less than .05V I know the DC to DC voltage has dropped below the "knee".
But again, my problem is if the hfe varies widely I may not get enough current to get the 20mA minimum, or I may get a damaging current if the hfe is larger than expected in a worst case scenario.

<small>[ December 02, 2005, 05:55 AM: Message edited by: ian ]</small>

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 8:21 am
by Chris Smith
Use the laser method, a PIN diode sensing the out put brightness which control the Transistor base. As optical power starts to exceeds the set limit, the feed back from the pin diode drops the power to the LED [or laser] and keeps it constant and secure.

Lasers like LEDS run away at the fist chance, and these circuits are their only protection in the LD arena.

I'll see If I can find my circuit diagram and post it later if you like?

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 11:37 am
by Engineer1138
The probability of a *partial* system failure is so low that I think you need to look at it from a reliability/risk standpoint.

What is the probability that the CPU will fail, but the rest of the circuit will still work?
What is the probability that the transistor will fail, but the CPU & LED still function?

If it really is so important that the LED stay on if the CPU fails, then create a missing-pulse detector circuit. Put a current limiting resistor in the power supply to the LED with a transistor that is always on (use a FET to avoid having a base current) across the resistor to shunt current around it. Your missing pulse detector will turn the transistor OFF if the CPU/PWM transistor dies and that will keep the LED on, but with its current limited by the resistor.

Curious: what is the application?

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 11:45 am
by Engineer1138
I read your post again and I'm wondering if I understood the problem.

You're trying to use PWM to both keep current around 20mA and the voltage just above the knee. Why? If you need 20mA, just shut the transistor drive off when the feedback resistor tells you it's at the setpoint. There shouldn't be that much inductance in the circuit to cause a noticeable phase difference between the current and the voltage at the LED?

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 3:05 pm
by ian
I thought it was clear. I'll try again........
I'm trying to get as near the "perfect" LED drive circuit as I can from a battery. Is that soooooo strange a thing to try to accomplish????
Understand the following............
1) If I use a resistor or any device that creates a large voltage drop I'm wasting power.
2) If the microprocessor is capable of raising the voltage and/or the current to the LED beyond its failure level, a glitch could burn out all my LEDS.
3) If I "just use a transistor" it will create a large power-wasting voltage drop. See 1.

I almost have the perfect circuit........
Right now as described I'm driving the LED from the positive side by a DC to DC converter. It converts the 6V at around 13mA to 3.1V at 20mA.
The voltage is programmable by the micro to just top the "knee" of the LED. That way, I get as little loss as possible by using the DC to DC converter voltage differential from battery to LED.
But as you know, I need to limit the current.
I do that by driving the transistor with a calculated base current to allow 30mA. That way, if the microprocessor works incorrectly, the maximum current is 30mA regardless of voltage to the LED.
Then I PWM the LED to approximate 20mA.

There are 3 problems with this design........
1) LED forward voltage drops can vary with colour and LED. I've solved this by using a programmable DC to DC converter. I just match the voltage to the LED. I do this by taking an analog reading from the 5 ohm resistor to GND.
If the voltage is too low I know the led needs a higher drive voltage. If the voltage "plateaus" I know the transistor is preventing further current gain by the limited base current and hfe.

2) There's no way to know what the exact hfe of the transistor will be. I've solved this by reading the voltage from the 5 ohm resistor once the LED drive voltage is high enough for current to plateau/flow. If that voltage is, as above, a variant of 20mA I PWM the circuit to imitate 20mA with very little loss.
3) My last problem is if the hfe cannot vary more than 33% a calculated resistor drop to the transistor base to produce 30mA could produce 20 to 40mA which I could PWM to imitate 20MA but if the variance of hfe is greater than 33% I could get less that the minimum 20mA, to more than the maximum 40mA. Underdriving the LED or burning it out. Hence my question about transistor hfe variances.

This is the most efficient and cost effective design I can think of, it's very inexpensive, it compensates for various LED voltages, it compensates for battery voltages, it compensates for various transistor hfe AND it can drive the LED at a consistent averaged 20mA throughout the life of the battery. I think its a good circuit except for problem #3.
Anybody got a better idea? Anybody know about transistor specs? Would a 2n3904 hfe vary mor than 33%?

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 3:31 pm
by jollyrgr
I cannot find the original article I was hoping to post on this subject. It was in a "WHITE LED CANDLEPOWER FORUM" page somewhere. The discussion was based on the fact that not all white LEDs will draw the same current driven from a given voltage; nominally 3.4 volts. The current would vary thus causing color to vary. I did find a similar article for an LED driver using a current regulator. See this: ... umber/3256

You can go with a simple voltage regulator to make a constant current regulator. No, I did not mistype that. You can use a regulator such as the LM317 (a voltage regulator) to form a constant current source. See this article:

You can use a couple transistors and design a CONSTANT CURRENT SOURCE. (Talk about simple!) See this article (again, this deals with LEDs). ... rent%20sou rce%20IC'

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 3:45 pm
by jimandy
...or use a "constant current" (current limiting) diode.

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 4:10 pm
by ian
Man, you guys are missing the point big time. I just can't make it any clearer. Current limiters will create a large power wasting voltage drop. There, that's the third time i've said that.

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 4:52 pm
by jimandy
You're right, I'm not seeing the point. What's wrong with creating
"a large power wasting voltage drop"
Some power is almost always wasted in a useful circuit.
I'm trying to understand the project. Honest.

(added) Oops, I just noticed you said battery powered. Maybe that's the reason for not wasting power. Right?

<small>[ December 02, 2005, 04:54 PM: Message edited by: jimandy ]</small>

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 7:54 pm
by Chris Smith
So use the pin diode as your feed back source, to control what ever device you are using to limit the current.

If you controlling current through pulsing or timing, the pulse width or rate can be altered using the PIN diode.

If your altering a PIC values to control your current, a PIN diode as feed back can control that too.

So what ever method you deem fit to limit your current loss, while maintaining your current draw, Incorporate a feed back loop via a PIN diode.

It regulates the feed back via a constant Brightness or out put rather than diode draw.

A trimmer pot can be incorporated for different replacement LED values from the start up point, and left at that setting for each individual led.

That’s how they control $5 to $5000 Laser diodes and High power LEDs of any wattage.

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 9:12 pm
by Robert Reed
Am I missing something here? For years Ive designed RF and MW attenuators using PIN diodes (which are a special and very lossy diode). These have no connection or properties to optoelectronics.

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 10:36 pm
by Engineer1138
ian: I guess I still feel like I'm missing something.

If you are doing current-feedback control with the resistor in the emitter leg, then why do you need the DC-DC converter? As long as you don't exceed the LED's max current (should be well in excess of 30mA for short pulses), it will be fine. Adding a DC-DC converter is actually increasing power consumption by the (in)efficiency of the converter.

Now as for your concern about a "glitch" burning up the LED, is it a laser diode? Those are the only ones I can think of that runaway quickly. Most "regular" LEDs will take an amp or so for a short time as long as the junction doesn't overheat.

The hfe on transistors these days is pretty close to the nominal value, but don't forget that it varies with temperature.

But the bottom line from what you've said so far is you want a good, efficient LED drive circuit. Simple answer: buy one. Check out Melexis for LED drive chips.

Re: "Perfect" LED current limiting challenge

Posted: Fri Dec 02, 2005 11:31 pm
by L. Daniel Rosa
Ian. You're making a smart torch or something like that aren't you? Is the failure mode that concerns you runaway code?

Have you considered using the PIC to directly control the DC-DC conversion? More specifically as a switching current regulator? This will free up some of the power budget and real estate for a low power opamp to monitor the sense resistor and kill base drive.

As for overdriving an LED. The only "static sensitive" electronics that I've damaged with sloppy handling (that I'm aware of) are white LEDs. I don't know about the other colors, but I'm inclined to believe that all GaN LEDs are similarly unforgiving as they are a lateral film (not a die) that is electrically (and possibly somewhat thermally) insulated from the leadframe where it is mounted.