Worked designs, step by step

Six real circuits, end to end: requirement, maths, part choice and BOM. In the “What if?” panels you change values and watch what breaks, live.

PracticeChapter 14

Each tab is a self-contained design: maths, animated schematic, lab panel and BOM. The formulas are derived in the theory chapters: 05, 06, 08, 09, 13.

A small logic-level MOSFET is enough. The AO3400A runs straight from the ESP32’s 3.3 V pin and stays cool.

Calculation

Load12 V fan, 0.25 AStart-up≈ 0.5 APWM25 kHzGPIO3.3 VSwitchlow-side
  1. VDS marginVDS ≥ 1.5 × 12 V≥ 18 Vpick a 30 V part
  2. RDS(on) at 3.3 Vbetween 48 mΩ @ 2.5 V and 32 mΩ @ 4.5 V≈ 42 mΩAO3400A, max, 25 °C
  3. Hot RDS(on)42 mΩ × 1.4≈ 59 mΩ
  4. Conduction lossP = 0.25² × 0.059 × 13.7 mWD = 1, worst case
  5. Peak gate currentI = 3.3 V / (100 + 30) Ω≈ 25 mAshort pulse, safe for the pin
  6. Turn-on gate currentIG = (3.3 − 1.7) / 130≈ 12 mAMiller plateau ≈ 1.7 V
  7. Transition timetr = 2 nC / 12 mA≈ 0.16 µsQgd ≈ 2 nC; tf ≈ 0.15 µs
  8. Switching lossP = ½ × 12 × 0.25 × 0.31 µs × 25 kHz≈ 12 mW
  9. Gate drive powerP = 4 nC × 3.3 V × 25 kHz≈ 0.3 mWspent in RG and the pin, not the MOSFET
  10. Temperature riseΔT = 16 mW × 125 °C/W≈ 2 °CSOT-23, RθJA
  11. PWM resolution80 MHz / 25 kHz = 320011 bitESP32 LEDC, 2048 steps
The AO3400A needs no heatsink. Total loss ≈ 16 mW, a rise of only 2 °C.
Animation

Final circuit: the GPIO PWMs, fan current freewheels through the diode

Animation slowed ~40 000×. With the MOSFET off, fan current keeps circulating through the SS14 (copper loop). Blue dots are gate current.

Design notes

  • Pull-down: 10 kΩ gate to source. The pin floats while the ESP32 boots; the resistor keeps the fan off.
  • Pin choice: avoid the strapping pins (GPIO0, 2, 12, 15).
  • Flyback: an SS14 Schottky across the fan, cathode to +12 V. At 25 kHz it must have no reverse recovery.

Part choice

AO3400A

30 V, 5.7 A. RDS(on) guaranteed down to 2.5 V. VGS(max) ±12 V, SOT-23, very cheap.

Why not a BJT?

0.5 A start-up needs 25–50 mA of base current: too much for the pin. At 25 kHz storage time is a problem too.

SS14 / 1N5819

Schottky: trr ≈ 0, VF ≈ 0.4 V. A 1N4007 is wrong in PWM (Chapter 15).

4-wire fan? Do not chop the supply; pull the fan’s own PWM wire low with a 2N7002. Chopping a 2/3-wire fan works, but the tach breaks and the fan may whine.
Lab

What if? Frequency, RG and losses

Model: AO3400A max RDS(on) (from the 2.5/4.5/10 V points), hot factor 1.4, Qgd = 2 nC, plateau 1.6 V + 0.15 V/A, pin resistance 30 Ω, RθJA = 125 °C/W, Ta = 25 °C. Plot: losses versus PWM frequency.

BOM

RefPartValue / notePackage
Q1AO3400A30 V, 5.7 A, logic-levelSOT-23
R1Gate resistor100 Ω0603
R2Pull-down10 kΩ0603
D1SS1440 V 1 A Schottky, across the fanSMA
C1, C2Decoupling10 µF 25 V + 100 nF0805
J1Fan header2/3 pinTHT

A 2N3904 and two resistors are enough. A 3.3 V pin saturates it easily for a 70 mA coil.

Calculation

