Externally powering LEDs so Arduino doesn't fry

teke115:
Hello,
I am making a type of LED arrangement almost like a display board with over 20 LEDs being used. My arduino gets very hot when i power 12 of them at once. Can someone draw me a setup on how I could hook up an external Power supply to power all of the LEDs while using the arduino as a switch? Thank you all!!!

First we need to know if you need to be able to turn on and off each of the 20 leds independently of each other or do they all turn on and off together as a single unit? Or some situation between those two extremes?

Lefty

fungus:

Hippynerd:
20 LEDs isnt too many for the arduino to control, even at 20mA each

My copy of the datasheet says maximum current allowed through the VCC or GND pin is 200mA...

20x20 is 400 - too much.

I cant find it right now, but Im fairly certain that the 5v line has a 500mA max because of the voltage on board voltage regulator. Each I/O pin is 40, and the 3.3 pin is 50mA. according to:

but it doesnt list the 5v pins current max.

I looked in the datasheet thats linked on the same page, and it does list this:
DC Current VCC and GND Pins................................ 200.0 mA
on page 313, but I think thats the IC, not the arduino as a whole.

Hippynerd:

fungus:

Hippynerd:
20 LEDs isnt too many for the arduino to control, even at 20mA each

My copy of the datasheet says maximum current allowed through the VCC or GND pin is 200mA...

20x20 is 400 - too much.

I cant find it right now, but Im fairly certain that the 5v line has a 500mA max because of the voltage on board voltage regulator. Each I/O pin is 40, and the 3.3 pin is 50mA. according to:
http://arduino.cc/en/Main/ArduinoBoardUno

but it doesnt list the 5v pins current max.

I looked in the datasheet thats linked on the same page, and it does list this:
DC Current VCC and GND Pins................................ 200.0 mA
on page 313, but I think thats the IC, not the arduino as a whole.

Yes the total +5vdc current available from the board is higher then 200ma, but it the things being powered are being controlled by digital output pins then their combined load current has to pass through the chips output pins thus the chip's lower total current limit takes precedence. That is unless one uses external switching transistors (or driver ICs) to control the current switching duties and the output pins only have to drive the transistor inputs.

Lefty

Well, that does make me wonder how my units have survived the abuse I have been delivering to them.

Hippynerd:
Well, that does make me wonder how my units have survived the abuse I have been delivering to them.

That has been puzzling us all.

I would say that it was just the cheap knock off units, but the uno was running a cube drawing upto 360mA, so the original unit seems pretty sturdy too.

Reliability and electronic life time is a statistical thing. If you over stress the components then that life time gets shortened no question about that. However, seeing that with a sample size of one is impossible no matter if it carries on working until hell freezes over or it goes fut tomorrow.

Well, technically just using the electronics shortens its life. so the only way to ultimately protect your electronics is to not ever use them.

Sample size has nothing to do with it. but if you say it can work until hell freezes over, then it sounds like specifications dont really matter.

VCC and AVCC can each support 200mA - so 400mA total.
The ports should then be limited to 300mA:
3. Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:
ATmega48A/PA/88A/PA/168A/PA/328/P:
1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150mA.
2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150mA.
If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.

So at 360mA, you're pushing it some.
Best bet is to use a couple of external shift registers such as TPIC6B595 that can sink the higher current amounts.
78 cents from avnet.com
https://avnetexpress.avnet.com/store/em/EMController/Counter-Shift-Register/Texas-Instruments/TPIC6B595N/_/R-1750249/A-1750249/An-0?action=part&catalogId=500201&langId=-1&storeId=500201&listIndex=-1&page=1&rank=0

Hippynerd:
it sounds like specifications dont really matter.

You hear the words ... but you don't listen to them.

Hippynerd:
Well, technically just using the electronics shortens its life. so the only way to ultimately protect your electronics is to not ever use them.

Sample size has nothing to do with it. but if you say it can work until hell freezes over, then it sounds like specifications dont really matter.

Why do you persist in being so resistant to trying to understand this subject? Those two statements are totally wrong. You have been told many times but you think that you know best. Let me tell you now, you don't.
The human propensity for self delusion never ceases to amaze me.

In the 320mA case (I dont have the datasheet on the LEDs, so I assume 20ma) didnt really happen until I converted the cube to using shift registers (originally it just used 20 pins, and 4 resistors, an it only lit one LED at a time.). With the shift registers, it changed it so that it was lighting 16 LEDs at a time, and it needed 16 resistors instead of 4. I should probably stick some transistors on the plane pins, and replace the shift registers with ones that will support 160mA.

