PWM to avoid resistor in front of LED? - Page 1
Forum section: electronics / beginners

author: casper.bang
author_rank: Frequent Contributor
timestamp: December 16, 2014, 08:57:31 pm
content: I know that in order to limit the current flowing through an LED, a resistor (decided by Ohms law) is needed. My experimentation on several occasions have proven though, that using PWM output of an MCU can apparently accomplish the same thing. So what goes on here, am I just lucky that the LED can survive the bursts or is it a known and viable way of reducing components?

author: tautech
author_rank: Super Contributor
timestamp: December 16, 2014, 09:03:17 pm
content: Quote from: casper.bang on December 16, 2014, 08:57:31 pmDone similar years ago with a 555 @ 30 Hz.Keep AV current below datasheet max and all should be well.What frequency and duty cycle have you achieved?

author: casper.bang
author_rank: Frequent Contributor
timestamp: December 16, 2014, 09:14:19 pm
content: Quote from: tautech on December 16, 2014, 09:03:17 pmAFAIK (my scope didn't arrive yet) I am driving an RGB LED @200Hz with a duty cycle varying between 30% and 70%.

author: Seekonk
author_rank: Super Contributor
timestamp: December 16, 2014, 09:17:09 pm
content: "am I just lucky that the LED can survive the bursts"Probably, depends on the LED voltage. Just look at all the LED stuff out there from China, direct connection to a battery. Everything has some internal resistance. Your MCU likely can't supply enough current. That current limiting turns into heat. I'd rather burn up a LED than a MCU. How lucky are you feeling? Excess current slowly will kill a LED. As said before, even with narrow pulses the peak current must be kept below the LED rated current.

author: wraper
author_rank: Unknown
timestamp: December 16, 2014, 09:52:36 pm
content: Quote from: tautech on December 16, 2014, 09:03:17 pmNothing will be well. MCU pin will be overloaded and LED probably will be overloaded too (if MCU pin can output enough current). On top of that you'll get huge ripple on MCU power rail. There is not only average but also max allowed peak current which basically becomes uncontrollable. Specified LED max peak current at 1/10 duty cycle, 0.1ms Pulse Width usually is about 5 times higher than average current.

author: casper.bang
author_rank: Frequent Contributor
timestamp: December 16, 2014, 10:02:15 pm
content: I play with ATTiny's though, they are almost as cheap as an LED.

author: hamdi.tn
author_rank: Frequent Contributor
timestamp: December 16, 2014, 10:09:54 pm
content: a resistor is way cheaper than both ... let's kill a led and an mcu and not add a resistor 100 time cheaper ... because logic...

author: mazurov
author_rank: Frequent Contributor
timestamp: December 16, 2014, 10:25:39 pm
content: Quote from: casper.bang on December 16, 2014, 08:57:31 pmIt's a way to control the light output of the LED programmatically by changing average power available to the device. You must guarantee to never exceed peak pulse current of the LED, i.e., your pulses are always shorter than specified in PPC number and the current is lower (this includes conditions when the MCU pin is asserted by mistake, like during power-on or when on-time register value mystically becomes larger than a period register in your PWM module). PWM is more flexible but resistor is more reliable - use what's more important to you.

author: wraper
author_rank: Unknown
timestamp: December 16, 2014, 10:50:58 pm
content: What I can say that with 5V supply it is impossible to not exceed 40mA max current per pin if using red or green led. Probably won't exceed if using blue led, however LED brightness will vastly change depending on MCU temperature which BTW will heat up because of torture.

author: dannyf
author_rank: Super Contributor
timestamp: December 16, 2014, 11:10:14 pm
content: QuoteTwo things helped you there:1) mcu's output capability is limited, typically to 20ma max. and2) leds and diodes in general have very good tolerance for high levels of current, particularly when pulsed. Rectifiers, for example, can commonly take on 100x - 200x of its rated current in pulses.Btw, I routinely drive leds from mcu output pins without a current limiting resistor.It is not that you cannot do it; it is just that you need to know the risk of doing it.

author: c4757p
author_rank: Super Contributor
timestamp: December 16, 2014, 11:14:59 pm
content: EMI

author: ExtremHybrid
author_rank: Newbie
timestamp: December 17, 2014, 04:27:05 am
content: If you dont care about a long LIFETIME of the LED, then it's actually a nice way to save some components for some semi-permanent installation . But if you are building something permanent that you want to last you a couple of years: DON'T DO IT. Using resistors is better than having to resolder a brand new LED into the circuit once in a while.

author: tggzzz
author_rank: Super Contributor
timestamp: December 17, 2014, 03:23:19 pm
content: PWM reduces the average power - but you have to choose the averaging interval appropriately. For example, merely by changing the averaging period, I can correctly define my average pulse rate to be anywhere between 220bpm and 0bpm.So, what's the most relevant averaging period for your case? Hint: I can think of at least two different periods.

author: tszaboo
author_rank: Super Contributor
timestamp: December 17, 2014, 03:38:05 pm
content: Something working, and something properly designed <- That is not the same thing. I always vote for the later one, after that you can do fancy stuff.

author: mikerj
author_rank: Super Contributor
timestamp: December 17, 2014, 04:52:03 pm
content: Quote from: dannyf on December 16, 2014, 11:10:14 pmIt's possible to "get away" with this in some situations, but it's certainly not good practice and you probably shouldn't be encouraging others to do it.

author: AG6QR
author_rank: Frequent Contributor
timestamp: December 17, 2014, 05:12:57 pm
content: In addition to what's already been said, remember that a LED draws much more current at a given voltage when the LED gets warm (the opposite of most resistors). As it draws more current, it heats up more, thus drawing still more current. This can lead to positive feedback thermal runaway if you're not careful. What worked in your air conditioned lab may not work in the field during summer, or when the device is in a rack above a heat-producing power amplifier, or...If you were to measure the average current, and adjust your PWM based on the measurement, so that you're delivering a controlled average current to the LED, then you can probably make that work reliably. But it won't be cheaper or lower parts count than including a current limiting resistor.