Relay5 V, 70 mACoil≈ 71 ΩL≈ 100 mH (assumed)GPIO3.3 V
  1. Collector currentIC = (5 − 0.2) V / 71 Ω≈ 70 mABC547 (100 mA) is marginal, 2N3904 (200 mA) is comfortable
  2. Minimum gainbetween 60 @ 50 mA and 30 @ 100 mAhFE(min) ≈ 402N3904 datasheet
  3. Base currentIB = 70 mA / 203.5 mAforced β = 20, half of hFE(min)
  4. Base resistorRB = (3.2 − 0.85) V / 3.5 mA≈ 670 Ω → 680 ΩE12; pin current is fine for any MCU
  5. Current stolen by pull-down0.85 V / 10 kΩ85 µAnegligible
  6. Transistor lossP = 70 mA × 0.2 V14 mW
  7. Coil voltage5 − 0.24.8 V3.75 V (75 %) is enough to pick up
  8. Coil energyE = ½ × 0.1 × 0.07²≈ 0.25 mJwithout a diode VCE exceeds 40 V
  9. Peak VCE with diode5 + 0.95.9 V
  10. Release time constantτ = 100 mH / 71 Ω≈ 1.4 msthe relay releases a few ms late
2N3904 + 680 Ω + 1N4148 is enough. The transistor is deep in saturation, losing only 14 mW.
Animation

Final circuit: the NPN drives the coil, at turn-off the current loops through the 1N4148

The contact closes above the pick-up current and opens below the drop-out current. The diode lets the current decay slowly, so release is delayed.

Design notes

  • Pull-down: 10 kΩ base to emitter. It drains leakage at boot and in cutoff.
  • Need faster release? Add a zener in series with the diode (design d).

Part choice

2N3904 / MMBT3904

40 V, 200 mA. Still hFE ≥ 40 at 70 mA. Cheap and everywhere.

Why not a MOSFET?

It would work (2N7002, AO3400A). But for a slow 70 mA load a BJT is enough.

1N4148

Peak current equals the coil current, 70 mA. Switching is slow, so a 1N4007 also works.

Lab

What if? Saturation, pin current and flyback

Model: VOH = 3.2 V, VBE(sat) = 0.85 V, 5 V coil, L = 100 mH. Saturation test: forced β ≤ hFE(min)/2 (good), ≤ hFE(min) (marginal). Without the diode VCE clamps at ~60 V avalanche (outside the transistor’s ratings).

BOM

RefPartValue / notePackage
Q12N3904 / MMBT390440 V, 200 mATO-92 / SOT-23
R1Base resistor680 Ω0603
R2Pull-down10 kΩ0603
D11N4148Across the coil, cathode to +5 VSOD-123 / DO-35
K1Relay5 V, 70 mA coil—

A 3.3 V GPIO cannot turn this MOSFET on safely; it needs a gate driver. The IRLZ44N’s RDS(on) is only guaranteed at 4, 5 and 10 V. A part with a 2 V threshold barely clears the plateau at 3.3 V.

Calculation 1: straight from 3.3 V

Load12 V LED strip, 5 APWM1 kHzVGS3.3 VRDS(on)≈ 60 mΩ, typicalAmbient≤ 40 °CRθJA62 °C/W
  1. Conduction lossP = 5² × 0.060 × 1.45≈ 2.2 W1.45 = temperature factor
  2. Junction temperatureTj = 40 + 2.2 × 62≈ 176 °C
Direct drive does not work. Tj exceeds the 175 °C limit, and even that figure is not guaranteed.

Calculation 2: with a 12 V gate driver

DriverUCC27517, VDD 12 VVGS12 VVGS(max)±16 VRDS(on)≤ 22 mΩ @ 25 °CRG10 Ω
  1. Hot RDS(on)22 mΩ × 1.37≈ 30 mΩat ~87 °C
  2. Conduction lossP = 5² × 0.030≈ 0.75 WD = 100 %, worst case
  3. Tj, no heatsinkTj = 40 + 0.75 × 62≈ 87 °Cworks, but the case is too hot to touch
  4. Tj, clip heatsinkTj = 40 + 0.64 × 21≈ 53 °C≈ 21 °C/W total
  5. Rise timetr = 15 nC × 12 Ω / 9.25 V≈ 20 nsplateau ≈ 2.75 V; tf ≈ 65 ns
  6. Switching lossP = ½ × 12 × 5 × 85 ns × 1 kHz≈ 2.6 mWnegligible
