EN

Transistor as a switch

Saturated bipolar and N-channel MOSFET to drive relays, motors and LEDs

A microcontroller pin supplies a few milliamperes at 3.3 or 5 V. To switch on a relay, a motor, an LED strip or a solenoid you need a transistor acting as a switch: the small control signal opens and closes a circuit with more current and, often, more voltage. It is usually placed on the low side (between the load and ground), because it can then be controlled with a ground-referenced voltage.

NPN bipolar transistor

A bipolar transistor carries a collector current \(I_C = h_{FE}\,I_B\) while in the active region. As a switch we want saturation: it is given more base current than needed, the collector-emitter voltage falls to 0.1 to 0.3 V and the transistor dissipates little. Since \(h_{FE}\) varies widely between units and with temperature, the design uses a forced β of 10 to 20 (a base current of \(I_C/10\)) or, at the very least, two to three times \(I_C/h_{FE,\min}\).

\[ I_B = \frac{I_C}{\beta_{\text{forced}}} \qquad R_B = \frac{V_{\text{control}} - V_{BE(sat)}}{I_B} \qquad P = V_{CE(sat)}\,I_C + V_{BE}\,I_B \]
Load and control
V
mA
V
mA
Transistor (datasheet)
V
V

N-channel MOSFET

A MOSFET is voltage-controlled: the gate is a capacitor and, in steady state, draws no current. When the gate-source voltage is well above the threshold, the channel behaves like a resistance \(R_{DS(on)}\) of a few milliohms. Note: the threshold \(V_{GS(th)}\) is the voltage at which it starts to conduct (about 250 µA), not the one at which it conducts well. The figure that matters is the \(R_{DS(on)}\) guaranteed at the gate voltage you will use. With 3.3 or 5 V you need a logic-level MOSFET, specified at VGS = 4.5 V or 2.5 V.

\[ P_{\text{cond}} = I_D^2\,R_{DS(on)} \qquad t_{sw} \approx \frac{Q_g\,R_g}{V_{\text{control}}} \qquad P_{sw} \approx V_{DS}\,I_D\,t_{sw}\,f \qquad T_j = T_a + P\,R_{\theta JA} \]
Load and control
V
A
V
Ω
kHz
MOSFET (datasheet)
V
mΩ
nC
°C/W
°C

The datasheet RDS(on) is usually given at 25 °C; at 100 °C it can be 50 to 70 % higher. The switching calculation is an order-of-magnitude estimate. 62 °C/W is the typical value for a TO-220 package without a heatsink.

Bipolar or MOSFET

Bipolar (BJT)MOSFET
ControlBy current: needs continuous base currentBy voltage: current only during transitions
On-state dropVCE(sat) of 0.1 to 0.3 V (1 V or more for Darlingtons)ID · RDS(on): millivolts on large MOSFETs
High currentsLoses efficiency and needs a lot of base currentIdeal: tens of amperes with little dissipation
Low control voltageWorks with 1 V or lessNeeds a logic-level model at 3.3 V
Price and robustnessVery cheap, tolerates static electricity wellCheap; the gate is sensitive to static electricity and overvoltage

Common transistors

ModelTypeMax. voltageMax. currentKey figureTypical use
BC547 / 2N3904NPN45 / 40 V100 / 200 mAhFE ≥ 100Small relays, LEDs, signals
BC337 / 2N2222ANPN45 / 40 V800 / 600 mAhFE ≥ 100Relays, buzzers, loads of hundreds of mA
TIP120NPN Darlington60 V5 AhFE ≥ 1000, VCE(sat) ≈ 2 VMotors and solenoids (it runs hot)
ULN2003 / ULN28037 or 8 Darlingtons with diodes50 V500 mA per channel5 V compatible inputsRelays and stepper motors
2N7000 / BSS138N-channel MOSFET60 / 50 V200 mARDS(on) of a few ohmsSignals, level shifting
AO3400N-channel MOSFET (SOT-23)30 V5.7 ALogic level, RDS(on) < 33 mΩ at 4.5 VLED strips and medium loads from 3.3 V
IRLZ44NN-channel MOSFET (TO-220)55 V47 ALogic level, RDS(on) ≈ 25 mΩ at 5 VMotors and large loads from 5 V
IRF540NN-channel MOSFET (TO-220)100 V33 ANot logic level: specified at 10 VNeeds a gate driver from a microcontroller

Indicative values; the maximum currents of MOSFETs assume an ideal heatsink and are much lower in practice.

Details that prevent failures

Related: LED resistor, optocouplers, level shifting and Ohm's law and power.