Author Topic: PWM to avoid resistor in front of LED?  (Read 4869 times)

0 Members and 1 Guest are viewing this topic.

Offline casper.bangTopic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: dk
  • Pro SE, amateur EE.
    • BangBits
PWM to avoid resistor in front of LED?
« on: December 16, 2014, 08:57:31 pm »
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?
 

Offline tautech

  • Super Contributor
  • ***
  • Posts: 28136
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: PWM to avoid resistor in front of LED?
« Reply #1 on: December 16, 2014, 09:03:17 pm »
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?
Done 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?
Avid Rabid Hobbyist
Siglent Youtube channel: https://www.youtube.com/@SiglentVideo/videos
 

Offline casper.bangTopic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: dk
  • Pro SE, amateur EE.
    • BangBits
Re: PWM to avoid resistor in front of LED?
« Reply #2 on: December 16, 2014, 09:14:19 pm »
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?
Done 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?

AFAIK (my scope didn't arrive yet) I am driving an RGB LED @200Hz with a duty cycle varying between 30% and 70%.
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: PWM to avoid resistor in front of LED?
« Reply #3 on: December 16, 2014, 09:17:09 pm »
 "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.
 

Online wraper

  • Supporter
  • ****
  • Posts: 16794
  • Country: lv
Re: PWM to avoid resistor in front of LED?
« Reply #4 on: December 16, 2014, 09:52:36 pm »
Keep AV current below datasheet max and all should be well.

What frequency and duty cycle have you achieved?
Nothing 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.
« Last Edit: December 16, 2014, 09:56:20 pm by wraper »
 

Offline casper.bangTopic starter

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: dk
  • Pro SE, amateur EE.
    • BangBits
Re: PWM to avoid resistor in front of LED?
« Reply #5 on: December 16, 2014, 10:02:15 pm »
I play with ATTiny's though, they are almost as cheap as an LED. :)
 

Offline hamdi.tn

  • Frequent Contributor
  • **
  • Posts: 623
  • Country: tn
Re: PWM to avoid resistor in front of LED?
« Reply #6 on: December 16, 2014, 10:09:54 pm »
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...  :palm:
 

Offline mazurov

  • Frequent Contributor
  • **
  • Posts: 524
  • Country: us
Re: PWM to avoid resistor in front of LED?
« Reply #7 on: December 16, 2014, 10:25:39 pm »
or is it a known and viable way of reducing components?

It'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.

 
With sufficient thrust, pigs fly just fine - RFC1925
 

Online wraper

  • Supporter
  • ****
  • Posts: 16794
  • Country: lv
Re: PWM to avoid resistor in front of LED?
« Reply #8 on: December 16, 2014, 10:50:58 pm »
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.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PWM to avoid resistor in front of LED?
« Reply #9 on: December 16, 2014, 11:10:14 pm »
Quote
n MCU can apparently accomplish the same thing.

Two things helped you there:

1) mcu's output capability is limited, typically to 20ma max. and
2) 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.
================================
https://dannyelectronics.wordpress.com/
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: PWM to avoid resistor in front of LED?
« Reply #10 on: December 16, 2014, 11:14:59 pm »
EMI :scared:
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline ExtremHybrid

  • Newbie
  • Posts: 5
Re: PWM to avoid resistor in front of LED?
« Reply #11 on: December 17, 2014, 04:27:05 am »
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.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19279
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: PWM to avoid resistor in front of LED?
« Reply #12 on: December 17, 2014, 03:23:19 pm »
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.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online tszaboo

  • Super Contributor
  • ***
  • Posts: 7306
  • Country: nl
  • Current job: ATEX product design
Re: PWM to avoid resistor in front of LED?
« Reply #13 on: December 17, 2014, 03:38:05 pm »
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.
 

Online mikerj

  • Super Contributor
  • ***
  • Posts: 3233
  • Country: gb
Re: PWM to avoid resistor in front of LED?
« Reply #14 on: December 17, 2014, 04:52:03 pm »
Btw, I routinely drive leds from mcu output pins without a current limiting resistor.

It'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.
 

Offline AG6QR

  • Frequent Contributor
  • **
  • Posts: 857
  • Country: us
    • AG6QR Blog
Re: PWM to avoid resistor in front of LED?
« Reply #15 on: December 17, 2014, 05:12:57 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf