safe source current for I/O pin on mega128

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I did a search and coudln't find anything..

so i'm using a port on my mega 128 to turn on BJTs to run some leds..

a total of 8 to be exact.. and the 8 BJT bases are connected to all the pins on port C..

anyway.. i have it set up so that at most 5mA of current will flow out of each output pin to turn on a BJT..

is that asafe current to source form the I/O pins?? this would maka a total of 40mA being sourced from one port..

thanks..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The data sheet knows all, tells all.... well at least as far as you can go without an engineer from ATMEL personally guiding you :wink:. Look at the latest 2467N–AVR–03/06 ATmega128 data sheet page 323 DC Characteristics table. Notes 3 and 4 under this table give you the sink and source current limits for combinations of port pins.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

RancidWannaRiot wrote:
Hello,

I did a search and coudln't find anything..

so i'm using a port on my mega 128 to turn on BJTs to run some leds..

a total of 8 to be exact.. and the 8 BJT bases are connected to all the pins on port C..

anyway.. i have it set up so that at most 5mA of current will flow out of each output pin to turn on a BJT..

is that asafe current to source form the I/O pins?? this would maka a total of 40mA being sourced from one port..

thanks..

oh it's in the notes lol.. i looked all over that datasheet and didn't look at the notes... thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

RancidWannaRiot wrote:
Hello,

I did a search and coudln't find anything..

so i'm using a port on my mega 128 to turn on BJTs to run some leds..

a total of 8 to be exact.. and the 8 BJT bases are connected to all the pins on port C..

anyway.. i have it set up so that at most 5mA of current will flow out of each output pin to turn on a BJT..

is that asafe current to source form the I/O pins?? this would maka a total of 40mA being sourced from one port..

thanks..

Quick answer: If you are just driving the LEDs, you can ditch the BJTs and drive the leds with 5mA per LED directly with AVR pins. This should be bright enough for normal applications, but if more current is needed, read on.

For other loads, see long answer here:

The information still exists in the datasheets. You need to just look it for awhile, this parameter is called something like IOH current, Current when output is high.

First of all there is a limit which says how much current you can put through one single IO pin. This is around 20..30mA.

Then there is a limit how much current you can put through a combination of IO pins, for example, there might be a total limit of 80mA for PORTB pins(this limits 8 pins for 10mA use), or maybe a limit of 100mA for a combination of ports like PORTB and PORTC together (this limits 16 pins for 6mA use).

Then there is a limit how much current you can feed through the power supply pins, which migh be around 200mA, so this limits that you cannot for example draw more than 10mA from 20 IO pins.

You need to find all this before you can say whether the AVR will be happy about conditions or not.

But take into account that 5mA of base current to a transistor with a hfe (beta) of around 100 will allow 500mA of collector current, so if you are controlling loads less than this, you can limit the base current to around 1mA, my choise for a base resistor in 5V systems is usually 4.7Kohm or 10 Kohms, with a 10Kohm pull-down from base to GND so that the transistor will be cut off in situations like booting etc.

Then again, why not use FETs, as they draw zero current (except when turning on/off, so give it a 10 to 100 ohm gate resistor), and can control even 1A loads very nicely.

- Jani