TExcelTAD
Home › Analog Electronics: Diodes, Transistors & Op-Amps › Analog Design Practice: Datasheets, Tolerances and Simulation First

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 −20-20 to +70 ∘C+70\ ^\circ\text{C}, 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 hand design simulation + tolerances prototype test review fails a spec measured result differs from simulation: find out why before changing parts
  1. Requirements as numbers with tolerances and conditions: "gain 11±2 %11 \pm 2\ \% at 1 kHz; −3 dB-3\ \text{dB} bandwidth at least 10 kHz; THD below 0.1 % at 5 V peak output; input-referred noise below 2 μV2\ \mu\text{V} rms in 10 Hz to 10 kHz; −20-20 to +70 ∘C+70\ ^\circ\text{C}; one 12 V supply." A requirement without a number cannot be tested.
  2. Hand design with the simplest models: it tells you which parts matter and by how much.
  3. Simulation of the nominal design, then with tolerances and temperature: worst case and Monte Carlo.
  4. Prototype, built so it can be measured (test points, a way to break the loop or inject a signal).
  5. Test against every requirement, with the uncertainty of each measurement.
  6. 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 0.5 mV0.5\ \text{mV}, max 3 mV3\ \text{mV} at 25 ∘C25\ ^\circ\text{C}, max 4 mV4\ \text{mV} over −40-40 to +85 ∘C+85\ ^\circ\text{C}" (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 ±1\pm 1 to 5 %5\ \%, X7R ±10 %\pm 10\ \% plus a large loss of capacitance with DC bias, aluminium electrolytics ±20 %\pm 20\ \%. 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 Rf=10 kΩR_f = 10\ \text{k}\Omega (1 %), Rg=1 kΩR_g = 1\ \text{k}\Omega (1 %), Cf=1.5 nFC_f = 1.5\ \text{nF} (5 %) across RfR_f to limit the bandwidth; requirements as above.

Find: nominal gain and bandwidth, their worst cases, and the Monte Carlo yield.

Solve:

G=1+RfRg=11.00,Gmax=1+10.1 kΩ0.99 kΩ=11.20 (+1.84 %),Gmin=1+9.9 kΩ1.01 kΩ=10.80 (−1.80 %)fp=12πRfCf=12π⋅10 kΩ⋅1.5 nF=10.61 kHz,fp,min⁡=12π⋅10.1 kΩ⋅1.575 nF=10.01 kHz\begin{aligned} G &= 1 + \frac{R_f}{R_g} = 11.00, \qquad G_\text{max} = 1 + \frac{10.1\ \text{k}\Omega}{0.99\ \text{k}\Omega} = 11.20\ (+1.84\ \%), \quad G_\text{min} = 1 + \frac{9.9\ \text{k}\Omega}{1.01\ \text{k}\Omega} = 10.80\ (-1.80\ \%) \\ f_p &= \frac{1}{2\pi R_f C_f} = \frac{1}{2\pi \cdot 10\ \text{k}\Omega \cdot 1.5\ \text{nF}} = 10.61\ \text{kHz}, \qquad f_{p,\min} = \frac{1}{2\pi \cdot 10.1\ \text{k}\Omega \cdot 1.575\ \text{nF}} = 10.01\ \text{kHz} \end{aligned}

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.

python · try it yourself
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 (GBW=1 MHz\text{GBW} = 1\ \text{MHz}) with an output that is linear to ±11 V\pm 11\ \text{V} and compresses into ±12 V\pm 12\ \text{V} 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.

bash · try it yourself
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. 9.65 kHz9.65\ \text{kHz}, below the 10 kHz requirement at nominal values. Two things the hand design missed: the exact −3 dB-3\ \text{dB} point of 1+Zf/Rg1 + Z_f/R_g is 10.70 kHz10.70\ \text{kHz}, not the pole frequency, and the op-amp's own closed-loop pole at GBW/11=91 kHz\text{GBW}/11 = 91\ \text{kHz} (Real Op-Amps: Gain-Bandwidth, Slew Rate and a SPICE Macro-Model) takes another 10 % off. Change Cf to 1.2n and SPICE gives 11.77 kHz11.77\ \text{kHz}; even 6 % low (worst-case RfR_f and CfC_f) it stays above 10 kHz.
  • Gain at 1 kHz is 10.94, not 11.00 (−0.55 %-0.55\ \%): the same poles reach down a decade. It still meets ±2 %\pm 2\ \%, 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 10−1210^{-12} 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, Rin=1 kΩR_\text{in} = 1\ \text{k}\Omega, Rf=10 kΩR_f = 10\ \text{k}\Omega, GBW=1 MHz\text{GBW} = 1\ \text{MHz}, slew rate 0.5 V/μs0.5\ \text{V}/\mu\text{s}) at 10 kHz. It has no CfC_f, so it shows only the op-amp's own limits.

