Active components: regulators, op-amps, MCUs
LDOs vs bucks, op-amp rules, and what a microcontroller needs around it on a board.
Day 4 · 50 min
After this lesson
- You can choose between an LDO and a buck converter by computing the losses.
- You can apply the op-amp golden rules to gain and comparator circuits.
- You can list the support circuitry a microcontroller needs.
Regulators, op-amps and the MCU on a board
Two ways to step a voltage down
A linear regulator (LDO) is a variable resistor in series with the load: an error amplifier compares the output with a reference and adjusts a pass transistor until Vout is right. Everything the transistor drops becomes heat, P = (Vin − Vout) · I, and the efficiency is just Vout / Vin. From 12 V to 3.3 V at 500 mA that is 8.7 V × 0.5 A = 4.35 W at 27.5% efficiency, inside a part the size of a fingernail whose junction rises 60 to 90 °C per watt. Its virtues are real: two capacitors, no switching noise, and 60 dB or more of supply rejection. The dropout voltage, the smallest Vin − Vout it can regulate, is 1.1 V typical and 1.3 V maximum at 0.8 A for the classic AMS1117 (Advanced Monolithic Systems datasheet) and 100 to 300 mV for modern PMOS parts.
A buck converter never lets a resistive element carry the difference. A switch connects the input to an inductor for a fraction D of each period, and the inductor and output capacitor average the pulses, so Vout = D · Vin: 3.3 V from 12 V needs D = 27.5%. While the switch is on, the inductor current rises by (Vin − Vout) · D / (L · f); while it is off, the low-side switch or a diode carries the current as it falls. Efficiency is typically 85 to 95% at moderate load, so the same 0.5 A job wastes about 0.2 W. The price is a 100 kHz to 2 MHz switching frequency, an inductor, input and output capacitors, a few millivolts of ripple, EMI, and a layout that needs care, because the loop of input capacitor and two switches carries amps in nanoseconds.
Boost, buck-boost and choosing
A boost converter makes Vout = Vin / (1 − D) and draws more current than it delivers: a 3.7 V cell producing 5 V at 1 A with 90% efficiency pulls 1.5 A. A buck-boost or SEPIC handles inputs that cross the output, as a Li-ion cell does around 3.3 V. The decision rule is simple. If (Vin − Vout) · I exceeds a watt or two, use a switcher. If the rail feeds a noise-sensitive analog circuit, follow the switcher with a low-noise LDO. If the drop is small and the current low, an LDO is cheaper and quieter.
Op-amps and comparators
An op-amp is a differential amplifier with enormous open-loop gain, so with negative feedback two golden rules hold: the output does whatever it takes to make the two inputs equal, and the inputs draw no current. The non-inverting amplifier then has gain 1 + Rf / Rg and the inverting one −Rf / Rin. A 10 mΩ shunt carrying 3 A drops 30 mV, and Rf = 99 kΩ with Rg = 1 kΩ gives a gain of 100, so an ADC sees 3.0 V. Respect the gain-bandwidth product: a 1 MHz part such as the LM358 has only 10 kHz of bandwidth at a gain of 100, and its few millivolts of input offset become hundreds of millivolts at the output. A comparator is the same triangle without feedback: the output slams to a rail depending on which input is higher. Add positive feedback for hysteresis, use a real comparator such as the open-collector LM393 (with a pull-up) instead of an op-amp, and never leave an input floating.
A microcontroller on a board
A bare MCU needs five things. Power: 100 nF at every supply pin, bulk capacitance per rail and a filtered analog supply. Reset: a 10 kΩ pull-up on the reset or EN pin, often with a capacitor and a button to ground. Boot configuration: strapping pins at defined levels, such as IO0 and IO12 on an ESP32. Clock: the internal RC oscillator is good to a few percent, but USB, CAN and accurate timing need a crystal, which uses the MCU's inverting amplifier plus two load capacitors, C1 = C2 = 2 · (CL − Cstray), about 10 pF for an 8 pF crystal with 3 pF of stray capacitance. An oscillator module is a powered clock with a buffered output; it costs more but removes the tuning. Programming: a header for SWD (SWDIO, SWCLK, reset, 3V3, ground), or UART plus the boot pins, or USB.
Interfaces and protection
For level shifting, a 5 V signal into a 3.3 V pin needs a resistor divider (1 kΩ over 2 kΩ for a slow signal such as the HC-SR04 echo), a BSS138 MOSFET stage with pull-ups for I²C, or a translator IC such as the 74LVC245. TVS diodes clamp surges and ESD: pick a standoff voltage above the working voltage, for example an SMBJ12A (12 V standoff, about 20 V clamp) on a 12 V input, place it at the connector, and give it a short, wide path to ground. Connectors carry the current and the abuse: a JST-XH is rated about 3 A per pin, and keyed housings stop reversed plugs. Add a P-FET or diode for reverse-battery protection on any supply that people plug in by hand.
Interactive: the buck converter in slow motion
Buck converter in slow motion
The duty cycle sets Vout = D · Vin. Watch the two switches alternate, the inductor current ramp up and down around the load current, and what the same job would cost as heat in an LDO.
- Output voltage D · Vin
- 3.30 V
- Inductor ripple ΔIL
- 0.218 A
- Peak inductor current
- 0.61 A
- Output ripple (ideal C)
- 2.47 mV
44% of the load current
Isat must exceed this
ΔI / (8 · f · Cout)
efficiency 27.5%
efficiency 89.7%
- LDO junction rise
- +261 °C
- LDO verdict
- Thermal shutdown
- Heat saved by the buck
- 4.16 W
- Switching share of buck loss
- 47%
at 60 °C/W
about 286 °C at 25 °C ambient
grows with frequency
In practice
Practice
Pick the regulator for the robot's logic rail
The robot's logic rail is 3.3 V at 500 mA for an ESP32 and its sensors, fed from a 12 V, 2000 mAh pack. (a) Compute the LDO's dissipation, efficiency and junction rise at 60 °C/W. (b) Estimate the loss of a buck converter at 90% efficiency, and the current each option draws from the pack. (c) Estimate the run time for each. (d) Choose an inductor for 30% ripple at 500 kHz.
Answer: show the worked solution
(a) LDO P = (12 - 3.3) x 0.5 = 4.35 W, efficiency 3.3 / 12 = 27.5%
junction rise = 4.35 W x 60 °C/W = 261 °C -> far past 150 °C shutdown
(b) Buck Pout = 3.3 x 0.5 = 1.65 W, Pin = 1.65 / 0.9 = 1.83 W, loss = 0.18 W
pack current: LDO 500 mA, buck 1.83 W / 12 V = 153 mA
(c) Runtime LDO 2000 mAh / 500 mA = 4 h, buck 2000 mAh / 153 mA = 13 h
(d) Inductor dI = 0.3 x 0.5 = 0.15 A
L = (12 - 3.3) x 0.275 / (0.15 x 500 kHz) = 31.9 µH -> choose 33 µH
peak = 0.5 + 0.075 = 0.575 A -> Isat of 1 A or more
ripple voltage = 0.15 / (8 x 500 kHz x 22 µF) = 1.7 mVThe LDO is not just inefficient here, it is impossible: 261 °C of rise means thermal shutdown within seconds. The buck costs an inductor and a careful layout but runs about 3.3 times longer on the same pack. If the ADC needs a very quiet 3.3 V, put a small LDO after a 5 V buck rail, where it only dissipates 1.7 V × 0.5 A = 0.85 W at full load.
Real-world scenario
Real-world scenario
The robot reboots every two minutes and the regulator is too hot to touch
A robot controller runs from a 3S Li-ion pack that sits near 12 V. An AMS1117-3.3 in a SOT-223 turns that into 3.3 V for an ESP32 with Wi-Fi, a few sensors and status LEDs, which together average about 200 mA. The board boots and drives normally for roughly two minutes, then resets; half a minute later it boots again and the cycle repeats. The regulator burns a finger, yet the pack voltage looks perfectly healthy on the meter.
Symptoms
- The board resets about two minutes after power-up, restarts roughly 30 seconds later, and repeats.
- The 3V3 rail collapses to 0 V at the moment of failure while the 12 V input stays steady.
- The SOT-223 is too hot to touch, and a thermal camera reads about 140 °C on its tab.
- The failure arrives later in a cold room and sooner inside the closed enclosure.
Interview questions
screenWhen would you choose an LDO over a buck converter, and when the reverse?
screenState the two golden rules of op-amps and use them to derive the gain of an inverting amplifier.
screenWhat does a microcontroller need on a board to start up reliably?
screenHow do you connect a 5 V sensor output to a 3.3 V microcontroller input?
deepA buck converter makes 3.3 V from 12 V. What is the duty cycle, and what sets the inductor value and the output ripple?
deepWhy does a buck converter layout matter so much, and which loops and nodes do you worry about?
Quiz
References and further reading
Where the ideas in this lesson come from, and what to read next. Books are the standard texts; papers are the original sources; standards are what employers work to.
- Documentationfree online
Espressif Systems (2025). ESP32 Hardware Design Guidelines: Schematic Checklist. docs.espressif.com.
Read: A real reset and boot-strap checklist for the MCU-on-a-board section.
- Documentationfree online
Advanced Monolithic Systems (2012). AMS1117: 1A Low Dropout Voltage Regulator (datasheet). advanced-monolithic.com (free PDF at advanced-monolithic.com/pdf/ds1117.pdf, http only).
Read: Page 3 for dropout and quiescent current, page 4 for why it needs a 22 µF tantalum output capacitor.
- Book
Paul Horowitz and Winfield Hill (2015). The Art of Electronics. Cambridge University Press, 3rd edition.
Read: The voltage-regulator and op-amp chapters.
- Bookfree online
Hank Zumbahlen (editor), Analog Devices (2008). Linear Circuit Design Handbook. Newnes.
Read: The op-amp basics chapter.
- Book
Ned Mohan, Tore M. Undeland and William P. Robbins (2003). Power Electronics: Converters, Applications, and Design. Wiley, 3rd edition.
Read: The DC-DC converter chapter for the buck converter in the viz.