# Calculated vs Rated Currents in Designing Transistor Switch Circuits

I am designing a circuit that drives a relay. I control the behavior of this circuit by using a BJT transistor that receives a DC signal from a micro controller.

Here is my schematic:

simulate this circuit – Schematic created using CircuitLab

So, I did the schematic and I want to predict current values such as Ic and Ib. Note that I want the transistor to operate in the saturation mode.

My questions that I need help with:

1- From where do I begin? Do I begin with Ic and then I go find Ib? or the opposite? or with Vce(sat)? or with the gain? Indeed, I chose to begin with Ic but I wanted to convince my self of my choice. Like why not Ib? Anyways, I am forced with one value of Ic, which is the coil current. It is 16.67 mA.

2- If I begin with Ic, and then I find Ib, I will face a potential contradiction. If the microcontroller is supplying 40 mA, would not that be Ib? So, why would I need to calculate Ib from Ic if I know it already? Note that my gain is roughly 100 given that my Vce(sat) is around .1 volts.

So, here is my main big question: which to choose, the rated current (40 mA) or the calculated one (.1 mA) for Ib?

3- I can ask a similar question if I would begin my analysis to with Ib. Which to choose for Ic? the rated (16.67 mA) or the calculated (4 A)*?

• Although 4 A will destroy my coil and therefore it is impossible for it to be chosen, which in turn leaves no basis for me to ask the question in the first place, [for the sake of "knowing more"]let us look at the Rated vs Calculated concern as a theoretical question without worrying about the practical sense of it.

4- If I am supposed to choose the calculated Ib, what is the advantage of knowing that the microcontroller is supplying 40 mA and how would this affect the value of the Rb (R1 in the schematic)?

Update: Relay datasheet is this

• Starting with the relay; you say it is rated at 16.67mA, but at what voltage? We need that information too. Also, please post a link to the relay's datasheet. It is important to realise that at the relay's rated operating voltage, it will only consume it's rated current; at its rated voltage, it doesn't matter if more current is available, the relay won't consume (allow it to flow) more. So the transistor must allow more than 16.67mA to flow through the relay. – gbulmer Sep 8 '16 at 20:44
• It is 12 volts rated. I updated my post with the datasheet. – Gold_Sky Sep 8 '16 at 20:54
• Note that the coil current for a single-pole relay is 16.7 mA, while a double-pole relay wants 25 mA. – Peter Bennett Sep 8 '16 at 23:23
• A microcontroller output supplies a voltage, not a current. – pipe Sep 9 '16 at 6:59
• @pipe then what does the 40mA have to do anyways in the microcontroller datasheet? – Gold_Sky Sep 9 '16 at 21:32

You are somewhat confused about currents, I think. Setting a value for $I_B$ doesn't force $I_C$ to a particular value. And you can't force a value of $I_C$ without supplying sufficient $I_B$ to allow it.

There is a big difference where the ratio between the two, $\beta= I_C/I_B$, that starts to happen when the voltage at the collector (for an NPN) dips below the voltage at the base. This is the start of saturation and you will start to have to supply not only the usual base current then but also some current to the newly forward-biased $V_{BC}$ junction. When you are operating a BJT as a switch, you are almost always making the choice that it is operated in saturation -- usually pretty deep saturation. I think it may help you to dig a little deeper into this behavior.

Let's start out imagining that you have set up your relay just as you have in your circuit, but you set $R_1=\infty\Omega$. Well, that's pretty much what it looks like if you don't even connect it up to the base. No current can flow into the base. With no current in the base, no current can flow from the collector to the emitter. Which means, in effect, that the resistance from the collector to the emitter is also infinite. This means that both sides of your relay are at $12V$, so it doesn't have any voltage across it. So it stays off.

Now imagine that $R_1$ becomes some finite value. If you assume that the base-emitter voltage is forward biased and is about $700mV$ across it, then the rest is what appears across $R_1$. If you are using a $5V$ output for $V_2$, then about $4.3V$ appears across $R_1$ and this allows a tiny current to flow, $I_B\approx 4.3V/R_1$. Without getting into bizarre, low current areas of a BJT, the collector current is now allowed to be about $\beta$ times as much. And for a small signal device, this is almost always $\beta\ge 100$. So now (ignoring inductance issues), that much current is allowed.

However, that doesn't mean that it works out that way.

Your relay spec says it is $720\Omega$. Suppose also that $R_1=68k\Omega$. Suppose the transistor's active mode $beta\approx 150$, too. (Not used as a switch here, for now.) Then $I_B\approx 63\mu A$ and $I_C\approx 150\times 63\mu A\approx 9.5mA$. So, now the coil experiences this current and drops $720\Omega\times 9.5mA\approx 6.8V$ across it. This means that the bottom end of your relay will be $12V - 6.8V\approx 5.2V$. Note that your relay does not have the proper voltage across it, which must be at least 70% of $12V$ or about $8.4V$ in order to latch it.

