Author Topic: Maximum current for PWMed leds (and mcu) ?  (Read 3248 times)

0 Members and 1 Guest are viewing this topic.

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 100
Maximum current for PWMed leds (and mcu) ?
« on: December 18, 2016, 11:51:08 am »
Hi,

  let's imagine you have a cheap mcu (attiny or pic10f) which is probably rated for 20 or 25mA maximum output, and LEDs which should be rated for 20mA, but you only really want 5mA because you need a rather low brightness.
  Now image the project should be really tiny (two 0402 LEDs glued on a SOT mcu) and you don't have space to hide the current limiting resistor. And image that the PSU is made of an USB charger (5V) with an in serie LED to have some dropdown voltage.

  Of course, that would be a terrible design. Depending on which leds are turned on by the MCU (one is 3.5V blue led, the other one is a 2.5V red led), you probably will get situation where too much current go through the red led. But since you only want low luminosity, the MCU will do some PWM.

  Now the question is : if I have a 0402 led (no datasheet, bought on ebay, let's assume 15mA continuous current is safe ?), and you PWM is at a 20% ratio with a 45mA current (hence having an average current of 9mA, will you burn you mcu ? will you burn your led ? Will thing be ok since nothing will overheat ?

  Edit : I found this datasheet form kingbright, and they say macimum pic current is 150mA. Does it mean that a continuous 13%*150mA pwm (20mA average) is ok ? (maybe a bit less than 10% not to exceed the maximum power dissipation, but at least I can hope that 40mA*15% is ok for my chinese no-brand leds ?)

Thank you,
John.
« Last Edit: December 18, 2016, 12:06:22 pm by Jaunedeau »
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18065
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #1 on: December 18, 2016, 11:59:02 am »
been there, done that, looked very stupid at the time. You MUST use a current limiting resistor.
 

Online Psi

  • Super Contributor
  • ***
  • Posts: 10236
  • Country: nz
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #2 on: December 18, 2016, 12:07:16 pm »
Use a stupidly high brightness LED in combination with the MCU internal pull-ups to power the LED and limit current.
This gets around your issue of not having room for the resistor.

Even with a 20-50k pullup resistor a high brightness LED is usually still bright enough.

If you have spare I/O you could parallel them up to get more total current though the pull-ups.
« Last Edit: December 18, 2016, 12:09:49 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 100
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #3 on: December 18, 2016, 12:09:26 pm »
been there, done that, looked very stupid at the time. You MUST use a current limiting resistor.

Yes, I know, but on this project I just can't. The LEDs will be glued directly on the mcu and I don't want any resitor to be viewable (and I only have stock of 0603 that don't feet on my SOT mcu anyway) :) Otoh, I can manually calibrate each PWM for each LED.
 

Online wraper

  • Supporter
  • ****
  • Posts: 17660
  • Country: lv
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #4 on: December 18, 2016, 12:11:50 pm »
Many leds have a peak current only a little bit higher than continuous current. Driving LEDs without a resistor, besides reliability issues, will cause brightness changing depending on MCU temperature.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18065
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #5 on: December 18, 2016, 12:23:33 pm »


Yes, I know, but on this project I just can't.

And you think physics and the real world care much about what you think you can and can't do ? As suggested using the internal pullups that are variable and not meant for this is the closest you will get. Last time I thought I could omit resistors because i was only using 3.3V I blew the outputs up so fast I did not even see the flash.
 

Offline JaunedeauTopic starter

  • Regular Contributor
  • *
  • Posts: 100
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #6 on: December 18, 2016, 01:06:01 pm »
Thank for all your asnwer, it starts to raise new ideas :

-Since my pwm will be less than 50% and I have only 2 LEDs, I can manage to have only 1 LED lite at any given time. Then I can use a resistor on the PSU line (out of sight). The voltage of the MCU will swing when the led is on (but its 1.8-5V), and the serie resistor would be the same for the blue and red led (but I can find a value which is ok for both and PWM the red light so it's not too brite). I will have to draw a different PSU line for each MCU so I can hide the resistor, but it's ok.
-Is there any chance I could find a 0.05-0.1mm wire with a high resistance (about 100Ohm for 10mm) ?
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18065
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #7 on: December 18, 2016, 01:25:40 pm »
resistivity and specific resistance of various materials is well documented. Copper that most wire is mostly made of will not have such a high resistance over 10mm
 

Offline matseng

  • Frequent Contributor
  • **
  • Posts: 563
  • Country: se
    • My Github
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #8 on: December 18, 2016, 04:53:17 pm »
Last time I thought I could omit resistors because i was only using 3.3V I blew the outputs up so fast I did not even see the flash.
What? That must have been some really sensitive shit then. All "normal" mcus for sure doesn't get killen in milliseconds by driving a led without a resistor. Nor can they burn out the LED. Especially not at 3.3 volts. The internal resistance of the output drivers together with the Vf of the LED limits the current enough.

Of course is not "good engineering" to just nilly-willy omit the current limiting resistors. But that is another issue.

I have tested some AVR's, both older and newer generations, and some PICs by shorting two gpios to gnd and two to vcc and set them to output the opposite levels. The chips barely got lukewarm at 5 volts, and not even that at 3.3. No discernable differences in the capabilities of the tortured ports compared to virgin ones after a couple of hours.

In all my years (40) of electronics tinkering I can't recall having fucked up a pin on a general chip by short circuiting it.

On the other hand if one sets the bench power supply to 20 mA current limiting and then connect a LED to it the led will be killed dead within milliseconds. ;-)
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18065
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #9 on: December 18, 2016, 05:05:04 pm »
Well I connected three LEDs to the chip. Each on a separate channel. They were connected so that they will be driven by the low side of the output driver and I spent a whole day trying to work out why another chip could not read the outputs as it was an interrupted input and because the outputs were not going from high to low they were just going from high to high impedance that other microcontroller could not read them. And I wasted a day in front of a customer trying to work this out until I remembered I had previously tried to drive the LEDs directly from the chip and I had in fact fried all of the low side transistors on the gates. And yes it most certainly happened that fast that I did not even see the LEDs flash. I just instantly blew MOSFETs inside the chip.
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14854
  • Country: de
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #10 on: December 18, 2016, 05:54:16 pm »
At lower voltage, the output drive power is limited. However it depends on the µC if a 3.3 V voltage is low enough to make the outputs more or less current limited to a reasonable value. The PIC / classical AVR have an output resistance somewhere in the 50-100 Ohms range at 3.3 V supply. So with a LED with 1.5-2 V drop the current should be in an acceptable range. If not, use 2,7 V or 3 V. More modern µC made for <= 3.3 V operation might need a lower voltage and can be more sensitive.

A resistor in the supply line (and no large bypass cap) is not that good - a rather variable supply may cause unreliable operation.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18065
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #11 on: December 18, 2016, 06:21:06 pm »
fact is there is a way of doing, it is the way it is done. End of. the OP seems to be trying to concoct anything that fits his plan and then wonders why the solution he wants is not available.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19995
  • Country: gb
  • 0999
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #12 on: December 18, 2016, 08:19:21 pm »
Use a stupidly high brightness LED in combination with the MCU internal pull-ups to power the LED and limit current.
This gets around your issue of not having room for the resistor.

Even with a 20-50k pullup resistor a high brightness LED is usually still bright enough.

If you have spare I/O you could parallel them up to get more total current though the pull-ups.
Yes, that will work.

If the original poster is unsure about what you meant, then they should search for microcontroller internal pull up resistor.

https://www.google.co.uk/search?q=microcontroller+internal+pull+up+resistor&ie=utf-8&oe=utf-8&gws_rd=cr&ei=-u5WWIylGaaNgAbE6YyACA
 

Offline Audioguru

  • Super Contributor
  • ***
  • Posts: 1507
  • Country: ca
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #13 on: December 18, 2016, 10:53:57 pm »
The OP wrongly thinks that the PIC limits its current to 25mA when the datasheet says its maximum allowed output current is 25mA. It is made of high speed Cmos (the HC kind) and a graph I have says its output current is trying to be 50mA to 60mA when it has a 5.0V supply and is driving an LED. Then "poof".
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Maximum current for PWMed leds (and mcu) ?
« Reply #14 on: December 19, 2016, 11:51:37 am »
Placing an R in the Vdd line of a processor can lead to some issues, like
PLL clock generation upset, crystal oscillator transients. Or at very least
some unpredictable behavior in processor operation.

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf