Sanity check constant current LED driver - Page 1
Forum section: electronics / projects

author: CountChocula
author_rank: Unknown
timestamp: January 23, 2023, 09:20:02 pm
content: Hey all!I'd like to repurpose a 24VDC 3A switching supply to drive 4 COB LEDs, and so designed a simple current limiting circuit that also supports dimming, attached below. The idea is to use parts on hand (ideally without setting fire to my office), rather than, say, purchasing a commercial constant-current supply, so I made do with what's in my component bins.The LEDs have a Vf of 5V, and are rated for 0.6A / 3W. I haven't built this yet—I was planning on breadboarding it tonight—but would love a sanity check on whether this makes sense or if I'm missing something big. Part of the goal was to try and keep thermal management to a reasonable level to account for the fact that there isn't enough voltage for 5 LEDs, and that the FET has to shed around 3.3V, even with a 1Ω current sense resistor. Thanks in advance for your help!—CC

author: Benta
author_rank: Super Contributor
timestamp: January 23, 2023, 09:38:05 pm
content: Overcomplicated to my mind. This is much simpler:

author: Benta
author_rank: Super Contributor
timestamp: January 23, 2023, 09:43:32 pm
content: PS: ignore the 19 V supply, it'll work fine with 24 V. Q1 can be what you have in your stash, the BD437 was chosen for high hFEto improve LED current precision.TIP31/MJD31 or MJE3055/MJD3033 will work just as well.

author: Jeff1946
author_rank: Regular Contributor
timestamp: January 23, 2023, 10:01:46 pm
content: Just a quick look. The power to the LM358 looks reversed. You might want to put a capacitor across R1 as there is no damping in the circuit. I would be inclined to use a PNP power transistor instead of the low voltage MOSFET as according to the specs gate to source voltage should not exceed 8 volts. Also a 500k? resistor between the pot's wiper and ground so if the wiper doesn't make good contact you won't overdrive the circuit.

author: Zero999
author_rank: Super Contributor
timestamp: January 23, 2023, 10:08:17 pm
content: Putting two op-amps and a common emitter amplifier within the same loop is asking for trouble with oscillation. Use the circuit posted by Benta.

author: Benta
author_rank: Super Contributor
timestamp: January 23, 2023, 11:11:29 pm
content: Actually, I never thought about replacing the NPN with a MOSFET. Might be a cool idea.The nasty factor is the LMV431 maximum voltage, which the MOSFET gate will not limit... I'm putting on my thinking hat right now on how that might work.I'll be back

author: Zero999
author_rank: Super Contributor
timestamp: January 23, 2023, 11:21:31 pm
content: I wouldn't worry. VGSof most MOSFETs when run at under 1A will keep the LMV431 within its supply voltage rating.Since the original poster has more headroom, he could just use the TL431.

author: Benta
author_rank: Super Contributor
timestamp: January 23, 2023, 11:44:25 pm
content: Quote from: Zero999 on January 23, 2023, 11:21:31 pmI was more thinking about unplugging the LEDs (this happens). The bipolar circuit will withstand that.Using the TL431 would increase the power dissipation in the sense resistors, that's just a tradeoff.But the relatively large capacitance in the feedback loop from the MOSFET gate needs some attention.It's not that easy...

author: mariush
author_rank: Super Contributor
timestamp: January 24, 2023, 12:05:54 am
content: You'd probably be able to adjust the feedback on the dc switching power supply to make the psu output around 26-27v ... it would involve changing a resistor value on the voltage reference or some voltage divider) and maybe changing output capacitors from 25v rated to 35v rated (they should be already, 24v is too close to 25v)2-3v above the sum of the led forward voltage should be enough for a led driver to work.For example seehttps://www.digikey.com/en/products/detail/diodes-incorporated/AL8861Y-13/6702376Get a 0.2 ohm resistor to limit current to around 550-600mA, add a generic but quality inductor and a diode and you can use a potentiometer to output 0.3v .. 2.5v on Vset to set brightness between 5% and 100%

author: Benta
author_rank: Super Contributor
timestamp: January 24, 2023, 12:20:00 am
content: Perhaps you should read the OP?Just a suggestion.

author: mariush
author_rank: Super Contributor
timestamp: January 24, 2023, 01:03:12 am
content: I read.... I guess everyone has TL431 references "on hand" , NDP6020 mosfets, and potentiometers and other things. Let's use 10-15 parts when you can use 3-4.By the time you mess with parts and circuits, you place a 5$ order on Digikey or other places and you get them in 1-2 days.

