Ben's Blog

No description yet.

  • Home
    Home This is where you can find all the blog posts throughout the site.
  • Categories
    Categories Displays a list of categories from this blog.
  • Tags
    Tags Displays a list of tags that have been used in the blog.
  • Archives
    Archives Contains a list of blog posts that were created previously.
  • Login
    Login Login form

Design Note (1) - Determining a NPN BJT's Base Resistor Value, When Used As A Switch

Posted by on in Development, Software and Tools
  • Font size: Larger Smaller

This blog post is about determining the value of the base resistor of a MMBT3904L, which is ON Semiconductor's variant of the general purpose 2N3904 NPN  Bipolar Junction Transistor (BJT), when used as a switch. The value is determined when the transistor is in the common emitter configuration. Sounds like a simple task and so it should be too. However, as we have commented many a time in our blog posts tasks that appear to be easy never are.  Hence, while undertaking this task we decided to follow Lao Tzu's (Who? - Ed) advice, which he elegantly formulated in the following quote: 

Do the difficult things while they are easy and do the great things while they are small. A journey of a thousand miles must begin with a single step - Lao Tzu.

So, as he has suggested the sensible approach in determining  the value of the resistance of the base resistor of a BJT is to perform the calculation a step at a time, as we demonstrate below.


This item of work has arisen out of our desire to interface a servo motor to a FPGA, as part of our 17 DOF robotic's project. The essential part of the interface circuit, relevant to this discussion, is presented in the Figure below. In this Figure it can be seen that a NPN transistor is simply used to turn a LED, embedded in an opto-coupler, ON and OFF. Hence, we are interested in the switching characteristics of NPN transistors in general and specifically the MMBT3904L. 


The first part of the figure above, part A, shows the MMBT3904 interfaced to a dual channel opto-coupler, the HCPL-2730. Also, it shows the base resistor, Rb,  of the BJT is driven by an FPGA IO pin and a load resistance, Rc, which is used to determine the amount of current that flows through the opt-coupler's LED.

When this Figure is redrawn, as part B, showing only the components relevant to this discussion and when Ohm's law is applied, we develop the two essential equations central to the discussion.


Equation (1) states that the FPGA pin IO voltage, when set to the LVTTL voltage standard, is equal to the voltage drop across the base resistor, IbRb and the voltage drop across the NPN transistor's base-emitter junction, VbeLikewise, equations (2) relates the supply voltage, Vdd, to the voltage drop across the load resistor, IfRc, the LED's forward voltage, Vf and the voltage drop across the BJT's common-emitter junction, Vce

Equations (1) and (2) above are linked by the equation (3) below, which relates the ratio of the collector current, Ic and base current, Ib to the DC current gain, hfe of the MMBT3904. Where in this case Ic is equivalent to the LED's forward current, If, and we will be using the two values interchangreably for this exercise.


So what do all these values mean and where do they come from or more importantly where do we get them from? Before we answer these question let's first try and understand what we mean by the ON, OFF switching characteristics of  a NPN BJT in general and the 2N3904 in particular with the use of the diagrams shown below.


The right-hand part of the Figure above shows the Collector Current versus Collector-Emitter Saturation Voltage curves of a typical transistor. The two particular regions of interest are the cut-off region and a saturation region. A NPN transistor is in its cut-off region, when there is no current flowing through its base resistor, hence IB = 0 and the transistor is in the OFF state. Hence, as a consequence, there will be no collector current flowing through the transistor and in the context of the opt-coupler its LED will be off.

Conversely, when the base current is set such that the transistor is fully ON, then the transistor is said to be saturated. When this occurs the transistor is operated in the saturation region, where the transistor's common-emitter resistance is very low and the transistor has a relatively small common-emitter voltage. 

Hence, our motivation, when operating a transistor as a switch is to ensure we always operate it in these two regions. To do so we need to have complete control of the two equations, (1) and (2) presented previously and we also need to understand how to use equation (3), which relates the base current to the collector current.

To switch the transistor OFF we simply need to make sure that there is no voltage supplied to the base resistor. For LVTTL, LVCMOS, etc voltage levels, setting the FPGA's IO pin to an output low voltage, VOL, which is typically ground, will achieve this. 


