---
title: Quantization and converter impairments
heading: Signal-to-noise with crest factor, effective bits, dither, aperture jitter and linearity errors
eyebrow: S7 · Lesson 6 · Quantization and converter impairments
xp: 50
---

::: hook
Lesson 4 gave the ideal converter's 6.02B + 1.76 dB. Real converters fall short of it in ways a designer must budget: signals that aren't full-scale sines have less headroom, a sampling clock that wanders by a tenth of a picosecond limits a fast converter more than its bits do, uneven code widths add distortion, and quantizing a quiet signal makes its error a distorted copy of the signal rather than noise. Each effect has a simple formula, and the formulas combine by adding noise powers.
:::

::: play
- The curve is an ADC's SNR against input frequency, combining B-bit quantization noise with the noise from sampling-clock jitter σ: $\text{SNR}_j = -20\log_{10}(2\pi f\sigma)$.
- At low frequencies the bits set the limit; above a crossover, jitter takes over and the SNR falls 20 dB per decade.
- A 14-bit converter with 100 fs of jitter loses about 4 dB at 100 MHz; with 1 ps it would be jitter-limited above about 8 MHz.
:::

```sim plot
view: graph
x: f = 1..1000 MHz log
y: S = 40..110 dB
slider: B = 8..18 = 14 step 1
slider: s = 10..1000 = 100 fs log
plot: -10*log(10^(-(6.02*B + 1.76)/10) + (2*pi*f*1e6*s*1e-15)^2) | label: SNR
```

::: predict
## A 14-bit ADC samples a 100 MHz tone with a clock whose rms jitter is 100 fs. About what SNR can it reach?

- [ ] 86 dB, its ideal quantization limit
- [x] About 82 dB: jitter alone limits it to 84 dB, and the two noises add
- [ ] About 60 dB
- [ ] 100 dB

::: reveal
Jitter gives $-20\log_{10}(2\pi \times 10^8 \times 10^{-13}) = 84.0$ dB, quantization 86.0 dB. Noise powers add: $-10\log_{10}(10^{-8.40} + 10^{-8.60}) = 81.9$ dB, an effective 13.3 bits. Better converters at high frequencies need better clocks first.
:::
:::

::: nameit
## Signals that aren't sines

A B-bit converter's quantization noise is $\Delta^2/12$ with full scale ±1 = $2^{B-1}\Delta$. A signal whose peak just reaches full scale and whose **crest factor** (peak/rms) is C gives
$$\text{SNR} = 6.02B + 4.77 - 20\log_{10}C$$
For a sine C = √2 and this is the familiar 6.02B + 1.76. Speech, OFDM and noise-like signals are loaded with C of 3 to 4 (10 to 12 dB), clipping only rarely, and lose that much SNR.

## Effective bits

Measured with a sine, the ratio of signal to everything else (noise plus distortion), **SINAD**, defines the **effective number of bits**: $\text{ENOB} = \frac{\text{SINAD} - 1.76}{6.02}$.

## Aperture jitter

A sampling instant wrong by δt errs by the signal's slope times δt. For a full-scale sine at f with rms clock jitter σ, the error's power relative to the signal gives
$$\text{SNR}_j = -20\log_{10}(2\pi f\sigma)$$
independent of the number of bits. Independent noise sources add in power: $\text{SNR} = -10\log_{10}\sum_i10^{-\text{SNR}_i/10}$.

## Dither

Quantizing a signal only a few LSBs in size makes the error correlated with it: harmonics instead of noise. Adding **dither** before quantizing, random noise of about an LSB, decorrelates the error. **TPDF** dither (the sum of two uniform ±½ LSB variables, 2 LSB peak to peak) makes the error's mean and variance independent of the signal, at the cost of three times the noise power: 4.77 dB of SNR. Subtractive dither, removed after conversion, costs nothing but needs the same random sequence at both ends.

## Linearity

A converter's codes aren't all one LSB wide. **Differential nonlinearity** is each code's width minus 1 LSB; DNL = −1 is a **missing code**. **Integral nonlinearity** is the accumulated deviation of the transfer curve from a straight line, the running sum of the DNL. INL bends the curve and produces harmonics; DNL adds noise-like error.
:::

::: example
## A 12-bit ADC digitizes speech loaded so its peaks just reach full scale with a crest factor of 4. What SNR does it give, against a full-scale sine?

::: solution
1. **SNR with a crest factor of 4.**
   $$\begin{aligned} \text{SNR} &= 6.02 \times 12 + 4.77 \\ &\quad - 20\log_{10}4 \\ &= 72.24 + 4.77 - 12.04 \\ &= 65.0\ \text{dB} \end{aligned}$$
2. **Compare a full-scale sine.**
   $$\begin{aligned} \text{SNR} &= 6.02 \times 12 + 1.76 \\ &= 74.0\ \text{dB} \end{aligned}$$
3. **The difference.** The 9 dB difference, a bit and a half, is the headroom real signals need.
4. **Why codecs compand.** It's why telephone codecs use companding, spending resolution where speech spends its time.

**Answer:** 65.0 dB for the speech, against 74.0 dB for a full-scale sine.
:::
:::

::: example
## A 16-bit audio converter adds TPDF dither. What SNR does it give, and why accept the loss?

::: solution
1. **Without dither.**
   $$\begin{aligned} \text{SNR} &= 6.02 \times 16 + 1.76 \\ &= 98.1\ \text{dB} \end{aligned}$$
2. **With TPDF dither.** TPDF triples the noise power, a 4.77 dB loss:
   $$\begin{aligned} \text{SNR} &= 98.1 - 4.77 \\ &= 93.3\ \text{dB} \end{aligned}$$
3. **What the loss buys.** A fading note decays smoothly into a steady hiss instead of turning into a buzz of harmonics as it nears the last few bits, which listeners find far worse than slightly more noise.

**Answer:** 93.3 dB, against 98.1 dB without dither; the small loss buys a smooth hiss in place of a harmonic buzz on quiet notes.
:::
:::

::: example
## An ADC's codes around mid-scale measure 1.0, 0.6, 1.5 and 0.9 LSB wide. What are their DNL values, and the INL at the end of each?

::: solution
1. **DNL.** DNL is the width minus 1:
   $$\text{DNL} = 0,\ -0.4,\ +0.5,\ -0.1\ \text{LSB}$$
2. **INL.** INL accumulates the DNL:
   $$\text{INL} = 0,\ -0.4,\ +0.1,\ 0.0\ \text{LSB}$$
3. **What it means.** The narrow code and the wide one beside it partly cancel in INL, but both distort small signals.
4. **A missing code.** A code of width 0 (DNL = −1) would never appear at all.

**Answer:** DNL of 0, −0.4, +0.5 and −0.1 LSB, and INL of 0, −0.4, +0.1 and 0.0 LSB.
:::
:::

::: check
kind: parts
given: B = 8 | 12 | 16; C = 2 | 3 | 4

## A {B}-bit converter digitizes a signal whose peaks just reach full scale with a crest factor of {C}.

::: part
answer: 6.02*B + 4.77 - 20*log(C)
unit: dB
tolerance: 0.5%

### What SNR does it give?

::: misses
- [6.02*B + 1.76] That's for a full-scale sine (C = √2).
- [any] $6.02B + 4.77 - 20\log_{10}C$.
:::
:::

::: part
answer: 20*log(C/sqrt(2))
unit: dB
tolerance: 0.5%

### How much less than a full-scale sine is that?

::: misses
- [any] $20\log_{10}(C/\sqrt2)$.
:::
:::
:::

::: check
kind: parts
given: S = 50 | 68 | 85; E = 10 | 12 | 14

## A converter measures {S} dB SINAD; another must reach {E} effective bits.

::: part
answer: (S - 1.76)/6.02
unit: bits
tolerance: 0.5%

### What is the first one's ENOB?

::: misses
- [S/6.02] Subtract the 1.76 dB first.
- [any] (SINAD − 1.76)/6.02.
:::
:::

::: part
answer: 6.02*E + 1.76
unit: dB
tolerance: 0.5%

### What SINAD must the second reach?

::: misses
- [any] $6.02\,\text{ENOB} + 1.76$.
:::
:::
:::

::: check
kind: parts
given: f = 10 | 100 | 500; s = 50 | 200 | 1000; S = 70 | 80

## A converter samples a {f} MHz full-scale tone with {s} fs of rms clock jitter.

::: part
answer: -20*log(2*pi*f*1e6*s*1e-15)
unit: dB
tolerance: 0.5%

### What SNR does jitter alone allow?

::: misses
- [any] $-20\log_{10}(2\pi f\sigma)$.
:::
:::

::: part
answer: 10^(-S/20)/(2*pi*f*1e6)*1e15
unit: fs
tolerance: 0.5%

### What jitter would allow {S} dB at that frequency?

::: misses
- [any] $\sigma = 10^{-\text{SNR}/20}/(2\pi f)$.
:::
:::
:::

::: check
kind: parts
given: B = 12 | 14 | 16; f = 50 | 200; s = 80 | 300

## A {B}-bit converter samples a {f} MHz tone with {s} fs of jitter.

::: part
answer: -10*log(10^(-(6.02*B + 1.76)/10) + (2*pi*f*1e6*s*1e-15)^2)
unit: dB
tolerance: 0.5%

### What total SNR does it reach?

::: misses
- [any] Add the quantization and jitter noise powers.
:::
:::

::: part
answer: (-10*log(10^(-(6.02*B + 1.76)/10) + (2*pi*f*1e6*s*1e-15)^2) - 1.76)/6.02
unit: bits
tolerance: 0.5%

### How many effective bits is that?

::: misses
- [any] (SNR − 1.76)/6.02.
:::
:::
:::

::: check
kind: parts
given: B = 8 | 16 | 24

## A {B}-bit converter adds TPDF dither.

::: part
answer: 6.02*B + 1.76 - 4.77
unit: dB
tolerance: 0.5%

### What full-scale sine SNR does it give?

::: misses
- [6.02*B + 1.76 - 3.01] TPDF dither has twice a uniform LSB's variance, so the total noise triples: 4.77 dB.
- [any] Subtract 4.77 dB.
:::
:::
:::

::: check
kind: parts
given: a = 0.4 | 0.7 | 1.2; b = 0.8 | 1.3 | 1.6

## Two adjacent codes measure {a} and {b} LSB wide, following codes of exactly 1 LSB.

::: part
answer: b - 1
unit: LSB
tolerance: 0.5%

### What is the second code's DNL?

::: misses
- [any] Width − 1 LSB.
:::
:::

::: part
answer: a + b - 2
unit: LSB
tolerance: 0.5%

### What is the INL at the end of the second code?

::: misses
- [any] The sum of the DNLs.
:::
:::
:::

::: check
kind: choice

## Why does adding a little random noise (dither) before quantizing a very quiet signal make it sound better, even though the measured SNR falls?

- [ ] Dither raises the signal level
- [x] Without dither the quantization error of a signal a few LSBs in size is a deterministic function of the signal, so it appears as harmonics and distortion that follow the signal; dither makes the error random and independent of the signal, a steady hiss the ear ignores
- [ ] Dither removes the quantization noise
- [ ] Dither increases the number of bits

::: misses
- [1] It adds noise; the signal is unchanged.
- [3] It adds noise; it changes the error's character, not its removal.
- [4] Resolution is unchanged; only the error's statistics change.
:::
:::

::: check
kind: derivation
vars: B = 4..24, C = 1.2..6, f = 1e5..1e9, s = 1e-14..1e-11

## A B-bit converter handles a signal of crest factor C; separately, a full-scale tone at f is sampled with jitter s.

::: step
answer: 6.02*B + 4.77 - 20*log(C)

### What quantization SNR does the first signal get?
:::

::: step
answer: -20*log(2*pi*f*s)

### What SNR does jitter allow the tone?
:::

::: step
answer: -10*log(10^(-(6.02*B + 1.76)/10) + (2*pi*f*s)^2)

### What is the tone's total SNR with B bits?
:::

::: right
Right. The smaller of the two SNRs dominates; equal ones together lose 3 dB.
:::
:::

::: check
kind: python

## Write `measure_snr(B, N=8192, cycles=1001, dither=False, seed=1)`: quantize a full-scale sine of `cycles` periods in N samples to B bits (step $2/2^B$, rounding, no clipping), optionally adding TPDF dither (the difference of two uniform [0, 1) LSB variables from `random.Random(seed)`), and return the SNR in dB.

```python starter
def measure_snr(B, N=8192, cycles=1001, dither=False, seed=1):
    return 0.0
```

```python solution
import math, random

def measure_snr(B, N=8192, cycles=1001, dither=False, seed=1):
    r = random.Random(seed)
    d = 2 ** (B - 1)
    sig = noise = 0.0
    for n in range(N):
        x = math.sin(2 * math.pi * cycles * n / N)
        v = x * d
        if dither:
            v += r.random() - r.random()
        q = math.floor(v + 0.5) / d
        sig += x * x
        noise += (q - x) ** 2
    return 10 * math.log10(sig / noise)
```

```python tests
for B in (10, 12, 16):
    assert abs(measure_snr(B) - (6.02 * B + 1.76)) < 0.3, "Undithered: 6.02B + 1.76 within 0.3 dB."
loss = measure_snr(16) - measure_snr(16, dither=True)
assert 4.5 < loss < 5.1, "TPDF dither costs about 4.77 dB."
```

::: right
Right. With 1001 cycles in 8192 samples the samples never repeat a pattern, so the error behaves like the uniform noise the formula assumes.
:::
:::

::: explain
## Why does clock jitter, rather than the number of bits, limit the SNR of fast converters?

::: model
Sampling at slightly the wrong moment gives the value the signal had at a slightly different time, so the error equals the signal's slope multiplied by the timing error. A sine's slope grows in proportion to its frequency, so at high frequencies even femtoseconds of jitter produce errors comparable to an LSB. This error doesn't depend on the converter's resolution, so adding bits stops helping once jitter dominates; the SNR then falls 20 dB per decade of frequency. Fast converters therefore need clocks with extremely low jitter, often more expensive than the converter itself.
:::
:::

::: practice
::: check
given: B = 10 | 14; C = 2.5 | 3.5
answer: 6.02*B + 4.77 - 20*log(C)
unit: dB
tolerance: 0.5%

## SNR of {B} bits for crest factor {C}?

::: misses
- [any] $6.02B + 4.77 - 20\log_{10}C$.
:::
:::

::: check
given: f = 30 | 300; s = 100 | 500
answer: -20*log(2*pi*f*1e6*s*1e-15)
unit: dB
tolerance: 0.5%

## Jitter-limited SNR at {f} MHz with {s} fs?

::: misses
- [any] $-20\log_{10}(2\pi f\sigma)$.
:::
:::

::: check
given: S = 50 | 60 | 74 | 86 | 92 | 98
answer: (S - 1.76)/6.02
unit: bits
tolerance: 0.5%

## ENOB from {S} dB SINAD?

::: misses
- [any] (SINAD − 1.76)/6.02.
:::
:::
:::
