---
title: "Transistor switches: losses, heat and high-side drive"
heading: What it costs to switch a load, and how to switch the positive side
eyebrow: C5 · Lesson 34 · Transistor switches
xp: 40
---

::: hook
An ideal switch wastes nothing: no voltage across it when it's on, no current through it when it's off. A transistor comes close, but not all the way. It drops a little voltage while it conducts, it passes through a moment of full voltage and full current every time it changes state, and if the load is a coil, it has to survive the coil's attempt to keep its current flowing. This lesson puts numbers on those losses, turns them into a temperature, and shows how to switch the positive side of a load from a low-voltage logic pin.
:::

::: play
- A **high-side** switch: a PMOS between the 12 V supply and the load, so the load's other end stays grounded. A logic pin can't pull the PMOS gate up to 12 V, so an NPN does the work: when the pin goes high, the NPN pulls the gate down and the PMOS turns on.
- The scope shows the gate and the load. Note the inversion twice over: pin high, gate low, load on.
- Lower RL to draw more current: the output barely drops, because the PMOS is fully on with 12 V of gate drive.
:::
:::

```sim circuit
VIN in 0 square 0 3.3 1k Hz         @ 0,3 down 2
RB in b 10k                         @ 0,3 right 2
Q1 g b 0 npn BF=100                 @ 2,3
RG vdd g 10k                        @ 3,-1 down 3
M1 out g vdd pmos VTO=-2 KP=1       @ 4,1 flip
RL out 0 24                         @ 5,2 down 3
VDD vdd 0 12                        @ 7,-1 down 6
slider: RL 2.4..240 log
scope: v(g), v(out)
time: 0..3m s
meter: i(RL)
```

::: predict
## A MOSFET with an on-resistance of 20 mΩ carries 5 A continuously. How much power does it dissipate?

- [ ] 0.1 W
- [x] 0.5 W
- [ ] 2.5 W
- [ ] 100 W

::: reveal
0.5 W: $I^2R_{on} = 25 \times 0.02$. Small for a 60 W load, but enough to warm a small package by about 30 °C. Conduction loss grows with the square of the current, so at 10 A it would be 2 W.
:::
:::

::: nameit
## Losses

**Conduction loss**, while on for a fraction D of the time:

$$P_\text{cond} = DI^2R_{on} \quad \text{(MOSFET)} \qquad P_\text{cond} = D\left(I_CV_{CE,\text{sat}} + I_BV_{BE}\right) \quad \text{(BJT)}$$

**Switching loss.** During each transition the voltage and current overlap. For a resistive or clamped load, roughly

$$P_\text{sw} = \tfrac12V I(t_r + t_f)f$$

so it grows with switching frequency. That's why fast switching matters, and why a MOSFET's gate must be driven hard.

**Gate drive.** A MOSFET's gate is a capacitor holding a charge $Q_g$ (tens of nanocoulombs for a power device). Switching it in time t needs a current of about $Q_g/t$, and the driver spends $Q_gV_{GS}f$ of power.

## Heat

Power becomes temperature through thermal resistance, °C per watt from the junction to the air:

$$T_J = T_A + P\,\theta_{JA}$$

A small TO-220 package in free air is about 60 °C/W; a heat sink brings the total down to a few °C/W. Keep $T_J$ well under the rating, typically 150 °C.

## Inductive loads

A coil's current can't change instantly, so if a switch opens on it, the coil drives its terminal as high as it takes to keep the current flowing, $V = L\,di/dt$: hundreds or thousands of volts in a microsecond, enough to destroy the transistor. A **flyback diode** across the coil gives the current a path, clamping the switch at the supply plus 0.7 V; the coil's stored energy, $\frac12LI^2$, is then dissipated in the coil's resistance and the diode at each turn-off.

## High-side switching

To switch the positive side, use a PNP or PMOS with its emitter or source at the supply. It needs its base or gate pulled down from the supply, which a logic pin can't do directly when the supply is higher than the pin, so a small NPN (or NMOS) does it, with a pull-up resistor turning the switch off. Keep $V_{GS}$ within the gate's rating (often ±20 V); with higher supplies, a Zener or divider limits it.
:::

::: example
## A MOSFET ($R_{on}$ = 20 mΩ, $t_r = t_f$ = 50 ns, $\theta_{JA}$ = 62 °C/W) switches 5 A from 12 V at 20 kHz and 50% duty. Find its losses and junction temperature at 25 °C ambient.

::: solution
1. **Conduction loss.**
   $$0.5 \times 25 \times 0.02 = 0.25\ \text{W}$$
2. **Switching loss.**
   $$\begin{aligned} P_{sw} &= \tfrac12 \times 12 \times 5 \times 100\ \text{ns} \\ &\quad \times 20\ \text{kHz} \\ &= 0.06\ \text{W} \end{aligned}$$
3. **Junction temperature.** The total is 0.31 W, so
   $$\begin{aligned} T_J &= 25 + 0.31 \times 62 \\ &= 44\ \text{°C} \end{aligned}$$
   No heat sink is needed.

**Answer:** it loses 0.25 W in conduction and 0.06 W in switching, 0.31 W in all, and the junction reaches 44 °C, so no heat sink is needed.
:::
:::

::: example
## A 100 mH relay coil carries 100 mA. What happens if its switch opens in 1 µs with no flyback diode?

::: solution
1. **Voltage to stop the current that fast.**
   $$\begin{aligned} L\,di/dt &= 0.1 \times \frac{0.1}{10^{-6}} \\ &= 10\ \text{kV} \end{aligned}$$
2. **What really happens.** The transistor breaks down long before, absorbing the coil's energy in its junction every time:
   $$\tfrac12 \times 0.1 \times 0.1^2 = 0.5\ \text{mJ}$$
3. **The fix.** A diode across the coil caps the switch at 12.7 V instead.

**Answer:** the coil would try to reach 10 kV, so the transistor breaks down and absorbs 0.5 mJ at every turn-off; a flyback diode caps it at 12.7 V.
:::
:::

::: example
## A MOSFET dissipates 3 W with $\theta_{JC}$ = 1.5 °C/W to its case and 0.5 °C/W through the insulating pad. How good must the heat sink be to keep the junction below 125 °C in 40 °C air?

::: solution
1. **Total thermal resistance allowed.** The thermal resistances add in series from junction to air, so
   $$\begin{aligned} \theta_{JC} + \theta_{CS} + \theta_{SA} &\le \frac{125 - 40}{3} \\ &= 28.3\ \text{°C/W} \end{aligned}$$
2. **Heat sink.** Take off the 1.5 and 0.5 °C/W:
   $$\theta_{SA} \le 26.3\ \text{°C/W}$$
   A small clip-on fin will do.
3. **Without a heat sink.** A package rated $\theta_{JA}$ = 62 °C/W would reach 40 + 3 × 62 = 226 °C.
4. **Why it matters.** Datasheet limits assume a junction temperature, so the heat path is part of the circuit's design.

**Answer:** the heat sink needs $\theta_{SA}$ ≤ 26.3 °C/W, which a small clip-on fin provides.
:::
:::

::: check
given: I = 2 | 10; Ron = 5 | 50; D = 0.25 | 0.6
answer: D*I^2*Ron/1000
unit: W
tolerance: 0.5%

## A MOSFET with $R_{on}$ = {Ron} mΩ carries {I} A for a fraction {D} of the time. What is its conduction loss?

::: right
Right. $DI^2R_{on}$ = {answer}.
:::

::: misses
- [I^2*Ron/1000] Multiply by the fraction of time it's on.
- [D*I*Ron/1000] Power is $I^2R$.
- [any] Not yet. $P = DI^2R_{on}$.
:::
:::

::: check
given: V = 12 | 48; I = 2 | 10; t = 20 | 100; f = 20 | 200
answer: 0.5*V*I*2*t*1e-9*f*1000
unit: W
tolerance: 0.5%

## A switch turns {I} A on and off from {V} V at {f} kHz, with rise and fall times of {t} ns each. What is its switching loss?

::: right
Right. $\frac12VI(t_r + t_f)f$ = {answer}.
:::

::: misses
- [0.5*V*I*t*1e-9*f*1000] Count both the rise and the fall.
- [any] Not yet. $\frac12VI(t_r + t_f)f$.
:::
:::

::: check
given: TA = 25 | 50; P = 0.5 | 2; th = 3 | 62
answer: TA + P*th
unit: °C
tolerance: 0.5%

## A transistor dissipates {P} W with a total thermal resistance of {th} °C/W, at {TA} °C ambient. What is its junction temperature?

::: right
Right. $T_A + P\theta_{JA}$ = {answer}.
:::

::: misses
- [P*th] Add the ambient temperature.
- [any] Not yet. $T_J = T_A + P\theta_{JA}$.
:::
:::

::: check
given: L = 10 | 100; I = 0.1 | 1; t = 1 | 10
answer: L*1e-3*I/(t*1e-6)/1000
unit: kV
tolerance: 0.5%

## A {L} mH coil carrying {I} A has its current interrupted in {t} µs with no flyback path. What voltage would it need?

::: right
Right. $L\,\Delta I/\Delta t$ = {answer}.
:::

::: misses
- [any] Not yet. $V = L\,di/dt$.
:::
:::

::: check
given: L = 10 | 100; I = 0.1 | 0.5; f = 10 | 100
answer: 0.5*L*1e-3*I^2*f
unit: W
tolerance: 0.5%

## A {L} mH solenoid carrying {I} A is switched off {f} times a second through a flyback diode. How much power goes into the diode and coil resistance at turn-off?

::: right
Right. $\frac12LI^2f$ = {answer}.
:::

::: misses
- [0.5*L*1e-3*I^2] That's the energy per turn-off; multiply by the rate.
- [any] Not yet. The stored energy, each time.
:::
:::

::: check
given: Qg = 10 | 60; t = 20 | 100
answer: Qg/t
unit: A
tolerance: 0.5%

## A MOSFET with {Qg} nC of gate charge must switch in {t} ns. What gate current does the driver need?

::: right
Right. $Q_g/t$ = {answer}.
:::

::: misses
- [any] Not yet. Charge over time.
:::
:::

::: check
given: VCC = 5 | 12; RL = 0.05 | 0.47; Vin = 3.3 | 5
answer: (Vin - 0.7)/((VCC - 0.2)/RL/10)
unit: kΩ
tolerance: 0.5%

## A BJT low-side switch drives {RL} kΩ from {VCC} V, from a {Vin} V pin. With a forced β of 10, what base resistor?

::: right
Right. {answer}.
:::

::: misses
- [(Vin - 0.7)/((VCC - 0.2)/RL/100)] Design for a forced β of 10, not the transistor's typical β.
- [any] Not yet. $I_B = I_C/10$, then $R_B = (V_\text{in} - 0.7)/I_B$.
:::
:::

::: check
kind: parts
given: P = 2 | 5 | 10; jc = 0.5 | 1.5; cs = 0.2 | 0.5; Ta = 25 | 40; Tj = 125 | 150

## A transistor dissipates {P} W with $\theta_{JC}$ = {jc} °C/W and $\theta_{CS}$ = {cs} °C/W, in {Ta} °C air.

::: part
answer: (Tj - Ta)/P - jc - cs
unit: °C/W
tolerance: 0.5%

### What heat-sink rating keeps the junction at or below {Tj} °C?

::: misses
- [(Tj - Ta)/P] Subtract the junction-to-case and case-to-sink resistances.
- [any] $\theta_{SA} = \frac{T_J - T_A}{P} - \theta_{JC} - \theta_{CS}$.
:::
:::

::: part
answer: Ta + P*(jc + cs)
unit: °C
tolerance: 0.5%

### How hot would the junction be with an ideal heat sink, $\theta_{SA}$ = 0?

::: misses
- [any] $T_A + P(\theta_{JC} + \theta_{CS})$.
:::
:::
:::

::: check
kind: derivation
vars: D = 0.05..0.95, I = 0.1..20, R = 0.001..1, V = 5..400, t = 0.000000001..0.000001, f = 1000..1000000

## A MOSFET switches current I from voltage V at frequency f and duty D, with on-resistance R and equal rise and fall times t.

::: step
answer: D*I^2*R

### What's its conduction loss?
:::

::: step
answer: V*I*t*f

### What's its switching loss?
:::

::: step
answer: D*I^2*R/(V*I*t)

### At what frequency are the two losses equal?
:::

::: right
Right. Above that frequency switching dominates, and faster edges or lower frequency pay off.
:::
:::

::: explain
## Why does switching an inductive load without a flyback diode destroy transistors?

::: model
A coil stores energy in its magnetic field and resists any change in its current. When the transistor turns off, the current through the coil has to keep flowing for a moment, and with nowhere else to go the coil raises its voltage until something conducts. That something is the transistor itself, broken down by hundreds or thousands of volts, absorbing the coil's stored energy in a tiny region of its junction. A diode across the coil gives the current a harmless loop at less than a volt above the supply, where it dies away through the coil's resistance.
:::
:::

::: practice

::: check
given: Ron = 10 | 100; I = 1 | 3
answer: I*Ron
unit: mV
tolerance: 0.5%

## How much voltage does a switch with {Ron} mΩ on-resistance drop at {I} A?

::: misses
- [any] $IR_{on}$.
:::
:::

::: check
given: TJ = 125 | 150; TA = 25 | 40; P = 2 | 5
answer: (TJ - TA)/P
unit: °C/W
tolerance: 0.5%

## A transistor dissipating {P} W must stay below {TJ} °C at {TA} °C ambient. What is the most thermal resistance it can have?

::: misses
- [any] $(T_J - T_A)/P$.
:::
:::

::: check
given: Qg = 20 | 50; V = 10 | 12; f = 50 | 500
answer: Qg*1e-9*V*f*1000*1000
unit: mW
tolerance: 0.5%

## How much power does a driver spend charging {Qg} nC of gate to {V} V at {f} kHz?

::: misses
- [any] $Q_gV_{GS}f$.
:::
:::
:::