Now, also because the collector is at $5.2V$, as well, it is higher than the base voltage and so you may actually experience $\beta\approx 150$. Or you have reason to believe so.

But you want to operate this as a switch! You want $12V$ across your relay -- or at least $9V$. How do you do this? By permitting more current for your collector. But this means you need to supply more base current, which means a smaller value for $R_1$. The value of $\beta\approx 150$ will work okay, so long as the collector stays above the base. After that? All bets are off and the value of $\beta$ will be in rapid decline.

What causes the collector to go lower than the base?? Did you notice that it is the collector current and the load?? In short, this isn't a property only of the BJT itself. But it is a property that arises from the BJT and its surrounding circuit, too. Suppose your relay had been $2k\Omega$ instead of $720\Omega$. Then the voltage drop across the relay, using $R_1=68k\Omega$ for the base, might have been $9.5mA\times 2k\Omega =19V$! This is more than your power supply there! Since that isn't actually possible, what happens is that the collector current cannot reach that much and instead will probably reduce itself to about the most it can achieve, or about $6mA$. Now, your base current will still be the same, or $63\mu A$. That's not going to change, because that's what the combination of $R_1$ and the transistor's $V_{BE}$ determines. So, as you can see, $\beta=6mA/63\mu A\approx 95$. It's already shrunk.

In practice, though, the collector will never quite reach the emitter's voltage. It will always be somewhat higher (in an NPN), no matter how much current you sock into the base. It can only lower itself just so far.

So this is why you often see an estimate of $\beta=10$ when used as a switch. This is often pretty pessimistic. But if you have to draw a hard line in the sand, then the number $10$ is pretty safe to use.

Enough about BJTs for now. Your relay?

It's an inductor. In this case, $L=1.2H$. This means that with $12V$ across it (assuming the BJT works as a perfect switch), the fastest you can expect to see it turned on to its full current level would be $\Delta t = \frac{\Delta I\times L}{V}=\frac{16.7mA\times 1.2H}{12V}=1.67ms$. This ignores the substantial resistance, which will further delay things. (By the way, the time constant for the relay is $\tau = \frac{L}{R}=\frac{1.2H}{720\Omega}\approx 1.67ms$. Coincidence? Probably not. Chances are this is by good design principles.) In general, you can assume it will take several of these periods before the current reaches the nominal value stated. So on the order of say $5-10ms$. (The release time will be much worse, because you only have a simple diode for the reverse time, which presents only a tiny voltage across the relay coil.)

