A4 · Project 2 · Tolerance analysis
Will ten thousand of these filters meet spec?
You've designed an active low-pass filter for a sensor: a Sallen-Key stage with two resistors and two capacitors, set for a 1.07 kHz corner and a Q of 0.74. On paper it's perfect. On a production line, every resistor is off by up to 1% and every capacitor by up to 5 or 10%, all at random. The customer's spec says the corner must be within ±5% and the Q within ±10%. In this project you'll find out what fraction of boards will pass, which part is to blame for the failures, and what one change would fix it.
Predict
The corner frequency goes as . If one capacitor is 10% high and everything else is exact, how far does the corner move?
About 5% low: . A square root halves the effect of each part's error on the corner. With four parts under the square root, their random errors partly cancel, which is exactly what the Monte Carlo will measure.
Name it
The circuit and the plan
A unity-gain Sallen-Key low-pass has and in series from the input to the op amp's + input, from the + input to ground, and from the junction of the resistors back to the output. Its response is
which is a second-order low-pass with
C6 shows where this comes from. The design: kΩ (±1%), nF (±5%) and nF (±10%). Model every tolerance as uniform.
The plan:
- Write a function for and and check the nominal design.
- Simulate 50,000 boards and find the yield against the spec.
- Find which part's tolerance hurts the most.
- Plot the distribution of against the spec limits.
Use rng = np.random.default_rng(0) and draw the parts in the order R1, R2, C1, C2, so your numbers match the checks.
Check
Write sk(R1, R2, C1, C2) returning (f0, Q), and set f0_nom, Q_nom for the nominal design.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Simulate 50,000 boards (uniform tolerances, default_rng(0), parts drawn in the order R1, R2, C1, C2). Set f0 and Q to the arrays of results, and yld to the fraction with within ±5% and within ±10% of nominal.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Find which part matters most. For each of the four parts in turn, simulate 50,000 boards where only that part varies over its tolerance (the others exact; default_rng(1), one fresh draw per part in the order R1, R2, C1, C2). Set spread to a dictionary from part name to the standard deviation of , and worst to the name with the largest.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Replace C2 with a ±2% part and re-run the full simulation from the second lab (default_rng(0), same order, 50,000 boards). Set yld2 to the new yield. Then plot a histogram of (60 bins) with dashed vertical lines at the ±5% spec limits, and label the axes.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Using your results, explain to a manager why the filter failed spec on some boards and what the cheapest fix is.
The filter's corner frequency depends on all four parts, but each part's error reaches the corner halved, through a square root, and the random errors partly cancel. The resistors are 1% parts, so they barely matter. The two capacitors dominate, and C2, at ±10%, causes about twice the spread of C1. Replacing just C2 with a 2% part brings nearly every board within spec, so that one part change is the cheapest fix; tightening the resistors would cost money and change almost nothing.
Practice
Keep practicing
2 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.