-+voutRfRinvingain falling (above f_CL/10)ideal gain11.00 V/VfCL (-3 dB)90.9 kHz|A(f)| linear10.934 V/Vout pk wanted4.92 Vrail limit+/-11.00 V2 pi f Vpk needs0.309 V/usSR available0.50 V/ussupply+/-12.0 V-100100T/2T3T/22TVf = 10.0 kHz+VS-VSvinvoutideal gain x vin

At 0.45 V0.45\ \text{V} in, the lab reads a closed-loop bandwidth of 90.91 kHz90.91\ \text{kHz}, a small-signal gain of 10.9310.93 at 10 kHz, and a full-power bandwidth of 16.17 kHz16.17\ \text{kHz} for the 4.92 V4.92\ \text{V} peak it actually delivers (ideal 4.95 V4.95\ \text{V}). Raise the input to 0.9 V0.9\ \text{V} (9.9 V output): the needed slew rate is 0.618 V/μs0.618\ \text{V}/\mu\text{s}, the full-power bandwidth drops to 8.087 kHz8.087\ \text{kHz} 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 ≫f3dB\gg f_{3\text{dB}}; 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 −50-50 to −60 dB-60\ \text{dB} (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. G=11G = 11, f3dB≈10.7 kHzf_{3\text{dB}} \approx 10.7\ \text{kHz} 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 Cf=1.2 nFC_f = 1.2\ \text{nF} and a general-purpose op-amp on a ±12 V\pm 12\ \text{V} 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, ±5 %\pm 5\ \% from CfC_f. THD at 5 V peak: the scope FFT will show harmonics only at its own floor (about −55 dB-55\ \text{dB}); 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

  1. A gain of 1+Rf/Rg1 + R_f/R_g uses 0.1 % resistors with Rf/Rg=99R_f/R_g = 99. What is the worst-case gain error?
  2. An op-amp's offset is "typ 1 mV1\ \text{mV}, max 5 mV5\ \text{mV}". In a gain-100 stage, what output offset do you design for?
  3. Why might a Monte Carlo yield of 99.98 % still lead to a failing product?
Answer
  1. Gmax=1+99⋅1.001/0.999=100.198G_\text{max} = 1 + 99 \cdot 1.001/0.999 = 100.198: about +0.20 %+0.20\ \% (and −0.20 %-0.20\ \% at the other corner); the error is close to the sum of the two tolerances times (G−1)/G(G - 1)/G.
  2. 100⋅5 mV=0.5 V100 \cdot 5\ \text{mV} = 0.5\ \text{V} (plus temperature drift), not 0.1 V.
  3. 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 0.5 mV0.5\ \text{mV}, max 3 mV3\ \text{mV}. A worst-case design uses…

  1. 0.5 mV0.5\ \text{mV}
  2. 1.75 mV1.75\ \text{mV}
  3. 3 mV3\ \text{mV} (and the over-temperature max if given)
  4. 0 mV0\ \text{mV}, since it can be trimmed

A non-inverting gain of 11 uses 1 % resistors (Rf=10 kΩR_f = 10\ \text{k}\Omega, Rg=1 kΩR_g = 1\ \text{k}\Omega). The worst-case high gain is about…

  1. 11.0211.02
  2. 11.1111.11
  3. 11.2011.20
  4. 11.5511.55

In the SPICE run, why was the bandwidth 9.65 kHz9.65\ \text{kHz} instead of the hand value of about 10.6 kHz10.6\ \text{kHz}?

  1. The resistors were out of tolerance
  2. The op-amp's finite gain-bandwidth adds a second pole, and the exact −3 dB-3\ \text{dB} point differs from the pole frequency
  3. SPICE has a numerical error
  4. The input amplitude was too large

A scope's built-in FFT is a poor tool for verifying THD below 0.01 % because…

  1. it cannot show sine waves
  2. its 8-bit ADC's own distortion and noise floor sit around −50-50 to −60 dB-60\ \text{dB}
  3. it only works above 1 MHz
  4. THD can only be computed by SPICE