D5 · Lesson 1 · Sampling and quantization
Turning a continuous signal into numbers by sampling it in time and rounding it in value, the Nyquist rate and the aliases that appear below it, the anti-aliasing filter, quantization step and noise, and the 6 dB per bit rule for an ADC's signal-to-noise ratio
Every digital audio recording, phone call and oscilloscope trace starts with two acts of approximation. Sampling keeps only the signal's values at regular instants, and quantization rounds each value to one of a fixed set of levels. Done right, sampling loses nothing at all: a signal with no frequencies above half the sampling rate can be rebuilt exactly. Done wrong, high frequencies masquerade as low ones, and no later processing can tell them apart. Quantization, meanwhile, always adds a little noise, and each extra bit cuts it in half.
- A tone of frequency f sampled at : the stems are the samples, the solid curve the original tone, the dashed curve the lowest-frequency tone through the same samples, which is what a reconstruction would play.
- Below they agree. Above it the samples fit a lower alias just as well.
- Listen to the alias: as you sweep f up past , the reconstructed tone comes back down.
Predict
A 5 kHz tone is sampled 8000 times per second with no filter in front. What frequency does the digital signal contain?
The Nyquist frequency is 4 kHz, and a tone above it folds back by the distance it overshoots: 8 − 5 = 3 kHz. The samples of a 5 kHz cosine are exactly the samples of a 3 kHz cosine, so once sampled the two are indistinguishable. That's why an analog anti-aliasing filter must remove everything above 4 kHz before the ADC.
Name it
Sampling
Sampling at rate keeps with . The sampling theorem: a signal with no content at or above , the Nyquist frequency, is determined exactly by its samples. A tone at f produces the same samples as tones at for every integer k, so content above appears at
CD audio samples at 44.1 kHz to cover hearing up to 20 kHz with room for the anti-aliasing filter to roll off.
Quantization
A B-bit converter with full-scale range FS has levels with step
and rounding adds an error spread evenly over ±Δ/2, a noise of RMS value . For a full-scale sine wave,
so each extra bit buys 6 dB: 16 bits gives 98 dB.
Worked example
A 12-bit ADC spans 0 to 3.3 V. What's its step, its quantization noise and its best SNR?
Show the solution
- Step size. Twelve bits give steps across the range:
- Quantization noise.
- Best SNR.
Answer a step of 0.806 mV, 0.233 mV RMS of quantization noise, and a best SQNR of 74 dB.
Worked example
A system samples at 8 kHz. Where do tones at 7.5 kHz and 9 kHz land? How many bits give an 80 dB SQNR?
Show the solution
- The 7.5 kHz tone. It folds back around the 8 kHz sampling rate:
- The 9 kHz tone.
- Bits for 80 dB. Solve for B: so a 13-bit converter, in practice a 16-bit one.
Answer 7.5 kHz aliases to 0.5 kHz and 9 kHz to 1 kHz, and 80 dB takes a 13-bit converter, in practice a 16-bit one.
Worked example
What are the best SQNRs of 16-bit and 24-bit audio converters, and which limit is likely to matter?
Show the solution
- 16-bit converter.
- 24-bit converter.
- The limit that matters. No analog circuit is quiet enough to use 146 dB: real 24-bit converters reach about 120 dB, limited by their analog noise rather than by quantization.
Answer 98.1 dB for 16 bits and 146.2 dB for 24 bits, but a real 24-bit converter stops near 120 dB, set by its analog noise.
Check
A 9 kHz tone is sampled at 8 kHz without filtering. At what frequency does it appear?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
What's the best signal-to-quantization-noise ratio a 12-bit converter can reach with a full-scale sine?
Check
An 8-bit ADC spans 3.3 V. How big is one step?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
What's the RMS quantization noise of that 8-bit, 3.3 V converter?
Write units the way you normally would: 1.5 µV, 1500 nV and 0.0015 mV are the same answer.
Check
A 12-bit ADC spans 0 to 1 V.
(a)
What is its step?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
(b)
What is its best SQNR for a full-scale sine?
Check
A 5 kHz tone is sampled at 44.1 kHz.
(a)
At what frequency does it appear?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
(b)
Is it below the Nyquist frequency (1 for yes)?
Explain why
Why must the anti-aliasing filter come before the ADC and not after it?
Sampling makes a tone at any frequency produce exactly the same sample values as tones at that frequency shifted by any multiple of the sampling rate, so content above half the sampling rate ends up looking identical to some frequency below it. Once the samples are taken, the information about which of those frequencies was really there is gone, and no digital filter can separate an alias from a genuine signal at the same frequency. The only way to prevent aliasing is to remove the high frequencies while the signal is still continuous, with an analog low-pass filter in front of the converter.
Practice
Keep practicing
8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.