Sampling theorem
All digital communication rests on a surprising claim: a continuous signal can be reconstructed exactly from isolated samples, as long as they are taken often enough. That “enough” has a precise value.
Spectral analysis and the idea of frequency content are developed in signals and Fourier analysis, and the conversion itself in A/D and D/A converters. Here we work on the criterion that decides how fast you have to sample and what happens if it is not respected.
01The statement
| Application | Useful band | Sampling | Why that value |
|---|---|---|---|
| Telephony | 300 to 3400 Hz | 8 kHz | A little more than twice 3400 Hz, leaving margin for the filter. |
| Digital audio | 20 Hz to 20 kHz | 44.1 kHz | Covers human hearing with margin for the input filter. |
| Instrumentation | depends on the process | 5 to 20 times | Reconstructing is not enough: the waveform has to be seen clearly. |
| Digital oscilloscope | bandwidth | 5 to 10 times | So the edges can be seen without relying on interpolation. |
Sampling at exactly twice the frequency only works with mathematically perfect signals and ideal filters. In practice a margin is taken: telephony samples at 8 kHz for a 3.4 kHz band, and audio at 44.1 kHz for 20 kHz. That margin is what gives the anti-aliasing filter a range of frequencies over which to attenuate.
02Aliasing
A signal containing a 5 kHz tone is sampled at 8 kHz, with no input filter.
- The Nyquist limit is 8/2 = 4 kHz. The 5 kHz tone exceeds it.
- Alias frequency: |8 − 5| = 3 kHz.
- In the reconstructed signal a 3 kHz tone appears that never existed, inside the usable band and therefore impossible to filter out.
It is the same phenomenon by which, in a film, the wheels of a car seem to turn backward: the camera “samples” at 24 or 30 frames per second and the wheel turns faster than that.
And it is analog, because once the signal is sampled the damage is irreversible: no digital processing can separate the alias from the legitimate signal. Its cutoff frequency is placed below fs/2, and its slope has to be steep enough that at fs/2 the attenuation is greater than the dynamic range of the converter.
That requirement is demanding: an eighth-order filter is not unusual. That is why oversampling is used, which puts the useful band far from fs/2 and allows a simple analog filter, leaving the fine filtering to the digital domain, where it is easy.
03Sample-and-hold and reconstruction
- The sample-and-hold circuit freezes the value while the converter works. Without it, a signal that changes during conversion produces a meaningless result.
- The aperture time —the time it takes to freeze— and the jitter —the variation of the sampling instant— limit accuracy at high frequency.
- Droop is the slow discharge of the hold capacitor: it must be negligible during the conversion.
- The D/A converter outputs steps, not a curve: it holds each value until the next sample.
- Those steps contain high-frequency components that were not in the original. The reconstruction filter removes them and returns the smooth curve.
- The hold also introduces a slight attenuation of high frequencies, which in demanding systems is compensated for.
If the samples are not taken at exactly equally spaced instants, the captured value corresponds to the wrong moment, and that amounts to an amplitude error. The faster the signal varies, the larger that error. In audio and digital radio, sampling clock jitter can limit performance long before the number of bits of the converter does.
04Pulse modulation and multiplexing
| Acronym | What it modulates in the pulse | Use |
|---|---|---|
| PAM | The amplitude of each pulse follows the value of the sample. | It is the intermediate step of every sampling: what exists before quantization. |
| PWM | The width of the pulse. The information is in the duration. | Power control, servos, switching power supplies, brightness control. |
| PPM | The position of the pulse within its interval. | Optical links and radio control. Good immunity to amplitude noise. |
| PCM | Each sample is quantized and encoded in bits. | All of telephony and digital audio. Developed in the next topic. |
Between one sample and the next there is free time, and that time is used to interleave the samples of other channels. It is the idea that allowed a single copper pair to carry thirty conversations.
In the European system, the E1 frame has 32 time slots of 8 bits each, repeated 8000 times per second: 32 × 8 × 8000 = 2.048 Mbit/s. Of those 32 slots, 30 carry voice and two are reserved for synchronization and signaling.
A digital link of 8.448 Mbit/s carrying 64 kbit/s telephone channels, with 5% of the capacity reserved for synchronization and control.
Usable capacity: 8.448 × 0.95 = 8.026 Mbit/s. Channels: 8,026,000/64,000 = 125 channels as a theoretical maximum.
The real system that works at that rate —the E2— carries 120 channels: four E1 frames of 30 channels each. The difference is the synchronization and justification bits that multiplexing needs in order to combine four frames whose clocks are not exactly equal.
05In the lab
With a generator and a sound card or an A/D converter, sample tones of increasing frequency without an input filter. Record the frequency from which the measured tone starts to go down instead of up, and verify the alias formula at several points.
Repeat the previous lab with an active low-pass filter inserted, with a cutoff below half the sampling frequency. Check that the aliases disappear and measure how much attenuation is needed at fs/2 for them to go unnoticed.
Convert a sampled signal back to analog and observe the steps on the oscilloscope. Add the reconstruction filter and compare. Measure the high-frequency content before and after with a spectrum analyzer.
With a microcontroller, sample four slow signals and transmit them interleaved over a single serial channel, with a synchronization word at the start of each frame. On the other side, separate them and reconstruct them. It is a complete TDM frame made by hand.
06Common mistakes
| Mistake | Consequence |
|---|---|
| Sampling without an anti-aliasing filter | Components that never existed appear, inside the useful band and impossible to remove afterwards. |
| Sampling at exactly twice the frequency | There is no margin for the filter: in practice considerably more is needed. |
| Filtering after the converter | Too late: the aliasing has already happened and is irreversible. |
| Believing that 2 times is enough to see the waveform | Nyquist guarantees reconstruction, not a legible display. To observe, 5 to 10 times is needed. |
| Ignoring clock jitter | It limits accuracy at high frequency long before the converter resolution does. |
| No sample-and-hold | The signal changes during conversion and the result does not correspond to any instant. |
| Forgetting the reconstruction filter | The D/A steps radiate and interfere, and the signal is not the original. |
07Self-assessment
What does the sampling theorem say?
That a band-limited signal is completely determined by its samples if the sampling frequency is at least twice its highest component.
A 6 kHz tone sampled at 8 kHz: where does it appear?
At |8 − 6| = 2 kHz, inside the useful band and with no way of telling it from a legitimate signal of that frequency.
Why does telephony sample at 8 kHz?
Because its band reaches 3400 Hz: twice that would be 6800 Hz, and 8 kHz leaves a reasonable margin for the anti-aliasing filter to work.
Where does the anti-aliasing filter go and why?
Before the converter, and it is analog. Once the signal has been sampled, the aliasing has already happened and no later processing can undo it.
What is the advantage of oversampling?
It puts the useful band far from fs/2, so a simple analog filter is enough and the fine filtering is done in the digital domain, where it is easy.
What is the sample-and-hold circuit for?
To freeze the value of the signal while the converter works. Without it, a signal that changes during conversion gives a result that does not correspond to any instant.
What is jitter and what effect does it produce?
The variation of the sampling instant. It amounts to an amplitude error, larger the faster the signal varies, and it can limit performance before the number of bits does.
Why is a filter needed after the D/A converter?
Because the D/A outputs steps, which contain high-frequency components that did not exist in the original. The reconstruction filter removes them.
Difference between PWM and PPM.
In PWM the information is in the width of the pulse; in PPM, in its position within the interval.
Where do the 2.048 Mbit/s of an E1 frame come from?
From 32 slots of 8 bits repeated 8000 times per second: 32 × 8 × 8000 = 2,048,000 bit/s. Thirty slots carry voice and two, synchronization and signaling.