V-I characteristics of AVR micro outputs? Current limiting?

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
terryking
 
Posts: 5
Joined: Sun Oct 24, 2010 1:25 am

V-I characteristics of AVR micro outputs? Current limiting?

Post by terryking »

Hi Everyone,

In the last Ask An Engineer, Lady Ada said that microcomputer output pins are current-limited and will not normally be damaged by a short to ground etc.

That was my experience years ago with TTL and CMOS chips in Parallel Printer Ports. If you put an LED from output to ground they current-limited at about 40 Ma and 2.2 volts. I used this "blasphemous" method for many projects with kids in school with old IBM PC's used for making "Machines" that did stuff. (http://terryking.us/parport) . I KNOW this "Violated the Spec" on these chips but I never had one fail in 100's of applications, and lots of people did this all over the world and never complained. (Except about "The Spec" !)..

I would like to be able to do similar "simple" stuff with Arduino.

What would be Really nice would be a V-I curve for AVR (Arduino) outputs. Then we could actually "Engineer" stuff..

Lady, can you point us to information on this???

Thanks!

Regards, Terry King ..On the Red Sea at KAUST.edu.sa
[email protected]
Newsletter: http://redseanews.info Community Information: http://redseainfo.info

User avatar
richms
 
Posts: 558
Joined: Tue Jan 20, 2009 3:05 am

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by richms »

It changes substantially depending how many pins you are abusing that way.

Even limiting to 20mA you will see some voltage drop on one pin when another few are asked to source 20mA

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by opossum »

There has been constant misinformation here about AVR output current.

FALSE: "AVR outputs are current limited"
TRUE: "AVR outputs can reliably supply a limited current"

There is a huge difference between these statements. There is limited current available for a given amount of droop. This characteristic can be exploited for current limiting in some specific cases. For example yellow LED with a Vf of 2.1 @ 20 mA driven by an AVR with Vcc of 3.0 V. The output droop will limit current to 20 mA when shunted by the 2.1 Vf of the LED. That would be reasonable design - not abusive. It is good practice to consider output droop when calculating current limiting resistor values.

FALSE: "An AVR output can supply 40 mA"
TRUE: "The absolute max current for a single output is 40 mA, total per port is 100 mA absolute max (typical), total for all outputs is 200 mA absolute max (typical)"

There is a huge difference between these statements too. The absolute max should be avoided - it is dangerous to approach it. A reasonable answer would be 5 mA with less that 500 mV droop from all pins concurrently and constantly.

The V/I curve is important when more than a small output current is needed. It is usually in the Electrical Specification section of the data sheet. Note that it changes with Vcc. It is not the same for all AVR.

Image

User avatar
terryking
 
Posts: 5
Joined: Sun Oct 24, 2010 1:25 am

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by terryking »

Hi oPossum,

Thanks for the information. I'll dig into the ATMEGA328 spec. I think we should try to develop some specific guidelines for people actually connecting wires to Arduinos. I was glad to see the Uno keep the DIP package and socket! More dissipation, more forgiving..

The 'official' Arduino "Hardware" section says things like (quotes):

- DC Current per I/O Pin 40 mA
- Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms.

Hopefully we could contribute some practical guidelines based on a clearer interpretation of the Spec..

Be back after finding my reading glasses :-)

Regards, Terry King

User avatar
terryking
 
Posts: 5
Joined: Sun Oct 24, 2010 1:25 am

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by terryking »

Hmmm. I didn't find those curves in the Spec. I have... I also did not find a reference to the "Per Port" maximums, although I know I've read something about it somewhere?? Can you / someone point to that??

Extracted from the AVR Spec as pointed to by Arduino:
---------------------( COPY )--------------------------
Each output buffer has symmetrical drive characteristics with both high sink and source
capability. The pin driver is strong enough to drive LED displays directly.

Absolute Maximum Ratings*

Stresses beyond those listed under “Absolute Maximum Ratings” may cause permanent damage
to the device. Exposure to absolute maximum rating conditions for extended periods may affect
device reliability.

DC Current per I/O Pin ..................................... 40.0 mA
DC Current VCC and GND Pins................................ 200.0 mA

Output Low Voltage(3) except RESET pin
IOL = 20 mA, VCC = 5V 0.9
IOL = 10 mA, VCC = 3V 0.6

Output High Voltage(4)
IOH = -20 mA, VCC = 5V 4.2
IOH = -10 mA, VCC = 3V 2.3
-----------------( END COPY )----------------------

How about "The pin driver is strong enough to drive LED displays directly." THAT could be misinterpreted by someone pretty easily!

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by opossum »

Get the ATmega 48/88/168/328 spec sheet directly from Atmel web site. It's all in there in chapter 28 Electrical Characteristics and chapter 29 Typical Characteristics.

I updated my previous post with the 328 source curves.

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by opossum »

terryking wrote: How about "The pin driver is strong enough to drive LED displays directly." THAT could be misinterpreted by someone pretty easily!
Yes! It does not mean no current limiting resistor is needed. It means that you can get 5 to 20 mA from each pin without additional circuitry ("directly") and that is enough for an LED. Some means of limiting current to safe levels is still required!

User avatar
terryking
 
