blob: 4fc1d31ce2e8786f842470b1afd6f6547dac5fd2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
---
title: High-side MOSFET switching
date: 2025-06-22
layout: post
---
Needed low-power switching for the [fingerprint door
lock](../fpm-door-lock-lp/). Servo and FPM draw high quiescent current--had to
cut power electronically during sleep. MOSFETs can do this.
Schematics belong to <a
href="https://electronics.stackexchange.com/users/292884/simon-fitch"
class="external" target="_blank" rel="noopener noreferrer">Simon Fitch</a>.
## Problem with simple low-side switching
Typical approach: GPIO → gate of N-channel MOSFET on low side, pull-down
resistor between gate and drain. Works if MCU and load don't share common
ground. Doesn't work when they do (like controlling a component powered by the
same MCU).
Issue: source potential = gate potential - threshold voltage. Example: 3.3V
gate - 1.5V threshold → 1.8V at load--not nearly enough for a servo. Raising
the gate potential above source is not always practical. Solution: high-side
switch.
## P-channel high-side switch

M1 is P-channel (high-side), M2 is N-channel (level converter). MCU output low
→ M2 off → R1 pulls M1 gate to +6V → servo off. MCU output high → M2 conducts →
M1 gate drops to 0V → servo on.
Note: IRF9540 in the schematic doesn't work. V<sub>GS</sub> (-10V) for
RDS<sub>on</sub> too much for 3.3V ATmega328P to drive. NDP6020P is the only
suitable through-hole MOSFET I could find.
## N-channel high-side switch

Less common but works if you have voltage high enough to drive the gate. Both
M1 and M2 are N-channel. MCU low → M2 off → M1 gate rises above threshold →
servo on. MCU high → M2 on → M1 gate drops → servo off. R2 prevents
high-impedance power-up from switching servo on.
M2 needed in both topologies for level conversion (0V ↔ +6V or +9V). Carries
<1mA. Gate-source threshold must be lower than MCU supply. Common choices:
2N7000, 2N7002, BSS138.
Note: D1 flyback diodes protect MOSFETs from voltage spikes caused by inductive
loads (servos, relays).
## A BJT alternative

Simpler, cheaper, more available. Q2 conducts when MCU outputs high. Q2
amplifies Q1's base current. Unlike MOSFETs (voltage-driven), BJTs are
current-driven. R3 and R4 must be calculated for desired base currents. <a
href="https://teachmetomake.wordpress.com/how-to-use-a-transistor-as-a-switch/"
class="external" target="_blank" rel="noopener noreferrer">Guide on BJT
switches</a>.
## Which topology?
MOSFETs preferred in professional work—more efficient when on. Harder to drive
at 3.3V due to V<sub>GS</sub> requirements for full saturation (low
R<sub>DS(on)</sub>).
N-channel: Lower on-resistance, cheaper, more efficient than P-channel. Harder
to drive high-side (gate must be above source—requires extra circuitry like
MOSFET drivers).
Used P-channel high-side for the door lock redesign. Simpler to drive from 3.3V
MCU, no driver needed.
## Further reading
- <a href="https://www.embeddedrelated.com/showarticle/98.php"
class="external" target="_blank" rel="noopener noreferrer">Different MOSFET
topologies</a>
- <a href="https://www.embeddedrelated.com/showarticle/809.php"
class="external" target="_blank" rel="noopener noreferrer">How to read
MOSFET datasheets</a>
- <a href="https://teachmetomake.wordpress.com/how-to-use-a-transistor-as-a-switch/"
class="external" target="_blank" rel="noopener noreferrer">How to use a
transistor as a switch</a>
- <a href="https://forum.digikey.com/t/guide-to-selecting-and-controlling-a-mosfet-for-3-3-vdc-logic-applications/42606"
class="external" target="_blank" rel="noopener noreferrer">Guide to
selecting and controlling a MOSFET for 3.3 VDC logic applications</a>
- <a href="https://forum.digikey.com/t/driving-a-large-relay-from-a-3-3-vdc-microcontroller-using-an-npn-darlington-transistor/41751"
class="external" target="_blank" rel="noopener noreferrer">Driving a large
relay from a 3.3 VDC microcontroller using an NPN Darlington transistor</a>
|