Driver + IRLZ44N + clip heatsink: Tj ≈ 53 °C. A 12 V gate stays safely below the ±16 V limit.
Animation

Final circuit: MCU → gate driver → IRLZ44N

The “drive” choice in the lab also changes this schematic. From a bare 3.3 V GPIO the gate rises slowly and hangs on the plateau (see the scope).

Design notes

  • Gate voltage: power the driver from 12 V, never from 24 V.
  • Capacitors: 470 µF + 100 nF at the strip feed, 1 µF at the driver VDD.
  • Gate: a 10 kΩ pull-down and a short gate loop.
  • If you use a DPAK: ~2.5 cm² of copper gives RθJA ≈ 50 °C/W.
  • Flicker: 1 kHz is invisible to the eye but cameras may band. With the driver, 20 kHz still costs only ~50 mW.

Part choice

IRLZ44N

55 V, 47 A, 25 mΩ guaranteed at 5 V. TO-220: easy to solder and to heatsink.

UCC27517

4 A peak, VDD 4.5–18 V. The TTL-threshold input takes 3.3 V. Alternative: TC4427.

Driver-less option

Pick a MOSFET with RDS(on) guaranteed at 2.5 V. See Chapter 06.

Lab

What if? Drive voltage, package and temperature

Model: IRLZ44N max RDS(on) (typical 60 mΩ at 3.3 V, not guaranteed), R(T) = R25·(1 + 0.006·(T − 25)), Qgd = 15 nC, plateau 2.6 V + 0.03 V/A. GPIO: RG 100 Ω + 30 Ω pin; driver: 10 Ω + 2 Ω. Tj is solved iteratively. Plot: Tj versus load current.

BOM

RefPartValue / notePackage
Q1IRLZ44N55 V, 47 A, 22 mΩ @ 10 VTO-220 + clip heatsink
U1UCC27517Low-side gate driver, VDD = 12 VSOT-23-5
R1Gate resistor10 Ω0805
R2Pull-down10 kΩ0603
C1, C2Driver decoupling1 µF 25 V + 100 nF0805
C3Strip feed bulk470 µF 25 VElectrolytic
F1Fuse7.5 A (see Chapter 12)Blade

An 18 V zener makes release 2.5× faster. The price: the MOSFET sees 43 V, so a 60 V part is used.

Calculation

trelease = τ · ln((I0 + Vc/R) / (Idrop + Vc/R)) Vc = clamp voltage. A larger Vc kills the current faster.
Solenoid24 V, 1.5 AR16 ΩL≈ 50 mH (assumed)Drop-out current20 % → 0.3 ARatea few Hz
  1. Time constantτ = 50 mH / 16 Ω≈ 3.1 ms
  2. Stored energyE = ½ × 0.05 × 1.5²≈ 56 mJ
  3. Release, diode onlyt = 3.1 ms × ln(1.55 / 0.35)≈ 4.7 msVc ≈ 0.8 V
  4. Release, diode + 18 V zenert = 3.1 ms × ln(2.68 / 1.48)≈ 1.9 msVc = 18.8 V; current is zero at 2.6 ms
  5. Peak VDS24 + 18.842.8 V29 % margin on a 60 V MOSFET
  6. Clamp energy per releaseEc = 18.8 × (4.69 − 3.05) mA·s≈ 31 mJthe other ~25 mJ heats the coil
  7. Zener average power31 mJ × 2 Hz≈ 60 mWa 5 W 1N5355B is relaxed
  8. MOSFET conduction lossP = 1.5² × 0.035 × 1.5≈ 0.12 WΔT ≈ 7 °C, no heatsink
FQP30N06L + 1N4007 + 18 V zener: release in 1.9 ms. The MOSFET sees at most 42.8 V, below its 60 V rating.
Animation

Final circuit: diode + zener clamp, plunger motion

Time slowed ~100×. At turn-off coil current loops through D1 and Z1; VDS = 24 V + VZ + VF. The lab settings also drive this animation.

