TExcelTAD
Home › Signals, Systems & Digital Filters for Engineers › Quantisation Noise, Dither and Word Length

Quantisation Noise, Dither and Word Length

Sampling discretises time; quantisation discretises amplitude. Every ADC rounds each sample to one of 2N2^N codes, and every fixed-point DSP operation rounds again. The famous rule "6 dB6\ \text{dB} per bit" hides three engineering questions: how much signal-to-quantisation-noise ratio do you really get when the signal is not a full-scale sine, what happens to very small signals that span only a few codes, and how many bits must the arithmetic inside a filter carry. The derivation of the uniform noise model is in Quantization; the converter-testing side (SINAD, ENOB, coherent sampling) is in Data Acquisition. This lesson is about designing with quantisation.

The additive noise model

A uniform quantiser with step qq (one LSB) maps xx to Q(x)=q round⁡(x/q)Q(x) = q\,\operatorname{round}(x/q). Write the result as the input plus an error, Q(x)=x+eQ(x) = x + e. When the signal is "busy" (it crosses many codes in an irregular way) the error behaves like white noise, uniform on [−q/2,q/2][-q/2, q/2]:

e‾=0,σe2=q212,noise spread evenly over 0…fs/2\overline{e} = 0, \qquad \sigma_e^2 = \frac{q^2}{12}, \qquad \text{noise spread evenly over } 0 \ldots f_s/2

For a bipolar converter with full scale ±VFS\pm V_\text{FS}, q=2VFS/2Nq = 2V_\text{FS}/2^N, and the signal-to-quantisation-noise ratio of a signal with rms value σx\sigma_x is

SQNR=10log⁡10σx2q2/12=6.02N+4.77−20log⁡10VFSσx dB\text{SQNR} = 10\log_{10}\frac{\sigma_x^2}{q^2/12} = 6.02N + 4.77 - 20\log_{10}\frac{V_\text{FS}}{\sigma_x}\ \text{dB}

For a full-scale sine VFS/σx=2V_\text{FS}/\sigma_x = \sqrt{2} and the formula becomes the familiar 6.02N+1.76 dB6.02N + 1.76\ \text{dB}. Two corrections matter in practice:

  • Level. Every dB the signal sits below full scale is a dB of SQNR lost. A sine at −20 dBFS-20\ \text{dBFS} on a 16-bit converter gets 78 dB78\ \text{dB}, not 9898.
  • Crest factor. Noise-like signals (speech, vibration, a multi-carrier radio signal) need headroom so their peaks do not clip; with peaks at 4σx4\sigma_x the formula gives 6.02N−7.27 dB6.02N - 7.27\ \text{dB}, about 9 dB9\ \text{dB} less than a full-scale sine.

Rounding vs truncation. Truncating (dropping the low bits, rounding toward −∞-\infty) has the same noise power but a mean error of −q/2-q/2, a DC offset that accumulates in integrators and long filters. Round, or account for the offset.

Worked example: two converters, two signals

Given: (a) a 16-bit audio ADC recording a quiet passage, a sine at −40 dBFS-40\ \text{dBFS}; (b) a 12-bit microcontroller ADC, 00 to 3.3 V3.3\ \text{V}, digitising vibration noise centred at mid-scale with σx=0.1 V\sigma_x = 0.1\ \text{V}.

Find: the SQNR in each case.

Solve: (a) 98.1−40=58.1 dB98.1 - 40 = 58.1\ \text{dB}. (b) q=3.3 V/4096=0.806 mVq = 3.3\ \text{V}/4096 = 0.806\ \text{mV}, q/12=0.233 mVq/\sqrt{12} = 0.233\ \text{mV} rms, SQNR=20log⁡10(100 mV/0.233 mV)=52.7 dB\text{SQNR} = 20\log_{10}(100\ \text{mV}/0.233\ \text{mV}) = 52.7\ \text{dB}.

Check: with the formula for (b), unipolar range 3.3 V3.3\ \text{V} is a bipolar ±1.65 V\pm 1.65\ \text{V}: 72.24+4.77−20log⁡10(16.5)=77.01−24.35=52.7 dB72.24 + 4.77 - 20\log_{10}(16.5) = 77.01 - 24.35 = 52.7\ \text{dB}. The 12-bit converter used at a 16.516.5 to 11 crest margin performs like a full-scale 8.5-bit one: the cost of headroom.

python · try it yourself
import numpy as np

rng = np.random.default_rng(1)

def sqnr_db(x, q):
    e = q * np.round(x / q) - x
    return 10 * np.log10(np.mean(x**2) / np.mean(e**2))

N, n = 16, 2**16
q = 2.0 / 2**N                                        # +/-1 V full scale
t = np.arange(n)
for level in (0, -20, -40, -60):
    A = 10 ** (level / 20) * (1 - 1e-9)
    x = A * np.sin(2 * np.pi * 0.0123457 * t + 0.3)   # an "irrational" frequency exercises many codes
    print(f"16-bit, sine at {level:4d} dBFS: SQNR {sqnr_db(x, q):6.2f} dB (formula {98.09 + level:6.2f})")

qa = 3.3 / 4096                                       # 12-bit, 0..3.3 V
x = 0.1 * rng.standard_normal(n)                      # vibration noise around mid-scale, sigma 0.1 V
print(f"12-bit, noise sigma 0.1 V: SQNR {sqnr_db(x, qa):.2f} dB")

trunc = qa * np.floor(x / qa) - x
print(f"truncation: mean error {1e3 * trunc.mean():.4f} mV (-q/2 = {-1e3 * qa / 2:.4f} mV), rms {1e3 * trunc.std():.4f} mV")
16-bit, sine at    0 dBFS: SQNR  98.09 dB (formula  98.09)
16-bit, sine at  -20 dBFS: SQNR  78.03 dB (formula  78.09)
16-bit, sine at  -40 dBFS: SQNR  58.09 dB (formula  58.09)
16-bit, sine at  -60 dBFS: SQNR  38.29 dB (formula  38.09)
12-bit, noise sigma 0.1 V: SQNR 52.66 dB
truncation: mean error -0.4034 mV (-q/2 = -0.4028 mV), rms 0.2332 mV

Small signals and dither

The white-noise model fails when the signal is small or very regular. A sine of 1.31.3 LSB amplitude crosses only three codes; the error is then a deterministic function of the signal, which shows up as harmonics (distortion) instead of noise. Even worse, a slowly varying input smaller than half an LSB disappears entirely. The cure is dither: add a small random signal before the quantiser. Triangular-PDF (TPDF) dither of ±1\pm 1 LSB peak makes the error's mean and variance independent of the signal: the harmonics vanish, the total error power rises from q2/12q^2/12 to q2/4q^2/4 (a 4.77 dB4.77\ \text{dB} penalty), and averaging can recover detail below one LSB.

python · try it yourself
import numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng(7)
n, k0 = 8192, 31                                  # coherent tone: 31 cycles in 8192 samples
t = np.arange(n)
x = 1.3 * np.sin(2 * np.pi * k0 * t / n)          # 1.3 LSB amplitude, q = 1
tpdf = rng.uniform(-0.5, 0.5, n) + rng.uniform(-0.5, 0.5, n)   # triangular, +/-1 LSB peak

spectra = {}
for name, d in (("no dither", 0.0), ("TPDF dither", tpdf)):
    y = np.round(x + d)
    e = y - x
    Y = np.abs(np.fft.rfft(y)) / n * 2
    harm = [20 * np.log10(Y[h * k0] / Y[k0] + 1e-15) for h in (3, 5, 7)]
    print(f"{name:12s}: error rms {e.std():.3f} LSB, H3 {harm[0]:6.1f} dBc, H5 {harm[1]:6.1f} dBc, H7 {harm[2]:6.1f} dBc")
    spectra[name] = 20 * np.log10(Y / Y[k0] + 1e-12)
print(f"theory: rms without dither (busy signal) {1 / np.sqrt(12):.3f} LSB, with TPDF {0.5:.3f} LSB")

f = np.arange(n // 2 + 1) / n
plt.figure(figsize=(7, 3))
for name, s in spectra.items():
    plt.plot(f, s, lw=0.8, label=name)
plt.xlim(0, 0.1); plt.ylim(-90, 5); plt.xlabel("f / fs"); plt.ylabel("dBc")
plt.legend(); plt.tight_layout(); plt.show()
no dither   : error rms 0.256 LSB, H3  -17.3 dBc, H5  -21.4 dBc, H7  -16.8 dBc
TPDF dither : error rms 0.501 LSB, H3  -40.6 dBc, H5  -45.0 dBc, H7  -45.2 dBc
theory: rms without dither (busy signal) 0.289 LSB, with TPDF 0.500 LSB

Without dither the odd harmonics are only 1717 to 21 dB21\ \text{dB} below the tone: a pure tone has turned into a distorted one, and the error (0.2560.256 LSB rms) does not even follow the busy-signal value of 0.2890.289 LSB. With dither the harmonic bins fall to −40-40 to −45 dBc-45\ \text{dBc}, which is just the flat noise floor in those bins, and the error is the predicted 0.500.50 LSB rms. Audio mastering adds dither every time it reduces word length (24 to 16 bits); measurement systems often get "free" dither from the analog noise of the front end, which is why averaging improves a noisy ADC's resolution but not a perfectly quiet one's.

Noise shaping goes one step further: feed the quantisation error back so it is pushed out of the band of interest, E(z)(1−z−1)E(z)(1 - z^{-1}) for first order. The total noise grows but the in-band part shrinks; combined with oversampling this is the principle of sigma-delta converters.

Word length inside the DSP

The same model covers arithmetic. Each rounding after a multiply injects about q2/12q^2/12 of noise at that point, which the rest of the filter then shapes and amplifies; a narrow-band IIR filter can amplify it by tens of dB. Typical rules of thumb, worked out in Filter Structures and Fixed Point:

  • Data path: at least as many bits as the converter, plus margin for the filter's noise gain.
  • Coefficients: enough bits that the quantised poles and zeros stay where you designed them (Biquads).
  • Accumulators: wide (a 16 × 16-bit multiply gives 32 bits; many 16-bit DSPs accumulate in 40 bits) and rounded once at the end.

Guided lab: the code histogram of a quiet ADC

Hand calculation. A 12-bit, 3.3 V3.3\ \text{V} ADC has q=0.806 mVq = 0.806\ \text{mV}. If the input noise is much below q/2q/2, every reading of a steady DC input is the same code (or two neighbours), and averaging 16 readings cannot do better than one LSB. If the front-end noise is about 0.50.5 LSB rms or more, the codes spread and averaging 16 readings improves the resolution about fourfold.

Simulation. In the dither program set the amplitude to 0.40.4 (below half an LSB) and print np.unique(y) without dither: the tone vanishes entirely (all zeros). With dither, averaging many periods recovers it.

What you would measure. Apply a steady 1.000 V1.000\ \text{V} from a divider on the board's reference (with a 100 nF100\ \text{nF} capacitor at the ADC pin) and log 1000 readings. A quiet layout gives a histogram 1 to 3 codes wide; with the processor's radio or USB busy, typically 5 to 10 codes. The standard deviation in LSB is the input-referred noise; compare its mean with the expected code 1.000/0.806 mV=12411.000/0.806\ \text{mV} = 1241, within the ADC's offset and gain error (often several LSB).

Hazards and safe setup. USB-powered board; the divider runs from the board's own 3.3 V3.3\ \text{V}, so the input can never exceed the pin's range.

Pitfalls

  • Quoting 6.02N+1.76 dB6.02N + 1.76\ \text{dB} for signals that use a fraction of full scale.
  • Truncating instead of rounding and finding a DC offset downstream.
  • Expecting averaging to add resolution to a noiseless converter.
  • Reducing word length (24 to 16 bits) without dither and getting distortion on quiet passages.

Practice

  1. What SQNR does a 24-bit converter have for a sine at −60 dBFS-60\ \text{dBFS}?
  2. A 10-bit converter quantises a Gaussian signal with peaks at ±4σ\pm 4\sigma just reaching full scale. What is the SQNR?
  3. How much does TPDF dither of ±1\pm 1 LSB raise the noise floor?
Answer
  1. 6.02×24+1.76−60=86.2 dB6.02 \times 24 + 1.76 - 60 = 86.2\ \text{dB} (in reality limited by the analog noise, typically 110110 to 120 dB120\ \text{dB} of dynamic range).
  2. 6.02×10−7.27=52.9 dB6.02 \times 10 - 7.27 = 52.9\ \text{dB}.
  3. From q2/12q^2/12 to q2/4q^2/4: 10log⁡103=4.77 dB10\log_{10}3 = 4.77\ \text{dB}.

Test yourself

The quantisation noise power of a rounding quantiser with step qq is

  1. q2/2q^2/2
  2. q2/4q^2/4
  3. q2/12q^2/12
  4. q/12q/\sqrt{12}

A 16-bit ADC records a sine at −20-20 dBFS. Its SQNR is about

  1. 98 dB
  2. 78 dB
  3. 58 dB
  4. 118 dB

Dither before a quantiser

  1. lowers the total noise
  2. turns signal-dependent distortion into signal-independent noise
  3. adds bits to the ADC
  4. is only for audio

Truncation instead of rounding adds

  1. more noise power
  2. a DC offset of −q/2-q/2
  3. harmonics only
  4. nothing