Skip to content
Tutorials Center
My learning

Topics

Lesson 4 of 38 ยท Getting Started

Quantization and the ADC

Learn how an analog-to-digital converter rounds samples to a fixed number of bits, why quantization adds noise, and the 6 dB per bit rule, with Python experiments.

Sampling chops time into steps. Quantization chops the amplitude into steps. An ADC with B bits can output only 2^B different values, so every sample is rounded to the nearest allowed level. The rounding error is a kind of noise that you can predict, measure and design around. This lesson shows how many bits you need and what happens when you have too few.

Uniform quantization

Suppose the input is limited to the range -1 ... +1 (the full scale). A B-bit uniform quantizer splits that range into 2^B equal steps of size

delta = 2 / 2^B

and rounds each sample to the nearest level. Rounding never moves a value by more than delta/2.

flowchart LR
    A["x (real number)"] --> B["divide by delta"]
    B --> C["round to integer"]
    C --> D["multiply by delta"]
    D --> E["xq (quantized value)"]

Quantization is scaling, rounding and scaling back.

Python A 3-bit quantizer

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

With 3 bits there are only 8 levels, and the largest error inside the range is delta/2 = 0.125. The very top value +1 does not exist in two's complement; the quantizer clips it to the highest level.

Quantization noise

The rounding error e[n] = xq[n] - x[n] is, for busy signals, almost random and evenly spread between -delta/2 and +delta/2. Its power is therefore delta^2 / 12. For a full-scale sine wave (power 1/2) the signal-to-quantization-noise ratio works out to

SQNR = 6.02 * B + 1.76 dB.

Each extra bit adds about 6 dB. A 16-bit converter gives roughly 98 dB, a 24-bit one roughly 146 dB (in practice analog noise limits real devices to less).

Python Measure SQNR and compare with 6.02 B + 1.76

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The measured values land close to the formula. The formula assumes the signal fills the range. A quiet signal wastes bits: halving the amplitude costs 6 dB, so recordings are normally set to peak just below full scale.

When the noise assumption fails

Quantization error is only noise-like when the signal moves across many levels. A tiny signal gets turned into a staircase, and the error then correlates with the signal and becomes audible distortion.

Python A quiet sine on a coarse grid

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The 0.04 amplitude sine reaches only three levels (-delta, 0, +delta); its output looks like a rough rectangular wave. A cure is dither.

Dither

Adding a little random noise (about one step in size) before quantizing breaks the correlation. The error turns into steady, harmless hiss, and surprisingly the quantizer then preserves signals smaller than one step on average.

Python Dither lets sub-step detail survive

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Plain rounding erases the 0.03 level completely, while the average of the dithered output recovers it. Professional audio uses dither whenever it reduces the bit depth.

Other ADC properties

  • Sampling rate and resolution are independent knobs: a fast ADC may have few bits (oscilloscopes), a precise one may be slow (scales, meters).
  • Oversampling ADCs (sigma-delta) sample very fast with 1 bit and use digital filtering to get 24 usable bits.
  • Dynamic range is the ratio between the largest and the smallest representable signal; the 6.02*B rule is its estimate.
  • Clipping happens when the input exceeds full scale. It creates harsh distortion, so scale the analog gain to keep a margin.
  • Floating point hides quantization during computing, but arithmetic in fixed-point DSP chips needs the same analysis for every multiplication.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How much does SQNR improve for each extra bit of an ADC?

    SQNR = 6.02 B + 1.76 dB, so every bit adds about 6 dB.
  2. 2. A full-range 8-bit quantizer covers -1 to +1. What is the step size?

    delta = 2 / 2^8 = 2/256, about 0.0078.
  3. 3. What is the maximum rounding error of a uniform quantizer with step delta?

    Rounding goes to the nearest level, so the error cannot exceed half a step.
  4. 4. What does dither do?

    Dither turns signal-dependent distortion into constant, benign noise.

Summary

  • Quantization rounds each sample to one of 2^B levels with step delta = full_scale_range / 2^B.
  • The error is at most delta/2 and acts like noise of power delta^2/12.
  • SQNR for a full-scale sine is about 6.02*B + 1.76 dB: 6 dB per bit.
  • Quiet signals waste bits and can suffer staircase distortion; dither fixes this.
  • Keep signals near full scale without clipping.

Next: Sequences and Basic Signals