Constant Current LED Driver - Page 1
Forum section: electronics / projects

author: Siddhat
author_rank: Regular Contributor
timestamp: February 19, 2021, 03:34:00 pm
content: Hello everyone.I've been designing a LED driver circuit in order to power a bunch of LEDs. The schematic of the LED driver in LTSPICE is shown below. I also want the LEDs to be dimmable. I know that PWM is the required approach but have no idea on how to implement to this circuit. How can the LED be made dimmable (adjustable brightness) using PWM?Thank you!

author: ajb
author_rank: Super Contributor
timestamp: February 19, 2021, 04:17:30 pm
content: In general you really only need one op amp for this sort of thing, so you should be able to simplify your circuit a fair bit.This circuit can be dimmed by adjusting the reference voltage (V4) which will adjust the current set point.A common way of accomplishing PWM dimming in switch mode constant current circuits is to put a transistor in parallel with the LED(s). Turning the transistor on shorts the LED, so current flows through it, and the LED turns off. This works in switch mode drivers because the converter is very efficient and only consumes a bit more power than it supplies to the LED. In a linear driver like you have here, showing the LED will increase the power dissipated in the pass transistor, so probably not a good idea. You would also need to both simulate and test the circuit to ensure that the current loop is stable when that transistor turns on and off.A simpler and more efficient way of adding PWM to a linear driver would be to use it to modulate the current set point. However this will limit your PWM frequency to a bit less than the bandwidth of your current loop, and again you'll need to simulate and test for stability.

author: jmelson
author_rank: Super Contributor
timestamp: February 19, 2021, 04:41:13 pm
content: There are literally THOUSANDS of LED current controller chips now being made. I have used a few of them such asLM3404HV and LM3405. These have dimming inputs.Jon

author: Gibson486
author_rank: Frequent Contributor
timestamp: February 19, 2021, 05:21:56 pm
content: Looks overly complex....Looks like you want to set a current source with 0.5V being your reference? You can reduce this to 1 op amp...Anyways...to PWM, you can try switching the 1V supply on and off.

author: gnuarm
author_rank: Super Contributor
timestamp: February 19, 2021, 05:36:36 pm
content: PWM is simple, you just disable the current drive for some amount of time. Your circuit could be modified for that easily by adjusting the reference voltage, V4.I did something similar where I used two transistors to control the current for a current loop driving a remote opto-isolator. It used an NPN emitter follower to regulate the current with the reference voltage set by a Vbe. The load would be in the collector leg and a current set resistor would be in the emitter leg. A second NPN is wired with the BE across the set resistor and the collector to the base of the first NPN. A series resistor to the first base then provides the PWM input. Any voltage above say 2V is enough to drive the set current. When the voltage across the current set resistor turns on the second transistor, current is pulled away from the base of the first NPN reducing the drive. The input voltage only needs to be high enough to turn on both transistors, ~1.2V, plus a voltage on the input resistor to assure the minimum base drive current (very light). The feedback loop works with the gain of both transistors, so it regulates very well, but with variation with temperature because of thermal effects on Vbe. A thermistor could be added to minimize the impact. If interested I can provide an LTspice file.This also has a fairly low drop out voltage of under 1V, ~0.62 for the set resistor and a bit of head room for the Vce of the transistor. Here is a copy of the schematic as a PDF. The diodes on the input allow for reversed input polarity. The LED does the same thing by protecting the BE of Q1 against excessive reverse voltage and gives an indicator. Neither are useful in your application. The capacitor slows the edge of the current change to reduce EMI which might be important in your use. You will need to size all the resistors and pick transistors to suit the details of your circuit.

author: pqass
author_rank: Super Contributor
timestamp: February 19, 2021, 05:39:50 pm
content: You want the 2nd to last or last circuit presented below.To PWM, just add another NPN transistor between main transistor's base/gate (if using a MOSFET) and ground (2nd to last circuit) or inject PWM into the +input of the opamp (last circuit presented).