Design notes

  • Gate drive: the FQP30N06L is not specified at 3.3 V. Power a UCC27517 from 12 V (78L12 off the 24 V rail).
  • Supply surges: put an SMBJ28A TVS on the 24 V input.
  • Why not let it avalanche? The energy then burns in the MOSFET. Only acceptable if EAR covers 56 mJ repetitively (Chapter 08).

Part choice

FQP30N06L

60 V logic-level TO-220, 35 mΩ with a 12 V gate. The ±20 V gate rating leaves margin for 12 V drive.

1N5355B (18 V 5 W)

A surge-rated zener. Alternative: a unidirectional TVS (SMBJ15A).

1N4007

The series diode stops the zener conducting forward in normal operation. In PWM use a UF4007 or a Schottky.

Lab

What if? Zener voltage, release time, VDS margin

Model: at turn-off di/dt = −(Vc + i·R)/L, Vc = VZ + 0.8 V (VZ = 0 → diode only). R = V/I0. Drop-out assumed at 20 % of I0. Faint curve: diode-only comparison.

BOM

RefPartValue / notePackage
Q1FQP30N06L60 V, 32 A, 35 mΩ @ 10 VTO-220
U1UCC27517Gate driver, VDD 12 VSOT-23-5
U278L1224 V → 12 V, 100 mASOT-89 / TO-92
D11N4007Series diodeDO-41
Z11N5355B18 V, 5 WAxial
D2SMBJ28A24 V input TVSSMB
R1, R2RG, pull-down10 Ω, 10 kΩ0805

Two directions need an H-bridge; use an integrated bridge IC. A discrete bridge leaves dead-time, bootstrap and protection to you. Shoot-through mistakes are easy to make.

Calculation

Motor12 V, 2 A runningRm1.2 ΩLm≈ 0.5 mHBridgeVNH5019A-E, ≈ 18 mΩ/switchPWM20 kHz
  1. Start-up (stall) currentI = 12 V / 1.2 Ω10 Aat every start, with zero back-EMF
  2. Running conduction lossP = 2² × 2 × 0.018 × 1.3≈ 0.19 Wtwo switches, temperature factor 1.3
  3. Switching lossP = ½ × 12 × 2 × 1.5 µs × 20 kHz≈ 0.36 Wthe bridge has slow edges, ~0.75 µs
  4. Stall lossP = 10² × 0.036≈ 3.6 Wsurvivable only briefly
  5. Ripple at 20 kHzΔI = 12 × 0.25 / (0.5 mH × 20 kHz)0.3 Aslow decay, D = 0.5
  6. Ripple at 1 kHzΔI = 12 × 0.25 / (0.5 mH × 1 kHz)6 Aaudible whine and extra copper loss
  7. Current-sense output10 A × 0.14 V/A1.4 VRCS ≈ 1 kΩ; fits the ADC
  8. Hot-plug peak currentI = 12 V / 0.1 Ω≈ 120 Aonly ESR + cable limit the 470 µF
The VNH5019A-E dissipates ≈ 0.55 W running at 20 kHz. Stall and hot-plug current still need limiting.
Animation

Final circuit: integrated H-bridge, forward/reverse and slow decay

With PWM on, current flows through two diagonal switches (copper). With PWM off, both low-side switches conduct and current circulates at the bottom (“slow decay”). Direction flips every ~3 s.

Design notes

  • Firmware limit: if I > 4 A for more than 300 ms, the motor is stalled; stop it.
  • Soft start: ramp the duty over ~300 ms. The start-up peak drops from 10 A to ~5 A.
  • Bulk capacitor: 470 µF low-ESR at the bridge is a must. Add an NTC or eFuse against hot-plug (Chapter 11).
  • MCU supply: give its regulator its own diode and capacitor, so dips do not reset it.
  • Braking: a decelerating motor pumps energy back into the supply. Add an SMBJ15A TVS and enough capacitance.

Bridge options

OptionProCon
VNH5019A-E12 A, protection, CS output, single packagePWM ≤ 20 kHz, mid price
DRV8871 / DRV8874Built-in current regulation, small~3.6–6 A peak: limits the 10 A stall, less torque
L298NCheap, everywhereBipolar: ~3 V drop at 2 A, ~6 W loss; motor gets 9 V
Discrete 4×N-MOS + driverScales to any currentDead-time, bootstrap and protection are your job
Lab

What if? Frequency, start-up ramp, current limit

