summaryrefslogtreecommitdiffstats
path: root/_site/log/mosfet-switches/index.html
blob: 032df223e66449cae68fd7eecf0cedb345467bfb (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html>
    <head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>High-side MOSFET switching</title>
  <link rel="stylesheet" href="/assets/css/main.css">
  <link rel="stylesheet" href="/assets/css/skeleton.css">
</head>


  <body>

    <div id="nav-container" class="container">
  <ul id="navlist" class="left">
    
    <li >
      <a href="/" class="link-decor-none">hme</a>
    </li>
    <li class="active">
      <a href="/log/" class="link-decor-none">log</a>
    </li>
    <li >
      <a href="/projects/" class="link-decor-none">poc</a>
    </li>
    <li >
      <a href="/about/" class="link-decor-none">abt</a>
    </li>
    <li>
      <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
    </li>
    <li>
      <a href="/feed.xml" class="link-decor-none">rss</a>
    </li>
  </ul>
</div>



    <main>
      <div class="container">
        <div class="container-2">
          <h2 class="center" id="title">HIGH-SIDE MOSFET SWITCHING</h2>
          <h5 class="center">22 JUNE 2025</h5>
          <br>
          <div class="twocol justify"><p>Needed low-power switching for the <a href="../fpm-door-lock-lp/">fingerprint door
lock</a>. Servo and FPM draw high quiescent current–had to
cut power electronically during sleep. MOSFETs can do this.</p>

<p>Schematics belong to <a href="https://electronics.stackexchange.com/users/292884/simon-fitch" class="external" target="_blank" rel="noopener noreferrer">Simon Fitch</a>.</p>

<h2 id="problem-with-simple-low-side-switching">Problem with simple low-side switching</h2>

<p>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).</p>

<p>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>

<h2 id="p-channel-high-side-switch">P-channel high-side switch</h2>

<p><img src="p_high_side.png" alt="P-channel high-side switching circuit" /></p>

<p>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.</p>

<p>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.</p>

<h2 id="n-channel-high-side-switch">N-channel high-side switch</h2>

<p><img src="n_high_side.png" alt="N-channel high-side switching circuit" /></p>

<p>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.</p>

<p>M2 needed in both topologies for level conversion (0V ↔ +6V or +9V). Carries
&lt;1mA. Gate-source threshold must be lower than MCU supply. Common choices:
2N7000, 2N7002, BSS138.</p>

<p>Note: D1 flyback diodes protect MOSFETs from voltage spikes caused by inductive
loads (servos, relays).</p>

<h2 id="a-bjt-alternative">A BJT alternative</h2>

<p><img src="bjt.png" alt="BJT architecture" /></p>

<p>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>.</p>

<h2 id="which-topology">Which topology?</h2>

<p>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>).</p>

<p>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).</p>

<p>Used P-channel high-side for the door lock redesign. Simpler to drive from 3.3V
MCU, no driver needed.</p>

<h2 id="further-reading">Further reading</h2>

<ul>
  <li><a href="https://www.embeddedrelated.com/showarticle/98.php" class="external" target="_blank" rel="noopener noreferrer">Different MOSFET
topologies</a></li>
  <li><a href="https://www.embeddedrelated.com/showarticle/809.php" class="external" target="_blank" rel="noopener noreferrer">How to read 
MOSFET datasheets</a></li>
  <li><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></li>
  <li><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></li>
  <li><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></li>
</ul>
</div>
          <p class="post-author right">by W. D. Sadeep Madurange</p>
        </div>
      </div>
    </main>

    <div class="footer">
  <div class="container">
    <div class="twelve columns right container-2">
      <p id="footer-text">&copy; ASCIIMX - 2026</p>
    </div>
  </div>
</div>


  </body>
</html>