author: CountChocula
author_rank: Unknown
timestamp: January 24, 2023, 01:26:18 am
content: Hi all, thanks for the kind replies.I went ahead and wired up my circuit on a breadboard (it was quick enough, so why not), and it's working fine, though not quite in the way I expected.As you folks pointed out, it does oscillate, but a 10µF cap from pin 1 of the '358 to ground and a 100nF between pins 6 and 7 slows things down enough to make them appear as though they are working fine. In reality, the circuitstilloscillates, but it basically behaves like a PWM controller, as you can see in the attached 'scope captures (the first is taken at the current sense resistor, while the second is on the output of the op amp).This accidentally results in very little power being dissipated in either the FET or power resistor, which are barely even warm (I did verify, incidentally, that 600mA of current is flowing to the LEDs, and they are plenty bright). Turning the pot down changes the oscillation frequency, which almost-works like a dimmer until the very end, when the cycling becomes low enough to be noticeable to the naked eye (this would not be a big deal for my purposes, TBH).I'm not sure if this is good or bad, to be honest… it's almost an unwittingly great result@Benta I would love to try out your suggestion, but I only have regular TL431's on hand, and I don't quite understand how the circuit works. Could you maybe give me a couple pointers? It looks like I could learn from it. Cheers!—CCPS: Thanks @Jeff1946 for pointing out that the LM358's power pins are upside down. It turns out that the symbol has somehow changed in my KiCAD library and it's now oriented in a different way from before, so I keep getting confused by this.

author: CountChocula
author_rank: Unknown
timestamp: January 24, 2023, 01:29:58 am
content: Quote from: mariush on January 24, 2023, 01:03:12 amI hear you, but part of thisisto try something new and learn from it, even if it is not the most efficient approach. If I were just looking for an expedient solution, I would probably go out and buy a constant current supply—they're plenty cheap and designed to commercial standards that give me a little more confidence than my breadboard.Besides, if I had just gone ahead and wired up my circuit without asking for advice, I wouldn't have had an opportunity to learn from you allCheers!

author: CountChocula
author_rank: Unknown
timestamp: January 24, 2023, 03:50:11 am
content: Update: transferred the circuit to a little protoboard… still working fine. These LEDs are crazy bright (and toasty, despite the hefty heatsink). Cheers!

author: Zero999
author_rank: Super Contributor
timestamp: January 24, 2023, 09:01:53 am
content: Quote from: CountChocula on January 24, 2023, 01:26:18 amWhy do you think the oscillation makes any difference to the power dissipated in resistor and FET? Remember P = VI = I2R = V2/R, whatever the frequency.QuoteThe oscillating doesn't really have and advantage. It just causes more electromagnetic emissions. It would be better to use a single op-amp and an N-MOSFET. If you must use a P-MOSFET then change the op-amp to one which will work with its inputs at the positive rail, such as the TL072 or LM301A.QuoteHis circuit will work with the TL431. I could explain how it works in detail, but I suggest you look at the TL431 data sheet to start. Hint: it's an op-amp, voltage reference and transistor in one IC.

author: CountChocula
author_rank: Unknown
timestamp: January 24, 2023, 01:59:00 pm
content: Hi Zero999, thank you for your note.Quote from: Zero999 on January 24, 2023, 09:01:53 amApologies, that was a bad turn of phrase; I didn't mean to imply that the oscillation magically negates Ohm's lawI am, however, puzzled by the thermal characteristics of the circuit; last night, I measured ~6V across the source and drain of the transistor. At a current of 600mA, I would expect it to dissipate ~3.5W, which according to the datasheet should make it really toasty, but it's barely warm at all, so I (very clearly) don't quite understand what's happening yet.QuoteI see—is that because that would make it possible for the op-amp to completely shut off the transistor? Sorry if this is a stupid question, I'm quite new to this.QuoteAh, I see—so it's not being used as a voltage reference. I will look into it and try to work it out this evening… for now, day job calls. Thanks again for all the pointers. Cheers!—CC

author: CountChocula
author_rank: Unknown
timestamp: January 24, 2023, 08:10:53 pm
content: QuoteThinking more about this, my statement makes no sense, since you were talking about the input, and not the output. I guess I see what's happening here now. Thanks!QuoteI've beenobsessingthinking about this and my understanding is that the TLV431 regulates the base of Q1 so that the voltage on the high side of the sense resistive network equals the TLV431's Vref of 1.24V. Since R3-R6 have an equivalent resistance of ~1.79Ω, a voltage drop of 1.24V across them is equivalent to ~700mA running through the circuit (this is equivalent, in fact, to one of the examples shown in the 431's datasheet now that I have looked at it). If so, I suppose I could change the sense resistors to work with a TL431, which has a Vref of 2.5V and is the equivalent component in my possession. Is this correct? Cheers!—CC