So we move on to the more interesting and difficult part of the problem how do we maintain the transistor in its saturation region to reliably switch it ON? To begin with lets start by understanding the parameters required to solve equation (2). A good starting point in solving this equation is with the forward voltage, Vf, which is the LED's input forward voltage. According to the HCPL-2730's data sheet, repeated for convenience in the Figure above, the forward voltage has a maximum value of 1.7V.  Hence, we shall take Vf = 1.7V and correspondingly we need to set the input forward current  If = Ic = 1.6mA.

 What happens if the forward voltage is typically less than the maximum value?

Knowing the values of Vf and If we could rearrange equation (2) to determine the load resistor, Rc. For our exercise we have determined, previously above, that  Vf = 1.7V and If = Ic = 1.6mA and we require our supply voltage, Vdd = 3.3V. The rearranged equation, shown as equation (4) below, also requires us to know the value of the  common-emitter voltage, Vce, before we can calculate Rc.


To determine Vce at saturation we need to check the collector-emitter saturation voltage vs collector current graph in the MMBT3904L's data sheet , an enhanced version of this graph is shown in the Figure below. From this graph we can see that when the input forward current, If = Ic = 1.6mA then Vce = 0.05V when saturated.


Hence, Rc is calculated as


We should next refer to a table of standard resistor values. Hence, we choose the value of the load resistor, Rc, to be 1K Ohm. In some tutorial you might see the value of Vce being ignored and not used in equation (5), since it value is quite comparably insignificant.

Finally, we need to choose a value of the base resistor, RB, that ensures the transistor is switched ON by keeping the transistor in the saturation region. To calculate this value we need to use equations (2) and (3). We also note that in the graph of the collector-emitter saturation voltage vs collector current, above, Ic/Ib = 10 and hence the DC current gain is 10. Now here comes the interesting part when calculating the value of Ib.  To guarantee that the transistor stays in the saturation region we halve the DC current gain, hfe shown in the graph above and use a value of hfe = 5 to determine Ib. Hence, Ib is calculated as 1.6 mA / 5 = 0.8 mA.

Next we need to confirm that when Ib is set to 0.8mA the common-emitter region of the transistor is indeed saturated by referring to the Collector Saturation Region graph of the MMBT3904L data sheet, repeated below. On this graph it can be seen that X approximately marks the spot where Ib = 0.8mA and Ic = 1.6mA, which is well within the saturation region. Good!


With this information we are now in a position to calculate the value of the base resistor, Rb, by rearranging equation (2). Hence


Now, we need to refer to the transistor's ON characteristics from the electrical characteristics table to determine the value of Vbe, as shown below. According to this Table the value of Vbe at saturation when the base current, Ib =1.0mA is typically 0.65V. Hence, we will use this value. If we have a transistor that has a Vbe, at saturation, of 0.85V, then Ib will be smaller, which is a good thing as it would further increase the saturation of the transistor! 


Now, in order to perform the coup the grĂ¢ce and finally determine Rb we need to determine the LVTTL value of the Cyclone V FPGA when is IO pin is set to VOH. To do this we need to refer to yet another data sheet, which lists the IO characteristics of the Cyclone V FPGA found in the "Cyclone V Device Handbook, Volume 1: Devices Interfaces and Integration - Altera". 


The I/O standards section is repeated above for the 3.3V LVTTL and it tells us that VCCIO, which is the voltage of the FPGA's IO pins when the FPGA's bank voltage is set to 3.3V. Hence, VLVTTL = 3.3V.  Rearranging equation (6) and substituting the known values, Rb = 3.312 Kilo Ohms.


Now, when we look at the Table of standard resistor values we see that 3.3 Kilo Ohms is the closest value. Although 3.3K Ohms is slightly less than our calculated 3.312Kilo Ohms it means that Ib will be minimally higher and hence Vce will be "pushed" further into the saturation region. Good!


 002-002-001-000050l.pngSo that's it for this blog post and I've quite enjoyed this one. It's a turned out to be a demonstration master class of what can be done when a problem is solved a step at a time, as recommended by Tau. For this particular configuration will shall use set Rc = 1 Kilo Ohm and Rb = 3.3 Kilo Ohm. To see this circuit in action you can head over to the 17 DOF Robotics Project where it will be integrated as part of our servo controller circuit. 

Last modified on