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.

Introduction

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, R_{b}, of the BJT is driven by an FPGA IO pin and a load resistance, R_{c}, 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, I_{b}R_{b} and the voltage drop across the NPN transistor's base-emitter junction, V_{be}. Likewise, equations (2) relates the supply voltage, V_{dd}, to the voltage drop across the load resistor, I_{f}R_{c}, the LED's forward voltage, V_{f} and the voltage drop across the BJT's common-emitter junction, V_{ce}.

Equations (1) and (2) above are linked by the equation (3) below, which relates the ratio of the collector current, I_{c} and base current, I_{b} to the DC current gain, h_{fe }of the MMBT3904. Where in this case I_{c} is equivalent to the LED's forward current, I_{f}, 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 I_{B} = 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, V_{OL}, 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, V_{f}, 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 V_{f} = 1.7V and correspondingly we need to set the input forward current I_{f} = I_{c} = 1.6mA.

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

Knowing the values of V_{f} and I_{f} we could rearrange equation (2) to determine the load resistor, R_{c}. For our exercise we have determined, previously above, that V_{f} = 1.7V and I_{f} = I_{c} = 1.6mA and we require our supply voltage, V_{dd }= 3.3V. The rearranged equation, shown as equation (4) below, also requires us to know the value of the common-emitter voltage, V_{ce, }before we can calculate R_{c}.

To determine V_{ce} 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, R_{c} is calculated as

We should next refer to a table of standard resistor values. Hence, we choose the value of the load resistor, R_{c}, 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, R_{B}, 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, I_{c}/I_{b} = 10 and hence the DC current gain is 10. Now here comes the interesting part when calculating the value of I_{b}. To guarantee that the transistor stays in the saturation region we halve the DC current gain, h_{fe} shown in the graph above and use a value of h_{fe} = 5 to determine I_{b}. Hence, I_{b} is calculated as 1.6 mA / 5 = 0.8 mA.

Next we need to confirm that when I_{b} 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, R_{b}, 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 V_{be}, as shown below. According to this Table the value of V_{be} at saturation when the base current, I_{b }=1.0mA is typically 0.65V. Hence, we will use this value. If we have a transistor that has a V_{be}, 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 R_{b} we need to determine the LVTTL value of the Cyclone V FPGA when is IO pin is set to V_{OH}. 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 V_{CCIO}, which is the voltage of the FPGA's IO pins when the FPGA's bank voltage is set to 3.3V. Hence, V_{LVTTL} = 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 I_{b} will be minimally higher and hence V_{ce} will be "pushed" further into the saturation region. Good!

Conclusion

So 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 R_{c} = 1 Kilo Ohm and R_{b} = 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.