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
- VDS marginVDS ≥ 1.5 × 12 V≥ 18 Vpick a 30 V part
- RDS(on) at 3.3 Vbetween 48 mΩ @ 2.5 V and 32 mΩ @ 4.5 V≈ 42 mΩAO3400A, max, 25 °C
- Hot RDS(on)42 mΩ × 1.4≈ 59 mΩ
- Conduction lossP = 0.25² × 0.059 × 13.7 mWD = 1, worst case
- Peak gate currentI = 3.3 V / (100 + 30) Ω≈ 25 mAshort pulse, safe for the pin
- Turn-on gate currentIG = (3.3 − 1.7) / 130≈ 12 mAMiller plateau ≈ 1.7 V
- Transition timetr = 2 nC / 12 mA≈ 0.16 µsQgd ≈ 2 nC; tf ≈ 0.15 µs
- Switching lossP = ½ × 12 × 0.25 × 0.31 µs × 25 kHz≈ 12 mW
- Gate drive powerP = 4 nC × 3.3 V × 25 kHz≈ 0.3 mWspent in RG and the pin, not the MOSFET
- Temperature riseΔT = 16 mW × 125 °C/W≈ 2 °CSOT-23, RθJA
- PWM resolution80 MHz / 25 kHz = 320011 bitESP32 LEDC, 2048 steps
Final circuit: the GPIO PWMs, fan current freewheels through the diode
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).
What if? Frequency, RG and losses
BOM
| Ref | Part | Value / note | Package |
|---|---|---|---|
| Q1 | AO3400A | 30 V, 5.7 A, logic-level | SOT-23 |
| R1 | Gate resistor | 100 Ω | 0603 |
| R2 | Pull-down | 10 kΩ | 0603 |
| D1 | SS14 | 40 V 1 A Schottky, across the fan | SMA |
| C1, C2 | Decoupling | 10 µF 25 V + 100 nF | 0805 |
| J1 | Fan header | 2/3 pin | THT |
A 2N3904 and two resistors are enough. A 3.3 V pin saturates it easily for a 70 mA coil.
Calculation
- Collector currentIC = (5 − 0.2) V / 71 Ω≈ 70 mABC547 (100 mA) is marginal, 2N3904 (200 mA) is comfortable
- Minimum gainbetween 60 @ 50 mA and 30 @ 100 mAhFE(min) ≈ 402N3904 datasheet
- Base currentIB = 70 mA / 203.5 mAforced β = 20, half of hFE(min)
- Base resistorRB = (3.2 − 0.85) V / 3.5 mA≈ 670 Ω → 680 ΩE12; pin current is fine for any MCU
- Current stolen by pull-down0.85 V / 10 kΩ85 µAnegligible
- Transistor lossP = 70 mA × 0.2 V14 mW
- Coil voltage5 − 0.24.8 V3.75 V (75 %) is enough to pick up
- Coil energyE = ½ × 0.1 × 0.07²≈ 0.25 mJwithout a diode VCE exceeds 40 V
- Peak VCE with diode5 + 0.95.9 V
- Release time constantτ = 100 mH / 71 Ω≈ 1.4 msthe relay releases a few ms late
Final circuit: the NPN drives the coil, at turn-off the current loops through the 1N4148
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.
What if? Saturation, pin current and flyback
BOM
| Ref | Part | Value / note | Package |
|---|---|---|---|
| Q1 | 2N3904 / MMBT3904 | 40 V, 200 mA | TO-92 / SOT-23 |
| R1 | Base resistor | 680 Ω | 0603 |
| R2 | Pull-down | 10 kΩ | 0603 |
| D1 | 1N4148 | Across the coil, cathode to +5 V | SOD-123 / DO-35 |
| K1 | Relay | 5 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
- Conduction lossP = 5² × 0.060 × 1.45≈ 2.2 W1.45 = temperature factor
- Junction temperatureTj = 40 + 2.2 × 62≈ 176 °C
Calculation 2: with a 12 V gate driver
- Hot RDS(on)22 mΩ × 1.37≈ 30 mΩat ~87 °C
- Conduction lossP = 5² × 0.030≈ 0.75 WD = 100 %, worst case
- Tj, no heatsinkTj = 40 + 0.75 × 62≈ 87 °Cworks, but the case is too hot to touch
- Tj, clip heatsinkTj = 40 + 0.64 × 21≈ 53 °C≈ 21 °C/W total
- Rise timetr = 15 nC × 12 Ω / 9.25 V≈ 20 nsplateau ≈ 2.75 V; tf ≈ 65 ns
- Switching lossP = ½ × 12 × 5 × 85 ns × 1 kHz≈ 2.6 mWnegligible
Final circuit: MCU → gate driver → IRLZ44N
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.
What if? Drive voltage, package and temperature
BOM
| Ref | Part | Value / note | Package |
|---|---|---|---|
| Q1 | IRLZ44N | 55 V, 47 A, 22 mΩ @ 10 V | TO-220 + clip heatsink |
| U1 | UCC27517 | Low-side gate driver, VDD = 12 V | SOT-23-5 |
| R1 | Gate resistor | 10 Ω | 0805 |
| R2 | Pull-down | 10 kΩ | 0603 |
| C1, C2 | Driver decoupling | 1 µF 25 V + 100 nF | 0805 |
| C3 | Strip feed bulk | 470 µF 25 V | Electrolytic |
| F1 | Fuse | 7.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
- Time constantτ = 50 mH / 16 Ω≈ 3.1 ms
- Stored energyE = ½ × 0.05 × 1.5²≈ 56 mJ
- Release, diode onlyt = 3.1 ms × ln(1.55 / 0.35)≈ 4.7 msVc ≈ 0.8 V
- 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
- Peak VDS24 + 18.842.8 V29 % margin on a 60 V MOSFET
- Clamp energy per releaseEc = 18.8 × (4.69 − 3.05) mA·s≈ 31 mJthe other ~25 mJ heats the coil
- Zener average power31 mJ × 2 Hz≈ 60 mWa 5 W 1N5355B is relaxed
- MOSFET conduction lossP = 1.5² × 0.035 × 1.5≈ 0.12 WΔT ≈ 7 °C, no heatsink
Final circuit: diode + zener clamp, plunger motion
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.
What if? Zener voltage, release time, VDS margin
BOM
| Ref | Part | Value / note | Package |
|---|---|---|---|
| Q1 | FQP30N06L | 60 V, 32 A, 35 mΩ @ 10 V | TO-220 |
| U1 | UCC27517 | Gate driver, VDD 12 V | SOT-23-5 |
| U2 | 78L12 | 24 V → 12 V, 100 mA | SOT-89 / TO-92 |
| D1 | 1N4007 | Series diode | DO-41 |
| Z1 | 1N5355B | 18 V, 5 W | Axial |
| D2 | SMBJ28A | 24 V input TVS | SMB |
| R1, R2 | RG, pull-down | 10 Ω, 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
- Start-up (stall) currentI = 12 V / 1.2 Ω10 Aat every start, with zero back-EMF
- Running conduction lossP = 2² × 2 × 0.018 × 1.3≈ 0.19 Wtwo switches, temperature factor 1.3
- Switching lossP = ½ × 12 × 2 × 1.5 µs × 20 kHz≈ 0.36 Wthe bridge has slow edges, ~0.75 µs
- Stall lossP = 10² × 0.036≈ 3.6 Wsurvivable only briefly
- Ripple at 20 kHzΔI = 12 × 0.25 / (0.5 mH × 20 kHz)0.3 Aslow decay, D = 0.5
- Ripple at 1 kHzΔI = 12 × 0.25 / (0.5 mH × 1 kHz)6 Aaudible whine and extra copper loss
- Current-sense output10 A × 0.14 V/A1.4 VRCS ≈ 1 kΩ; fits the ADC
- Hot-plug peak currentI = 12 V / 0.1 Ω≈ 120 Aonly ESR + cable limit the 470 µF
Final circuit: integrated H-bridge, forward/reverse and slow decay
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
| Option | Pro | Con |
|---|---|---|
| VNH5019A-E | 12 A, protection, CS output, single package | PWM ≤ 20 kHz, mid price |
| DRV8871 / DRV8874 | Built-in current regulation, small | ~3.6–6 A peak: limits the 10 A stall, less torque |
| L298N | Cheap, everywhere | Bipolar: ~3 V drop at 2 A, ~6 W loss; motor gets 9 V |
| Discrete 4×N-MOS + driver | Scales to any current | Dead-time, bootstrap and protection are your job |
What if? Frequency, start-up ramp, current limit
BOM
| Ref | Part | Value / note | Package |
|---|---|---|---|
| U1 | VNH5019A-E | H-bridge, 12 A, CS output | MultiPowerSO-30 |
| C1 | Bulk | 470 µF 25 V low ESR | Electrolytic |
| C2 | Decoupling | 100 nF + 1 µF | 0805 |
| R1, C3 | CS resistor + filter | 1 kΩ, 10 nF | 0603 |
| D1 | SMBJ15A | Braking TVS | SMB |
| F1 | Fuse | 5 A slow-blow (stalls are brief) | Blade |
| RT1 | NTC (optional) | ~1 Ω cold, for hot-plug | Disc |
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
- VGS straight from the GPIO3.3 − 12−8.7 Vthe P-MOS stays on; an NPN level shifter is needed
- 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
- RDS(on)between 60 mΩ (−4.5 V) and 50 mΩ (−10 V)≈ 57 mΩ
- NPN collector currentIC = 12 V / 20 kΩ0.6 mA
- NPN base currentIB = (3.3 − 0.7) / 10 kΩ0.26 mAvery deep saturation
- Inrush with a hard switch-onI = 12 V / 0.15 Ω≈ 80 Athe 12 V rail collapses and everything on it resets
- Gate current on the plateauIG = (12 − 1.8)/R2 − 1.8/R10.84 mA|VGS| ≈ 1.8 V
- Output slew ratedV/dt = 0.84 mA / 330 nF≈ 2.5 V/msramp ≈ 4.7 ms
- Inrush with soft startI = 100 µF × 2.5 V/ms≈ 0.25 Aon top of the load current
- 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
Final circuit: P-MOS + NPN level shifter + Miller-capacitor soft start
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.
What if? Soft start and the gate divider
BOM
| Ref | Part | Value / note | Package |
|---|---|---|---|
| Q1 | AO3401A | −30 V, −4 A, P-MOS | SOT-23 |
| Q2 | BC847 / MMBT3904 | NPN level shifter | SOT-23 |
| R1, R2 | Gate divider | 10 kΩ, 10 kΩ | 0603 |
| R3, R4 | RB, pull-down | 10 kΩ, 100 kΩ | 0603 |
| C1 | CGD (soft start) | 330 nF 25 V (+ opt. 1 kΩ series) | 0603 |