Engineering · Simulator 097
Digital systems store a signal as a list of numbers taken at regular moments. Change how fast the signal oscillates and how often it is sampled. See when the samples capture it faithfully, when a fast wave masquerades as a slow one, and how the number of bits per sample limits precision.
CollegeCollege signals and systems
Sampling at rate f_s keeps only the values at times n/f_s. The Nyquist–Shannon sampling theorem says a signal containing only frequencies below f_s / 2 (the Nyquist frequency) can be rebuilt exactly from its samples by sinc interpolation:
x(t) = Σₙ x[n] · sinc(f_s t − n), sinc(u) = sin(πu) / (πu)
A frequency above f_s/2 is not lost but disguised: its samples are identical to those of a lower alias,
f_alias = | f − k f_s | for the whole number k that brings it into 0 … f_s/2
The spectrum chart shows why: sampling copies the signal's spectrum around every multiple of f_s, and only the copy inside the shaded band 0 … f_s/2 is reconstructed. Real converters therefore put an anti-aliasing filter before the sampler.
A zero-order hold (a staircase that holds each value until the next sample) is how simple converters output samples; it is not an exact reconstruction. Quantization rounds each sample to one of 2ⁿ levels; for a full-scale sine wave the signal-to-quantization-noise ratio is about 6.02 n + 1.76 dB.
Frequencies here are in hertz on a slow time scale so the waves are visible; the same rules apply to audio at kilohertz. Sinc reconstruction uses a finite stretch of samples, so it is very slightly imperfect near the edges.
CD audio samples at 44.1 kHz. What is the highest frequency it can represent? If a 30 kHz ultrasonic tone reached the converter without filtering, at what frequency would it be heard?
The Nyquist frequency is 22.05 kHz. A 30 kHz tone aliases to |30 − 44.1| = 14.1 kHz, well inside the audible range, which is why an anti-aliasing filter must remove everything above about 20 kHz before sampling. Scaled down: try 30 Hz sampled at 44.1 Hz.
A 7 Hz tone sampled at 10 Hz. The Nyquist frequency is 10 / 2 = 5 Hz, and 7 Hz is above it, so it aliases.
Alias: falias = |7 − 1 × 10| = 3 Hz. The samples are exactly those of a 3 Hz wave, and the reconstruction shows 3 Hz.
Another case: 23 Hz sampled at 20 Hz gives |23 − 20| = 3 Hz as well. Very different signals can produce identical samples.
Fix: sample at more than 2 × 7 = 14 Hz, or filter out everything above 5 Hz before sampling. CD audio uses 44.1 kHz so that everything up to 22.05 kHz, above human hearing, is kept.
Bit depth: each extra bit halves the rounding step. 8 bits give 256 levels (about 50 dB signal-to-noise), 16 bits give 65 536 levels (about 98 dB).
A signal can be rebuilt exactly from its samples if it contains no frequency at or above half the sampling rate. That half is the Nyquist frequency.
When a frequency above the Nyquist limit is sampled, its samples match a lower frequency, so it appears as the wrong, lower tone. It is the same effect as wheels that seem to spin backwards in films.
Subtract the nearest whole multiple of the sampling rate: falias = |f − k fs|, choosing k so the result lies between 0 and fs/2.