Hardware Academy
PCB Design

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.

Power tree of the motor-driver board: the pack enters through J1 and Q1, splits at the VM node into the motor driver and the regulator, and the 3.3 volt rail feeds the ESP32, the EN network and the LED; each part is labelled with the law that acts there2S Li-ion pack6.0 to 8.4 VJ1JST XH, 3 AQ1 P-FETOhm: 0.15 V at 3 AVM node: KCL3.0 A + 0.155 A in = outU2 TB6612FNGtwo H-bridgesMotor LMotor Rwinding: right-hand rule,flyback V = L · di/dtU3 AMS1117-3.3P = 5.1 V × 0.15 A = 0.77 Wheat, +46 °C3V3ESP32 + C7V = L · di/dtR2, C8 on ENτ = R · C = 10 msR3 and D1KVL: 3.3 = 1.3 + 2.0R4 100 k / R5 47 kdivider 2.69 V, Rth 32 kΩto the ADC pin, with C9 100 nFFollow the current left to right; every ground return runs back to the pack over the ground plane.
The board's power tree, with the law that acts at each part pinned next to it. The interactive below walks this tree station by station.
The right-hand rule drawn twice: a hand gripping a straight copper trace with the thumb along the current and the fingers along the circling field, and a hand gripping a coil with the fingers along the current and the thumb pointing to the coil's north endthumb: currentfingers: fieldNSfingers: currentthumb: field (north)Straight trace: thumb along the current,fingers curl the way the field goesCoil, like the motor winding: fingers along the current,thumb points to the north end
The right-hand rule two ways: thumb along the current in a straight trace and the fingers follow the field; fingers along the current in a coil and the thumb points to its north end.

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.

Top view of the motor-driver board. Station: Power in: J1 and Q1. Lit parts: J1, Q1, R1. Every part is a button you can inspect, and 12 test points take the multimeter's probes.J2 Motor AJ3 Motor BU2TB6612FNGJ1 BatteryQ1R1U3AMS1117-3.3U1ESP32-WROOM-32SW1SW2J5 Line LJ7 UARTJ4 HC-SR04J6 Line RGNDVBATVMIN3V3ENIO13AKIO35 VBAT_SENSEM1AM1B60 × 40 mm, top view. Left motor forward. Dots are conventional current; their speed follows the amps.

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.

Step 1 / 8

Power in: J1 and Q1

Ohm's law: V = I · R, and the heat P = I² · R

The pack feeds the board through Q1: 1.155 A drops 57.75 mV across its 50 milliohm channel+−7.4 V packQ1 P-FET50 mΩ ongateR1 100 kΩpulls the gate low1.155 AVM = 7.342 V− 57.75 mVlost across Q1Ohm: the FET is a small resistor, so V = I · R and P = I² · R
Pack current
1.155 A

motors + regulator input

Drop across Q1 V = I · R
57.75 mV
Heat in Q1 P = I² · R
66.7 mW

SOT-23, keep under about 0.5 W

Drop along 13 mm of VM trace
4.80 mV

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.

