BJT transistor driver
Moving on from MOSFETs, let's look at using BJTs (Bipolar Junction Transistors) as switches.
The advantages of BJTs are that they are small and cheap. The disadvantages are that they are current-driven rather than voltage-driven like MOSFETs, and in general are more suited to low-power applications, like driving a few LEDs, a small motor or a relay.
This circuit is similar to the "low side" MOSFET driver described above. The emitter of the transistor is connected to Ground, so it "sinks" current. The transistor is an NPN transistor. A similar and common part would be the BC546/547/548 transistors.
Two important calculations here are the two resistors. R_{B} - the Base resistor, and R_{L} - the Load resistor.
Some loads (like motors) will not need a load resistor as they will be naturally current limited (however they may require a fly-back diode as described above).
Calculate the load resistor
Let's assume that we want to drive the LED with 20 mA, and we establish that the LED has a forward voltage drop of 1.7V (from the datasheet, or by measurement).
We can see from the datasheet for our transistor that (in this case) that the Collector−Emitter Saturation Voltage V_{CE(sat)} is around 0.4V with a load of 15 mA.
Thus the voltage drop over the resistor will be:
```
V = 5 - 1.7 - 0.4 = 2.9 V
```
And since we want 20 mA to flow we can use Ohm's Law to calculate R_{L}:
```
RL = 2.9 / 0.020 = 145 ohms
```
So we'll use a standard value of 150 ohms for R_{L}.
Power dissipated by this resistor will be I^{2}R, which would be:
```
PL = 0.020
```^{2} * 150 = 0.060 (60 mW)
Thus a 1/8 watt resistor would be fine.
Calculate the base resistor
We want to fully "saturate" (turn on) the transistor, so a fairly substantial amount of current will be required. The datasheet quotes the "Collector−Emitter Saturation Voltage" as being one when I_{C} is 150 mA and I_{B} is 15 mA, thus we can deduce that (at those current levels) the transistor will only have a gain of 10 (that is, 150/15) when saturated, thus we would require a current of 2 mA to flow through the Base to the Emitter (that is, 20mA / 10).
The datasheet says that the Base−Emitter Saturation Voltage V_{BE(sat)} is around 1.3V with a load of 15 mA, thus the voltage drop over the resistor will be:
Since we want 2 mA to flow we can use Ohm's Law to calculate R_{B}:
```
RB = 3.7 / 0.002 = 1850 ohms
```
Thus a 2k resistor should be satisfactory.
Power dissipated by this resistor will be I^{2}R, which would be:
```
PB = 0.002
```^{2} * 1600 = 0.008 (8 mW)
Thus a 1/8 watt resistor would be fine here too.
Transistor power dissipation
Next we need to calculate the power dissipated by the transistor which will be the sum of the base-emitter power and the collector-emitter power.
```
power = (V
```_{BE(sat)} * I_{BE}) + (V_{CE(sat)} * I_{CE})
V_{BE(sat)} = 1.3 (from datasheet)
I_{BE} = 0.002 (2 mA - as calculated above)
V_{CE(sat)} = 0.4 (from datasheet)
I_{CE} = 0.020 (20 mA - as calculated above)
R_{ØJA} = 200 °C/W (from datasheet)
**Power** = (1.3 * 0.002) + (0.4 * 0.020) = 0.0106 (10.6 mW)
**Heat gain** = 0.0106 * 200 = 2.12 °C
Calculations in Lua
```
-- standard values for 5% resistors
standardValues = {
1.0, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0,
3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1,
10.0 }
-- turn a resistance into the next highest standard value (5%)
function makeStandardValue (value)
local exponent = math.floor (math.log10 (value))
local fraction = 10^(math.log10 (value) - exponent)
for k, v in ipairs (standardValues) do
if v > fraction then
return v * 10^exponent
end -- if
end -- for
error "Shouldn't get here"
end -- function makeStandardValue
-- parameters
-- the transistor (from the datasheet)
VBEsat = 1.3 -- volts (Base-Emitter Saturation Voltage)
VCEsat = 0.4 -- volts (Collector-Emitter Saturation Voltage)
RthetaJA = 200 -- °C/W (Thermal Resistance, Junction to Ambient)
-- the load
Vload = 5 -- volts (load supply voltage on the motor / LED)
LEDforward = 1.2 -- LED forward voltage (zero if no LED)
ICE = 0.02 -- current through load (collector) in amps
-- how we are turning on the transistor
Venable = 5 -- volts to enable the transistor (eg. Arduino pin)
-- calculate RL (load resistor)
VL = Vload - LEDforward - VCEsat
RL = makeStandardValue (VL / ICE)
PL = ICE^2 * RL
print (string.rep ("-", 10) .. " Load resistor " .. string.rep ("-", 10) )
print ("Voltage over RL =", VL .. " V")
print ("RL =", RL .. " ohms")
print ("RL power =", PL .. " watts (" .. math.floor (PL * 1000) .. " mW)")
-- calculate RB (base resistor)
print (string.rep ("-", 10) .. " Base resistor " .. string.rep ("-", 10) )
VB = Venable - VBEsat
IBE = ICE / 10 -- rule of thumb, use 1/10 of collector current for full saturation
RB = makeStandardValue (VB / IBE)
PB = IBE^2 * RB
print ("RB =", RB .. " ohms")
print ("RB power =", PB .. " watts (" .. math.floor (PB * 1000) .. " mW)")
-- calculate transistor power
print (string.rep ("-", 10) .. " Transistor power " .. string.rep ("-", 10) )
Power = (VBEsat * IBE) + (VCEsat * ICE)
print ("Power =", Power * 1000, "mW")
Heatgain = Power * RthetaJA
print ("Heat =", Heatgain, "degrees C")
```
Summary
The net result here is that we are using 2 mA from the Arduino output pin to control a 20 mA LED. Now, an Arduino can directly drive 20 mA, however the workings above should let you calculate resistors for other loads. |