Analog Design Practice: Datasheets, Tolerances and Simulation First
Every circuit in this course works on paper with nominal values. A product has to work on every one of ten thousand boards, from to , five years after it was built, with parts from whichever distributor had stock. The difference between a schematic and a design is the discipline this lesson describes, and it is the roadmap's milestone for this stage: design and document an analog circuit from requirements through simulation, prototype and test results. It also covers the last laboratory project: measure gain, bandwidth, distortion and noise.
The workflow
- Requirements as numbers with tolerances and conditions: "gain at 1 kHz; bandwidth at least 10 kHz; THD below 0.1 % at 5 V peak output; input-referred noise below rms in 10 Hz to 10 kHz; to ; one 12 V supply." A requirement without a number cannot be tested.
- Hand design with the simplest models: it tells you which parts matter and by how much.
- Simulation of the nominal design, then with tolerances and temperature: worst case and Monte Carlo.
- Prototype, built so it can be measured (test points, a way to break the loop or inject a signal).
- Test against every requirement, with the uncertainty of each measurement.
- Review and document: schematic, calculations, simulation decks, test results and the differences between them.
Reading a datasheet
A datasheet is a contract only where it says min or max. A "typ" value is the middle of the production spread at one temperature: half the parts are worse. Read every number with its conditions (supply, load, temperature, frequency) and the note on how it is guaranteed (tested in production, or "guaranteed by design or characterisation"). An op-amp's input offset might read "typ , max at , max over to " (an illustrative pattern, not a specific part): design with the 4 mV. Typical-performance graphs (gain against frequency, noise density, output swing against load) show behaviour the tables cannot, but they too are typical. Absolute maximum ratings are survival limits, not operating conditions. Finally, check the errata and the revision date.
Tolerances, worst case and Monte Carlo
Resistors come in E-series values: E24 (5 %, 24 values per decade), E96 (1 %), E192 (0.5 % and better). Ceramic C0G capacitors are typically to , X7R plus a large loss of capacitance with DC bias, aluminium electrolytics . Every part also drifts with temperature (resistor tempco in ppm/K, capacitor characteristics) and with age.
Worst-case analysis puts every part at the end of its tolerance that hurts the output most. It is guaranteed but pessimistic: all parts at their limits together is very unlikely. Monte Carlo draws each part from its distribution many times and looks at the spread of the result, which predicts the yield (the fraction of boards that meet the spec). Use worst case for safety-relevant limits and Monte Carlo for everything else, and remember both are only as good as the circuit model.
Derating. Run parts well inside their ratings: resistors at no more than about half their rated power, capacitors at no more than about half to 80 % of their rated voltage (ceramics lose capacitance under bias, electrolytics live longer), semiconductors below their maximum junction temperature with margin (LDOs, Dropout and Thermal Design). An electrolytic capacitor's life roughly doubles for every 10 K it runs cooler.
Worked example: does the design meet its spec?
Given: a non-inverting stage (The Ideal Op-Amp) with (1 %), (1 %), (5 %) across to limit the bandwidth; requirements as above.
Find: nominal gain and bandwidth, their worst cases, and the Monte Carlo yield.
Solve:
Check: on paper both specs hold even at the worst case, with the bandwidth only just. The Monte Carlo below agrees. The simulation further down will disagree, and that is the point of this example.
import numpy as np
Rf0, Rg0, Cf0 = 10e3, 1e3, 1.5e-9
tol = {"Rf": 0.01, "Rg": 0.01, "Cf": 0.05}
gain = lambda Rf, Rg: 1 + Rf / Rg
f3db = lambda Rf, Cf: 1 / (2 * np.pi * Rf * Cf) # pole of Rf || Cf (gain >> 1)
print(f"nominal: gain {gain(Rf0, Rg0):.3f}, bandwidth {f3db(Rf0, Cf0) / 1e3:.2f} kHz")
# Worst case: push every part to the end of its tolerance that hurts most
g_hi = gain(Rf0 * 1.01, Rg0 * 0.99); g_lo = gain(Rf0 * 0.99, Rg0 * 1.01)
bw_lo = f3db(Rf0 * 1.01, Cf0 * 1.05)
print(f"worst case: gain {g_lo:.3f} ... {g_hi:.3f} ({100 * (g_lo / 11 - 1):+.2f} % ... {100 * (g_hi / 11 - 1):+.2f} %),"
f" bandwidth down to {bw_lo / 1e3:.2f} kHz")
# Monte Carlo: tolerances taken as 3 sigma of a normal distribution
rng = np.random.default_rng(1)
N = 20000
Rf = Rf0 * (1 + tol["Rf"] / 3 * rng.standard_normal(N))
Rg = Rg0 * (1 + tol["Rg"] / 3 * rng.standard_normal(N))
Cf = Cf0 * (1 + tol["Cf"] / 3 * rng.standard_normal(N))
G, BW = gain(Rf, Rg), f3db(Rf, Cf)
print(f"Monte Carlo ({N} boards): gain sigma {100 * float(np.std(G)) / 11:.3f} %,"
f" bandwidth sigma {100 * float(np.std(BW) / np.mean(BW)):.2f} %")
ok = (np.abs(G / 11 - 1) <= 0.02) & (BW >= 10e3)
print(f"yield for gain within 2 % and bandwidth >= 10 kHz: {100 * float(np.mean(ok)):.2f} %")
print(f"bandwidth below 10 kHz on {100 * float(np.mean(BW < 10e3)):.2f} % of boards")nominal: gain 11.000, bandwidth 10.61 kHz
worst case: gain 10.802 ... 11.202 (-1.80 % ... +1.84 %), bandwidth down to 10.01 kHz
Monte Carlo (20000 boards): gain sigma 0.425 %, bandwidth sigma 1.70 %
yield for gain within 2 % and bandwidth >= 10 kHz: 99.98 %
bandwidth below 10 kHz on 0.03 % of boards
The fixed seed (default_rng(1)) makes the run repeatable; change it and the yield moves in the second decimal, the Monte Carlo's own sampling error.
Simulation first: the model the hand design left out
The hand analysis treated the op-amp as ideal. The SPICE session uses the course op-amp macro-model () with an output that is linear to and compresses into rails. It measures the gain at 1 kHz, the frequency where the response is 3.01 dB below its low-frequency value, and the total harmonic distortion (fourier) at 5 V and 12 V peak output.
cat > amp.cir <<'EOF'
* Gain-11 non-inverting stage, Rf = 10k || Cf = 1.5n, Rg = 1k, course op-amp macro-model
* output stage: linear to +-11 V, then compresses to the +-12 V rails
.subckt OA inp inn out
G1 0 n1 inp inn 1m
R1 n1 0 100meg
C1 n1 0 159.2p
E1 out 0 TABLE {v(n1)} = (-14,-12) (-11,-11) (11,11) (14,12)
.ends
VIN in 0 DC 0 AC 1 SIN(0 0.4545 1k)
X1 in n out OA
Rf out n 10k
Cf out n 1.5n
Rg n 0 1k
.control
ac dec 100 10 1meg
meas ac g10 find vdb(out) at=10
let target = g10 - 3.0103
meas ac f3db when vdb(out)=amp;target fall=1
meas ac gain1k find vm(out) at=1k
tran 2u 5m
fourier 1k v(out)
alter VIN sin = [ 0 1.1 1k ]
tran 2u 5m
fourier 1k v(out)
.endc
.end
EOF
ngspice -b amp.cir 2>&1 | grep -E '^(g10|gain1k|f3db) +=|THD'g10 = 2.082689e+01
f3db = 9.648910e+03
gain1k = 1.093980e+01
No. Harmonics: 10, THD: 3.69432e-12 %, Gridsize: 200, Interpolation Degree: 1
No. Harmonics: 10, THD: 0.293278 %, Gridsize: 200, Interpolation Degree: 1
Three findings:
- Bandwidth fails. , below the 10 kHz requirement at nominal values. Two things the hand design missed: the exact point of is , not the pole frequency, and the op-amp's own closed-loop pole at (Real Op-Amps: Gain-Bandwidth, Slew Rate and a SPICE Macro-Model) takes another 10 % off. Change
Cfto1.2nand SPICE gives ; even 6 % low (worst-case and ) it stays above 10 kHz. - Gain at 1 kHz is 10.94, not 11.00 (): the same poles reach down a decade. It still meets , but it eats a quarter of the tolerance budget before any resistor error.
- Distortion. The model is perfectly linear below 11 V, so SPICE reports essentially 0 % THD at 5 V peak (the is rounding). That is a statement about the model, not the amplifier: real op-amps distort through their input stage, output stage and the load, and datasheets give typical THD+N figures for audio parts from about 0.01 % down to 0.0001 % or less (the OPA1612 lists 0.000015 % at 1 kHz, gain 1, 3 V rms; 2026 values). Driven to 12.1 V peak into the compressed region, the model shows 0.29 %. Distortion is measured on the prototype, not trusted from a simple model.
Interactive: gain-bandwidth and slew rate
The op-amp lab with the same stage (non-inverting, , , , slew rate ) at 10 kHz. It has no , so it shows only the op-amp's own limits.
At in, the lab reads a closed-loop bandwidth of , a small-signal gain of at 10 kHz, and a full-power bandwidth of for the peak it actually delivers (ideal ). Raise the input to (9.9 V output): the needed slew rate is , the full-power bandwidth drops to and the state reads "slew-rate limited". A requirement for 10 V at 10 kHz would need a faster op-amp, whatever the resistors.
The test plan: gain, bandwidth, distortion, noise
| Quantity | Method | Instrument limits to know |
|---|---|---|
| Gain | 1 kHz sine at about half full scale; ratio of output to input rms, both on the same meter or scope | meter accuracy (0.5 to 1 %); measure input and output with the same instrument so its gain error cancels |
| Bandwidth | sweep the generator, find where the output falls to 0.707 of its 1 kHz value (or a Bode analyser) | probe and scope bandwidth ; generator amplitude flat with frequency (check it) |
| Distortion (THD or THD+N) | low-distortion sine; scope FFT or an audio analyser; harmonics relative to the fundamental | a scope's 8-bit ADC sees about to (0.1 to 0.3 %), so it can only show distortion above that; the generator's own distortion is a floor |
| Noise | input shorted (or terminated in the source resistance), extra gain, a band-limiting filter of known ENBW, true-rms reading divided by total gain (Noise in Analog Circuits) | the scope's own noise floor; mains hum (battery supply, shielding) |
| Over temperature | repeat key tests at the extremes (a temperature chamber, or at least a hair dryer and a freezer spray for a quick look) | condensation on cold boards |
Record every result with its uncertainty and the conditions, next to the requirement and the simulation. Where the three differ, the explanation is the most valuable line in the report: it is either a bad model, a bad measurement or a bad board. Measurement methods in depth are in Electrical & Electronic Measurements.
Design review checklist
- Every requirement has a number, a test, and a result.
- Worst-case or Monte Carlo analysis for every requirement that depends on tolerances; temperature included.
- Every part within its derated limits (power, voltage, current, temperature) in the worst case, including start-up and faults.
- Datasheet "max" values used for errors, "min" for capabilities; every typical value flagged.
- Stability: each feedback loop's phase margin checked with the real load, including capacitive loads and cables.
- Input protection (ESD, overvoltage) and output short-circuit behaviour.
- Layout reviewed against Grounding, Shielding and PCB Layout for Analog.
- Simulation decks, calculations and measurements stored with the schematic revision they belong to.
Guided lab: characterise the gain-11 stage
Hand calculation. , with an ideal op-amp; THD negligible below the rails.
Simulation. The SPICE deck above with your op-amp's GBW, and the Python tolerance run.
What you would measure. Build the stage with and a general-purpose op-amp on a current-limited bench supply. Gain at 1 kHz: expect 10.9 to 11.1 within your meter's 1 %. Bandwidth: expect about 11 to 12 kHz with a 1 MHz op-amp, more with a faster one, from . THD at 5 V peak: the scope FFT will show harmonics only at its own floor (about ); if you see more, suspect the generator or the probe ground. Noise: short the input, add a second gain of 10 and a 10 kHz RC filter, and compare with the budget in Noise in Analog Circuits. Write it up with the requirement, simulation and measured columns side by side.
Hazards and safe setup. Low voltage, current-limited supplies; switch both rails on together. Keep the generator's amplitude below the level that drives the output into the rails when you are not testing clipping.
Pitfalls
- Designing with typical values. Half the parts are worse.
- Trusting a model outside what it models. The macro-model here has no distortion mechanism below its clamp, no offset and no input noise.
- Tolerances that are not independent. Resistors from one reel are often correlated; capacitor values all shift together with temperature. Monte Carlo with independent draws can be optimistic.
- Changing parts before understanding a mismatch. First decide whether the model, the measurement or the board is wrong.
Practice
- A gain of uses 0.1 % resistors with . What is the worst-case gain error?
- An op-amp's offset is "typ , max ". In a gain-100 stage, what output offset do you design for?
- Why might a Monte Carlo yield of 99.98 % still lead to a failing product?
Answer
- : about (and at the other corner); the error is close to the sum of the two tolerances times .
- (plus temperature drift), not 0.1 V.
- The model may be missing effects (here the op-amp's bandwidth made every board fail), tolerances may be correlated, or the requirement may be tested under conditions the simulation did not include.
Test yourself
A datasheet lists an op-amp's offset as typ , max . A worst-case design uses…
- (and the over-temperature max if given)
- , since it can be trimmed
A non-inverting gain of 11 uses 1 % resistors (, ). The worst-case high gain is about…
In the SPICE run, why was the bandwidth instead of the hand value of about ?
- The resistors were out of tolerance
- The op-amp's finite gain-bandwidth adds a second pole, and the exact point differs from the pole frequency
- SPICE has a numerical error
- The input amplitude was too large
A scope's built-in FFT is a poor tool for verifying THD below 0.01 % because…
- it cannot show sine waves
- its 8-bit ADC's own distortion and noise floor sit around to
- it only works above 1 MHz
- THD can only be computed by SPICE