C1 · Lesson 12 · Resistor networks lab
Series and parallel in code, standard resistor values, choosing a divider, tolerance by Monte Carlo, and ladder networks, in Python
Lessons 5 to 11 reduced networks by hand: series and parallel, dividers, real resistors with tolerances, loading, nodal and mesh analysis, delta–wye. A designer does the same reductions in code, and adds the questions hand analysis avoids: which standard values come closest to a ratio, how far a batch of 5% resistors can push a divider, and what an endless ladder converges to. In this lab you'll write those small tools, and check each against the formulas from the lessons.
- Each sample is the output of a 10 kΩ over 10 kΩ divider from 5 V, built from two resistors drawn at random within ±t%. The histogram collects 5000 of them.
- The curve is a Gaussian with the spread predicted from the tolerance, for uniform errors.
- Halve the tolerance and the spread halves. Step 4 does the same Monte Carlo in Python, for any divider.
Predict
A 5 V to 3.3 V divider must be built from standard E24 values (1.0, 1.1, 1.2, … 9.1 and their multiples of ten). How close can two resistors from the first two decades get to the ratio 0.66?
Within about 0.1%: 4.7 over 9.1 (or 4.7 kΩ and 9.1 kΩ) gives 0.6594, 0.09% short of 0.66. With 576 pairs to choose from, a near-perfect ratio usually exists, but finding it by hand is tedious. Step 3 searches all pairs.
Name it
Series and parallel in code
Series resistances add; parallel ones add as conductances, . Written as small functions, they combine into any series–parallel network in one line, the way the lessons reduced them on paper.
Standard values
Resistors come in E-series, with N values per decade spaced about apart: E12 for 10% parts, E24 for 5%, E96 for 1%. The nearest standard value to x is the one closest on a log scale, since the series is evenly spaced in log.
Choosing a divider
For a target ratio , search every pair of standard values and keep the one with the smallest error. Two decades of E24 give 48 values each way, so 2304 pairs, which a computer checks instantly.
Tolerance by Monte Carlo
A ±t% resistor can be anywhere in its band. Drawing each resistor at random within its tolerance, many times, gives the distribution of the output. For a divider of equal resistors with uniform errors, the output's standard deviation is ; Monte Carlo handles any network and any error distribution without new algebra.
Ladders
A ladder of series R and shunt R, n sections long, has input resistance given by repeating . As n grows it converges to the value that reproduces itself, , which is = 1.618R.
Worked example
Find the E24 pair, from 1.0 to 91, that makes the best 5 V to 3.3 V divider. What's its error, and what does it actually output?
Show the solution
- Search all pairs. The ratio closest to 0.66 comes from = 4.7 and = 9.1 (in any unit, say kΩ): an error of 0.00058.
- Output. From exactly 5 V:
- An exact target. For other targets the search can be exact: 1.8 V from 3.3 V needs 0.5455, which 1.0 over 1.2 hits exactly, since
- Check the pair. A designer would then check the pair's total resistance against the load and the power budget.
Answer 4.7 over 9.1 (say kΩ) is the best pair, with a ratio of 0.65942, an error of 0.00058 and an output of 3.297 V.
Worked example
A 10 kΩ over 10 kΩ divider from 5 V uses ±5% resistors. What's the spread of its output, by Monte Carlo and by formula?
Show the solution
- Monte Carlo. Drawing both resistors uniformly within ±5% 200 000 times gives a mean of 2.500 V and a standard deviation of 0.0510 V.
- Each resistor's spread. Each resistor's standard deviation is
- Combine by formula. The output depends on their ratio with sensitivity ¼ each, and the two add in quadrature: The formula agrees with the Monte Carlo result.
- Worst case. With both resistors at opposite extremes the output is off by ±0.125 V, nearly 2.5σ. Monte Carlo shows how rarely that corner occurs.
Answer the output has a mean of 2.500 V and a standard deviation of 0.0510 V by both methods, and the worst case is ±0.125 V.
Worked example
A ladder alternates 1 kΩ in series and 1 kΩ to ground, section after section. What's its input resistance after one, two and many sections?
Show the solution
- One section.
- Two sections.
- Three sections.
- Many sections. The values close in quickly on the golden ratio, since r must equal :
- Transmission lines. A long transmission line, modeled as such a ladder, presents its characteristic impedance in the same way, which C10 takes up.
Answer the input resistance is 2 kΩ after one section, 1.667 kΩ after two, 1.625 kΩ after three, and 1.618 kΩ (the golden ratio) after many.
Check
Step 1. Write series(*r) and parallel(*r) returning the combined resistance of any number of resistors.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 2. Write nearest_e24(x) returning the E24 value nearest to x on a log scale, in the same decade or the next (so 9.6 rounds to 10).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 3. Write best_divider(ratio) returning (R1, R2) from E24 values between 1.0 and 91 that make closest to ratio.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 4. Write divider_mc(R1, R2, tol, n, seed) returning (mean, std) of a divider's output from 5 V when each resistor is drawn uniformly within ±tol (a fraction) of its value, over n trials.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Step 5. Write ladder(n, R) returning the input resistance of an n-section ladder of series R and shunt R with its far end open: one section is 2R, and each added section gives .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Resistors of 4.7, 2.2 and 22 kΩ.
(a)
What's 4.7 kΩ in series with the parallel pair of the other two?
Write units the way you normally would: 1.5 kΩ, 1500 Ω and 0.0015 MΩ are the same answer.
(b)
What are all three in parallel?
Check
A divider uses = 4.7 and = 9.1 for a target ratio of 0.67. What's its ratio error, in percent of the target?
Check
An equal-resistor divider from 5 V uses ±1% parts with uniform errors. What's the standard deviation of its output?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
An endless ladder alternates 4.7 kΩ in series and 4.7 kΩ to ground. What's its input resistance?
Write units the way you normally would: 1.5 kΩ, 1500 Ω and 0.0015 MΩ are the same answer.
Explain why
Why does Monte Carlo usually give a smaller spread than a worst-case tolerance analysis?
A worst-case analysis puts every resistor at the edge of its tolerance band in whichever direction hurts most, all at once. Real resistors' errors are independent and spread across the band, so their effects partly cancel: one resistor high is as likely to pair with another high as with another low. Monte Carlo draws many combinations from the actual distributions and reports how the output is really spread, which for independent errors grows only as the square root of the sum of their squares. The worst case is still possible, but it sits far out in the tail, and Monte Carlo shows how rare it is, which is what a production yield depends on.
Practice
Keep practicing
6 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.