Go Down

Topic: output to transistor (Read 1 time) previous topic - next topic

Lubby

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.


RuggedCircuits

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

davekw7x

#2
Jul 16, 2010, 10:22 pm Last Edit: Jul 16, 2010, 10:38 pm by davekw7x Reason: 1
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.

Lubby


raron

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)

Grumpy_Mike

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?

davekw7x

#6
Jul 19, 2010, 03:44 pm Last Edit: Jul 20, 2010, 01:40 am by davekw7x Reason: 1
@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.


Go Up