I have a couple other cubes that are running a fair amount of electricity (kill-a-watt shows about 1/2 watt). They run off of USB wall warts one is 500mA, the other is 850mA, and my guess is that they are using all of it. Those cubes use 16 lines, and im pretty sure that they are lighting no more than 8 LEDs at a time. One cube uses resistors, the other cube does not.

If i run a cube off battery, I should be able to measure the current.

Grumpy_Mike:

Hippynerd:
Well, technically just using the electronics shortens its life. so the only way to ultimately protect your electronics is to not ever use them.

Sample size has nothing to do with it. but if you say it can work until hell freezes over, then it sounds like specifications dont really matter.

Why do you persist in being so resistant to trying to understand this subject? Those two statements are totally wrong. You have been told many times but you think that you know best. Let me tell you now, you don't.
The human propensity for self delusion never ceases to amaze me.

You say a lot of stuff, you try be insulting, but you dont really say anything of any value.

Which part of any of this was I suppose to understand me up on the subject?

It seems all you are good at is telling me im all wrong, but never why, because telling me that im wrong seems to be the only important thing to you.

I keep telling you why you are wrong but you do not want to understand.

Grumpy_Mike:
I keep telling you why you are wrong but you do not want to understand.

Short version: You believe that "specifications dont really matter".

Not only that, you give out 'advice' based on that philosophy.

So, now you want to tell me what Im thinking and feeling?
Why do you want to try to tell me what Im thinking? why do you always get it wrong?

because you are both only interested in telling me Im wrong.

Show me some evidence of your claims, or take them back.

That goes for both of you.

I understand that you wont reply, because whenever I have pointed that out, you both respond with responses like
"I keep telling you why you are wrong but you do not want to understand."

and
"You believe that "specifications dont really matter". "

This is not educational at all, Its just trying to make someone out to be the bad guy, It only serves to make you feel superior, its the opposite of helpful.

Lefty and crossroads posted some facts, did you notice how they didnt add a bunch of subjective crap that has no pertinent info?

I dare you to stick to the facts.

OK I will try one more time, but this is a triumph of hope over expectation because you have ignored facts in the past.

I used to do this for a living so I have been involved with this process professionally.

Look at how reliability of a circuit is measured, calculated, worked out. An link, this is one of the first I found:-
http://www.ece.cmu.edu/~koopman/des_s99/electronic_electrical/
Look at the bath tub curve. This shows that you can get a failure at any time but there is more chance of getting one early or late.

Read the bit about stressing components.

Now the more a thing is subjected to stress, the shorter is it's life, this applies for lots of things including electrical circuits.

There is not one point in a rating of a component where below is safe and above it instantly vaporises. Engineering is not that good. It is a continuum to more stress a component is placed under the shorter will be its life. So how much stress is safe?
To find out what you have to do is to test a lot of parts under conditions to accelerate any ageing. Most of us can't do that so it is lucky that the manufacturers do it for us. They work out what is a safe stress and publish it in the data sheet.
So if you step over that line then the component does not instantly die but it's life is shortened. The more the stress the shorter the life, too much and the life is very short indeed.

So when we make stuff into a system we need to go through all that with the complete system. You take a number of samples, the more samples the shorter time you get your answer. You also subject it to accelerating conditions like elevated temperature and humidity. You have to wait for two failures to get a 65% estimation of the life. You have to do this because one failure could just be a "random" failure from the bath tub curve. You then subtract the accelerating factors to give you the life time of the system. The longer the test and the more failures you get the higher degree of certainty is your life time estimate.

From that you can see that just testing one sample is not going to tell you anything. Just like the fatal dose of poisons is worked out by the concept of a half lethal dose. That is a dose that will kill half the people it is administered to. It will not kill half the people but you can not conclude from just giving it to one person that it is safe or not.

So the way systems are designed are that the stresses on components are less than that stated by the manufacturers. Normally these are reduced to the 80% level. Even then some parts of a system may fail before others and by testing you can hope to identify these parts and either replace them with higher ratings parts or try and reduce the stress on a part.

Now what you are doing is taking a design that exceeds the manufacturers ratings and coming to the conclusion that because it is still working, you say undiminished, then the design and practice of exceeding these limits is some how validated.