author: gnuarm
author_rank: Super Contributor
timestamp: February 19, 2021, 05:44:20 pm
content: Quote from: Siddhat on February 19, 2021, 03:34:00 pmI just looked at your design in detail and realized you are using an integrator to reduce your error term to zero. I don't recall ever seeing that used in a circuit like this.Normally an amp would be used without the negative feedback allowing the path through the pass transistor to provide the feedback. This is a control loop and you have two capacitors creating filters. You might have issues with stability.

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 19, 2021, 06:31:55 pm
content: You can do this with a single opamp and a single-rail supply, and make it voltage-controlled on top of it.This is the basic structure:You can easily generate the control voltage from PWM using simple RC filtering. Done.The opamp can be powered with a single supply. As you probably won't need to get down to very small currents.Note that this arrangement is not particularly efficient - the shunt resistor (R1) will dissipate R1*Iout^2.Also note that depending on the number of LEDs in series (I don't know if by "to power a bunch of LEDs" you meant many LEDs in series controlled by the same driver, or many drivers controlling only one LED each...), it may require a much higher voltage than 12V for powering the LED string. You'll need to choose the MOSFET appropriately, and obviously have access to/generate such a voltage.As suggested above, and particularly if you need several channels and better efficiency, using an off-the-shelf LED driver IC would probably make more sense. Many are multi-channel, have good efficiency, are dimmable, and some available from chinese vendors are extremely cheap.

author: MarkF
author_rank: Super Contributor
timestamp: February 19, 2021, 08:25:46 pm
content: You will need a few more components (Essentially, this is the configuration of a dummy load.):

author: gnuarm
author_rank: Super Contributor
timestamp: February 19, 2021, 10:14:16 pm
content: Quote from: MarkF on February 19, 2021, 08:25:46 pmThat circuit is still not done. If he wants to PWM the output he has to generate a PWM pulse train with a specific voltage for the current in the on state. You suggested a PWM signal to generate that level, so PWM the PWM.This could be done by running the PWM at a very high rate and disabling it for the LED PWM, but there's only so many clock cycles and the degree of control over setting the LED current and the LED dimming will compete. But I suppose it's not a big deal in most cases. The PWM for the LED needs to be something high enough it isn't seen. I can see the flashing of tail lights, so I'd like that to be 1 kHz. Work up from there with the resolutions...

author: Zero999
author_rank: Super Contributor
timestamp: February 19, 2021, 10:25:17 pm
content: I think the point is: why bother with PWM? The main reason why it's done is because it's convenient to generate with a microcontroller. If the requirement is just to control the brightness of the LED, then skip the PWM and vary the reference voltage.Why have a MOSFET? If the maximum LED current is only 10mA, just use the op-amp to drive the LED directly.

author: gnuarm
author_rank: Super Contributor
timestamp: February 19, 2021, 11:10:51 pm
content: I didn't pick up on that the current is so low. Not sure what the motivations are for this circuit. Why not just pick a resistor to set the current limit and use a transistor to PWM or just turn it off.I think the op amp is over kill no matter what. The same result can be obtained using a bipolar transistor and a resistor in the emitter leg for a first order control based on the voltage from the I/O pin. For more precise control of the current two bipolar transistors will set the current very accurately with no worry about the input voltage.

author: Siddhat
author_rank: Regular Contributor
timestamp: February 20, 2021, 04:01:20 am
content: Quote from: ajb on February 19, 2021, 04:17:30 pmAdjusting the reference voltage V4 changes the current through the LED and resistor R3. But the need is to make the current constant and still be able to adjust the brightness. The simplified circuit does not have a decent performance when implemented on a breadboard. So, some search on the internet helped to realize this circuit.

author: Siddhat
author_rank: Regular Contributor
timestamp: February 20, 2021, 04:06:12 am
content: Quote from: jmelson on February 19, 2021, 04:41:13 pmYes, there are chips that help. But the aim is to achieve the goal with only op amps and transistors that help to learn and understand the circuit actually for students in academics.

author: Siddhat
author_rank: Regular Contributor
timestamp: February 20, 2021, 04:12:40 am
content: Quote from: Gibson486 on February 19, 2021, 05:21:56 pmI want the to set the current with 1V being the reference. Yes, I simulated by switching the 1V supply with PWM and worked just fine. But when a PWM is used, why does the input not see an averaged 0.5V at the input when a 0V to 1V and 50% duty cycle PWM is used?

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 20, 2021, 04:54:44 pm
content: Quote from: Siddhat on February 20, 2021, 04:12:40 amYou did something wrong probably. PWM just needs to be low-pass filtered to get the average voltage. It's done all the time when you don't have access to a real DAC. Show us what you did exactly.