author: Benta
author_rank: Super Contributor
timestamp: January 24, 2023, 08:42:55 pm
content: Quote from: CountChocula on January 24, 2023, 08:10:53 pmCorrect, I mentioned this in my reply #7. You have plenty of voltage headroom (my original design was targeted at getting as many LEDs as possible to run at a given voltage, so it's at the limit).Basically, you'll be transferring power dissipation from the pass transistor to the sense resistors, so be certain to calculate the power loss in those.The voltage across the sense resistors is equal to the Q1 collector current + the Q1 base current, which is the reason for selecting a high hFEtype transistor, and also why the sense resistor value is a bit lower than what the LED current would warrant.

author: Zero999
author_rank: Super Contributor
timestamp: January 24, 2023, 09:15:06 pm
content: The TL431 and a Darlington such as the TIP121, or the PN2222A and a power transistor such as the TIP31 will work well in Benta's circuit.

author: Benta
author_rank: Super Contributor
timestamp: January 24, 2023, 09:20:44 pm
content: Quote from: Zero999 on January 24, 2023, 09:15:06 pmNo, please don't do that.Darlingtons are particularly prone to oscillation in this circuit. Been there, done that. Just live with the higher base current.

author: Zero999
author_rank: Super Contributor
timestamp: January 24, 2023, 09:37:35 pm
content: Quote from: Benta on January 24, 2023, 09:20:44 pmI admit, i haven't tried that, but would have thought it would have been better than a MOSFET or the circuit attached to the original post.

author: Benta
author_rank: Super Contributor
timestamp: January 24, 2023, 10:08:54 pm
content: Quote from: Zero999 on January 24, 2023, 09:37:35 pmThat's OK, I'm still playing around with the MOSFET idea, but no conclusion yet.The problem using a Darlington is that it's almost impossible to stifle the oscillation due to the high gain.It can be done by using a high-value base resistor, but that has the downside that the cathode voltage of the TL/TLV431 is no longer limited.You can of course throw an additional Zener or a couple of resistors at the circuit to solve that, but then the inherent simplicity starts to go away.Anyway, how precise does LED current need to be? An hFEof 30 will give around 3% error. So what, with 5% sense resistors and LED binning all over the place?There are a lot of pitfalls here, and I've been down most of them

author: Zero999
author_rank: Super Contributor
timestamp: January 24, 2023, 11:18:41 pm
content: Quote from: Benta on January 24, 2023, 10:08:54 pmWhat do you mean by high gain?A Darlington pair has a lower voltage gain than a single transistor, but a massively higher current gain. In both cases, an emitter follower has a slight voltage loss, not gain.

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 24, 2023, 11:29:00 pm
content: Original schematic: why not use a NMOS, in a current sink topology (rather than a PMOS in a current source topology) and get rid of the NPN transistor? This is a very common approach that works well. (You can add a cap in the feedback loop to avoid possible oscillations, but often just using a relatively slow opamp is enough to get something stable.)Sure otherwise you can use a single bipolar transitor as shown above, but the current sink topology with an opamp and a NMOS works plenty fine in most cases and just takes minimal care with the feedback loop to ensure it won't oscillate.

author: Benta
author_rank: Super Contributor
timestamp: January 24, 2023, 11:33:14 pm
content: Quote from: Zero999 on January 24, 2023, 11:18:41 pmI think you're going off on a tangent here that's not helpful to the OP. Again: been there, done that (hint: the sense resistors translate to voltage gain. Also, I never said the voltage gain was the problem with the Darlingtons).

author: CountChocula
author_rank: Unknown
timestamp: January 25, 2023, 01:22:27 pm
content: Quote from: Benta on January 24, 2023, 11:33:14 pmPlease do go on all the tangents you like. I'm learning lots and really appreciate all the discussion

author: CountChocula
author_rank: Unknown
timestamp: January 25, 2023, 01:26:46 pm
content: Quote from: SiliconWizard on January 24, 2023, 11:29:00 pmThank you! I think I'm going to try a bunch of different circuits, including moving to a NMOS sink topology like you suggest. The reason I didn't go for it the first time around was that I didn't want the circuit to be energized when the lights are supposed to be off, so high-side regulation seemed better, but I guess that's not a huge deal in this case.This started as a scratch-an-itch problem, but it's turning into a cool opportunity to try all kinds of different things, so I like the idea of exploring various possibilities.