You have made no measurements of light output you have just looked at it over six months or so and say it is no difference. If you take an LED and put 20mA through it and then change the current so that 13mA goes through it you can tell it gets darker. However, if you show the LED with one current and then turn it off for 5 second or so. Then put up at random one of the two currents, then you are very hard put to say what current the LED is receiving. Now I know you are not going to believe this so I invite you to make your own game of guessing the brightness and see how close you can get reliably.

Now do you understand why one sample tells you nothing about the reliability of a system design?

You have started by claiming that I have ignored facts, that is not true. In some cases it was a simple oversight, other cases its unknown if there is any excessive damage going on, and dont have a scanning tunnelling microscope or decapping ability to measure stuff, It is entirely possible that there is no excessive damage going on, or that there is significant damage going on, but it may still take a very long time before any noticeable change occurs (dimming or complete failure).

I'm told that Im causing damage to LEDs and microcontroller, but I have no effective way to measure it, and since I can not measure it, you are assuming that I am doing damage. I may or may not be doing excessive damage, but LEDs will wear even when used within manufacturers specifications, exceeding those specifications will accelerate the damage, there is no question about that. This type of damage is like erosion, it may take a very long time to see any results of the damage. Im also being told that the level of damage is in excess of multiple times the rated value, You may expect to run a part over spec for a small amount of time, but not multiple times the spec, for extended periods of time, like I have been lead to believe. The fact that the parts have shown no signs of wear over extended periods of time suggest to me that the theory that I maybe running LEDs well in excess of 100mA (and the microcontroller many times that, since its running many LEDs at once) is inaccurate. It seems unlikely that the microcontroller or LEDs would sustain that level of overstress, and that is why I am sceptical about your assertions that Im am doing inordinate amounts of damage.

The cubes Im working on do not require high reliability, like they would if they were being used in aerospace, or medical type uses, nor are the in large production, or in any mission critical devices, they are toys and learning tools for hobbyists. If I were, then sample size would be important, and with the same parts I have repeated the results 3 times with the exact same results, however with enough different parts, i might start to see different results.

If the situation were running 400mA through a device rated at 200mA, then you likely expect a catastrophic failure in a short period of time. It would not be the slow erosion type of failure, it would likely be the type of failure where a part is not able to dissipate the heat fast enough, causing thermal overload and catastrophic failure.

Im still unclear on what the current spec really is. Is it 200mA, is it 300mA if you use the right ports, is it 400mA under some conditions? In the case of running 20 LEDs at 20mA, you would likely be using the arduinos ground, but the atmegas vcc, so the real bottleneck seems to be the VCC on the atmega chip. Even thought the voltage regulator wont have a problem delivering the 400mA, the CPU will probably have trouble dissipating the heat. At the very least, its right at the max specs, and the worst, its twice the load that the part is rated for.

In the case of the single color cube, where where it uses upto 320mA at a time, it may be that is just over the 300mA limit, and while it exceeds the limit, its not exceeding the limit by many times, and may just increase the likelyhood of failure. I do think that It has been sourcing (or trying to at least) upto 320mA on each of the 4 plane pins (this does make a lot of assumptions that are unverified though), and that seems way too high (almost 10 times the limit for a single i/o pin.) and I dont see how that could be happening without causing catastrophic failure in a very short period of time (like poof, instant burnout). In retrospect, I have no idea why this thing didnt just smoke, Im pretty sure i was sourcing way too much current on 4 pins. It has been down for a long time, I broke the usb connector on it, and its sort of half repaired. I plan on putting some transistors on the plane pins before I run it again.

In the case of the 64 RGB LED cube, where I am running 192 LEDs from a single microcontroller with and without resistors, Im told that im running the LEDs at 5v, and that is causing them to use a lot more than the expected 20mA. The issue with the LEDs is a non-linear current issue, where a tiny amount of voltage, can make a huge current difference, and one or two volt may increase the current as much 10 times (like 200mA), but only for a fraction of a second. If several LEDs are using hundreds of mA, then the microcontroller (in this case it is using i/o ports for both sinking and sourcing) is also taking many hundreds of mA, well exceeding the 200/300/400 specification. The theory you present is that it is definitely causing damage, but it may not the typical thermal overload type situation, rather a slow erosion type situation due to short duration time.

I have a digital volt meter, and it can measure current, but it cant measure it as fast as the microcontoller and change it (and reverse polarity), so its not very effective for measuring peak current, it just displays a sort of average, or truncated current measurement.

Yesterday, i did measure the current through the cube via 6v battery (4AA), and through a 5v(5.25 technically) power supply. They both used about the same amount of current.