Model: Rm = 1.2 Ω, constant load torque (2 A), mechanical time constant 150 ms, inductance neglected for start-up; ripple from the slow-decay formula. Faint curve: start without ramp or limit.

BOM

RefPartValue / notePackage
U1VNH5019A-EH-bridge, 12 A, CS outputMultiPowerSO-30
C1Bulk470 µF 25 V low ESRElectrolytic
C2Decoupling100 nF + 1 µF0805
R1, C3CS resistor + filter1 kΩ, 10 nF0603
D1SMBJ15ABraking TVSSMB
F1Fuse5 A slow-blow (stalls are brief)Blade
RT1NTC (optional)~1 Ω cold, for hot-plugDisc

The switch must be high-side; the sensor ground must stay tied to the MCU. Cut the low side and the board feeds itself through the signal lines and the MCU pin diodes. This “phantom powering” can damage the pins.

Calculation

Loadsensor board, 12 V 0.3 AInput capacitance100 µFQ1AO3401A, ±12 VR1 = R210 kΩCGD330 nFGPIO3.3 V
  1. VGS straight from the GPIO3.3 − 12−8.7 Vthe P-MOS stays on; an NPN level shifter is needed
  2. VGS with the divider−(12 − 0.1) × 10k / 20k≈ −5.95 Vpulling the gate to 0 V would give −12 V: right at the limit
  3. RDS(on)between 60 mΩ (−4.5 V) and 50 mΩ (−10 V)≈ 57 mΩ
  4. NPN collector currentIC = 12 V / 20 kΩ0.6 mA
  5. NPN base currentIB = (3.3 − 0.7) / 10 kΩ0.26 mAvery deep saturation
  6. Inrush with a hard switch-onI = 12 V / 0.15 Ω≈ 80 Athe 12 V rail collapses and everything on it resets
  7. Gate current on the plateauIG = (12 − 1.8)/R2 − 1.8/R10.84 mA|VGS| ≈ 1.8 V
  8. Output slew ratedV/dt = 0.84 mA / 330 nF≈ 2.5 V/msramp ≈ 4.7 ms
  9. Inrush with soft startI = 100 µF × 2.5 V/ms≈ 0.25 Aon top of the load current
  10. MOSFET energy during the ramp½CV² + V·I·t/6 = 7.2 + 2.8≈ 10 mJpeak ~2.4 W; check the 10 ms pulse in the SOA
Inrush drops from 80 A to 0.25 A. The output rises gently in ~5 ms and the 12 V rail holds.
Animation

Final circuit: P-MOS + NPN level shifter + Miller-capacitor soft start

GPIO high → NPN conducts → the divider pulls the gate ~6 V down → the P-MOS turns on. CGD holds the gate on its plateau, so the output rises in ~5 ms. The copper side branch on the right is the 100 µF charging current.

Design notes

  • Base pull-down: 100 kΩ. It keeps the NPN off at boot.
  • Turn-off is slower, ~20 ms: only R1 discharges CGD. Lower R1 if you need it faster.

Part choice

AO3401A

−30 V, −4 A, ≤ 60 mΩ @ −4.5 V. VGS(max) ±12 V, so the divider is required. On a 24 V rail raise R2 or pick a ±20 V P-MOS.

BC847 / MMBT3904

Level shifter carrying only 0.6 mA. Any small NPN or a 2N7002 works.

Ready-made

A load-switch IC or an eFuse does the same in one package. See Chapter 11.

Lab

What if? Soft start and the gate divider

Model: |Vplateau| = 1.8 V, R1 gate–source, R2 gate–NPN, NPN VCE(sat) = 0.1 V; with CGD = 0 the intrinsic Crss ≈ 70 pF applies and inrush is limited by R = 0.15 Ω. Resistive load. AO3401A VGS(max) = ±12 V.

BOM

RefPartValue / notePackage
Q1AO3401A−30 V, −4 A, P-MOSSOT-23
Q2BC847 / MMBT3904NPN level shifterSOT-23
R1, R2Gate divider10 kΩ, 10 kΩ0603
R3, R4RB, pull-down10 kΩ, 100 kΩ0603
C1CGD (soft start)330 nF 25 V (+ opt. 1 kΩ series)0603