How to calculate the transistor base resistor value to switch a load
Ron Czapala
Posts: 2,418
I have a 12V LED strip that draws 120mA and I want to control it with a BS2 and a NPN transistor (e.g. 2N2222)
How do you calculate the value for the resistor between the transistor base and the BS2 pin?
The load will be connected between the collector and +12V and the emitter will be connected to GND.
I know that since it is not an inductive load, I will not need a diode.
Also, I am not sure what the minimum hFE is from the 2N2222 spec sheet...
How do you calculate the value for the resistor between the transistor base and the BS2 pin?
The load will be connected between the collector and +12V and the emitter will be connected to GND.
I know that since it is not an inductive load, I will not need a diode.
Also, I am not sure what the minimum hFE is from the 2N2222 spec sheet...
Comments
-Phil
Thanks Phil, but where does the 0.7v constant come from?
- Ron
-Phil
Before I got your first reply, I was trying different values. It worked with a 1k resistor but I'm sure it wasn't enough to reach the saturation point. It was only drawing 4mA.
Thanks again.
My preference is to drive the transistor with LESS current in order to run the microcontroller with less stress - lets say that generally means 2-5ma per pin.
But youall are insisting on driving the transistor to saturation (which in theory makes the Rce close to 0 ohms. I presume the idea is that the transistor runs cooler and less overall energy is wasted.
This tends to point back to using Darlington pairs to have the best of both worlds, rather than taxing the micro-controller. Or of course, going over to MOSfets.
I use a 12V lead acid battery to power my motors and I would think a large base resistor would keep things cooler.
http://www.eevblog.com/forum/beginners/transistor-calculations/
Did you need a current limiting resistor to drive the LED strip, to me this is more important than turning "on" a transistor. Almost any resistor at the base of the transistor would be fine as long as a current limiting resistor is installed in series with the 12V LED strip. In fact you don't even need a resistor at the base of the transistor to be using it as a switch - not the best idea, but proves a point.
Also a LED strip cant be an inductive load - unless you are entering the world of calculus and want to know the inductance of the LED strip.
If the LED strip has a current limiting resistor then the base resistor of the transistor is not important. Fully saturated or not the current is limited with the LED strip resistor.
I just cannot seem to see a good reason to drive at 25ma. Am I not understanding something?
Even 15ma is better if saturation is an optimal condition.
@Bits
I see your point of view -- but without any resistor on the base, a thoughtless reconfiguration or a short circuit might damage the micro-controller. By always having 240ohms or more, the micro-controller's individual pin is protected regardless of what happens.
~~~~~~~~~~~~~~~~
I DO indeed understand that the BasicStamp can tolerate 25ma on an individual pin, but if all the pins are in use that would not work as the Port of 8 pins would likely be overloaded (8x25ma=200ma) and it gets even more bizarre with claiming 40ma is reasonable for the Propeller.
So I am trying to determine if driving to saturation is really worthwhile. I believe the 2N2222 has a gain of about hfe =100 in this context. So 3ma X 100hfe = 300ma, but not saturated. Lets say we go to 5ma to drive a bit over 5v/.005a = 1000ohms.
That is what I was wanting to know. The 2n2222 pdf has 150ma at 30V saturated by being driven at 15ma. SEE Switching characteristics.
You're partially right about omitting the base resistor. Consider the following three circuits:
In circuit A, the base current is limited by the same resistor that limits the emitter current, and by the gain of the transistor. The current through the resistor is:
But most of that is collector current, due to the transistor's gain. The portion allocated to the base is approximately:
Incidentally, this is a good circuit to use if you want to control the load current without using an LM317 or transistor/op-amp combo. It's not as accurate, though.
In circuit B (an emitter follower), the same principle applies, except that the base current is further limited by the resistance of the load.
In circuit X (the circuit this thread concerns -- a common emitter configuration), there is nothing in either the base circuit or emitter circuit to limit the base current (i.e. the resistor is no longer in the base-current path). If the base voltage is above 0.7V, the base current is essentially infinite -- or whatever the base driver is able to force through it. This will damage either the transistor, the driver, or both. That's why you need a resistor in the base circuit to limit the base current in this configuration.
-Phil
It did seem to work fine when I used a 1k ohm resistor - the 2n2222 did not get warm and was only drawing 4mA from the BS2.
@Phil,
Thanks for the previous post - it helps to better understand the various circuit configurations.
My steppers got very warm even though I ran them at the rated 12V. I used an 8Ω ceramic resistor which works fine but I think there is a better way.
A nice alternative to the 2N2222 (if you are not going to use a mosfet) is a ZTX1049. It's gain is much higher, typically x400, and it saturates down to less than 50mV with 10mA of base current and 0.5A of collector current. Margin of safety. It is in a thermally enhanced TO92 package that lets it take pulses of current up to 4A.
You can also get a high current gain with a darlington connection. That takes 1 or 2 mA of base current from the Stamp or Prop. The saturation voltage of a Darlington is around 0.7V.
1k
4.1 mA
116.5 mA
270
14.5 mA
117.5 mA
Using the 1k did reduce the LED strip current slightly but dropped the base current by 10 mA.
That could really help limiting the load on a BS2 pin bank...
Many older circuits that used darlingtons on heatsinks to get enough current gain can be replaced by a much smaller modern device such as a superbeta switching transistor or a MOSFET. The ZTX1049 is a nice example there, and my favorite is the ZTX851, 5A contin, 20A peak, 50mV at 1A, all in a tiny e-line package... And unlike power MOSFETs you don't have to worry about being logic-level!
Thanks, now that I see the drawings, placing the resistor does certainly seem an issue on restricting current to the base
And for the power hungry,
Here is a nice TO-92 packaged Darlington to go beyond the 2n2222
NPN 2N5308 hfe = 7000 to 20000
Not sure about a PNP mate
Power output is about 50% higher than the 2n2222 , but using in similar power situations these will bring the micro-controller into being able to drive power on lots of pins at the same time.
One could go to the TIP120 and TIP125, but those T0-220 packages are too big - even without heat sinks.
The idea here is to use saturation to gain speed and not to heat the package until it glows.
@Tracy Allen
I always am at a loss to the fact that transistors just don't fall in line with the specification parameters. But you are right, they are sloppy little devils and I hope these Darlingtons will offer some head room for people that want to have a design where EVERYTHING runs cool.
I've just realized there are two ways to optimize the choice of base current: you can choose the base drive where further increases in base current cause a smaller increase in collector current (dynamic gain below 1). Driving any harder is "throwing good money after bad" perhaps.
You could also (and more logically) choose the base current where the total losses in the base resistor and the transistor are a minimum. You need the graph of saturation voltage against collector and base currents for that. By minimum I mean the local minimum when the transistor is on (the true minimum is with it switched off of course).
What if I use a transistor to turn on a relay?
Transistors and MOSfets generally switch DC in power switching.
Relays are quite handy for 120VAC and 240VAC at 12amps or more. Relays may be noisy and may create voltage spikes, but they can provide complex switching logic with DPDT or other mechanical configurations. For example -- One DPDT relay can work as the equivalent of an H-bridge.
Power transistors just get too hot and may actually have thermal runaway. Relays are generally running cool - no heat sinks required. This may be an excellent reason for use on a vehicle or in a robot.
And yes, I would use a transistor to turn on a relay.
I posted a Darlington in a TO-92 as an alternative to a Beta-transistor. Even at saturation, the Darlington will still have a .7V drop across CE due to the pair. It really isn't that great if you are switching 5-6volts. A saturated Beta-transistor might be better. The main point is that we all have to deal with what is available and what is absurdly costly. There is no one right answer.
In many contexts, a micro-controller may actually do very little power switching, but a lot of communications and sensing. In such situations, relays are a very good alternative and there are a lot of high amperage 12VDC relays that were created for the automotive industry that have proven durability in hostel environments with extreme temperature ranges. Why bother building something that is elegant, but not robust?
-Phil
I believe that triacs have difficulties with inductive loads. Am I correct?
Admittedly, solid-state just keeps getting better and better - but when you are trying to handle 30amps of 240AC, the heat sink for a solid-state relay is rather large and the mechanical relay is relatively small.
Also, pitting in relays is more of a problem with DC as all the metal migrates in only one direction. With AC, the metal actually travels back and forth and with good engineering seems to last quite long.
And I personally have yet to see a solid-state replacement for a starter solenoid. Do they really make such beasts? They need to switch 80 or more amps.
No.
A snubber is required across the TRIAC (MT1 to MT2), unless it's a "snubberless" TRIAC.