Basic Electronics, Chapter 6: Challenge 3 solution (High-side switching and level shifting) (a) Divider from 5 V to a 3.3 V input: 1 kohm in series, 2 kohm to ground Vout = 5 x 2 / (1 + 2) = 3.33 V Divider current = 5 / 3000 = 1.67 mA Output resistance = 1k || 2k = (1 x 2) / (1 + 2) = 667 ohm tau = 667 x 20e-12 = 13.3 ns (10-90 % rise about 29 ns: fast enough for signals of a few MHz) With 4.7 kohm instead of 2 kohm: Vout = 5 x 4.7 / (1 + 4.7) = 4.12 V which is ABOVE a 3.3 V pin's supply. The input's protection diodes would conduct and the pin can be damaged. The ratio must give 3.3 V or below at the HIGH level. Divider current drops to 5 / 5700 = 0.88 mA. (b) P-channel IRF9540N high side, 24 V, 470 ohm load, NPN shifter from a 3.3 V pin With R6 = 10 kohm alone: when Q1 is on, the gate is pulled to about 0.1 V. VGS = 0.1 - 24 = -23.9 V, beyond the gate's +/-20 V maximum. The oxide layer breaks down and the MOSFET is destroyed. With a second 10 kohm between the gate and Q1's collector the two resistors divide the 24 V: gate voltage = 0.1 + (24 - 0.1) x 10k / (10k + 10k) = 12.05 V VGS = 12.05 - 24 = -11.95 V (a safe, well-enhanced value) Q1 collector current = (24 - 0.1) / 20000 = 1.195 mA Q1 VCE when off = 24 V (the whole supply). A 2N3904 has VCEO of 40 V, so it copes with 16 V of margin (below about 30 V is the sensible limit; above that use a higher-voltage transistor or two resistors in series). Base resistor for 1 mA from 3.3 V: RB = (3.3 - 0.7) / 0.001 = 2600 ohm -> E12 below: 2.2 kohm (IB = 1.18 mA) The minimum base current for forced beta 10 is only 1.195 / 10 = 0.12 mA, so this is generous. Turn-OFF (the gate returns to 24 V through R6 only): tau = 10000 x 1.3e-9 = 13 us, 10-90 % = 2.2 x 13 = 28.6 us. Load check: RDS(on) 0.117 ohm, current = 24 / 470 = 51 mA, VDS = 6 mV, P = 0.051^2 x 0.117 = 0.3 mW. Load power = 24^2 / 470 = 1.2 W: use a 2 W resistor. (c) Choosing the part and the board - 12 V buzzer, 30 mA, from an Uno: BJT (2N3904) low-side. Small load, 5 V pin supplies the base current easily: RB = (5 - 0.8) / 0.003 = 1.4 kohm -> 1.2 kohm. Use a flyback diode if it is a magnetic buzzer (coil), not a piezo one. - 12 V, 2 A pump pulsed at 1 kHz, from an ESP32: logic-level MOSFET (rated at 2.5 V or 3.3 V gate, such as the AO3400A or an IRLB8721 tested at 3.3 V). Over 300 mA, with PWM, from 3.3 V. Gate resistor 220 ohm, pull-down 10 kohm, flyback diode (a pump is an inductive motor). Conduction loss 2^2 x 0.05 = 0.2 W. - 5 V relay, 70 mA, from a Pico: BJT (2N3904) is fine at 70 mA. The Pico pin supplies only 4 mA by default, so use a forced beta of about 20: RB = 680 ohm gives IB = (3.3 - 0.8) / 680 = 3.7 mA, forced beta 70 / 3.7 = 19. Datasheet minimum hFE of 60 leaves a margin of about 3. A flyback diode is needed across the coil. - 6 V, 100 mA filament lamp from an Uno: logic-level MOSFET (IRLZ44N) low-side. The cold lamp draws about 10 times its running current (about 1 A), five times what a 2N3904 can carry. Gate resistor 220 ohm, pull-down 10 kohm. No flyback diode (a lamp is not inductive). Checklist - A P-channel gate must reach the source voltage to turn off, so a 3.3 V pin cannot turn off a 12 V high-side switch alone. - Keep |VGS| below 20 V: add a divider or a Zener on higher supplies. - Under about 100 mA a BJT; over about 300 mA or with PWM a logic-level MOSFET. - A lamp's cold inrush and a motor's stall current set the size of the switch.