+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 20 of 30

Thread: How to calculate the transistor base resistor value to switch a load

  1. #1

    Default How to calculate the transistor base resistor value to switch a load

    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...

  2. #2

    Default Re: How to calculate the transistor base resistor value to switch a load

    The minimum current gain for a PN2222 driving a 150mA is around 100. So the base current in your case has to be at least 120mA/100 = 1.2mA. You're not going to be operating it in its linear region, though, but in saturation. So, in order to keep VCE(sat) as low as possible, you should drive the base a lot harder than that, say, at 15mA. For a BS2, that would equate to a 270-ohm base resistor: (5 - 0.7)/.015 == 286.

    -Phil

  3. #3

    Default Re: How to calculate the transistor base resistor value to switch a load

    Quote Originally Posted by Phil Pilgrim (PhiPi) View Post
    The minimum current gain for a PN2222 driving a 150mA is around 100. So the base current in your case has to be at least 120mA/100 = 1.2mA. You're not going to be operating it in its linear region, though, but in saturation. So, in order to keep VCE(sat) as low as possible, you should drive the base a lot harder than that, say, at 15mA. For a BS2, that would equate to a 270-ohm base resistor: (5 - 0.7)/.015 == 286.

    -Phil
    Thanks Phil, but where does the 0.7v constant come from?

    - Ron

  4. #4

    Default Re: How to calculate the transistor base resistor value to switch a load

    0.7V is the base-emitter voltage.

    -Phil

  5. #5

    Default Re: How to calculate the transistor base resistor value to switch a load

    Works great!
    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.

  6. #6

    Default Re: How to calculate the transistor base resistor value to switch a load

    With GP 2N2222-ish switching transistors, I always grab the first 220 or 330 ohm resistor I find. Conveniently, BS2 HW boards have 220 ohm resistors on all the IO pins, and that's close enough for me. No additional resistor necessary.

  7. #7

    Default Re: How to calculate the transistor base resistor value to switch a load

    Okay, I am now wondering more about saturation. Do we really need it or not?

    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.
    Hwang Xian Sheng
    Kaohsiung/Gaoxiung
    Taiwan/Formosa
    R.O.C/Province of China, P.R.C.

    "My comments are independent... and at times just plain wrong. At other times, they just might be helpful. So consider the source."

  8. #8

    Default Re: How to calculate the transistor base resistor value to switch a load

    @Phil Pilgrim. What is Vce(sat)? 15mA / 1.2mA = 12.5! That's a big difference.
    I use a 12V lead acid battery to power my motors and I would think a large base resistor would keep things cooler.
    Larry

    If the grass is greener on the other side...it's time to water your lawn.

  9. #9

    Default Re: How to calculate the transistor base resistor value to switch a load

    There is currently a very similar discussion going on at eevblog.com

    http://www.eevblog.com/forum/beginne...-calculations/
    - Rick

  10. #10

    Default Re: How to calculate the transistor base resistor value to switch a load

    Quote Originally Posted by Ron Czapala View Post
    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...
    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.
    I would love to change the world, but they won't give me the source code!


  11. #11

    Default Re: How to calculate the transistor base resistor value to switch a load

    You need to limit the current both at the collector and at the base. Most likely the 12V LED strip has its own current limiter since (I assume) it's supposed to be able to be connected directly to a 12V power supply. The base of the transistor needs a current limiting resistor since the base-emitter junction appears mostly like a (forward biased) diode which will conduct any amount of current available once the voltage goes over about 0.7V. I believe a BS2 I/O pin can supply about 25mA and more than that starts to cause thermal stress and other problems if continued. A 2N2222's base can pull way more than that if you don't limit the current with a base resistor.

  12. #12

    Default Re: How to calculate the transistor base resistor value to switch a load

    I respectfully disagree with you and here is why.

    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 would love to change the world, but they won't give me the source code!


  13. #13

    Default Re: How to calculate the transistor base resistor value to switch a load

    The problem really has little to do with the LED strip and would exist even if the 2N2222 collector were not connected. It has to do with the Stamp output driving essentially a silicon diode that can easily draw over 50mA once the forward voltage (0.7V) is passed. The Stamp (PIC) I/O pin output structures are rated for an absolute maximum current of 25mA. They don't specify what will happen if you draw more than that, but there's a variety of damage that will occur. It's possible to design I/O pin output structures that can self-limit output current and survive a short circuit indefinitely. The Propeller's I/O pin circuitry is one example of that, but the PIC used in the BS2 doesn't do it. If you short-circuit a Stamp I/O output pin for any length of time (seconds), it will be damaged.

  14. #14

    Default Re: How to calculate the transistor base resistor value to switch a load

    @Phil
    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.
    Hwang Xian Sheng
    Kaohsiung/Gaoxiung
    Taiwan/Formosa
    R.O.C/Province of China, P.R.C.

    "My comments are independent... and at times just plain wrong. At other times, they just might be helpful. So consider the source."

  15. #15

    Default Re: How to calculate the transistor base resistor value to switch a load

    Saturation is the condition where Vce is at a minimum and any further increases in base current would have no effect. The transistor's power dissipation is mostly determined by Vce and Ic. If you're happy with the voltage drop across the transistor and the power dissipation is easily handled, there's no need to drive the transistor into saturation. For switching, it's the most efficient to just barely drive the transistor into saturation. There's less heating of the transistor and you get the widest voltage swings on the output.

  16. #16

    Default Re: How to calculate the transistor base resistor value to switch a load

    [QUOTE=There's less heating of the transistor and you get the widest voltage swings on the output.[/QUOTE]

    That is what I was wanting to know. The 2n2222 pdf has 150ma at 30V saturated by being driven at 15ma. SEE Switching characteristics.
    Last edited by Loopy Byteloose; 07-10-2012 at 04:24 PM.
    Hwang Xian Sheng
    Kaohsiung/Gaoxiung
    Taiwan/Formosa
    R.O.C/Province of China, P.R.C.

    "My comments are independent... and at times just plain wrong. At other times, they just might be helpful. So consider the source."

  17. #17

    Default Re: How to calculate the transistor base resistor value to switch a load

    Bits,

    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:
    IC = (VB - 0.7) / R
    But most of that is collector current, due to the transistor's gain. The portion allocated to the base is approximately:
    IB ~ (VB - 0.7) / (R * hFE)
    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
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	npn_drivers_abx.gif‎
Views:	11085
Size:	2.7 KB
ID:	94099  

  18. #18

    Default Re: How to calculate the transistor base resistor value to switch a load

    The LED strip was designed to be powered directly from a 12V source - it has 18 blue LEDs and several resistors along it's length.

    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.
    Last edited by Ron Czapala; 07-10-2012 at 05:02 PM.

  19. #19

    Default Re: How to calculate the transistor base resistor value to switch a load

    @Mike Green. Thanks for the explanation of Vce. It'll help me design a better circuit next time.
    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.
    Larry

    If the grass is greener on the other side...it's time to water your lawn.

  20. #20

    Default Re: How to calculate the transistor base resistor value to switch a load

    A bipolar transistor officially enters saturation at the point where its collector-emitter voltage drops below the base-emitter voltage. It is not a sharp transition. The gain of the transistor falls steadily as it approaches and enters saturation. The gain of a bipolar transistor is not well-controlled in manufacturing. So if you go through a handful of 2N2222s, you will find a few that require much less base current to be fully saturated, and also a few that have to be pushed really hard. For a one-off, you at liberty to select the best one.

    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.

+ Reply to Thread

Similar Threads

  1. Transistor Base Resistor
    By geneshults in forum General Discussion
    Replies: 6
    Last Post: 11-08-2011, 12:43 AM
  2. Transistor base current?
    By dev/null in forum General Discussion
    Replies: 10
    Last Post: 08-21-2009, 12:09 AM
  3. Terminology question, no load capacitor and no load resistor
    By Timothy D. Swieter in forum General Discussion
    Replies: 5
    Last Post: 03-26-2008, 09:59 PM
  4. Resistor with a Transistor
    By Joe Fishback in forum BASIC Stamp
    Replies: 4
    Last Post: 09-02-2006, 08:42 AM
  5. Replies: 2
    Last Post: 06-27-2006, 12:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts