C1222 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

C12 · Lesson 22 · Driving loads

Transistor switches, inductive kicks and switching losses

A pin supplies 3.3 V and about 8 mA: enough for an LED, nowhere near enough for a relay, a motor, a solenoid or a strip of lights. Between the pin and the load goes a transistor, and choosing it is where firmware meets power electronics. The pin must turn the transistor fully on, the transistor must not overheat, and when an inductive load turns off, the current it was carrying has to go somewhere, or the voltage spike destroys the transistor within a few switchings.

  • A GPIO pin (0 to 3.3 V) drives a logic-level MOSFET switching a 12 V relay coil (100 mH, 100 Ω). The scope shows the drain and the gate.
  • RD is in series with the flyback diode. At 1 Ω, the diode catches the coil's current when the switch opens, and the drain only rises to about 12.9 V: the supply plus the diode's drop.
  • Raise RD to 1 MΩ, as if the diode were missing: the coil drives the drain up until the MOSFET avalanches at 60 V, every cycle.

Predict

A 12 V, 100 Ω relay coil is switched by an NPN transistor with a minimum β of 100. Can a GPIO pin's 8 mA drive it into saturation reliably?

Name it

Low-side switches

The load goes from the supply to the transistor, and the transistor to ground, so the pin drives it relative to ground.

  • BJT: saturate it with a forced β of 10 to 20: IB=IC/βforced, RB=(Vpin−0.7)/IB. It drops VCE(sat), about 0.2 V.
  • MOSFET: choose a logic-level part whose RDS(on) is specified at VGS = 2.5 or 3.3 V; a part rated at 10 V may barely turn on from 3.3. It drops IRDS(on).

Losses

Conduction: P=I2RDS(on)D for duty D. Switching: each transition passes through full voltage and full current at once for ts, so

Psw≈12VI(tr+tf)f

The transition takes about t=Qg/Ig, the gate charge over the gate current. A pin's few milliamps make microsecond transitions; a gate-driver chip's amperes make nanosecond ones.

Inductive loads

A coil's current can't stop instantly. With nowhere to go, Ldi/dt drives the switch's voltage up until something breaks down. A flyback diode across the coil carries the current around it, and it decays with τ=L/R. That's slow: a relay releases late. A Zener in series with the diode lets the coil's voltage reach VZ, so the current falls faster:

t=LRln⁡I0R+VZI1R+VZ

to fall from I0 to I1, at the price of the switch seeing V+VZ.

H-bridges

Four switches let a motor run both ways. If both switches on one side conduct together, they short the supply: shoot-through. Drivers add dead time between turning one off and the other on.

Worked example

Size the base resistor for a 12 V, 100 Ω relay coil switched by an NPN from a 3.3 V pin with an 8 mA limit.

Show the solution
  1. Collector current. IC=12V100Ω=120mA
  2. Base current. A forced β of 20 needs 6 mA, under the pin's limit.
  3. Base resistor. It drops 2.6 V: RB=2.6V6mA=433Ω so 430 Ω.
  4. Why not drive it harder. A forced β of 10 would need 12 mA, more than the pin can give.

Answer 430 Ω, for a forced β of 20.

Worked example

A MOSFET with 2 µs of total transition time switches 2 A at 12 V and 20 kHz. Compare its switching loss with its conduction loss at 50 mΩ and 50% duty.

Show the solution
  1. Switching loss. Psw=12×12×2×2μs×20kHz=0.48W
  2. Conduction loss. Pcond=22×0.05×0.5W=0.1W
  3. Compare. Driven straight from a pin, the switching loss dominates, five times the conduction loss.
  4. With a gate driver. A driver making 10 ns transitions, 20 ns in all, cuts the switching loss to 4.8 mW.

Answer 0.48 W of switching loss against 0.1 W of conduction loss, so switching dominates, about five times larger.

Worked example

A relay (100 mH, 100 Ω, 120 mA) releases when its current falls to 30%. How long does release take with a plain flyback diode, and with a 24 V Zener in series?

Show the solution
  1. Time constant. τ=LR=100mH100Ω=1ms
  2. Diode only. t=τln⁡10.3=1.20ms
  3. With the Zener. Here 3.6 V is 30% of the coil's 12 V: t=1ms×ln⁡12+243.6+24=0.27ms four and a half times faster.
  4. The cost. The drain sees 36 V instead of about 13.

Answer 1.20 ms with a plain diode, and 0.27 ms with the 24 V Zener, which puts 36 V on the drain.

Check

An NPN switches a 12 V, 50 Ω coil from a 3.3 V pin, with a forced β of 20.

(a)

What collector current flows (ignore VCE(sat))?

Write units the way you normally would: 1.5 mA, 1500 µA and 0.0015 A are the same answer.

(b)

What base resistor?

Check

A MOSFET with RDS(on) = 20 mΩ carries 2 A at 75% duty; its package has 60 °C/W to ambient.

(a)

What is its conduction loss?

Write units the way you normally would: 1.5 W, 1500 mW and 0.0015 kW are the same answer.

(b)

How far above ambient does it run?

Check

A switch turns 1 A at 24 V on and off at 100 kHz, with 2 µs per transition.

(a)

What is its switching loss?

Write units the way you normally would: 1.5 W, 1500 mW and 0.0015 kW are the same answer.

(b)

What fraction of the power it switches is that?

Check

A MOSFET's gate needs 15 nC and is driven with 8 mA.

(a)

About how long is each transition?

Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.

(b)

What gate-drive power does 20 kHz switching at 3.3 V take?

Check

A coil of 100 mH and 50 Ω carries its full 12 V current when the switch opens; it releases at 30% of that.

(a)

How long does release take with a plain flyback diode?

Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.

(b)

And with a 48 V Zener in series with the diode?

(c)

What peak voltage does the switch see then?

Check

A pin-driven MOSFET has RDS(on) = 30 mΩ at 3.3 V gate drive and carries 0.5 A continuously.

(a)

What voltage does it drop?

Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.

(b)

What does it dissipate?

Check

An H-bridge's firmware switches the high side off and the low side on in the same instruction. What goes wrong?

Check

Write switch_losses(v, i, rds, qg, ig, f, d): a MOSFET switching current i at voltage v, on-resistance rds, gate charge qg driven by ig amperes (each transition takes qg/ig), at f Hz and duty d. Return (conduction, switching, total) in watts.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why does turning off a relay coil without a flyback diode damage the transistor that switches it?

Practice

Keep practicing

9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.