Posts: 5
Joined: Sun Oct 24, 2010 1:25 am

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by terryking »

oPossum wrote:Get the ATmega 48/88/168/328 spec sheet directly from Atmel web site. .
Now THAT's a Spec. Funny how there's another spec document that doesn't say it's incomplete.

OK, the spec information is clear, then, for Digital Output pins up to 20 ma. There is no information on characteristics from 20 to 40 ma.
Since the reality is that there's a fet device turned on well, with a fairly constant On resistance, the curves probably extrapolate reasonable well.

The 328 has about .5 volts droop in both source and sink at 20ma. That means the R on is about 25 ohms.

It probably would have about 1.0 volts droop at 40ma. I'll test that soon.. BUT it would probably source or sink about 200ma in a short-circuit condition. That's about 1 watt in the output circuit area for the pin, and that sounds, technically speaking, Real Bad!

oPossum, I could not find any reference to a PER PORT maximum current in the spec, with quite a few searches. Can you point to that anywhere? I know I heard about it somewhere... The Spec. says maximum Vcc and Ground chip current is 200ma. So 10 pins at 20ma is at max that way. But that's still not a lot of power dissipation in the chip: each output pin drops .5V at 20ma so there's only 10 milliwatts dissipated on chip per pin.

I found this discussion on the Arduino Forum, which is related, but not cookbook!:
http://www.arduino.cc/cgi-bin/yabb2/YaB ... 902243/all

ANYWAY, the only reason I care: Let's try to get some consensus on what Arduino users should to told about acceptable output pin currents. The 40ma the Arduino website talks about is a problem, and there's no mention of total current.

I just found another discussion here:
http://www.arduino.cc/cgi-bin/yabb2/YaB ... 7338756/12
which interestingly has some earlier Atmel spec that shows the V-I characteristics in the "Beyond the absolute maximum" zone! The curves are fairly linear out to 2 volts internal drop and 70ma or so.

This all implies that if you connected a LED display that had 3.0 volts drop at 40ma and you connected it between two output pins, one of which was source and the other sink, AND you ran about 50% duty cycle, you'd have 1.0 volts drop in both source and sink, and a peak current of 40 ma and an average current of 20ma. Maybe that's skirting the edge of workability???

Any-ANYWAY, I also sent a note into Atmel and maybe we can all collaborate on language for the Arduino site that will keep users from getting into trouble..

Thanks for listening, if you're still awake :-)

User avatar
opossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by opossum »

Do you have a link to the other spec sheet? I would like to take a look at it.

The per port limits are in the notes after table 28-1. It is not strictly per port, more like per group.

A reasonable general spec would be 5 mA per pin. Anything more should be done within per port and per chip limits as specified in the ATmega328 spec sheet from Atmel.

I think there would be opposition to a 5 mA recommend limit because so may people have "successfully" abused the specs with "no problems."

User avatar
westfw
 
Posts: 2010
Joined: Fri Apr 27, 2007 1:01 pm

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by westfw »

Let's try to get some consensus on what Arduino users should to told about acceptable output pin currents. The 40ma the Arduino website talks about is a problem, and there's no mention of total current.
I think the current recommendations are working fine, actually... "Use a resistor for LED and never connect anything that uses more than 40mA."

The actual details are complicated, especially for the Arduino Audience (for example, part of the 20mA vs 40mA distinction is whether you can tolerate a voltage drop that takes you out of logic-level limits, which may not be a problem for the higher-current devices connected.) If you want to be more creative, delve into the actual chip datasheet and/or experiment and/or take your chances.

We haven't mentioned USB limits, or the power dissipation limits of the Arduino voltage regulator AS CONFIGURED on the board (and dependent on input voltage), either...

User avatar
terryking
 
Posts: 5
Joined: Sun Oct 24, 2010 1:25 am

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by terryking »

westfw wrote:I think the current recommendations are working fine, actually... "Use a resistor for LED and never connect anything that uses more than 40mA."
Thanks, westfw...

I think a lot of beginning Arduino users look at the Uno first page (I did).. and go with "40ma is OK". It takes quite a bit of digging to find any specific recommendations (thus the several lengthy discussions about this).

Since Arduino is aimed largely at Non-Engineers, I feel that the first things users see should point to a simple set of "don't get in trouble" recommendations. I hope to hear from an applications engineer at Atmel soon; maybe that will lend some light.

Meanwhile, IF the recommendation was something like "a 220 ohm resistor from the output port to most devices is safe and will protect the Arduino from damage if a short to ground or 5 volts happens". That would put 22ma in/out with a 'short", about 15ma into most LEDs, and about 20ma into into the base of a NPN low side or PNP high side switching transistor - plenty to switch 1 A.

Let's see what we hear. Then there's the question of wether the Arduino establishment wants to add anything like this...

User avatar
len17
 
Posts: 394
Joined: Sat Mar 14, 2009 7:20 pm

Re: V-I characteristics of AVR micro outputs? Current limiting?

Post by len17 »

oPossum wrote:Do you have a link to the other spec sheet? I would like to take a look at it.
This page: http://www.atmel.com/dyn/products/produ ... rt_id=4198
has links to two datasheets - one has 33 pages, the other has 566 pages.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”