Pages: [1]   Go Down
Author Topic: output to transistor  (Read 1089 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an output to a TIP 122 transistor.  Normally I'd but a resistor in before the base of the transistor.  Is this necessary for the current coming from the Arduino output pins?  If it is what's a recommended resistor rating?

Would the same apply to a smaller transistor such as a 2N2222 or something like a relay?

Thanks.

Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, you will need a resistor in series with the base of the transistor. Even for smaller transistors. I would start with 1k and see if it works. If the transistor cannot switch enough current, make the resistor a bit lower. If you give us details of what you're switching with the transistor (esp. current) we can make a more intelligent estimate on this resistor size.

I wouldn't drive a relay directly from an Arduino pin. I'd use a transistor to provide the necessary relay coil current.

http://www.ruggedcircuits.com
Logged

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 5
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is this necessary for the current coming from the Arduino output pins?

Generally speaking: Yes.  The ATMega chip data sheet says that you shouldn't connect anything that tries to draw more than 10 mA.  It does not say that the ATmega safely limits the current to 10 mA.  See Footnote.

Quote
recommended resistor rating

It depends.

The current gain of the TIP122 is something over 1000 if you have a load that wants to draw 1A.  Therefore something like 1 mA of base current will drive it into saturation (which is what you want).

My rule of thumb for this case would be to make the base current something on the order if 0.5 mA - 1 mA.  So I might try a 4.7K Ohm resistor in series with the base.  (Note that if your load draws less than 1A, the resistor can still bd 4.7K, but I might make it something like 10K if the load is 0.5A.)  If the load is more than 1A, I would probably be a little more circumspect in my calculations.

For just about any garden-variety transistor such as the 2N2222, I have found that, with a collector current of a hundred mA or so, the gain will be something more than 100, so, it "just happens" that my target base current would, again, be something on the order of 1 mA.   Then, again, the resistor that I might start with would be something like 4.7K Ohms.

Note that, in spite of the coincidence in these two examples, it is not true that all transistor interfaces will turn out to require 4.7K Ohm base resistors.  You should know the required load current and you should have at least an estimate of the current gain of the transistor at that value of collector current.

Regards,

Dave

Footnote:
Even if it "seems to work" without a base resistor you should know that overstressing I/O voltages and currents can have cumulative bad effects that may shorten the lifetime of your CPU even if it doesn't fail immediately.  Metal migration in the I/O circuitry of the IC will (probably) eventually cause a failure of, at least, that I/O cell, if not the whole chip.
« Last Edit: July 16, 2010, 03:38:56 pm by davekw7x » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks this is helpful.
Logged

Norway
Offline Offline
Sr. Member
****
Karma: 4
Posts: 423
microscopic quantum convulsions of space-time
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
or something like a relay?
An entirely different beast, though you can use a transistors as a similar switch. But a transistor would be required anyway as an intermediary to drive the relay from the arduino. Also don't forget to protect the transistor (though many have built-in protection diodes), and in addition have a protection diode in anti-parallel to the relay, as the coils will produce back emf when switching off. This could damage the transistor and/or the arduino and other circuitry.

Here is a page I always seem to land on when googling this: http://www.kpsec.freeuk.com/trancirc.htm For relays, scroll to the middle of that page. (or click here: http://www.kpsec.freeuk.com/trancirc.htm#relays)
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33372
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The ATMega chip data sheet says that you shouldn't connect anything that tries to draw more than 10 mA.

Where does it say this?

It lists the operating conditions as 20mA and the absolute maximum as 40mA but I have not seen a 10mA figure anywhere. Have I missed something?
Logged

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 5
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Grumpy_Mike
Quote
Have I missed something?

No.  I misspoke.  Sorry.  The 10 mA max source/sink current for any given I/O pin is the maximum recommended for an ATmega operating with Vcc = 3V.   See Footnote. 

Regrets,

Dave

Footnote:
The test conditions are in Table 28.1.  Unless otherwise stated, I consider test conditions to be recommended operating conditions.

The bottom line answer is still the same (obviously, you, Grumpy_Mike, knew this already, but it's what the Original Poster asked about):

You need a resistor between the ATmega output pin and the base of a transistor operating in common emitter mode because there is no internal current limiter inside the microcontroller chip that protects against connection to devices that can draw too much current.

« Last Edit: July 19, 2010, 06:40:15 pm by davekw7x » Logged

Pages: [1]   Go Up
Jump to: