---
title: Noise and precision lab
heading: Noise budgets, offset budgets, bandgap curvature and converter SNR, in Python
eyebrow: C6 · Lesson 46 · Noise and precision lab
xp: 50
---

::: hook
A precision signal chain is judged by its error budget: how much noise, offset and drift each part adds, and which one dominates. Lessons 35 to 45 gave the pieces one at a time. In this lab you'll write the functions a designer uses to add them up: noise density from an op amp and its source, RMS noise over a band with a 1/f corner, the output error from offsets and bias currents, the curvature a real bandgap reference leaves behind, and the combined signal-to-noise ratio of a converter limited by quantization, clock jitter and thermal noise at once.

::: play
- The curve is an amplifier's input noise density against frequency: flat at high frequency, rising as $1/\sqrt f$ below the corner frequency.
- Raise the corner. The low-frequency noise climbs, and the RMS noise over the band grows, but only logarithmically in the band's low end.
- Compare the readout with the white noise alone: below a decade or two of corner frequency, the 1/f part barely matters.
:::
:::

```sim plot
view: graph
x: f = 0.1..100k Hz log
y: e = 1..1000 nV/√Hz log
slider: en = 1..50 = 10 nV/√Hz log
slider: fc = 1..10k = 100 Hz log
plot: en*sqrt(1 + fc/f) | label: noise density | samples: 300
plot: en | color: ch2 | label: white floor | samples: 2
readout: RMS from 0.1 Hz to 10 kHz, µV = en*1e-3*sqrt(fc*ln(1e5) + 9999.9) | digits: 4
readout: white noise alone, µV = en*1e-3*sqrt(9999.9) | digits: 4
```

::: predict
## An amplifier has 10 nV/√Hz of white noise with a 1/f corner at 100 Hz. Over 0.1 Hz to 10 kHz, how much does the 1/f noise add to the RMS?

- [ ] Nothing
- [x] About 6%: 1.06 µV against 1.00 µV
- [ ] About twice as much
- [ ] Ten times as much

::: reveal
About 6%. The noise power is $e_n^2\left(f_c\ln\frac{f_2}{f_1} + f_2 - f_1\right)$: the 1/f part contributes $100 \times \ln10^5$ = 1151 Hz of equivalent bandwidth against the white part's 10,000 Hz. The 1/f part grows only with the logarithm of the band's span, so it dominates only for low-frequency measurements, near DC, or with a high corner.
:::
:::

::: nameit
## Noise density

An op amp with voltage noise $e_n$ and current noise $i_n$, driven from a source resistance $R_s$ at temperature T, has an input-referred density

$$e_\text{tot} = \sqrt{e_n^2 + (i_nR_s)^2 + 4kTR_s}.$$

## Noise over a band

With a 1/f corner $f_c$, the density squared is $e_n^2\left(1 + \frac{f_c}{f}\right)$, and integrating from $f_1$ to $f_2$:

$$v_\text{rms} = e_n\sqrt{f_c\ln\frac{f_2}{f_1} + (f_2 - f_1)}.$$

## Offset budget

At the output of a non-inverting amplifier with noise gain G and feedback resistor $R_f$: offset gives $GV_{OS}$; bias current gives $I_BR_f$, or only $I_{OS}R_f$ when a resistor $R_f \parallel R_g$ in the non-inverting lead balances the two bias currents. Errors from independent sources are often added in quadrature for a typical value, and directly for a worst case.

## Bandgap curvature

A junction's voltage at a fixed (proportional-to-T) current is closer to

$$V_{BE}(T) = V_{G0}\left(1 - \frac{T}{T_0}\right) + V_{BE0}\frac{T}{T_0} - \eta\frac{kT}{q}\ln\frac{T}{T_0},$$

with $V_{G0}$ ≈ 1.205 V and η ≈ 3. The log term can't be cancelled by a linear PTAT voltage, so a first-order bandgap tuned for zero slope at $T_0$ is a downward bow, its peak at $T_0$.

## Converter SNR

Independent noise sources add in power. With quantization ($6.02N + 1.76$ dB), jitter ($-20\log(2\pi f\sigma)$) and thermal noise (signal RMS over noise RMS), all as dB below the signal,

$$\text{SNR} = -10\log\left(10^{-\text{SNR}_q/10} + 10^{-\text{SNR}_j/10} + 10^{-\text{SNR}_t/10}\right).$$
:::

::: example
## An op amp with $e_n$ = 10 nV/√Hz and $i_n$ = 1 pA/√Hz amplifies a 10 kΩ source at 300 K. What's the input-referred density, and which term dominates?

::: solution
1. **The three terms.** The source's thermal noise is $\sqrt{4kT \times 10^4}$ = 12.9 nV/√Hz, the current noise through it 10 nV/√Hz, and the op amp's own 10 nV/√Hz.
2. **Together.**
   $$\begin{aligned} e_\text{in} &= \sqrt{100 + 100 + 166} \\ &= 19.1\ \text{nV}/\sqrt{\text{Hz}} \end{aligned}$$
3. **Which dominates.** The source does: no op amp can make the chain quieter than the source's own resistance, which is why low-noise design starts with the source.

**Answer:** 19.1 nV/√Hz, dominated by the source's own thermal noise.
:::
:::

::: example
## A first-order bandgap uses $V_{G0}$ = 1.205 V, $V_{BE0}$ = 0.65 V at 300 K and η = 3, trimmed for zero slope at 300 K. What's its output there, and how much does it bow over −40 °C to 125 °C?

::: solution
1. **Output at 300 K.** Zero slope at $T_0$ puts the output at
   $$\begin{aligned} V_\text{REF} &= V_{G0} + \eta\frac{kT_0}{q} \\ &= 1.205 + 3 \times 25.85\ \text{mV} \\ &= 1.2826\ \text{V} \end{aligned}$$
   a little above the band gap.
2. **Across the range.** Evaluating the curve across 233 K to 398 K gives a peak at 300 K and lows at the ends, 1.2805 V and 1.2788 V: a bow of 3.8 mV.
3. **As a drift spec.** A box method of specifying drift turns that into 18 ppm/K. Curvature correction is what gets references below 5 ppm/K.

**Answer:** the output is 1.2826 V at 300 K, and it bows by 3.8 mV over the range, 18 ppm/K by the box method.
:::
:::

::: example
## A 14-bit converter samples a full-scale 10 MHz sine (2 V peak to peak) with 1 ps of clock jitter and 100 µV RMS of thermal noise. What's its SNR, and its effective number of bits?

::: solution
1. **Quantization alone.** 86.0 dB.
2. **Jitter.**
   $$\begin{aligned} &-20\log(2\pi \times 10^7 \times 10^{-12}) \\ &= 84.0\ \text{dB} \end{aligned}$$
3. **Thermal.**
   $$20\log\frac{0.707\ \text{V}}{100\ \mu\text{V}} = 77.0\ \text{dB}$$
4. **Add the powers.**
   $$\begin{aligned} \text{SNR} &= -10\log(10^{-8.60} \\ &\quad + 10^{-8.40} + 10^{-7.70}) \\ &= 75.8\ \text{dB} \end{aligned}$$
   or $\frac{75.8 - 1.76}{6.02}$ = 12.3 effective bits.
5. **What dominates.** The thermal noise does; buying a 16-bit converter would gain almost nothing.

**Answer:** the SNR is 75.8 dB, 12.3 effective bits.
:::
:::

::: check
kind: python

## Step 1. Write `noise_density(en, i_n, Rs, T=300)` returning the input-referred noise density in V/√Hz.

```python starter
import math

def noise_density(en, i_n, Rs, T=300):
    return en

print(noise_density(10e-9, 1e-12, 1e4))
```

```python solution
import math

def noise_density(en, i_n, Rs, T=300):
    return math.sqrt(en ** 2 + (i_n * Rs) ** 2 + 4 * 1.380649e-23 * T * Rs)

print(noise_density(10e-9, 1e-12, 1e4))
```

```python tests
assert abs(noise_density(10e-9, 1e-12, 1e4) - 19.1227e-9) < 1e-12, f"Expected 19.1 nV/√Hz; got {noise_density(10e-9, 1e-12, 1e4)}"
assert abs(noise_density(1e-9, 0, 0) - 1e-9) < 1e-18, "With no source, only the op amp."
```

::: right
Right. Three independent sources add in power.
:::
:::

::: check
kind: python

## Step 2. Write `noise_rms(en, fc, f1, f2)` returning the RMS noise from $f_1$ to $f_2$ of a density with white level `en` and 1/f corner `fc`.

```python starter
import math

def noise_rms(en, fc, f1, f2):
    return en * math.sqrt(f2 - f1)

print(noise_rms(10e-9, 100, 0.1, 1e4))
```

```python solution
import math

def noise_rms(en, fc, f1, f2):
    return en * math.sqrt(fc * math.log(f2 / f1) + (f2 - f1))

print(noise_rms(10e-9, 100, 0.1, 1e4))
```

```python tests
assert abs(noise_rms(10e-9, 100, 0.1, 1e4) - 1.055992e-6) < 1e-12, f"Expected 1.056 µV; got {noise_rms(10e-9, 100, 0.1, 1e4)}"
assert abs(noise_rms(5e-9, 1000, 0.1, 1e4) - 0.7333626e-6) < 1e-12, "A 1 kHz corner at 5 nV: 0.733 µV."
```

::: right
Right. The 1/f part grows with the logarithm of the band's span.
:::
:::

::: check
kind: python

## Step 3. Write `output_error(G, Vos, Ib, Ios, Rf, compensated)` returning the worst-case output error of a non-inverting amplifier: $GV_{OS}$ plus $I_BR_f$, or $I_{OS}R_f$ if `compensated`.

```python starter
def output_error(G, Vos, Ib, Ios, Rf, compensated):
    return G * Vos

print(output_error(101, 1e-3, 100e-9, 10e-9, 100e3, False))
```

```python solution
def output_error(G, Vos, Ib, Ios, Rf, compensated):
    return G * Vos + (Ios if compensated else Ib) * Rf

print(output_error(101, 1e-3, 100e-9, 10e-9, 100e3, False))
```

```python tests
assert abs(output_error(101, 1e-3, 100e-9, 10e-9, 100e3, False) - 0.111) < 1e-12, "Lesson 37: 101 mV + 10 mV."
assert abs(output_error(101, 1e-3, 100e-9, 10e-9, 100e3, True) - 0.102) < 1e-12, "Compensated: 101 mV + 1 mV."
```

::: right
Right. Bias compensation helps only if the bias currents match better than they are large.
:::
:::

::: check
kind: python

## Step 4. Write `bandgap(VG0, VBE0, T0, eta, Tmin, Tmax)` returning `(Vref0, bow)`: the output at $T_0$ of a first-order bandgap with zero slope there, and its peak-to-peak variation over $T_\text{min}$ to $T_\text{max}$ (sample every 0.01 K). Use k/q = 8.617333e-5 V/K.

```python starter
def bandgap(VG0, VBE0, T0, eta, Tmin, Tmax):
    return VG0, 0.0

print(bandgap(1.205, 0.65, 300, 3, 233.15, 398.15))
```

```python solution
import numpy as np

def bandgap(VG0, VBE0, T0, eta, Tmin, Tmax):
    kq = 8.617333e-5
    vbe = lambda T: VG0 * (1 - T / T0) + VBE0 * T / T0 - eta * kq * T * np.log(T / T0)
    slope0 = -(VG0 - VBE0) / T0 - eta * kq
    vref = lambda T: vbe(T) - slope0 * T
    T = np.arange(Tmin, Tmax + 1e-9, 0.01)
    v = vref(T)
    return float(vref(T0)), float(v.max() - v.min())

print(bandgap(1.205, 0.65, 300, 3, 233.15, 398.15))
```

```python tests
v0, bow = bandgap(1.205, 0.65, 300, 3, 233.15, 398.15)
assert abs(v0 - 1.282556) < 1e-5 and abs(bow - 3.760e-3) < 2e-6, f"Expected 1.2826 V and a 3.76 mV bow; got {v0}, {bow}"
assert bandgap(1.205, 0.65, 300, 0, 233.15, 398.15)[1] < 1e-12, "With no log term, the cancellation is perfect."
```

::: right
Right. The PTAT term can only cancel a straight line; the log term is what's left.
:::
:::

::: check
kind: python

## Step 5. Write `adc_snr(N, f, sigma, vn, vpp)` returning `(snr_db, enob)` for an N-bit converter sampling a full-scale sine of `vpp` peak to peak at frequency f, with jitter `sigma` and thermal noise `vn` RMS.

```python starter
import math

def adc_snr(N, f, sigma, vn, vpp):
    s = 6.02 * N + 1.76
    return s, N

print(adc_snr(14, 10e6, 1e-12, 100e-6, 2))
```

```python solution
import math

def adc_snr(N, f, sigma, vn, vpp):
    q = 6.02 * N + 1.76
    j = -20 * math.log10(2 * math.pi * f * sigma)
    t = 20 * math.log10(vpp / (2 * math.sqrt(2)) / vn)
    s = -10 * math.log10(10 ** (-q / 10) + 10 ** (-j / 10) + 10 ** (-t / 10))
    return s, (s - 1.76) / 6.02

print(adc_snr(14, 10e6, 1e-12, 100e-6, 2))
```

```python tests
s, e = adc_snr(14, 10e6, 1e-12, 100e-6, 2)
assert abs(s - 75.7779) < 1e-3 and abs(e - 12.2953) < 1e-3, f"Expected 75.8 dB and 12.3 bits; got {s}, {e}"
s2, e2 = adc_snr(16, 10e6, 1e-12, 100e-6, 2)
assert s2 - s < 1.5, "Two more bits barely help when thermal noise dominates."
```

::: right
Right. The largest noise source sets the SNR; improving the others buys almost nothing.
:::
:::

::: check
kind: parts
given: en = 2 | 10 | 30; fc = 100 | 1000; f2 = 1 | 10

## An amplifier has {en} nV/√Hz of white noise with a {fc} Hz corner, measured from 0.1 Hz to {f2} kHz.

::: part
answer: en*sqrt(fc*ln(f2*1000/0.1) + (f2*1000 - 0.1))/1000
unit: µV
tolerance: 0.5%

### What's the RMS noise?

::: misses
- [en*sqrt(f2*1000)/1000] Include the 1/f part.
- [any] $e_n\sqrt{f_c\ln\frac{f_2}{f_1} + (f_2 - f_1)}$.
:::
:::

::: part
answer: fc*ln(f2*1000/0.1)/(f2*1000 - 0.1)*100
unit: %
tolerance: 0.5%

### By what percentage does the 1/f part add to the noise power?

::: misses
- [any] $\frac{f_c\ln(f_2/f_1)}{f_2 - f_1}$.
:::
:::
:::

::: check
given: q = 74 | 86 | 98; j = 70 | 84; t = 80 | 90
answer: -10*log(10^(-q/10) + 10^(-j/10) + 10^(-t/10))
unit: dB
tolerance: 0.5%

## A converter's quantization, jitter and thermal SNRs are {q}, {j} and {t} dB. What's its overall SNR?

::: right
Right. Add the noise powers: {answer}.
:::

::: misses
- [-20*log(10^(-q/20) + 10^(-j/20) + 10^(-t/20))] Independent noises add in power, not amplitude.
- [any] $-10\log\sum10^{-\text{SNR}_k/10}$.
:::
:::

::: explain
## Why does adding a few bits of resolution to a converter often barely improve its signal-to-noise ratio?

::: model
Quantization noise is only one of several independent noise sources in a converter, along with the clock's jitter and the thermal noise of its front end, and independent noises add in power. The total is dominated by the largest one. Each extra bit cuts quantization noise by 6 dB, but if thermal noise or jitter is already well above the quantization noise, cutting the quantization noise further changes the total power very little, and the effective number of bits stays close to what the largest noise source allows.
:::
:::

::: practice

::: check
given: en = 4 | 20; fc = 30 | 3000; f2 = 5 | 50
answer: en*sqrt(fc*ln(f2*1000/0.1) + (f2*1000 - 0.1))/1000
unit: µV
tolerance: 0.5%

## {en} nV/√Hz, corner {fc} Hz, 0.1 Hz to {f2} kHz. RMS noise?

::: misses
- [any] $e_n\sqrt{f_c\ln\frac{f_2}{f_1} + (f_2 - f_1)}$.
:::
:::
:::
