Maximum current for PWMed leds (and mcu) ? - Page 1
Forum section: electronics / beginners

author: Jaunedeau
author_rank: Regular Contributor
timestamp: December 18, 2016, 11:51:08 am
content: 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 thisdatasheetform 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.

author: Simon
author_rank: Unknown
timestamp: December 18, 2016, 11:59:02 am
content: been there, done that, looked very stupid at the time. You MUST use a current limiting resistor.

author: Psi
author_rank: Super Contributor
timestamp: December 18, 2016, 12:07:16 pm
content: 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.

author: Jaunedeau
author_rank: Regular Contributor
timestamp: December 18, 2016, 12:09:26 pm
content: Quote from: Simon on December 18, 2016, 11:59:02 amYes, 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.

author: wraper
author_rank: Unknown
timestamp: December 18, 2016, 12:11:50 pm
content: 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.

author: Simon
author_rank: Unknown
timestamp: December 18, 2016, 12:23:33 pm
content: Quote from: Jaunedeau on December 18, 2016, 12:09:26 pmAnd 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.

author: Jaunedeau
author_rank: Regular Contributor
timestamp: December 18, 2016, 01:06:01 pm
content: 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) ?

author: Simon
author_rank: Unknown
timestamp: December 18, 2016, 01:25:40 pm
content: 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

author: matseng
author_rank: Frequent Contributor
timestamp: December 18, 2016, 04:53:17 pm
content: Quote from: Simon on December 18, 2016, 12:23:33 pmWhat? 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. ;-)

author: Simon
author_rank: Unknown
timestamp: December 18, 2016, 05:05:04 pm
content: 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.

author: Kleinstein
author_rank: Super Contributor
timestamp: December 18, 2016, 05:54:16 pm
content: 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.

author: Simon
author_rank: Unknown
timestamp: December 18, 2016, 06:21:06 pm
content: 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.

author: Zero999
author_rank: Super Contributor
timestamp: December 18, 2016, 08:19:21 pm
content: Quote from: Psi on December 18, 2016, 12:07:16 pmYes, 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

author: Audioguru
author_rank: Super Contributor
timestamp: December 18, 2016, 10:53:57 pm
content: The OP wrongly thinks that the PIC limits its current to 25mA when the datasheet says its maximumallowedoutput 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".

author: danadak
author_rank: Super Contributor
timestamp: December 19, 2016, 11:51:37 am
content: Placing an R in the Vdd line of a processor can lead to some issues, likePLL clock generation upset, crystal oscillator transients. Or at very leastsome unpredictable behavior in processor operation.Regards, Dana.