author: SiliconWizard
author_rank: Super Contributor
timestamp: February 20, 2021, 05:31:17 pm
content: Quote from: MarkF on February 19, 2021, 08:25:46 pmThe image I linked is, as I said, the basic structure. It wasn't meant to be a complete circuit. (The image is courtesy of Analog Devices BTW.)That said, any additional compensation network may or may not be required entirely depending on the load and the parts you're using. In particular, if the load is stable (as LEDs mostly are) and the opamp is slow enough, the circuit with no compensation will work fine.Attached is an example (LTSpice) circuit with a 10kHz, 1V PWM input controlling a current of up to 100mA. It should be able to go as low as 1mA with reasonable accuracy. That looks like a quite usable range to me. (Actually, with a 0V PWM input, the current gets as low as ~15µA from simulation, it may be a bit higher than this in practice. Accuracy degrades below 1mA. For LED brightness adjustment, that seems more than adequate.)You can add compensation if that makes you feel more comfortable, but with the opamp I used, it really shouldn't be necessary. It will draw about 50µA on the opamp's power supply.

author: jmelson
author_rank: Super Contributor
timestamp: February 20, 2021, 08:04:07 pm
content: Quote from: Siddhat on February 20, 2021, 04:06:12 amAH, OK, this is a learning project! Totally different goals then.Jon

author: gnuarm
author_rank: Super Contributor
timestamp: February 20, 2021, 09:17:35 pm
content: Quote from: Siddhat on February 20, 2021, 04:06:12 amDid you look at the circuit I provided? Using two NPN transistors uses the Vbe of one as the reference voltage. Since this is amplified by both transistors it has lots of gain, not much less than an op amp, so is pretty stable. The current is set by the resistor R3. The resistor divider R1/R2 is set to provide adequate current to drive the base of Q1 (~5 uA with the parts I've chosen) so Q2 has room to work by stealing current. R1/R2 creates a Thevenin equivalent which setting the voltage slightly above what is needed by the two BE voltages makes the R3 voltage and the load current more stable.Delete the various diodes and apply power to PWR and input signal to R1. The optoisolator is your LED string. Pulsing the input signal at R1 creates the PWM of the LED current.You will find this circuit to be very good for not having a voltage reference.If you want an even more simple circuit you can set the current through R3 purely with the voltage set by the R1/R3 pair. This will work ok, but the current will also depend on the hFE of the transistor and so vary a bit from unit to unit.The only variation of the current in the two transistor circuit are thermal effects. A forward biased diode voltage changes by -2 mV for each °C rise. Not a large effect, but if the device warms up significantly -2 mV/°C adds up. Adding an NTC resistor in series with R3 will mitigate that. The math is a bit messy to pick an NTC device, so I won't bore you with it.

author: Gibson486
author_rank: Frequent Contributor
timestamp: February 20, 2021, 10:21:44 pm
content: Quote from: Siddhat on February 20, 2021, 04:12:40 amI think there is some confusion. PWM will give you an avg over time...if the device cannot fully respond fast enough. So, if you measure your input, you will simply see the voltage switching between on and off at whatever frequency and duration you choose.The concept of using PWM to make a device see a percentage of the power only works if the device's response is slower than that of the frequency being driven. In this case, your LED can not pulse to full power at the frequency driven. Instead, it turns on at to certain percentage, but turns off. Since your eyes cannot see pulses faster than 60Hz (or is it 30?), you perceive this as just a dimmer LED as a function of your PWM cycle and frequency. If you put this on a camera that capture faster than your driving frequency, you will likely see it it modulating with the frequency (in fact, if you do not synchronize it correctly, your still pictures will not have even illumination across the set of captures!) . In contrast, your op amp is likely able to respond faster than your switching frequency and if you used an oscope to capture the input, those things can capture in the Mhz, so there should be no issues seeing the full waverform.

author: Ian.M
author_rank: Super Contributor
timestamp: February 20, 2021, 11:42:12 pm
content: Quote from: gnuarm on February 20, 2021, 09:17:35 pmSee the temperature stabilized PWMable BJT current sinks I presented in this thread last August:https://www.eevblog.com/forum/projects/temperature-independent-constant-current-with-fast-transient-response-to-pwm/

author: gnuarm
author_rank: Super Contributor
timestamp: February 21, 2021, 10:05:58 am
content: Quote from: Ian.M on February 20, 2021, 11:42:12 pmInteresting. Thanks