← ME-6 · INTERFACING THE REAL WORLD

Driving loads safely

YOU WILL BE ABLE TO
  • Compute whether a load exceeds a GPIO's capability.
  • Choose between a MOSFET and a BJT as a load switch.
  • Explain inductive kickback and size a flyback diode.
  • Account for inrush and stall currents.

ME-2's capstone crossed this line once: a WS2812 strip wanting 480480 mA from a pin rated for about 1212 mA. This lesson makes the reasoning general, and adds the hazard that catches people who have already learned the current limit — inductance.

The first question is always arithmetic. What current does the load want, at what voltage, and continuously or in bursts? Compare against the pin's rating and against the total the chip can supply across all pins at once, which is a separate and smaller number than the per-pin limit multiplied by the pin count. If the load wins, a switch is required, and ME-2 L3's low-side n-channel MOSFET is the default answer: logic-level gate, RDS(on)R_{DS(on)} specified at the gate voltage you actually have, a gate resistor, and a gate pull-down.

A BJT can do the same job and occasionally should. Its base needs continuous current — IC/βI_C/\beta, so a 500500 mA load at β=100\beta = 100 needs 55 mA of base drive, within a pin's ability but not free — and it drops about 0.20.2 V when saturated rather than millivolts. In exchange it is cheap, tolerant, and unbothered by the gate-threshold questions that make MOSFET selection fussy. For small loads either works; above an amp or so, the MOSFET's conduction loss wins decisively.

Now the hazard. Any coil — a relay, a solenoid, a motor winding — is an inductor, and CA-5 L2 established that inductor current cannot change instantly. Open a switch in series with a coil carrying current and the inductor will produce whatever voltage is required to keep that current flowing, which with a fast switch means hundreds or thousands of volts. That spike appears directly across the switching device and destroys it.

vL=Ldidtv_L = L\frac{di}{dt}the kickback, from CA-5
+12 VcoilDfM1GPIO
The flyback diode: reverse biased in normal operation, it conducts the coil's current when the switch opens.

The diode sits across the coil, oriented so that it is reverse biased — and therefore invisible — while the switch is closed and current flows normally. The instant the switch opens, the coil's bottom terminal flies upward; as soon as it exceeds the supply by one diode drop, the diode conducts and provides a path for the coil current to circulate and decay. The switch now sees only supply plus 0.70.7 V instead of a kilovolt.

Vswitch≈Vsupply+0.7 VV_{switch} \approx V_{supply} + 0.7\ \text{V}clamped, with the flyback diode fitted
WORKED EXAMPLE

Sizing a relay driver

  1. A relay coil: 1212 V, 3030 mA, inductance about 100100 mH. Switched by a low-side MOSFET from a GPIO.
  2. Load current is trivial, so conduction loss is irrelevant; almost any logic-level part works.
  3. Without a flyback diode: opening the switch in, say, 11 µs would demand v=L di/dt=0.1×(0.03/10−6)=3000v = L\,di/dt = 0.1 \times (0.03/10^{-6}) = 3000 V. The MOSFET's drain-source rating is perhaps 6060 V. It dies on the first switch-off.
  4. With a diode rated for at least 3030 mA (any small signal diode qualifies) across the coil, the drain sees about 12.712.7 V. Decay time constant L/RL/R using the coil's own resistance (400 Ω400\ \Omega at 1212 V, 3030 mA) is 0.1/400=0.250.1/400 = 0.25 ms — the relay releases in under a millisecond.
A 3000 V spike becomes 12.7 V, for the price of one diode.
WORKED EXAMPLE

Inrush and stall

  1. A small DC motor draws 200200 mA running. Its stall current — with the rotor held — is often five to ten times that, and it draws stall current for the first tens of milliseconds of every start.
  2. So the switch, the supply, and the traces must all handle perhaps 11–22 A briefly, not 200200 mA.
  3. Incandescent lamps behave similarly: a cold filament has a fraction of its hot resistance, so inrush is many times the steady current.
  4. Design for the peak, then check the average for thermal purposes. Designing for the average alone produces a device that fails on startup — the worst kind of intermittent fault.
Size switches for stall and inrush; size heatsinks for average.

PRACTICE

Q1

A load draws 250250 mA at 55 V. Can a 3.33.3 V GPIO rated at 1212 mA drive it directly? What is the minimum you must add?

Q2

A solenoid with L=50L = 50 mH carrying 500500 mA is switched off in 22 µs with no protection. Estimate the voltage that appears across the switch.

Q3

Why is a flyback diode invisible during normal operation, and what determines how fast the coil current decays through it once fitted?

Q4

A motor is specified at 300300 mA. Give two reasons the switching device should be rated well above that.

Driving loads safely · ME-6 · iLearnSTEM Electronics