I actually have complete 64 RGB LED setups, 2 are in cube form, one in hat form, all use the same parts, but the interconnections are slightly different. The 2 cubes have been running for over 2 months each, and one of them has never had any resistors, but the other one has been modified a couple times using resistors. I measured the current through the hat setup, it has no resistors, and it measures just over 40mA at startup, then fluxuates between 30 and 40mA.
The cube with resistors has had 2 sized resistors, I started with 100 ohm resistors, but have replaced them with 50 ohm resistors. With the 50 ohm resistors seem to run the cube between 25-30mA. Using 2 100 ohm resistors the cube uses between 30 and 35mA. The resistors make a very noticeable difference in brightness.

These measurements are with a very slow device (relatively speaking), so it is unlikely to show very high readings that are a very short duration (like a couple milliseconds), and we cant trust that these measurements are accurate for such small durations, but can give you a good idea of the overall consumption. You can see that the overall consumption between uncontrolled (no resistors), and overcontrolled (200 ohms) is not more than 50% difference, which means that unresistored is likely well under 200% of the specification, since 200 ohms keeps both the LEDs and the microcontroller well under spec. My guess is using no resistors is not too far over spec, and may not even be over spec.

Because the LEDs are charlieplexed, it means that 2 resistors are always being used when lighting a single LED, and it means I have to use one size resistor for 3 different LEDs and as such, I can not light each LED with the same amount of current.
with 100 ohm resistors, the blue and green and red should be well under 20mA, assuming they are getting 5v. With 5v, the red should need 150 ohms and the blue and green need 100 ohm. When using the 100 ohm resistors, no LED should be getting anywhere near the 20mA current limit. Changing to 2 50 ohm resistors should put the blue and green at their limit, but put the red over its limit.
I've measured the voltage at the Vin, and the 5v on the cubes, and they are way below 5v, in some cases, as low as barely over 4volts. If I assume the LEDs are actually getting 4.5v, then 2 50 ohm resistors puts the red at about 25ma, while the blue and green are under 20mA. That isnt very excessive, but it is just over the assumed specification.

In the case of charlieplexing, you always have 2 diodes in circuit, which means that other diode may be having some effect on the circuit, it maybe that is helping prevent overcurrent.

The other thing that the charlieplexed cube has going for it is the lack of parts, its literally, microcontroller, LED, and wire. Here is a quote from the document that linked:

"Reliable circuit design. As a general rule, simpler designs will be more reliable. Thus there should be a push for simplicity throughout all phases of the design process. The necessity of all parts should be questioned and design simplifications should be employed where available. This can be through circuit design simplifications or by simply using fewer parts. Also, the use of standard components and circuits is always recommended (where a component could be as complex as a microprocessor)."

When I say, I havnt ignored you, I really mean that I havnt ignored you, I have said that I am sceptical, and I have good reason to sceptical.

Since you want to bring up hope over expectation, lets examine the difference between resorting to name calling, and calling someone ignorant, I would say that is measurable improvement, so keep up the good work, maybe one day we can have conversation where I dont have to tolerate such nonsense.

It looks like you put a lot of thought, and effort into your post, and with one tiny exception, you kept to the facts. I expect that was difficult, so I am compelled to thank you for your effort and consideration.

retrolefty:

Im still unclear on what the current spec really is. Is it 200mA, is it 300mA if you use the right ports, is it 400mA under some conditions? In the case of running 20 LEDs at 20mA, you would likely be using the arduinos ground, but the atmegas vcc, so the real bottleneck seems to be the VCC on the atmega chip. Even thought the voltage regulator wont have a problem delivering the 400mA, the CPU will probably have trouble dissipating the heat. At the very least, its right at the max specs, and the worst, its twice the load that the part is rated for.

Well there is some disagreement among some of us members (me and CrossRoads for sure) on what the maximum safe total current consumption for a avr chip is. Others have not really issued an opinion on the matter one way or another, at least where I can find. The datasheet is not all the clear on the following question, at least for two of us members.

So can a AVR mega1280 chip actually have 800 ma flowing through it if loads are carefully balanced between the port/pins or is there a absolute maximum 200 ma chip total current limit?

Lefty

Ok I give up.
You are a lost case.
You obviously know more about reliability of design than I do. I have only made products that they have manufactured half a million of and had the lowest return rate of any product they ever made so what do I know about reliability? You obviously know a lot more. You also know a lot more about the components than the component manufacturer, why not offer them advice?