author: Zero999
author_rank: Super Contributor
timestamp: January 25, 2023, 07:22:11 pm
content: Quote from: Benta on January 24, 2023, 11:33:14 pmHow can resistors translate to voltage gain? Resistors attenuate, not amplify.You just said.Quote from: Benta on January 24, 2023, 10:08:54 pmWithout specifying whether you were talking about voltage or current gain. Please explain why adding a Darlington pair causes oscillation.

author: Benta
author_rank: Super Contributor
timestamp: January 25, 2023, 08:17:22 pm
content: Try it out yourself. Over and out.

author: Zero999
author_rank: Super Contributor
timestamp: January 25, 2023, 08:23:57 pm
content: Quote from: Benta on January 25, 2023, 08:17:22 pmI could, but what would be the point? It would not help me understand why.

author: Benta
author_rank: Super Contributor
timestamp: January 26, 2023, 12:40:21 am
content: OK, I've now played around with replacing the pass transistor with a MOSFET (IRFZ14, pretty standard, I think) and using a TL431 as reference instead.The results are sobering, to say the least.The TL431 gives no problems compared to the the TLV431, so that's fine.But the combination TL431+IRFZ14 has produced one of the most powerful oscillators I've seen. And it's impossible to tame.I was sceptical to start with, but that was only my "gut feeling" Now I've seen it in real life.This is the circuit (ignore the gate resistor, it makes no difference). Feel free to try it out yourself:

author: CountChocula
author_rank: Unknown
timestamp: January 26, 2023, 01:16:49 pm
content: Quote from: Benta on January 26, 2023, 12:40:21 amThanks for trying, very interesting find. When I'm back home this weekend, I'm going to try putting together a version of my original circuit using a low-side topology just for fun as well—I recognize that yours is superior, but I'm still keen to try it out, if only for the sake of completeness, since we ended up looking at all kinds of different solutions in the thread. I'll report back once I have some results.Thanks again for all the suggestions and help, I really appreciate the support.—CC

author: Zero999
author_rank: Super Contributor
timestamp: January 26, 2023, 02:29:21 pm
content: You want dimming, so as nice and simple as the TL431+transistor circuit is, it won't do on its own.If you don't have a suitable power BJT, then four of those PN2222As could be connected in parallel.Attached is the practical schematic and an LTSpice simulation, with the potentiometer and TL431 replaced with a voltage source to make it easier to simulate. If it oscillates add some base resistors: try 1k, then increase it, if it's still a problem.

author: CountChocula
author_rank: Unknown
timestamp: January 26, 2023, 08:42:21 pm
content: Quote from: Zero999 on January 26, 2023, 02:29:21 pmThank you! Interesting idea to put the dimmer pot on the feedback pin of the 437. I'll try it out!

author: Zero999
author_rank: Super Contributor
timestamp: January 26, 2023, 08:50:43 pm
content: Quote from: CountChocula on January 26, 2023, 08:42:21 pmThe voltage across the sense resistors, R1 to R4, tracks the reference voltage. I = V/R so the current changes. All the potentiometer does is vary the reference voltage.I used four transistors, rather than one, because a single PN2222A can't dissipate that amount of power, without smoking.

author: Benta
author_rank: Super Contributor
timestamp: January 26, 2023, 09:05:38 pm
content: Quote from: CountChocula on January 26, 2023, 01:16:49 pmNothing "superior" about it, it's mainly optimized for simplicity. It can be made even simpler, but with less LED current precision.Dimming is not in the circuit. Either a more complex solution is needed for that, or you use PWM dimming, which will work fine.

author: CountChocula
author_rank: Unknown
timestamp: January 31, 2023, 12:27:08 am
content: Just thought I'd give one final update—I ended up going with a variant of Benta's original circuit; the only thing I changed is using a slightly larger sense resistor (I didn't need to run the LEDs at maximum brightness for my application) and adding a simple PWM circuit for dimming. I'm a bit concerned about thermal management—the pass transistor gets quite hot and, while I have added a heatsink, I'm worried that there won't be enough air circulation inside the enclosure, but I'll give it a test and see how it goes.Thanks again for all the help!—CC

author: Benta
author_rank: Super Contributor
timestamp: January 31, 2023, 12:46:37 am
content: Quote from: CountChocula on January 31, 2023, 12:27:08 amGlad you found a solution. You'll have the thermal issue no matter which circuit you choose, so I canẗ help you there.