x[n]0−141−102−63−24+25+66+107+14010101ADCx[0]–x[1]–x[2]–x[3]–x[4]–1bits = 3; d = 32 / 2**bits2i = np.floor(x / d) + 43i = np.clip(i, 0, 2**bits - 1)4q = (i - 3.5) * dx[1] = 3.39 mVx100
012345-16-12-8-40481216t (ms)mVx(t) AND q[n]x[1] = 3.39 mV3.39 -> 2 mV · e = −1.39 mV8 heights, 4 mV apart010203039-2-1012n (sample number)e (mV)ERROR e[n]3 bits: |e| ≤ 2 mV3 bits ±24 bits ±1 mV
Coloured parts: what the current step is about; everything else rests in whiteBlocks: samples in, a level ruler with 8 slices, the converter (ADC), 3 bit lamps, memory and a Python code cardPlots: x(t) with the rounded staircase q[n], and the error e[n] for 3 and 4 bitsThe bead rises to the true value, then glides to its slice's middle; the dashed ring keeps the true value, the red gap is the errorA 3-bit converter over −16 to +16 mV has 8 levels, Δ = 4 mV apart. Each sample x[n] = 10·sin(2π·440·n/8000) mV is rounded to the middle of its slice and stored as 3 bits. "About 6 dB per bit" is 20·log10(2) = 6.02 dB. The formula 6.02·N + 1.76 dB holds for a full-scale sine and treats the error as noise spread evenly over ±Δ/2.

Slices and rounding

  1. Sampling gave exact values such as 3.39 mV. A converter can only store a fixed set of numbers. A 3-bit converter splits −16 to +16 mV into 2³ = 8 equal slices. Each slice is Δ = 32 / 8 = 4 mV tall.

From levels to bits

What rounding costs

In code

The working

# step 1/9 · levels

full-scale range  −16 .. +16 mV  (32 mV)
bits              N = 3
levels            2^N = 2 × 2 × 2 = 8
step (1 LSB)      Δ = 32 mV / 8 = 4 mV

slice  covers            stands for
  7    +12 .. +16 mV     +14 mV
  6     +8 .. +12 mV     +10 mV
  5     +4 ..  +8 mV      +6 mV
  4      0 ..  +4 mV      +2 mV
  3     −4 ..   0 mV      −2 mV
  ...
  0    −16 .. −12 mV     −14 mV

The tone (10 mV, 440 Hz, sampled 8000 times a second) is the example from "What a signal is". The 3-bit converter over −16 to +16 mV is chosen so the levels are easy to see; real audio converters use 16 to 24 bits. Every number in the figure is computed from this model. This is a mid-rise quantizer: a threshold sits at 0 mV and every level is the middle of its slice. Many converters use a mid-tread quantizer instead, which has a level at exactly 0. Both keep the error within half a step.