Model assumptions: Q1 at 50 mΩ with the pack on its gate; the AMS1117 at 60 °C/W and 5 mA of ground current; about 1 nH per millimetre of decoupling trace plus 0.5 nH in the capacitor; a 4 Ω, 1 mH winding at 20 kHz PWM; a typical SAR ADC input of about 10 pF. The ESP32 pin threshold of 0.75 × VDD is from the ESP32 datasheet. The multimeter reads DC: the motor terminals show the PWM average, and EN is read after it has settled. All numbers are the model's, not measurements; use them to see how each law behaves, then measure your own board.

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
text
(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.
The pack reaches J1 and Q1's gate is held at ground by R1, so the P-FET turns on and VM rises through its 50 mΩ channel. The bulk capacitors charge, the AMS1117 brings 3V3 up, and the driver stays idle because its STBY pin is pulled low. EN rises through R2 into C8 with a 10 ms time constant, so the ESP32 is released about 14 ms after the rail, once it is stable. The firmware then sets the pins, enables STBY, and the H-bridges start steering current into the windings. Every step is a law in action: Ohm at Q1, Kirchhoff at the VM node, RC on EN.
screenWhere would you apply Kirchhoff's current law on this board, and why does it matter for choosing parts?
At the VM node, where the pack current splits into the two motor channels and the regulator. Whatever each branch draws, the sum comes through the connector, the fuse, Q1 and the first stretch of trace, so those parts are rated for the sum, not for one branch. Two stalled N20 motors are about 3 A together, which is why the JST XH pins, a 3 A fuse and a 1.5 mm trace were chosen. If I later add a branch, say a 5 V buck for a servo, the same node tells me the connector budget just shrank.
screenWhy does the status LED need a resistor, and how do you choose its value?
An LED is a diode: above its forward voltage the current rises very steeply, so without a resistor the pin or the LED would set the current by accident. Kirchhoff's voltage law around the loop gives 3.3 V = I · R + Vf, so R = (3.3 − Vf) / I. For a red LED at 2.0 V and 1.3 mA that is 1 kΩ, and the resistor dissipates only 1.7 mW. A blue LED drops about 3.0 V, which leaves 0.3 V for the resistor and barely 0.3 mA through 1 kΩ, so it needs about 60 Ω for 5 mA or a higher supply. I also keep the current well under the 20 mA a GPIO pin can source.
screenState the right-hand rule and give one place on a motor board where it matters.
Point the thumb of your right hand along the current in a wire and your fingers curl the way the magnetic field circles it; for a coil, curl the fingers along the current and the thumb points along the field inside, toward the coil's north end. In the motor, the H-bridge sets which way the current flows through the winding, so reversing AIN1 and AIN2 reverses the field and the torque. The same rule explains why the motor traces radiate: the current loop from the driver to the connector and back makes a field proportional to its area, which is why the loop is kept short and over a ground plane.
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.
The heat is (Vin − Vout) · I plus the ground current's share: 5.1 V × 0.15 A is 0.77 W, plus 8.4 V × 5 mA, about 0.81 W in total. At 60 °C/W for a SOT-223 on a modest pad that is a 48 °C rise, so about 73 °C in a 25 °C room, which is fine. The budget runs out near 400 mA, where 2.1 W puts the junction at the 150 °C shutdown line, and sooner in a warm enclosure. I would switch to a buck, or add one as a pre-regulator, once the sustained current passes about 250 mA, because the junction would then sit above 100 °C and Wi-Fi bursts would push it further. A buck at 90% efficiency wastes about a tenth of that power.
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.
Seen from the pin, the divider is a source of Vpack × 47 / 147 behind R1 ∥ R2 = 32 kΩ. A successive-approximation ADC connects a small sampling capacitor to the pin for a short window, and through 32 kΩ that capacitor cannot reach the source voltage before the conversion starts, so the result reads low, and it depends on whatever the previous channel left on the capacitor, which is the noise. The fix is a 100 nF capacitor from the pin to ground: it holds thousands of times the sampling charge, so each sample takes a negligible bite, and the divider refills it with a 3.2 ms time constant between readings. Smaller resistors, 10 kΩ over 4.7 kΩ, would also work but would draw 0.57 mA from the pack all the time. I would also average a few samples in firmware and check the ESP32's attenuation setting.

Quiz

1. Both motors stall at 1.5 A each while the logic draws 150 mA through the regulator. What current does the battery connector carry?
2. A red LED with a 2.0 V forward drop sits in series with 1 kΩ on the 3.3 V rail. You swap in a blue LED with a 3.0 V drop and keep the resistor. What happens to the current?
3. The reverse-polarity FET has 50 mΩ of on-resistance and carries 3 A. How much power does it dissipate?
4. The battery divider is 100 kΩ over 47 kΩ. What resistance does the ADC pin see looking back into it, and what does the 10 kΩ rule say?
5. EN is pulled up through 10 kΩ with 1 µF to ground. About how long after 3V3 appears does EN reach 75% of the rail?
6. A decoupling capacitor sits 10 mm of thin trace away from the pin it serves, and the chip pulls a 50 mA step in 2 ns. Taking about 1 nH per millimetre, how far does the pin voltage dip?
7. Current flows through a motor winding and makes a magnetic field. You reverse the H-bridge so the current flows the other way. By the right-hand rule, what happens to the field?
8. The AMS1117 makes 3.3 V from an 8.4 V pack while supplying 150 mA. Ignoring its own 5 mA, how much heat does it make, and how far does its junction rise at 60 °C/W?

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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Ω.

  5. Bookfree online

    Richard P. Feynman, Robert B. Leighton and Matthew Sands (1964). The Feynman Lectures on Physics, Volume II: Mainly Electromagnetism and Matter. Addison-Wesley; free online edition by Caltech.

    Read: Chapter 13, sections 13-1 to 13-5: the field of a wire and of a solenoid, and the right-hand rule.

  6. 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.

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

  8. 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.

  9. 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.

  10. 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.