At this point, you may better understand things. To start out, you take note of the relay current and you assume that you will supply enough base current that the collector current will rise to its maximum (which is determined by the relay's load resistance divided into the supply voltage you are applying to the relay.) You will need about one tenth that much for the base. Knowing that, you compute the base resistor sufficient to drop enough voltage between the control voltage and the expected base voltage of the BJT. That's about it.

So, if your control voltage is $5V$ and your base voltage is taken as $700mV$, and your relay current is supposed to be about $16-17mA$, then your base current needs to be about $1.6-1.7mA$ and you compute the resistor value as $R_1 = \frac{5V-0.7V}{1.7mA}\approx 2.5k\Omega$. A nearby value is either $2.2k\Omega$ or $2.7k\Omega$. Both will work okay. Note that Glen_geek also got about to the same place (in a LOT less time!)

NOTE ABOUT BETA: Beta is just a ratio which turns out to be relatively flat over some range of current densities in a BJT and also only when the BJT is being used in its non-saturated, active region (or reverse-active.) When a BJT is used as a switch, you instead want the collector to be pushed as close as possible to its emitter. Often, you can get this value, called $V_{CE}$, to be less than $200mV$. Which is taken to be a reasonable approximation of a switch (good enough for "horse shoes," as they used to say.) But this also means that $V_{BC}$ must now be forward biased, too. To see this, pick any voltage value for the emitter -- just make up a value. Let's say $V_E=+15V$ just to be annoying for a moment. Now, we need the NPN BJT to be forward biased, so we know that the base must be about $+700mV$ higher still. So $V_B=+15V+700mV=+15.7V$. But we are operating this as a switch, which hopefully (if we are doing it right -- yet to be seen) means that $V_{CE} \le 200mV$. So this means that $V_C \le +15.2V$. Note that $V_C < V_B$. Now we get to another important point. There is another diode in there. It used to be shown on the early transistor schematic drawings because the early transistors were actually symmetrical in their manufacture and behavior. That's long gone now. But there is a diode pointing from the base to the collector, as well. This diode is now forward biased, if the transistor is being operated as a switch. And this forward diode has a LOT of current flowing in it, too. Not as much as is flowing from base to emitter. But there is still a lot of current flowing from base to collector, now. Enough to severely ruin the value of $\beta$. In order to get a switch behavior out of the BJT, you have to assume that this other diode is also forward biased and also sucking current from the base. It doesn't help improve the collector current, though. This is because the collector is only changing its value by a few hundred millivolts no matter how much base current is applied to power both of those forward biased diodes. So you can't really do much to squeeze $V_{CE}$ any smaller, which means you can't really do much to increase the remaining voltage across whatever is attached to the collector, either. And that is the only way you could increase the collector current. So you can increase the base current, which supports supplying the base-collector diode with additional current which allows the collector to squeeze a little closer to the emitter, but it does all this without really increasing the collector current much. But the base current just keeps on increasing as much as you want it to do.

It turns out (and you can look at the datasheets where they show you all this info) that it is common practice (not required, if you know what you are wanting to do) to estimate $\beta=10$ as a sufficiently bad value that yields as sufficiently good (small) value of $V_{CE}$.

I probably should have worded all that better. But I don't have a lot of time right now to do that. If you have more questions, I'll see about fixing up my wording a bit.

• The thing that I did not understand, for now, is why a gain of 10 is safer than a gain of 100? I know that 10 does the job but why is it safer? – Gold_Sky Sep 9 '16 at 22:41
• @Gold_Sky: I'll add a comment at the bottom of what I wrote. Look for it soon. – jonk Sep 9 '16 at 22:44

OK, your relay coil is a very thin long wire having 720 ohms resistance. When the switching transistor is ON, 16.7 mA current flows through the coil, then through this saturated transistor, and back to the 12v supply. So Ic=16.7mA This is where we start.

On some 2N2222 data sheets, a graph of Vce(sat) vs. Ic is shown. On most of these type graphs, base current is set to one-tenth of Ic. Although the transistor has much higher current gain (perhaps 200), the base is over-driven to ensure that the transistor switch is unambiguously ON. If you follow this rule-of-ten, then you want to design base current to be 1.67mA.

Let us suppose your microcontroller runs from a +5v supply so that the value of R1 (base resistor) can be found. With logic 1 pulling one end of this resistor nearly to +5v, base voltage of Q1 will be about +0.65v. This leaves the remaining 4.35 v across R1. So R1 = 4.35/0.00167 ohms. That's 2605 ohms. You can use the next higher standard value 2700 ohms, because the factor-of-ten overdrive is more than necessary. From your microcontroller output pin, only 1.67 mA. current will be drawn (not 40mA). When it is switched to logic 0, no current will be drawn.

Why provide more base current than necessary? Transistor current gain can vary a lot (a Fairchild data sheet suggests it can be as low as 75). The extra base current also forces Vce to a smaller value, ensuring that Q1 acts as a good switch.
Military or automotive designs are a bit more stringent where very wide temperature extremes must be accommodated.

• The coil of a solenoid is not simply 'a very thin long wire having 720 ohms resistance'. It is quite a big inductor, more than 1H. So the current should be bigger than 16.67mA to switch quickly. Further, the datasheet I'm looking at (Fairchild PN2222A) says Vbe worst case might be 1.2V. So, sticking with a 10x gain rule, one might justify much harder drive, say R1 = 3.8V/0.005A = 760ohm, still well within the capability of the MCU pin. I was taught to reduce the base resistor when driving current, so the nearest preferred E24 is 680 ohms (820 ohm would be okay; we have 10x slop). – gbulmer Sep 9 '16 at 1:28
• @gbulmer: To switch more quickly, requires more voltage across the coil. The rate of change of current is always $\frac{\mathrm{d} I}{\mathrm{d} t}=\frac{V-I\cdot R_L}{L}$. – jonk Sep 9 '16 at 5:25
• @gbulmer: I may have been a bit optimistic saying Vbe(sat) is 0.65v, but your 1.2v is overly pessimistic: this is for Ic=150mA and Ib=15mA. Either of our designs would be OK, since the design window is quite wide. – glen_geek Sep 9 '16 at 17:19
• @glen_geek So, you basically started with Ic, and then you found Ib by first "selecting the gain" that you need. But, if I was able to find Vce(sat) that corresponds to my Ic, then finding Ib from Ib vs Vce(sat) graph, I will be not have to know what my gain is. It will be simply "found". I just do not understand why you brought up the 10X rule. If my basis says that the lower Vce(sat) the better my switch is, then to get this lowest value of Vce(sat), I just need to make sure my IC current is high enough regardless of what my gain is. What is your basis of stating out the 10X rule, then? – Gold_Sky Sep 9 '16 at 21:47
• @glen_geek According to the load equation, the best condition for this circuit is to have Ic=16.67 mA since, with this amount, Vce(sat) is zero. – Gold_Sky Sep 9 '16 at 21:53