Go Down

Topic: How many LED's from Mega 2560 (Read 1 time) previous topic - next topic

dcattena

Hi, i'm working on a project where I have to control about 28 LED's from the 5v digital pins. I want to run them all independent of each other and each only are going to draw about 15-20mA.
I'm getting different answers everywhere but if I have an external power source plugged in say 9v 1.7A, will the board be fine with powering all these LED's.

Thanks.

CrossRoads

#1
Feb 27, 2012, 04:36 am Last Edit: Feb 27, 2012, 04:39 am by CrossRoads Reason: 1
Yes.  Make sure that all Vcc, AVcc, and Gnd pins are connected.  The device can handle 800mA that way.

You may have to spread them around a little:

Although each I/O port can sink more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:

ATmega640/1280/2560:
1.)The sum of all IOL, for ports J0-J7, A0-A7, G2 should not exceed 200 mA.
2.)The sum of all IOL, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200 mA.
3.)The sum of all IOL, for ports G3-G4, B0-B7, H0-B7 should not exceed 200 mA.
4.)The sum of all IOL, for ports E0-E7, G5 should not exceed 100 mA.
5.)The sum of all IOL, for ports F0-F7, K0-K7 should not exceed 100 mA.

If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater
than the listed test condition.

4. 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:

ATmega640/1280/2560:
1)The sum of all IOH, for ports J0-J7, G2, A0-A7 should not exceed 200 mA.
2)The sum of all IOH, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200 mA.
3)The sum of all IOH, for ports G3-G4, B0-B7, H0-H7 should not exceed 200 mA.
4)The sum of all IOH, for ports E0-E7, G5 should not exceed 100 mA.
5)The sum of all IOH, for ports F0-F7, K0-K7 should not exceed 100 mA.

If IOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

dcattena

Awesome, thankyou. So just confirming cause ive read this 200mA max everywhere. Is that only for running out of the chip itself but if my source can supply enough its fine?

Sorry im new to all of this.

Thanks again

CrossRoads

200mA for a '328, 800mA for a '2560.

800mA running thru the chip out to (or from) the LEDs.

Remaining current will go to supplying other parts on the board: USB interface, regulators, etc.

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Nick Gammon

Where does it say 800 mA? Page 367 of the datasheet says:

Quote
DC Current VCC and GND Pins: 200.0 mA


That implies to me that no matter what the ranges are for individual pins, you can't put more than 200 mA into the device. Maybe I'm wrong.
http://www.gammon.com.au/electronics

CrossRoads

I read it as 200mA per pin - and there's 4 of each of them, so 800mA total.

Goes with the note below the table:

ATmega640/1280/2560:
1.)The sum of all IOL, for ports J0-J7, A0-A7, G2 should not exceed 200 mA.
2.)The sum of all IOL, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200 mA.
3.)The sum of all IOL, for ports G3-G4, B0-B7, H0-B7 should not exceed 200 mA.
4.)The sum of all IOL, for ports E0-E7, G5 should not exceed 100 mA.
5.)The sum of all IOL, for ports F0-F7, K0-K7 should not exceed 100 mA.

Adds up to 800mA in my book.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Nick Gammon

It doesn't say you can add them. That is:

1. <= 200
2. <= 200
3. <= 200
4. <= 100
5. <= 100

AND don't put more than 200 mA into the chip. :)

I must admit that section looks pretty crazy if you can't add them up, but what does it mean by a maximum of 200 mA into VCC then?

It makes a certain amount of sense. If internally the copper traces can only handle 200 mA, then they are saying that you can't put more than 200 mA into the chip. Then they are saying that each port only handles 200 mA. Well, obviously, if the whole chip can only take 200 mA.

Here's one possible explanation ... MOSFETs can sink a lot more current than is applied on the gate, right? So if the pins are sinking, then they could sink 200 mA per group of pins, because the 200 mA doesn't have to come from Vcc.

But to source it, the current has to come from somewhere, hence the limit of 200 mA. Just a guess, maybe someone else knows more about it.
http://www.gammon.com.au/electronics

dcattena

Ive searched everywhere and no one is entirely sure, arduino's site is pretty vague about it. Ill get the mega tomorrow and ill test it if it blows up at least we have a definitive answer :)

Nick Gammon

The reference schematic for the Mega 2560 shows a MC33269 voltage regulator, which can provide 800 mA of current. So it would appear on the face of it that the designers expected the chip to draw 800 mA.
http://www.gammon.com.au/electronics

CrossRoads

I believe it is as the datasheet says:

"DC Current VCC and GND Pins: 200.0 mA"
There are 4 Vcc pinS, an AVcc pin, and 5 gnd pinS.

Theoretically, the part could thus handle an Amp.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Nick Gammon

http://www.gammon.com.au/electronics

Go Up