Components in action: one board, every law
Power up the robot's motor-driver board one part at a time and watch Ohm's law, Kirchhoff's laws, the RC time constant and the right-hand rule work on real values.
Day 4 · 55 min
After this lesson
- You can follow the current through a real board from the battery connector to the motor and say what each part does on the way.
- You can apply Ohm's law, KCL, KVL, the voltage divider, Thevenin's theorem, the RC time constant and V = L·di/dt to the parts of the motor-driver board with real numbers.
- You can use the right-hand rule to find the direction of the magnetic field around a trace and inside a motor winding, and say what reversing the current does.
One real board, and the handful of laws that run it
Start with the water picture
Think of a garden hose. The tap's pressure is voltage, the water passing a point each second is current, and a kink in the hose is resistance. On the robot's motor-driver board the tap is a two-cell lithium pack at 6.0 to 8.4 V. This lesson follows that flow from the battery connector to the motor winding and stops at each part to show one law with the board's own numbers.
Ohm's law at the connector: Q1 is a resistor when it is on
After J1 the current meets Q1, a P-channel MOSFET that protects the board if the pack goes in backwards. The right way round it is switched on, and a switched-on MOSFET is a small resistor, here about 50 mΩ. Ohm's law, V = I · R, says what that costs: with both motors stalled at 1.5 A each plus the logic, about 3.15 A flows, so Q1 drops 0.16 V. The heat follows from P = I² · R, about 0.5 W, the limit for a SOT-23 package.
Kirchhoff's current law at the VM node
A river that splits around an island carries, in both arms together, exactly the water that arrived. Charge cannot pile up either, so at any junction the currents in equal the currents out. On this board the junction is the VM node just after Q1. It feeds the TB6612FNG with the two motor currents and the AMS1117 with the logic current plus the regulator's own 5 mA. At stall that is 1.5 + 1.5 + 0.155 = 3.155 A, and that total is what the connector pins, the fuse, Q1 and the first trace must carry. The 100 µF capacitor on the node is the local reservoir: a 1.5 A start-up surge lasting 10 µs drags it down by only ΔV = I · Δt / C = 0.15 V.
Power dissipation at the regulator
A linear regulator is a tap that throttles the pressure down and turns the difference into heat. The AMS1117 takes 8.4 V from a full pack and delivers 3.3 V, so every milliamp through it drops 5.1 V: P = (Vin − Vout) · I = 5.1 V × 0.15 A = 0.77 W, plus 8.4 V × 5 mA of ground current. At 60 °C/W for a SOT-223 on a modest pad, 0.81 W is a 48 °C rise, so about 73 °C, which is fine. Push the logic rail to 400 mA with Wi-Fi and the junction reaches the 150 °C shutdown line. Above a few hundred milliamps a buck converter in front of the regulator wastes a tenth of the power.
Kirchhoff's voltage law around the LED
Walk a loop of hills back to your own door: every metre you climbed, you also descended. Voltage around a closed loop works the same way, the rises equal the drops. The status LED is the smallest loop on the board: pin IO13 lifts the charge to 3.3 V, R3 drops some of it, the LED drops its forward voltage and ground closes the loop. A red LED drops about 2.0 V, so R3 gets 1.3 V and, by Ohm's law, 1.3 V / 1 kΩ = 1.3 mA flows: 3.3 − 1.3 − 2.0 = 0. Swap in a blue LED, which drops about 3.0 V, and only 0.3 V is left for the resistor: 0.3 mA, too dim to see. The rule for the resistor is R = (Vcc − Vf) / I, and the current should stay well under the 20 mA a microcontroller pin can source.
The voltage divider and Thevenin at the ADC pin
Two resistors in series share the voltage in proportion to their size, Vout = Vin · R2 / (R1 + R2). The battery monitor uses 100 kΩ over 47 kΩ, so a full 8.4 V pack appears as 2.69 V at the ADC pin. Thevenin's theorem adds the catch: seen from the pin, the divider is not a perfect 2.69 V source but a source behind R1 ∥ R2 = 32 kΩ. A tap at the end of a long thin pipe reads full pressure until you draw water, and an ADC draws a gulp of charge every time it samples. 32 kΩ is three times the 10 kΩ an ADC input likes, so this board puts 100 nF right at the pin: the capacitor hands over each gulp and the divider refills it in a few milliseconds.
The RC time constant on EN
Fill a bucket through a narrow tap and it fills fast at first, then slower as the level rises. A capacitor charging through a resistor does the same, and the product τ = R · C sets the pace: 63% of the way at 1τ, 75% at 1.39τ, 99% at 5τ. The ESP32's EN pin hangs off 10 kΩ to 3V3 with 1 µF to ground, so τ = 10 ms and EN crosses the chip's 0.75 × VDD threshold about 14 ms after the rail appears. That delay is the point: the regulator and the capacitors settle before the processor starts.
Decoupling: every trace is a small inductor
Water in a long hose has inertia: open the nozzle and it takes a moment to get going. Current has the same inertia, called inductance, and every millimetre of thin trace is about 1 nH of it. An inductor resists a change in current with V = L · di/dt. When the ESP32 switches, it pulls 50 mA in about 2 ns, 25 million amps per second, so 1 nH costs 25 mV and 10 mm of trace costs 250 mV, enough to glitch 3.3 V logic. The 100 nF capacitors C7 and C4 sit within a millimetre or two of their pins for exactly this reason: they shrink the loop the fast current has to travel, and with it the inductance.
The right-hand rule at the motor
In 1820 Ørsted saw a compass needle turn beside a wire: a current makes a magnetic field. The right-hand rule gives its direction. Grip a wire with your right hand, thumb along the current, and your fingers curl the way the field circles it. For a coil, curl your fingers along the current and your thumb points along the field inside, toward the coil's north end. The motor winding is that coil, and the H-bridge decides which way the current goes through it: reverse AIN1 and AIN2 and the field flips, so the torque flips. The winding is also an inductor, so when the bridge switches the current off it fights back with V = L · di/dt; 1 A stopped in 100 ns through 1 mH would be 10 kV, which is why the MOSFETs' body diodes give the current a path and clamp the pin at VM plus 0.7 V.
Interactive: the board in action
The board in action: eight stations, one current path
Follow the current from the battery connector to the motor. Each station lights the parts it is about, runs the charge along the real copper, and recomputes its law as you move the sliders. Click or tab to any part to inspect it, or switch the multimeter on and put its two probes on the board's test pads.
Ringed pads are test points for the meter.
Keyboard: Tab to a part or a test point, Enter or Space to inspect it or place a probe, Escape to close the card or lift the probes.
Power in: J1 and Q1
Ohm's law: V = I · R, and the heat P = I² · R
- Pack current
- 1.155 A
- Drop across Q1 V = I · R
- 57.75 mV
- Heat in Q1 P = I² · R
- 66.7 mW
- Drop along 13 mm of VM trace
- 4.80 mV
motors + regulator input
SOT-23, keep under about 0.5 W
1.5 mm wide, 1 oz: 4.16 mΩ
Dots are conventional current and move at a speed proportional to the amps. Red copper is the top layer, blue the bottom; amber halos mark the copper and parts the station is about.
In practice
Practice
Audit the board at full load
Both motors stall at 1.5 A, the logic rail draws 150 mA, and the pack is full at 8.4 V. (a) Find the pack current and the drop and heat in Q1. (b) Find the regulator's heat and junction temperature at 60 °C/W, then repeat for a 400 mA Wi-Fi burst and say what you would change. (c) The status LED becomes blue and must run at 5 mA: choose R3. (d) Firmware wants EN to wait 50 ms after the rail: choose C8.
Answer: show the worked solution
(a) Pack current 1.5 + 1.5 + 0.15 + 0.005 = 3.155 A (KCL at the VM node)
Q1 V = 3.155 A x 0.05 Ω = 0.158 V, P = 3.155² x 0.05 Ω = 0.498 W
a SOT-23 at its limit: fine for a stall, not for ever; 1.5 mm trace drops only 13 mV
(b) U3 at 150 mA (8.4 - 3.3) x 0.15 + 8.4 x 0.005 = 0.807 W -> +48 °C -> 73 °C junction, fine
U3 at 400 mA (8.4 - 3.3) x 0.40 + 0.042 = 2.08 W -> +125 °C -> 150 °C, thermal shutdown
put a 5 V buck in front (loss about 0.15 W at 400 mA) and let the LDO drop 1.7 V
(c) Blue LED 5 mA R = (3.3 - 3.0) / 0.005 = 60 Ω -> 56 Ω or 62 Ω (E24), P = 15 mW
or keep 1 kΩ and fit a red LED: 1.3 mA is plenty for an indicator
(d) EN for 50 ms t = 1.386 x R x C -> C = 0.050 / (1.386 x 10 kΩ) = 3.6 µF
4.7 µF gives 65 ms, 3.3 µF gives 46 ms; pick 4.7 µF if the firmware says 'at least'Every line is one of the laws from the theory: KCL for the pack current, Ohm and I²R for Q1, (Vin − Vout) · I for the regulator, KVL for the LED and τ · ln 4 for EN. The audit also shows why the numbers in a design review are never read off a datasheet alone: the regulator is fine at the nominal load and over the line in a Wi-Fi burst.
Real-world scenario
Real-world scenario
Telemetry says the pack is at 7.0 V while the meter says 7.9 V
Rev B of the motor-driver board carries the battery-monitor divider, 100 kΩ over 47 kΩ, straight into an ADC pin, and the firmware converts counts back to volts with the 147/47 ratio. On the bench a multimeter reads 7.90 V at the connector. The firmware reports 7.0 to 7.3 V, and the number jumps by 0.2 V between consecutive samples. Swapping the ESP32 module changes nothing. The 100 nF capacitor marked C9 on the drawing was left off the first build to save a part.
Symptoms
- The reported pack voltage is 8 to 12% low, and the error grows when the firmware samples the two line sensors just before it.
- Readings jump by about 0.2 V from sample to sample, far more than the resistors' 1% tolerance can explain.
- Probing the divider's midpoint with a 10 MΩ multimeter shows the expected 2.53 V, steady.
- Fitting a 100 nF capacitor from the ADC pin to ground makes the reading settle at 7.88 V.
Interview questions
screenWalk me through what happens electrically when the robot's motor-driver board is switched on.
screenWhere would you apply Kirchhoff's current law on this board, and why does it matter for choosing parts?
screenWhy does the status LED need a resistor, and how do you choose its value?
screenState the right-hand rule and give one place on a motor board where it matters.
deepA linear regulator drops 8.4 V to 3.3 V at 150 mA. Do the thermal maths, and tell me at what current you would switch to a buck.
deepThe ADC reads a 100 kΩ over 47 kΩ battery divider and the result is low and noisy. Diagnose it with Thevenin and fix it.
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.
- Book
Paul Horowitz and Winfield Hill (2015). The Art of Electronics. Cambridge University Press, 3rd edition.
Read: Chapter 1 for Ohm, Kirchhoff, dividers and Thevenin; chapter 9 for linear regulators and their heat.
- Paper
Gustav Kirchhoff (1845). Ueber den Durchgang eines elektrischen Stromes durch eine Ebene, insbesondere durch eine kreisförmige. Annalen der Physik und Chemie 140(4), 497-514.doi:10.1002/andp.18451400402
Read: The closing section: both circuit laws in their original words.
- Book
Georg Simon Ohm (1827). Die galvanische Kette, mathematisch bearbeitet. T. H. Riemann, Berlin.
Read: The preface and the first chapter, to see how V = I · R was argued from experiments.
- Paper
Léon Charles Thévenin (1883). Sur un nouveau théorème d'électricité dynamique. Comptes rendus hebdomadaires des séances de l'Académie des sciences 97, 159-161.
Read: All two pages; the theorem behind the divider's 32 kΩ.
- Bookfree online
Read: Chapter 13, sections 13-1 to 13-5: the field of a wire and of a solenoid, and the right-hand rule.
- Book
Henry W. Ott (2009). Electromagnetic Compatibility Engineering. Wiley.
Read: The decoupling chapter: V = L · di/dt and why distance to the pin is inductance.
- Book
Austin Hughes and Bill Drury (2019). Electric Motors and Drives: Fundamentals, Types and Applications. Newnes, 5th edition.
Read: The brushed DC motor chapter: torque from current, back-EMF from speed.
- Documentationfree online
Espressif Systems (2025). ESP32 Hardware Design Guidelines: Schematic Checklist. docs.espressif.com.
Read: The EN (CHIP_PU) RC network and the ADC input notes.
- 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: Ground current and thermal resistance for the regulator station.
- Documentationfree online
Toshiba (2014). TB6612FNG: Driver IC for Dual DC Motor (datasheet). toshiba.semicon-storage.com.
Read: Output saturation voltage and the body diodes that catch the flyback.