PWM Based LED Driver

prototype-600

A followup to the constant current driver for a high power LED post, Elmars writes:

If anybody is interesed, I have posed a follow up to this original post with a simple PWM LED driver, adding an ATtiny85 mCU. The post includes schematic, board layout and code for the ATtiny85. I hav tested the circuit up to 22 volts without a current limiting resistor. The FET only needs a small heat sink. Efficiency can be further improved by replacing the LM358 with an RC/LM741. The LM741 has a much sharper rise and fall time than the LM358 when run at 2KHz, resulting in the FET spending less time as a resistor. (during the slow ramp/fall the FET acts as a resistor, generating heat)

Via the comments.

Join the Conversation

12 Comments

  1. Well, this is a bit off the usual expectations of what a typical PWM LED driver would do. Most PWM LED driver ICs that are step-down uses buck DC conversion, that means an inductor somewhere. However, this circuit does not appear to have an inductor, and perhaps runs at a slow 2KHz — sounds like a squarish wave (well, as square as the opamp can make it) and that means pulsed voltage.

    Without an inductor, look at the current path: battery, LED, NFET, resistor. Since the NFET is used in switching mode, the resistor drop as little as possible by design, and I don’t see anything else in the breadboard circuit, it looks like there’s nothing to really drop the pulsed battery voltage from the 18V or so except for battery droop. So ask yourself: what voltage is really going through the LED?

    Have Elmars looked at the waveform at the LED module? Of course the battery and the opamp will smooth the waveform some but I think it will still look like a pulsed thingy. Since it’s only the feedback voltage that is smoothed via the filter, and the PWM is digitally driven by the MCU, with the FET in switch mode, the LED is probably pulsing at over-voltage with respect to the LED’s specs.

    Hobby enthusiasts should carefully consider things when evaluating whether they want to copy this design.

    Now the LED should survive a degree of over-spec if power is pulsed (depends on materials and thermals, etc.), but I reiterate, no commercial PWM LED driver IC would do something like this. Kinda no warranty if parts are used in this way; pulsed power is usually never promised in any LED data sheet.

    What do others think? Moderator please delete the earlier posting if this posts fine, thank you.

    1. The waveform through the LED is a 2kHz square wave. The operating principle is based on average current throughput (i.e. managing heat <70C), minimal cost/components and maximum energy efficiency. The most expensive component in this build is the ATtiny85. I am also not driving the LED at full rated power, although I have run at 80% for 48 hours in this configuration with no adverse impact.

      I looked at and tested various inductor based circuits but all of them required a large heatsink on the FET, as they generate a sine wave. This circuit does not require a heatsink on the FET when run at 300mA load @ 20V (design goal). I have not looked at buck circuits yet. (maybe in the future)

      Not sure why you would think the op-amp would smooth the waveform. As designed, the op-amp amplifies the square wave from 5V peak to VCC peak. The op-amp output drives the FET gate from 0 to VCC and back as quickly as possible, to avoid a ramp and subsequent heat generation in the FET.

      The circuit was tested at a 16KHz PWM. The LM358 is unable to ramp at this speed (LM358 starts to lose steam at about 4kHz). An LM741 was successfully tested at 16kHz, but the waveform was more like a sawtooth waveform, and at 25% duty cycle, the waveform was a slanted ramp in both directions generating significant heat on the FET. An even faster op-amp is required to switch the 20V in something resembling a square wave. (or get an FET designed for 5v mCU operation)

      Finally… never heard of chinese ebay sellers giving a warranty. But then again, if you need a warranty, spend 5x more and buy from Mouser. Or buy a proper controller. I think I have won, as I have yet to burn one out, have about 20 LEDs to go, and learned a bunch about op-amp performance, FET performance, low pass filters, and more. :)

      1. Good for you that it is working so far.

        At 2KHz, the tiny LED chips have at least 10X more time to heat and cool than typical PWM freqs. That’s more thermal stress that temp measurements can’t assess. If lifetime is reduced, a 48 hour test may not show it. Though it sounds like a good burn-in test, it may not shed any light on wear-out failure.

        By inductor, obviously I meant buck circuits only, we are talking PWM switching anyway. Opamps are not designed to drive power FET gates, output slew rate is poor on old opamps. The slow rise and fall times (compared to usual FET drivers) will lead to slower switching times for the power FET and increased losses at the FET. But I suppose at 2KHz it’s still mostly a square wave.

        I don’t wish to be someone trying to spoil your fun. When someone publishes a circuit that drives LEDs at voltages far above spec, I think it should be pointed out that this is not a typical scenario and may not work out positively for everyone.

  2. :)

    No worries, I understand where you are coming from, and am also very experienced working with engineers who know their stuff… if one forgets they think in assembly even when asleep, it is easy to get offended pretty quick. So no problem. See the smile a couple lines above?

    Anyway, you do bring up a good point and it is worth mentioning. This circuit doesn’t really have to run at 20v to drive a 12v 1A LED. The circuit will do just as good (better?) a job driving the LED at lesser voltages. In line with your comments, the optimum for max output is about 13 volts when taking into consideration the circuit’s inherent resistance. Any less than 13v input and it is not possible to drive the LED at full output.

    Anyway, Merry Christmas! Still waiting for the switching circuit I asked you about last time…

    1. I’m only here to shoot the breeze. ;-)
      I think the forums is a better place for discussing circuit proposals etc…

  3. Gate capacitance is of course what’s slowing the risetime. You can overcome that with just a simple PNP/NPN pair as a buffer between the output of the OpAmp and the gate of the fet, you don’t need a fancy driver for something like this. Something like say a BC639/640 combination will do just fine, but even a BC547/557 will do the job, just might strain a bit more. With the likelihood of longer leads when playing, it’s not a bad idea to stick a small resistor in series with the gate connection and a 16V or 18V Zener from G-S.

    1. nope. No zener. There is a pulldown resistor on the gate (R3) in the schematic. I don’t have a 16 or 18 volt zener on hand, but during the holidays I will see if a 10+5.1 series makes a difference. Will also test the series resistor. Thanks!

      1. Oh OK, looked like one was connected to the left leg of the fet, but obviously not. The resistor is just to damp potential oscillations and is not essential, but is generally accepted as good practice. The Zener is also not required, it’s just good practice to protect the gate from over-voltage spikes, often from things like driving inductive loads and the capacitive coupling between Drain and Gate. While it may not be an inductive load, if you’re fast switching (raise and fall times) high currents (di/dt) and longish wires, it can effectively become one – It all depends on the rate of change combined with things like length of wire, how it’s laid out, etc. Not likely to be an issue when driven with a slow slew rate op-amp, but if you add a bit of a buffer as suggested above, the rate of change will increase quite a bit.

Leave a comment

Leave a Reply to KH Cancel reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.