ELEC6218 · Signal ProcessingAnalog & Digital Filter Design
Signal Processing · Lecture notesProf. Çelik
ELEC6218 · Signal Processing
Lecture 3
Sampling and Reconstruction
Under suitable conditions a continuous-time signal is completely determined by its values at equally spaced instants of time. This lecture develops that result, the sampling theorem, together with the reconstruction of a signal from its samples, the consequences of sampling too slowly, and the processing of continuous-time signals by discrete-time systems. The quantization of the sample values, which unlike sampling cannot be undone, is treated alongside.
Represent sampling as multiplication by a periodic impulse train, derive the spectrum of the sampled signal, and state the sampling theorem together with its conditions.
Determine the frequency and phase at which an undersampled sinusoid is reconstructed, and explain the stroboscopic effect and bandpass sampling in these terms.
Convert between frequency in hertz \(f\), continuous-time frequency \(\Omega\) and discrete-time frequency \(\omega\), and relate the DTFT of a sequence to the spectrum of the signal from which it was obtained.
Describe reconstruction as interpolation, and compare band-limited interpolation, the zero-order hold and the first-order hold in the time and frequency domains.
Analyse the sampling, decimation and interpolation of discrete-time signals, and specify the filter of a rational U/D sample-rate converter.
Estimate quantization noise and the signal-to-quantization-noise ratio using the 6 dB-per-bit rule.
Lecture 3
Contents
Sections 3.2–3.5 develop the sampling theorem and the effect of undersampling. Section 3.6 relates continuous-time and discrete-time frequency. Sections 3.7–3.9 treat reconstruction, practical converters and quantization, and Sections 3.10 and 3.11 consider the sampling of sequences and changes of sampling rate.
iNotation used in this lecture
\(x_c(t)\)
the continuous-time signal to be sampled
\(p(t)\)
the periodic impulse train, or sampling function
\(x_p(t)\)
the impulse-train sampled signal \(x_c(t)p(t)\), still a continuous-time signal
\(x[n]=x_c(nT)\)
the sequence of samples
\(T\), \(f_s=1/T\)
sampling period (s) and sampling rate (Hz)
\(\Omega_s=2\pi/T\)
sampling frequency in rad/s; \(\Omega_s/2\) is the folding frequency
\(\Omega_M\)
the highest frequency present in \(x_c(t)\); \(2\Omega_M\) is the Nyquist rate
\(x_r(t)\), \(H_r(j\Omega)\)
the reconstructed signal and the ideal reconstruction filter
\(h_0(t)\), \(h_1(t)\)
impulse responses of the zero-order and first-order holds
\(N\); \(x_p[n]\), \(x_b[n]\)
sampling period of a sequence; the sampled and the decimated sequences
\(U\), \(D\)
integer upsampling and downsampling factors; the overall sampling-rate conversion factor is \(U/D\)
\(R\), \(\Delta\)
quantizer word length in bits, and step size
\(e[n]\), \(\sigma_e^2\)
quantization error sequence and its variance
Frequency variables. \(f\) is measured in hertz, \(\Omega=2\pi f\) in rad/s, and \(\omega=\Omega T\) in rad/sample. Only the interval \(-\pi<\omega\le\pi\) contains distinct discrete-time frequencies.
Figures from the textbook. Figures marked “after Oppenheim & Willsky” are redrawn, in the notation of these notes, from A. V. Oppenheim and A. S. Willsky, Signals and Systems, 2nd ed., Prentice Hall, 1997, Chapter 7. Figures 3.7.e and 3.7.h are computed from a drawn test image.
3.1 Introduction
Under certain conditions, a continuous-time signal can be represented completely by its values at points equally spaced in time, and can be recovered from them. This property follows from the sampling theorem. A motion picture is a familiar illustration. It consists of a sequence of frames, each an instantaneous view of a continuously changing scene, and when the frames are shown at a sufficiently high rate we perceive continuous motion. A printed picture provides a spatial analogue, since it consists of a fine grid of dots, each a sample of the continuous scene.
The sampling theorem is also the link between continuous-time and discrete-time signals. Because a suitably band-limited signal can be recovered exactly from its samples, it can be represented by a sequence, processed by a discrete-time system and converted back to continuous time. Discrete-time systems are flexible, inexpensive and easily reproduced, and this is the main reason why so much continuous-time signal processing is now carried out digitally.
Two distinct operations are involved when a physical signal is converted into a sequence of numbers. They have very different properties, and it is important to keep them separate.
Discretization of time · sampling
Sampling is reversible under conditions that we shall state precisely. If the signal is band-limited and the sampling rate is high enough, the signal can be recovered exactly from its samples. Otherwise aliasing occurs and the original signal cannot be recovered.
Discretization of amplitude · quantization
Quantization replaces each sample value by the nearest of \(2^R\) levels, and the difference between the two values is lost. No condition on the signal removes this loss; it can only be made small and predictable (Section 3.9).
In the design of a converter the two operations are therefore treated differently. The sampling rate is chosen to satisfy the conditions of the sampling theorem, while the word length is chosen to meet a specified noise level.
Figure 3.1. The complete processing chain, and the sections of this lecture that treat each stage. A continuous-time lowpass filter appears at both ends. At the input it acts as an anti-aliasing filter, removing frequencies that would otherwise be aliased; at the output it acts as a reconstruction filter, removing the spectral images produced by the converter. Section 3.8 explains why neither filter can be omitted.
The lecture is organized as follows. Sections 3.2 to 3.5 introduce impulse-train sampling, derive the sampling theorem and examine the effect of undersampling, including the deliberate undersampling of bandpass signals. Section 3.6 establishes the relation \(\omega=\Omega T\) between continuous-time and discrete-time frequency. Sections 3.7 and 3.8 consider reconstruction by interpolation and the holds used in practice, and Section 3.9 treats quantization. Sections 3.10 and 3.11 extend the ideas of sampling to discrete-time signals, leading to decimation, interpolation and rational sample-rate conversion.
3.2 Representation of a signal by its samples: impulse-train sampling
Without further information, a set of equally spaced samples does not determine a signal uniquely. Figure 3.2.a shows three different continuous-time signals that have identical values at integer multiples of \(T\); that is, \(x_1(kT)=x_2(kT)=x_3(kT)\) for every integer \(k\). Clearly, infinitely many signals pass through the same set of samples.
Figure 3.2.a. Three continuous-time signals with identical values at integer multiples of \(T\). The samples alone do not distinguish between them. After Oppenheim & Willsky, Fig. 7.1.
The situation changes if the signal is band-limited, that is, if its Fourier transform is zero outside a finite band of frequencies, and if the samples are taken sufficiently close together in relation to the highest frequency present. The samples then specify the signal uniquely, and it can be reconstructed from them exactly. This is the content of the sampling theorem, which we now develop.
A convenient representation of sampling at regular intervals is obtained by multiplying the signal by a periodic impulse train,
$$ p(t)=\sum_{n=-\infty}^{\infty}\delta(t-nT). $$
(3.1)
This mechanism is known as impulse-train sampling and is shown in Figure 3.2.b. The impulse train \(p(t)\) is called the sampling function, its period \(T\) the sampling period, and its fundamental frequency \(\Omega_s=2\pi/T\) the sampling frequency. The sampled signal is the product
$$ x_p(t)=x_c(t)\,p(t). $$
(3.2)
By the sifting property of the unit impulse (Lecture 1), \(x_c(t)\delta(t-t_0)=x_c(t_0)\delta(t-t_0)\). Applying this to each impulse of \(p(t)\) gives
That is, \(x_p(t)\) is an impulse train whose impulse areas are the values of \(x_c(t)\) at intervals of \(T\).
Figure 3.2.b. Impulse-train sampling. The signal is multiplied by the sampling function \(p(t)\), and the product \(x_p(t)\) is an impulse train whose areas are the sample values \(x_c(T)\), \(x_c(2T)\), and so on. After Oppenheim & Willsky, Fig. 7.2.
Two points about this representation should be noted. First, \(x_p(t)\) is still a continuous-time signal: it is a function of \(t\) that is zero except at multiples of \(T\). The continuous-time Fourier transform can therefore be applied to it, and in Section 3.3 we use it to determine the effect of sampling in the frequency domain. Second, \(x_p(t)\) is not the same object as the sequence of samples. The discrete-time sequence
$$ x[n]=x_c(nT) $$
(3.4)
is indexed by the integer \(n\), and consecutive values are separated by one unit of \(n\) rather than by \(T\) seconds. The conversion from \(x_p(t)\) to \(x[n]\) may therefore be regarded as a normalization of the time axis, as Figure 3.2.c illustrates for two sampling periods. We shall see in Section 3.6 that this normalization is responsible for the scaling of the frequency axis between continuous and discrete time.
Figure 3.2.c. Sampling with a periodic impulse train followed by conversion to a discrete-time sequence. (a) The overall C/D system. (b) \(x_p(t)\) for \(T=T_1\) and \(T=2T_1\); the dashed envelope is \(x_c(t)\). (c) The resulting sequences. The impulse trains in (b) differ in their spacing on the time axis, whereas both sequences in (c) are drawn with unit spacing in \(n\). After Oppenheim & Willsky, Fig. 7.21.
Impulse-train sampling is a mathematical model. Narrow pulses of large amplitude, which approximate impulses, are difficult to generate and transmit, and practical samplers instead acquire the signal over a short aperture and hold the value on a capacitor. The model is nevertheless the appropriate starting point, because it predicts the frequency-domain consequences of sampling in their simplest form. The hold operation is considered in Section 3.7.
3.3 The effect of sampling in the frequency domain
Since \(x_p(t)\) is the product of \(x_c(t)\) and \(p(t)\), the multiplication property of the Fourier transform (Lecture 2, Eq. (2.31)) gives \(X_p(j\Omega)=\frac{1}{2\pi}X_c(j\Omega)*P(j\Omega)\). The Fourier transform of the periodic impulse train is itself an impulse train, with impulses at the multiples of the sampling frequency:
\(\Omega\) and \(\Omega_s\) are different kinds of quantity
\(\Omega\) · the frequency variable
The horizontal axis of every continuous-time spectrum, in rad/s. It takes every real value from \(-\infty\) to \(\infty\). \(X_c(j\Omega)\) and \(X_p(j\Omega)\) are functions of \(\Omega\), in the same way that \(x_c(t)\) is a function of \(t\).
\(\Omega_s\) · a fixed number
The sampling frequency \(\Omega_s=2\pi/T\), in rad/s. It is set by the sampler, does not vary, and marks one particular point on the \(\Omega\) axis, as do \(\Omega_M\) and \(\Omega_0\).
In the term \(X_c\big(j(\Omega-k\Omega_s)\big)\) of Eq. (3.6), \(\Omega\) runs along the axis while \(k\Omega_s\) is a constant shift: the \(k\)th replica is \(X_c(j\Omega)\) moved so that its centre sits at \(\Omega=k\Omega_s\). For example, sampling with \(T=1\) ms gives \(\Omega_s=2\pi\times1000\approx6283\) rad/s, so the replicas are centred at \(\Omega=0,\ \pm6283,\ \pm12566,\ldots\) rad/s, while \(\Omega\) itself can be any frequency at which the spectrum is evaluated.
Thus \(X_p(j\Omega)\) is a periodic function of \(\Omega\), consisting of a superposition of shifted replicas of \(X_c(j\Omega)\) scaled by \(1/T\). This is illustrated in Figure 3.3 for a signal band-limited to \(|\Omega|<\Omega_M\). In part (c), \(\Omega_M<\Omega_s-\Omega_M\), and the replicas do not overlap; the spectrum of \(x_c(t)\) is then reproduced exactly, apart from the factor \(1/T\), around each integer multiple of the sampling frequency. In part (d), \(\Omega_s<2\Omega_M\), and adjacent replicas overlap.
Figure 3.3. Effect in the frequency domain of sampling in the time domain. (a) Spectrum of the original signal. (b) Spectrum of the sampling function. (c) Spectrum of the sampled signal with \(\Omega_s>2\Omega_M\). (d) Spectrum of the sampled signal with \(\Omega_s<2\Omega_M\). After Oppenheim & Willsky, Fig. 7.3.
Frequency-domain effect of sampling
Sampling a continuous-time signal with period \(T\) replicates its spectrum at intervals of \(\Omega_s=2\pi/T\) and scales it by \(1/T\). The original spectrum is retained, centred at \(\Omega=0\), and every other term of Eq. (3.6) is a shifted copy of it.
This periodic replication is the reason that the spectrum of a sampled signal, and hence the DTFT of a sequence, is periodic. Section 3.6 shows that the period \(\Omega_s\) becomes \(2\pi\) when the frequency axis is normalized.
Whether \(x_c(t)\) can be recovered from \(x_p(t)\) depends, therefore, on whether the replicas in Eq. (3.6) overlap. This question leads directly to the sampling theorem.
3.4 The sampling theorem and the effect of undersampling
Let \(x_c(t)\) be band-limited, so that \(X_c(j\Omega)=0\) for \(|\Omega|>\Omega_M\). The replica of Eq. (3.6) centred at the origin extends to \(\Omega_M\), and the replica centred at \(\Omega_s\) begins at \(\Omega_s-\Omega_M\). The two do not overlap provided \(\Omega_s-\Omega_M>\Omega_M\), that is,
When this condition holds, \(x_c(t)\) can be recovered from \(x_p(t)\) by a lowpass filter that retains the replica at \(\Omega=0\) and rejects all the others. The filter must have gain \(T\), to cancel the factor \(1/T\) in Eq. (3.6), and a cutoff frequency between \(\Omega_M\) and \(\Omega_s-\Omega_M\):
The complete system for sampling and reconstruction is shown in Figure 3.4.a, together with the spectra at each point. The result may be stated as follows.
Figure 3.4.a. Exact recovery of a continuous-time signal from its samples using an ideal lowpass filter. (a) System for sampling and reconstruction. (b) Spectrum of \(x_c(t)\). (c) Spectrum of \(x_p(t)\). (d) The ideal lowpass filter \(H_r(j\Omega)\) of Eq. (3.8). (e) Spectrum of the reconstructed signal \(x_r(t)\). After Oppenheim & Willsky, Fig. 7.4.
The sampling theorem
Let \(x_c(t)\) be a band-limited signal with \(X_c(j\Omega)=0\) for \(|\Omega|>\Omega_M\). Then \(x_c(t)\) is uniquely determined by its samples \(x_c(nT)\), \(n=0,\pm1,\pm2,\ldots\), if \(\Omega_s>2\Omega_M\), where \(\Omega_s=2\pi/T\).
To reconstruct \(x_c(t)\), form the impulse train of Eq. (3.3), in which the impulse areas are the sample values, and apply the lowpass filter of Eq. (3.8). The output is equal to \(x_c(t)\) for all \(t\).
The frequency \(2\Omega_M\), which the sampling frequency must exceed, is called the Nyquist rate, and the frequency \(\Omega_M\), one-half of the Nyquist rate, is often called the Nyquist frequency. Many texts and software packages use the term Nyquist frequency for \(f_s/2\) instead; to avoid ambiguity these notes refer to \(\Omega_s/2\) as the folding frequency.
Historical note
The result was available in the mathematical literature, in a variety of forms, long before it was used in communication engineering; J. M. Whittaker's work on interpolatory function theory is an early example. H. Nyquist (1928) and D. Gabor (1946) observed, on the basis of Fourier series, that \(2\tau W\) numbers are sufficient to describe a signal of duration \(\tau\) and bandwidth \(W\). The theorem appeared explicitly in the literature of communication theory with C. E. Shannon's paper “Communication in the presence of noise” (Proceedings of the IRE, 1949).
Three remarks complete the statement. First, the theorem asserts more than an approximate representation: under its conditions the samples determine every value of \(x_c(t)\), including the values between the sampling instants. Second, the inequality is strict; Example 3.1 shows that sampling a sinusoid at exactly twice its frequency is not sufficient. Third, the band between \(\Omega_M\) and \(\Omega_s-\Omega_M\) contains no signal energy and may be used as the transition band of the reconstruction filter. This guard band has zero width when the signal is sampled at the Nyquist rate, and it widens as the sampling rate is increased.
Ideal filters cannot be realized, and in any practical application the filter of Eq. (3.8) is replaced by a nonideal filter that approximates the desired characteristic closely enough for the problem at hand. Any departure from the ideal characteristic produces some discrepancy between \(x_r(t)\) and \(x_c(t)\), and the acceptable level of this distortion then determines the choice of filter. To emphasize the basic principles, we continue to assume ideal filters in the development that follows.
3.4.1 Aliasing
If \(\Omega_s<2\Omega_M\), the replicas in Eq. (3.6) overlap. Where they overlap their values add, \(X_c(j\Omega)\) is no longer reproduced within \(|\Omega|<\Omega_s/2\), and \(x_c(t)\) can no longer be recovered by lowpass filtering. This effect is called aliasing. The reconstructed signal then differs from \(x_c(t)\), but the two remain equal at the sampling instants. With the cutoff frequency \(\Omega_c=\Omega_s/2\), each term of the reconstruction is zero at every sampling instant except its own (Section 3.7.1), so that for any choice of sampling frequency
$$ x_r(nT)=x_c(nT),\qquad n=0,\pm1,\pm2,\ldots $$
(3.9)
Some insight into the relation between \(x_c(t)\) and \(x_r(t)\) when aliasing occurs is obtained from the simple case of a sinusoid,
$$ x_c(t)=\cos\Omega_0 t, $$
(3.10)
whose spectrum consists of a pair of impulses at \(\pm\Omega_0\). Figure 3.4.b shows \(X_p(j\Omega)\) for four values of \(\Omega_0\) with \(\Omega_s\) fixed, together with the passband of the reconstruction filter for \(\Omega_c=\Omega_s/2\). To make the movement of the replicas visible, the impulse originating at \(+\Omega_0\) is drawn with a solid line and that originating at \(-\Omega_0\) with a dashed line. For the four cases the reconstructed output is as follows.
\(\Omega_0\)
Condition
Reconstructed signal
\(\Omega_s/6\)
\(\Omega_0<\Omega_s/2\)
\(x_r(t)=\cos\Omega_0t=x_c(t)\)
\(2\Omega_s/6\)
\(\Omega_0<\Omega_s/2\)
\(x_r(t)=\cos\Omega_0t=x_c(t)\)
\(4\Omega_s/6\)
\(\Omega_0>\Omega_s/2\)
\(x_r(t)=\cos(\Omega_s-\Omega_0)t\ne x_c(t)\)
\(5\Omega_s/6\)
\(\Omega_0>\Omega_s/2\)
\(x_r(t)=\cos(\Omega_s-\Omega_0)t\ne x_c(t)\)
Figure 3.4.b. Effect in the frequency domain of oversampling and undersampling a sinusoid. (a) Spectrum of \(x_c(t)=\cos\Omega_0t\). (b), (c) Spectrum of the sampled signal with \(\Omega_s>2\Omega_0\). (d), (e) Spectrum with \(\Omega_s<2\Omega_0\). The dashed rectangle is the passband of the reconstruction filter. As \(\Omega_0\) increases from (b) to (e), the solid impulses move to the right and the dashed impulses to the left, and in (d) and (e) the impulses within the passband are no longer those of the original signal. After Oppenheim & Willsky, Fig. 7.15.
When aliasing occurs, the original frequency \(\Omega_0\) takes on the identity of the lower frequency \(\Omega_s-\Omega_0\), so that
As \(\Omega_0\) increases from \(\Omega_s/2\) towards \(\Omega_s\), the output frequency \(\Omega_s-\Omega_0\) decreases, and when \(\Omega_0=\Omega_s\) the reconstructed signal is a constant. This is to be expected, since sampling once per cycle gives equal samples, identical to those obtained from a constant signal. Frequencies above \(\Omega_s/2\) are thus reflected, or folded, about \(\Omega_s/2\), which accounts for the term folding frequency. Figure 3.4.c shows the four cases in the time domain. In each case the lowpass filter fits to the samples a sinusoid whose frequency is less than \(\Omega_s/2\).
Figure 3.4.c. Effect of aliasing on a sinusoidal signal. For each value of \(\Omega_0\), the original signal (solid curve), its samples, and the reconstructed signal (dashed curve) are shown: (a) \(\Omega_0=\Omega_s/6\); (b) \(\Omega_0=2\Omega_s/6\); (c) \(\Omega_0=4\Omega_s/6\); (d) \(\Omega_0=5\Omega_s/6\). There is no aliasing in (a) and (b). In (c) and (d) the reconstruction is a sinusoid of lower frequency that passes through the same samples. After Oppenheim & Willsky, Fig. 7.16.
3.4.2 Phase reversal, and sampling at exactly the Nyquist rate
Consider next the sinusoid \(x_c(t)=\cos(\Omega_0t+\phi)\). Its spectrum has the same form as before, except that the impulse at \(+\Omega_0\) now has area \(\pi e^{j\phi}\) and the impulse at \(-\Omega_0\) has area \(\pi e^{-j\phi}\). For the cases (b) and (c) of Figure 3.4.b the reconstruction is again \(x_c(t)\). In cases (d) and (e), however, the impulses that fall within the passband originate from the opposite sides of the original spectrum, so that their phases are interchanged. The result is
in which the sign of the phase has been reversed. This phase reversal is responsible for the apparent reversal of rotation in the stroboscopic effect described in Section 3.4.3.
The sampling theorem requires the sampling frequency to be greater than twice the highest frequency in the signal, not merely greater than or equal to it. The following example shows why.
EXAMPLE 3.1 · Sampling a sinusoid at exactly twice its frequency
The signal \(x_c(t)=\cos(\Omega_st/2+\phi)\) is sampled by an impulse train with sampling frequency \(\Omega_s\), that is, at exactly twice the frequency of the sinusoid, and the result is applied to an ideal lowpass filter with cutoff frequency \(\Omega_s/2\). Determine the output \(x_r(t)\), and consider the case \(\phi=-\pi/2\).
1
The samples
With \(T=2\pi/\Omega_s\), the argument at \(t=nT\) is \((\Omega_s/2)nT+\phi=\pi n+\phi\). Since \(\sin\pi n=0\),
Substituting these samples in the interpolation formula, Eq. (3.22), and using \(\sin[\pi(t-nT)/T]=(-1)^n\sin(\pi t/T)\), every term has the same numerator. With \(u=t/T\) and the expansion \(\pi\cot\pi u=\sum_n 1/(u-n)\), the sum becomes
The output is a sinusoid of the correct frequency, but its amplitude is \(\cos\phi\) and its phase is zero. Hence \(x_r(t)=x_c(t)\) only when \(\phi\) is an integer multiple of \(\pi\).
4
The case \(\phi=-\pi/2\)
Then \(x_c(t)=\sin(\Omega_st/2)\), whose values at the sampling instants are \(\sin\pi n=0\). The samples are identically zero, and so is the output of the filter. The signal is shown in Figure 3.4.d.
A sinusoid at exactly \(\Omega_s/2\) cannot be recovered from its samples, because its amplitude and phase are not determined by them. This is why the sampling frequency must strictly exceed the Nyquist rate.
Figure 3.4.d. The sinusoid \(x_c(t)=\sin(\Omega_st/2)\) of Example 3.1. Its values at the integer multiples of the sampling period \(T=2\pi/\Omega_s\) are all zero, so that sampling at this rate produces a sequence that is identically zero. After Oppenheim & Willsky, Fig. 7.17.
Aliasing cannot be removed after sampling
Where replicas overlap, Eq. (3.6) adds their values, and the separate contributions cannot subsequently be identified. An aliased component is indistinguishable from a genuine component at the same frequency. Protection against aliasing must therefore be provided before sampling, by a continuous-time anti-aliasing filter that removes the components which would otherwise be folded into the band of interest. This is the purpose of the first block in Figure 3.1.
EXAMPLE 3.2 · Two different signals with identical samples
The signals \(x_c(t)=\cos(4000\pi t)\) and \(\tilde x_c(t)=\cos(16000\pi t)\) are both sampled with \(T=1/6000\) s. Compare the two sequences, and determine the output of an ideal reconstruction system in each case.
1
Folding frequency
The sampling frequency is \(\Omega_s=2\pi/T=12000\pi\), so the folding frequency is \(\Omega_s/2=6000\pi\).
2
First signal
Here \(\Omega_0=4000\pi<6000\pi\), and the sampling theorem is satisfied. With \(\omega_0=\Omega_0T=2\pi/3\) (Eq. (3.17)),
$$x[n]=\cos(2\pi n/3).$$
3
Second signal
Here \(\tilde\Omega_0=16000\pi\) exceeds the folding frequency. Its samples are
Both sequences are reconstructed as \(\cos(4000\pi t)\). For the second signal this is an aliased output: the replica at \(\tilde\Omega_0-\Omega_s=4000\pi\) lies within the passband, and the 8 kHz tone is reconstructed as a 2 kHz tone.
Since the two sequences are identical, no processing of the samples can determine which signal produced them. The information that distinguishes the two signals is lost at the sampler.
MATLAB corner
The following script illustrates aliasing numerically. It sweeps the frequency of a sampled tone through and beyond the folding frequency and measures the frequency at which the tone appears in the sampled data. It then plays the same effect as an audible chirp, and finally reconstructs a band-limited signal with the interpolation formula of Eq. (3.22) to verify that the result passes through every sample.
Goal: plot the measured frequency against the true frequency through and beyond \(f_s/2\), and verify that ideal band-limited interpolation reproduces the samples exactly.
aliasing_demo.m
MATLAB
%% aliasing_demo.m - Part 1: watch a tone fold back about fs/2 (Eq. 3.7)
fs = 1000; % sampling rate, so folding is at 500 Hz
f0 = 100:50:1900; % sweep the true tone well past fs/2
n = 0:2047;
fa = zeros(size(f0));
for k = 1:numel(f0)
x = cos(2*pi*f0(k)/fs*n); % the SAMPLES - all we ever get
X = abs(fft(x .* hann(numel(n))'));
[~,i] = max(X(1:end/2));
fa(k) = (i-1)*fs/numel(n); % frequency actually measured
end
figure('Color','w'); plot(f0, fa, 'LineWidth', 1.6); grid on; hold on;
Figure 3.4.e. Results of aliasing_demo.m. Left: the measured frequency follows the true frequency up to \(f_s/2\) and then decreases, so that every tone is reported at a frequency in \([0,f_s/2]\); the pattern repeats with period \(f_s\). Right: the band-limited reconstruction of Eq. (3.22) passes through every sample, since each sinc term is zero at all sampling instants other than its own.
3.4.3 The stroboscopic effect
The reflection of higher frequencies into lower ones by undersampling is the principle on which the stroboscopic effect is based. Consider the arrangement in Figure 3.4.f, in which a disc with a single radial line rotates at a constant rate and is illuminated by a strobe. The strobe acts as a sampling system, since it illuminates the disc for very brief intervals at a periodic rate. When the strobe frequency is much higher than the rotational frequency, the rotation is perceived correctly. When the strobe frequency becomes less than twice the rotational frequency, the disc appears to rotate more slowly than it does, and, because of the phase reversal of Eq. (3.12), it may appear to rotate in the opposite direction. At one flash per revolution the line appears stationary, since the rotational frequency has been aliased to zero.
Figure 3.4.f. The strobe effect. The flashing strobe samples the position of the radial line on the rotating disc. After Oppenheim & Willsky, Fig. 7.18.
In general, the apparent rate of a periodic motion observed by a sampler is obtained by folding the true rate \(f_r\) into the interval \(|f|\le f_s/2\):
A negative value of \(f_a\) corresponds to apparent rotation in the reverse direction. Figure 3.4.g shows three successive strobe positions for three rotational rates. A similar effect is commonly observed in films, in which the wheels of a moving vehicle may appear to rotate slowly or backwards. A film is a sequence of frames taken at a rate of typically 24 frames per second, and this rate is the sampling frequency.
Figure 3.4.g. Three successive strobe positions of the radial line for three rotational rates. At \(f_r=0.25f_s\) the motion is perceived correctly; at \(f_r=f_s\) the line appears stationary; at \(f_r=0.92f_s\) it appears to rotate slowly backwards, with \(f_a=-0.08f_s\) from Eq. (3.13).
EXAMPLE 3.3 · The wagon-wheel effect
A film camera operating at 24 frames per second records a wheel with 12 identical spokes rotating at 2 revolutions per second. Describe the motion seen in the film, and repeat for 2.1 and 1.9 revolutions per second.
1
The sampled quantity
The camera is a sampler with \(f_s=24\) Hz. Since the spokes are indistinguishable, the motion observed is the passage of spokes, which occurs at the rate
$$f_r=12\times2=24\ \text{Hz}.$$
2
Apparent rate at 2 rev/s
From Eq. (3.13), \(f_a=24-24=0\). The wheel appears stationary while the vehicle moves.
3
Slightly faster or slower
At 2.1 rev/s, \(f_r=25.2\) Hz and \(f_a=1.2\) Hz, so the wheel appears to rotate slowly forwards. At 1.9 rev/s, \(f_r=22.8\) Hz and \(f_a=22.8-24=-1.2\) Hz, so the wheel appears to rotate slowly backwards.
The camera samples the scene without any anti-aliasing filter, and the motion seen in the film is the aliased rotation.
Equation (3.13) also explains a limitation of the stroboscope as an instrument for measuring rotational speed. The image is stationary whenever \(f_a=0\), which occurs not only for \(f_r=f_s\) but for every \(f_r=kf_s\) with \(k\) an integer. A stationary image therefore determines the speed only to within an integer multiple of the flash rate. The ambiguity is resolved by noting that the highest flash rate giving a single stationary image is equal to the rotational rate.
Aliasing is also used deliberately in the sampling oscilloscope, an instrument intended for observing very high-frequency periodic waveforms. The waveform is sampled at a rate well below its frequency, and the aliased waveform, at a much lower frequency, can be displayed with ordinary circuitry. The deliberate undersampling of bandpass signals, considered next, rests on the same principle.
3.5 Sampling of bandpass signals
The sampling theorem as stated in Section 3.4 applies to signals whose spectra extend from zero frequency to \(\Omega_M\). The essential requirement in its derivation, however, is that the replicas in Eq. (3.6) should not overlap. For a signal whose spectrum occupies a band well away from zero frequency, this requirement can be met with a sampling rate much lower than twice the highest frequency. Sampling in this way is called bandpass sampling, or undersampling, and is widely used in radio receivers.
Let the signal occupy \(f_L\le|f|\le f_H\), with bandwidth \(B=f_H-f_L\). Sampling again places replicas at every multiple of \(f_s\), but the positive-frequency band and its mirror image at negative frequencies leave gaps into which the replicas can fall without overlap. This occurs when \(f_s\) lies in one of the intervals
The integer \(n\) identifies the Nyquist zone, of width \(f_s/2\), from which the band is folded into the baseband interval \([0,f_s/2]\). At the end points of each interval the replicas touch, and a practical design keeps away from them. Taking the largest admissible value of \(n\) gives the lowest usable rate,
which equals \(2B\) only when \(f_H\) is an integer multiple of \(B\). For \(n=1\), Eq. (3.14) reduces to the lowpass condition \(f_s\ge2f_H\), so that the bandpass result contains the lowpass result as a special case.
Figure 3.5. A bandpass signal sampled at a rate far below \(2f_H\). The replicas fall into the gaps between the band and its mirror image, and one of them lies in the baseband interval without overlap. A sampling rate outside the intervals of Eq. (3.14) would cause the replicas to overlap.
Requirements that are not relaxed
Bandpass sampling lowers the sampling rate, but three other requirements remain. The anti-aliasing filter must be a bandpass filter that removes everything outside \(f_L\le|f|\le f_H\), since noise in every other Nyquist zone is folded onto the signal. The analog input bandwidth and the sample-and-hold aperture of the converter must still accommodate \(f_H\); a converter clocked at 8 MHz does not necessarily respond to a 72 MHz input. Finally, the effect of clock jitter is determined by the signal frequency \(f_H\) rather than by \(f_s\), so the jitter specification becomes tighter in proportion to the reduction in rate.
EXAMPLE 3.4 · Sampling a 70 MHz intermediate-frequency signal
A receiver presents an intermediate-frequency signal occupying 68–72 MHz to an analog-to-digital converter. Sampling it as a lowpass signal would require \(f_s>144\) MHz. Determine the admissible sampling rates, and the lowest of them.
1
Band edges and bandwidth
\(f_L=68\) MHz and \(f_H=72\) MHz, so that \(B=4\) MHz and \(\lfloor f_H/B\rfloor=18\). There are 18 Nyquist zones to consider.
2
Admissible intervals
Equation (3.14) gives, for selected values of \(n\):
n
lower limit 2f_H/n
upper limit 2f_L/(n−1)
window
10
14.40 MHz
15.11 MHz
0.71 MHz wide
16
9.00 MHz
9.07 MHz
0.07 MHz wide
18
8.00 MHz
8.00 MHz
a single point
3
Lowest rate
The lowest rate is \(f_{s,\min}=2(72)/18=8\) MHz, which equals \(2B\) because \(f_H\) is an exact multiple of \(B\). The interval for \(n=18\) has zero width, however, and allows no tolerance on the clock frequency.
4
A practical choice
The value \(n=10\) with \(f_s=14.7\) MHz leaves about 0.3 MHz of tolerance below and 0.4 MHz above, while still reducing the rate by a factor of almost ten. The converter must nevertheless accept a 72 MHz input, and its clock jitter must be specified with respect to 72 MHz.
Bandpass sampling performs the translation of the band to low frequencies as part of the sampling operation.
3.6 Relation between continuous-time and discrete-time frequency
We now relate the spectrum of the sequence \(x[n]\) to that of the continuous-time signal from which it was obtained. Section 3.3 gave \(X_p(j\Omega)\) as a sum of replicas of \(X_c(j\Omega)\). Transforming the sampled signal \(x_p(t)=\sum_n x_c(nT)\,\delta(t-nT)\) of Eq. (3.3) term by term, using the fact that the transform of \(\delta(t-nT)\) is \(e^{-j\Omega nT}\), gives a second expression for the same spectrum, in terms of the sample values:
Eqs. (3.6) and (3.16) therefore describe the same \(X_p(j\Omega)\): the first in terms of the spectrum \(X_c(j\Omega)\), the second in terms of the samples \(x_c(nT)\). The DTFT of \(x[n]\) is \(X(e^{j\omega})=\sum_n x[n]e^{-j\omega n}\) (Lecture 2, Eq. (2.41)). With \(x[n]=x_c(nT)\), the two sums are identical term by term when \(\omega\) is identified with \(\Omega T\). Consequently,
Substituting \(\Omega=\omega/T\) into the replica form of Eq. (3.6), \(X_p(j\Omega)=\frac{1}{T}\sum_k X_c\big(j(\Omega-k\Omega_s)\big)\) with \(\Omega_s=2\pi/T\), expresses the DTFT of the sequence directly in terms of the spectrum of \(x_c(t)\):
The relations among \(X_c(j\Omega)\), \(X_p(j\Omega)\) and \(X(e^{j\omega})\) are illustrated in Figure 3.6 for two sampling rates. The spectrum of the sequence is obtained from that of \(x_c(t)\) by periodic replication at multiples of \(\Omega_s\), Eq. (3.6), followed by the linear scaling \(\omega=\Omega T\) of the frequency axis, Eq. (3.17). The replication is a consequence of impulse-train sampling. The frequency scaling may be regarded as a consequence of the normalization of time in the conversion from \(x_p(t)\) to \(x[n]\) shown in Figure 3.2.c: by the time-scaling property of the Fourier transform, a scaling of the time axis by \(1/T\) produces a scaling of the frequency axis by \(T\).
Figure 3.6. Relation between \(X_c(j\Omega)\), \(X_p(j\Omega)\) and \(X(e^{j\omega})\) for two sampling rates, \(T=T_1\) and \(T=T_2=2T_1\). In both cases the DTFT is periodic with period \(2\pi\). After Oppenheim & Willsky, Fig. 7.22.
Discrete-time frequency
\(\omega=\Omega T\)
The frequency variable of the sequence \(x[n]\), in rad/sample: \(\Omega\) in rad/s multiplied by \(T\) in s/sample.
Sampling frequency
\(\Omega_s=2\pi/T=2\pi f_s\)
A fixed point on the \(\Omega\) axis in rad/s, set by the sampling period \(T\) or the sampling rate \(f_s=1/T\) in Hz.
Under the correspondence \(\omega=\Omega T\), the following frequencies correspond:
Since the sampling frequency corresponds to \(\omega=2\pi\), the replicas \(X_c\big(j(\Omega-k\Omega_s)\big)\) of Eq. (3.6) repeat with period \(2\pi\) on the discrete-time frequency axis, and the folding frequency corresponds to \(\omega=\pi\). The periodicity of the DTFT and the folding of continuous-time frequencies about \(\Omega_s/2\) are therefore two descriptions of the same effect.
Conversion between frequency variables
A 1 kHz tone sampled at \(f_s=8\) kHz:
Hz
\(f=1000\)
rad/s
\(\Omega=2\pi f=6283\)
rad/sample
\(\omega=\Omega T=2\pi(1000)/8000=\pi/4\)
check
\(\pi/4<\pi\), so the tone lies below the folding frequency
The ratio \(\omega/\pi\) gives the frequency as a fraction of the folding frequency, here 0.25. The filter-design functions in MATLAB specify frequencies in this normalized form.
3.7 Reconstruction of a signal from its samples using interpolation
Interpolation, the fitting of a continuous signal to a set of sample values, is the general procedure by which a signal is reconstructed from its samples, either exactly or approximately. In the system of Figure 3.4.a, the reconstructed signal is the output of a filter with impulse response \(h(t)\) whose input is \(x_p(t)\). With \(x_p(t)\) given by Eq. (3.3),
Equation (3.19) describes how a continuous curve is fitted between the sample points, and different choices of \(h(t)\) give different interpolation procedures. We consider three of them: band-limited interpolation, which is exact for band-limited signals sampled above the Nyquist rate, and the zero-order and first-order holds, which are simpler approximations.
3.7.1 Band-limited interpolation
For the ideal lowpass filter of Eq. (3.8), \(H_r(j\Omega)=T\) for \(|\Omega|<\Omega_c\) and \(0\) otherwise, with \(\Omega_M<\Omega_c<\Omega_s-\Omega_M\), the impulse response is
With the usual choice \(\Omega_c=\Omega_s/2=\pi/T\), the factor \(\Omega_cT/\pi\) is equal to one, and Eq. (3.21) takes the form known as the Whittaker–Shannon interpolation formula:
In this case \(h_r(0)=1\) and \(h_r(nT)=0\) for \(n\ne0\). At a sampling instant \(t=mT\), therefore, every term of the sum vanishes except the term \(n=m\), and \(x_r(mT)=x[m]\), which is the property stated in Eq. (3.9). Between the sampling instants all of the terms contribute. The reconstruction is illustrated in Figure 3.7.a. Interpolation with the impulse response of an ideal lowpass filter is called band-limited interpolation, since it reconstructs \(x_c(t)\) exactly whenever \(x_c(t)\) is band-limited and the sampling frequency satisfies the conditions of the sampling theorem.
Figure 3.7.a. Ideal band-limited interpolation using the sinc function. (a) Band-limited signal \(x_c(t)\). (b) Impulse train of samples \(x_p(t)\). (c) Reconstruction in which each impulse is replaced by a sinc function, Eq. (3.22); the sum of the sinc functions is \(x_r(t)\). After Oppenheim & Willsky, Fig. 7.10.
Practical limitations of band-limited interpolation
The sinc function extends over all time. Evaluating Eq. (3.22) at a single instant therefore requires every past and future sample, and the corresponding filter is noncausal with an impulse response of infinite duration. This is the time-domain counterpart of the ideal frequency-selective characteristic of Eq. (3.8). Practical systems approximate band-limited interpolation by finite, causal interpolating functions, of which the holds described below are the simplest.
3.7.2 The zero-order hold
Narrow pulses that approximate impulses are difficult to generate, and it is often more convenient to produce the sampled signal in the form given by a zero-order hold. Such a system samples \(x_c(t)\) at a given instant and holds that value until the next sampling instant, as shown in Figure 3.7.b. The output is a staircase approximation to \(x_c(t)\), and digital-to-analog converters commonly produce an output of this form.
Figure 3.7.b. Sampling with a zero-order hold. The output \(x_0(t)\) holds each sample value for one sampling period. After Oppenheim & Willsky, Fig. 7.5.
The output \(x_0(t)\) of the zero-order hold can in principle be generated by impulse-train sampling followed by an LTI system with a rectangular impulse response, as depicted in Figure 3.7.c. In the notation of Eq. (3.19),
Figure 3.7.c. The zero-order hold represented as impulse-train sampling followed by an LTI system whose impulse response \(h_0(t)\) is a rectangular pulse of duration \(T\). After Oppenheim & Willsky, Fig. 7.6.
The frequency response of the zero-order hold follows from the transform of a rectangular pulse together with the time-shifting property:
Its magnitude falls from \(T\) at \(\Omega=0\) to \(2T/\pi\) at \(\Omega=\Omega_s/2\), a reduction by the factor \(2/\pi\), or 3.92 dB, and it has zeros at the nonzero multiples of \(\Omega_s\). The linear-phase factor corresponds to a delay of half a sampling period, which does not distort the waveform. Figure 3.7.d compares \(|H_0(j\Omega)|\) with the magnitude of the ideal interpolating filter. The zero-order hold is evidently a coarse approximation: it attenuates the upper part of the signal band, and it passes a considerable part of each spectral image.
Figure 3.7.d. Magnitude of the transfer function of the zero-order hold, superimposed on that of the ideal interpolating filter. After Oppenheim & Willsky, Fig. 7.11.
In some applications the output of the zero-order hold is adequate without further filtering, particularly when lowpass filtering is applied naturally at a later stage. Figure 3.7.e illustrates this for an image, sampled and reconstructed in two dimensions. Part (a) is the original image, and part (b) shows its samples taken with spatially narrow pulses at a spacing of 12 pixels in each direction. Part (c) is the result of applying a two-dimensional zero-order hold to (b), which produces a mosaic. The human visual system introduces lowpass filtering with a cutoff frequency that decreases with viewing distance, so that when the image is viewed from a distance the discontinuities of the mosaic are smoothed. Part (d) is obtained with one-fourth of the sample spacing in each direction; with normal viewing the mosaic is then much less evident, although the edges of the lettering and the fence remain visibly stepped.
Figure 3.7.e. The zero-order hold applied to an image. (a) Original image. (b) Impulse sampling with a spacing of 12 pixels. (c) Two-dimensional zero-order hold applied to (b). (d) Zero-order hold after sampling with one-fourth of the spacing used in (b) and (c). Computed for these notes from a drawn test image, after Oppenheim & Willsky, Figs. 7.12 and 7.14.
3.7.3 The first-order hold
The zero-order hold produces a discontinuous output. A smoother reconstruction is obtained by linear interpolation, in which adjacent sample points are joined by straight lines, as in Figure 3.7.f. The result is continuous, although its derivative is discontinuous at the sample points because of the changes in slope.
Figure 3.7.f. Linear interpolation between sample points. The dashed curve represents the original signal and the solid curve the linear interpolation. After Oppenheim & Willsky, Fig. 7.9.
Linear interpolation, also called the first-order hold, again has the form of Eq. (3.19), with the triangular impulse response
illustrated in Figure 3.7.g. Since \(h_1(t)\) is a rectangular pulse of duration \(T\) convolved with itself and scaled by \(1/T\) (Problem 3.5), its frequency response is the square of a sinc function:
At \(\Omega=\Omega_s/2\) its magnitude is \(4T/\pi^2\), a reduction of 7.84 dB relative to its value \(T\) at zero frequency, and it has double zeros at the nonzero multiples of \(\Omega_s\). Compared with the zero-order hold, the first-order hold attenuates the images more strongly, but it also attenuates the upper part of the signal band more. As defined here \(h_1(t)\) is noncausal; a causal implementation delays it by \(T\), which introduces the linear-phase factor \(e^{-j\Omega T}\) without changing the magnitude.
Figure 3.7.g. Linear interpolation (first-order hold) as impulse-train sampling followed by convolution with a triangular impulse response. (a) System for sampling and reconstruction. (b) Impulse train of samples. (c) Impulse response of the first-order hold. (d) First-order hold applied to the sampled signal. (e) Transfer function of the first-order hold compared with that of the ideal interpolating filter and with the magnitude of the zero-order hold, \(|H_0(j\Omega)|\) (dashed). After Oppenheim & Willsky, Fig. 7.13.
Figure 3.7.h compares the zero-order and first-order holds applied to the same samples of the test image. The first-order hold, which in two dimensions interpolates linearly between the four nearest samples, removes the blocks of the mosaic, although fine detail such as the lettering and the fence, which the sampling has aliased, is not restored by either hold. In an analogous manner, second- and higher-order holds can be defined that produce reconstructions of greater smoothness. The output of a second-order hold, for example, is continuous and has a continuous first derivative, although its second derivative is discontinuous.
Figure 3.7.h. Reconstruction of the test image from samples at a spacing of 8 pixels. (a) Zero-order hold. (b) First-order hold, implemented as bilinear interpolation between neighbouring samples. Computed for these notes from a drawn test image, after Oppenheim & Willsky, Figs. 7.12 and 7.14.
The properties of the three interpolating functions are compared below.
Band-limited interpolation
\(h(t)\): sinc function, infinite duration, noncausal. Exact reconstruction of band-limited signals. Gain at \(\Omega_s/2\): edge of the passband. Images: removed completely.
Zero-order hold
\(h(t)\): rectangle of duration \(T\). Output: staircase, discontinuous. Gain at \(\Omega_s/2\): \(2/\pi\), or \(-3.92\) dB. Images: attenuated only near the multiples of \(\Omega_s\). Delay \(T/2\).
First-order hold
\(h(t)\): triangle of duration \(2T\). Output: continuous, with discontinuous slope. Gain at \(\Omega_s/2\): \(4/\pi^2\), or \(-7.84\) dB. Images: attenuated by a squared sinc. Delay \(T\) when made causal.
3.8 Practical sampling and reconstruction
3.8.1 The anti-aliasing filter
Physical signals are never exactly band-limited. Noise and interference extend above the band of interest, and any component above the folding frequency is aliased into the band when the signal is sampled. A continuous-time lowpass filter, the anti-aliasing filter, is therefore placed before the sampler to attenuate these components. It cannot be replaced by a discrete-time filter after the converter, because at that point the aliased components already occupy the same frequencies as the wanted signal (Section 3.4.1).
3.8.2 Oversampling
A realizable anti-aliasing filter has a transition band of nonzero width between the frequencies that it passes and those that it rejects. If the signal is sampled at the Nyquist rate, the guard band between the signal band and the first replica has zero width, and the filter would have to be ideal. In oversampling, the sampling rate is chosen well above \(2f_M\), so that the replicas are further apart and the analog filter can have a gradual transition, as shown in Figure 3.8.a. A sharp discrete-time filter, followed by decimation (Section 3.11), then completes the band-limiting. For this reason audio converters sample above 40 kHz for a 20 kHz band, and sigma–delta converters operate internally at much higher rates.
Figure 3.8.a. Guard band and anti-aliasing filter, positive frequencies only. The signal band is shown in colour, the replicas at multiples of \(\Omega_s\) in grey and the anti-aliasing filter in green. (a) At the Nyquist rate the first replica begins at \(\Omega_M\), so the guard band has zero width and the filter would have to change from passband to stopband instantaneously. (b) At \(\Omega_s=4\Omega_M\) the first replica begins at \(\Omega_s-\Omega_M=3\Omega_M\). The filter may roll off gradually over the guard band, of width \(\Omega_s-2\Omega_M\). Components that survive in the transition band alias to frequencies between \(\Omega_M\) and \(\Omega_s-\Omega_M\), outside the signal band, where the discrete-time filter removes them.
Oversampling and quantization noise
Oversampling also improves the signal-to-noise ratio. Under the model of Section 3.9, the quantization noise power \(\sigma_e^2\) depends only on the step size \(\Delta\) and is spread uniformly over the frequency range up to \(f_s/2\). When \(f_s\) is doubled, the same noise power is spread over twice the bandwidth, and only half of it falls within the signal band. The improvement is 3 dB, or half a bit, for each doubling of the sampling rate. Noise shaping in sigma–delta converters improves this considerably further.
3.8.3 Reconstruction from the output of a zero-order hold
When a digital-to-analog converter produces the output of a zero-order hold, the reconstruction filter must compensate for the frequency response of the hold. Figure 3.8.b shows the representation of the zero-order hold from Figure 3.7.c followed by a reconstruction filter \(H_{\mathrm{eq}}(j\Omega)\). The overall output \(r(t)\) is equal to \(x_c(t)\) if the cascade of \(h_0(t)\) and the reconstruction filter is the ideal lowpass filter of Eq. (3.8), that is, if \(H_0(j\Omega)H_{\mathrm{eq}}(j\Omega)=H_r(j\Omega)\). From Eq. (3.24), this requires
Figure 3.8.b. Cascade of the representation of a zero-order hold (Figure 3.7.c) with a reconstruction filter. The equalizer is the filter \(H_{\mathrm{eq}}(j\Omega)\) of Eq. (3.27), and the dashed box is the overall reconstruction filter \(H_r(j\Omega)=H_0(j\Omega)H_{\mathrm{eq}}(j\Omega)\). After Oppenheim & Willsky, Fig. 7.7.
For a cutoff frequency \(\Omega_c=\Omega_s/2\), the magnitude and phase of \(H_{\mathrm{eq}}(j\Omega)\) are shown in Figure 3.8.c, together with those of the hold that it compensates. Within the passband the magnitude rises from 1 at \(\Omega=0\) to \(\pi/2\) at the band edge, compensating the droop of the hold, and the phase increases linearly, cancelling the half-sample delay. The phase advance cannot be realized causally, and it is not needed, since a delay of \(T/2\) does not distort the waveform. The magnitude correction is approximated in practice, frequently by a discrete-time filter with a response proportional to \((\Omega T/2)/\sin(\Omega T/2)\) placed before the converter. In many applications the output of the zero-order hold is used without any correction.
Figure 3.8.c. The equalizer for a zero-order hold, cutoff \(\Omega_s/2\), shown with the hold it compensates (positive frequencies). (a) Magnitude. The relative gain of the hold, \(|H_0(j\Omega)|/T\) (amber), droops to \(2/\pi\) at \(\Omega_s/2\) and reaches zero at \(\Omega_s\). Up to the cutoff the equalizer \(|H_{\mathrm{eq}}(j\Omega)|\) (indigo) is its reciprocal, rising to \(\pi/2\), and the product (green) is flat at 1. The shaded region is the signal band for an oversampling factor \(L=4\), where the droop is only 0.22 dB. (b) Phase. The hold delays the signal by \(T/2\), a phase of \(-\Omega T/2\); the equalizer has the opposite phase, so the sum is zero. Adapted from Oppenheim & Willsky, Fig. 7.8.
Oversampling reduces the need for compensation. If the hold operates at a rate several times the Nyquist rate, the signal occupies only the lower part of the interval \(|\Omega|<\Omega_s/2\), where the droop is small, as Figure 3.8.d illustrates.
Figure 3.8.d. The zero-order hold at two rates. The dashed curve is the band-limited signal and the solid curve the output of the hold. With the shorter hold interval of the oversampled case the staircase follows the signal more closely, and the droop of Eq. (3.24) within the signal band is smaller.
What the equalizer does
The problem. Holding each sample for \(T\) seconds averages the signal over that interval, and averaging smooths fast variations more than slow ones. The gain of the hold, \(|H_0(j\Omega)|=T\left|\frac{\sin(\Omega T/2)}{\Omega T/2}\right|\), is \(T\) at \(\Omega=0\) and falls to \(2T/\pi\), about 64% of that, at \(\Omega_s/2\). High-frequency parts of the signal therefore come out weaker than they should. This is the droop.
The fix. The equalizer has, at each frequency, the reciprocal of the relative gain of the hold, \(|H_{\mathrm{eq}}(j\Omega)|=\frac{\Omega T/2}{\sin(\Omega T/2)}\) for \(|\Omega|<\Omega_s/2\). The hold followed by the equalizer then has the flat gain \(T\) over the whole passband.
Why the bowl shape. The droop curve is almost flat near \(\Omega=0\) and bends down more and more steeply towards the band edge. Its reciprocal starts almost flat at 1 and bends up more and more steeply, reaching \(\pi/2\approx1.57\) at \(\Omega_s/2\). Where the hold loses little, the equalizer adds little; where the hold loses most, the equalizer boosts most. Figure 3.8.c(a) shows the two curves and their product.
With oversampling. The signal occupies only \(|\Omega|<\Omega_M\), the nearly flat part of the droop curve, and the hold's relative gain at the band edge, \(\frac{\sin(\pi/2L)}{\pi/2L}\) with oversampling factor \(L=\Omega_s/2\Omega_M\), approaches 1 quickly. The boost the equalizer must supply, its reciprocal, approaches 1 with it:
\(L=\Omega_s/2\Omega_M\)
Hold gain at \(\Omega_M\), relative to \(T\)
Droop
Equalizer boost at \(\Omega_M\)
1 (Nyquist rate)
0.637
3.92 dB
1.571
2
0.900
0.91 dB
1.111
4
0.974
0.22 dB
1.026
8
0.994
0.06 dB
1.006
At high oversampling factors the droop is small enough that the equalizer is usually omitted. A lowpass reconstruction filter is still required, because the images at multiples of \(\Omega_s\) remain, but it can have the gradual transition of Section 3.8.2.
3.9 Quantization
Sampling discretizes the time axis, but the amplitude of each sample is still a real number. A quantizer with a word length of \(R\) bits maps each sample to the nearest of \(2^R\) levels spanning the range \([-X_m,X_m]\), as in Figure 3.9.a, so that the step size is
Figure 3.9.a. The quantizer and its error model. Top: C/D conversion, quantization and coding. Middle: the characteristic of a 3-bit uniform quantizer with offset-binary codes. Bottom: the uniform probability density assumed for the error. The error is a deterministic function of the input, and describing it as noise is a model; the model is accurate when the signal traverses many quantization levels between samples.
Quantization is a nonlinear, memoryless operation, and the methods of LTI analysis do not apply to it directly. It is usual, therefore, to represent the quantized value as the sum of the sample and an error signal,
and to model \(e[n]\) as a white sequence, uniformly distributed over one quantization step, as in the bottom panel of Figure 3.9.a, and uncorrelated with \(x[n]\). Under these assumptions the noise power follows in three steps.
Deriving the noise power
Step 1: the probability density. A uniform distribution over \([-\Delta/2,\Delta/2]\) has a constant density \(p(e)=c\) on that interval and zero elsewhere. The total probability must be 1, and the interval has width \(\Delta\), so \(c\,\Delta=1\) and
Step 2: the mean square value. The expected value of any function \(g(e)\) is \(E[g(e)]=\int g(e)\,p(e)\,de\). With \(g(e)=e^2\) and the density of Step 1, the integrand is \(e^2\cdot\frac{1}{\Delta}=\frac{e^2}{\Delta}\). This is where the \(e^2/\Delta\) in Eq. (3.30) comes from. Because the mean of \(e\) is zero, \(E[e^2]\) is also the variance \(\sigma_e^2\).
Consider a signal that uses the full range of the converter and is uniformly distributed over \([-X_m,X_m]\). Its power is \(P_x=\frac{1}{2X_m}\int_{-X_m}^{X_m}x^2\,dx=X_m^2/3\), and dividing by Eq. (3.30), with \(\Delta\) from Eq. (3.28), gives
Each additional bit therefore improves the SQNR by approximately 6 dB, giving about 48 dB for 8 bits, 72 dB for 12 bits, 96 dB for 16 bits and 144 dB for 24 bits. For a full-scale sinusoid the corresponding figure is \(6.02R+1.76\) dB. These values assume that the signal fills the range of the converter. If the amplitude of the signal is halved, its power falls by a factor of four and the SQNR by 6 dB, so that the gain preceding the converter is as important as its word length.
Limitations of the additive-noise model
The model assumes that the error is uncorrelated with the signal. This assumption fails for simple signals such as a slow ramp or a low-level periodic waveform, for which the error is itself periodic and produces harmonic components instead of a uniform noise floor. Adding a small random signal, called dither, before quantization removes the correlation. Dither does not reduce the error power, and in fact increases it slightly, but it replaces the harmonic distortion by a smooth noise floor.
MATLAB corner
The script below compares the measured SQNR of a uniform quantizer with Eq. (3.32), using a signal that spans many quantization levels. It then quantizes a low-level sinusoid with and without dither to show the conditions under which the additive-noise model fails.
Goal: measure the SQNR as a function of word length and compare it with the \(6.02R\) dB line, and show that without dither the quantization error of a low-level sinusoid consists of discrete harmonics.
quantization_sqnr.m
MATLAB
%% quantization_sqnr.m - measure the 6.02R dB rule instead of trusting it (Eq. 3.32)
N = 2^16; Xm = 1;
x = Xm * (2*rand(1,N) - 1); % uniform on [-Xm, Xm], as Eq. (3.31) assumes
bits = 4:2:16; sqnr = zeros(size(bits));
for k = 1:numel(bits)
R = bits(k);
D = Xm / 2^(R-1); % step size, Eq. (3.28)
xq = D * round(x/D); % the quantizer
e = xq - x;
sqnr(k) = 10*log10(mean(x.^2)/mean(e.^2));
fprintf('R=%2d measured %6.2f dB var(e)=%.3e D^2/12=%.3e\n', ...
R, sqnr(k), var(e), D^2/12);
end
figure('Color','w'); plot(bits, sqnr, 'o-', 'LineWidth',1.5); hold on; grid on;
plot(bits, 6.02*bits, '--');
xlabel('word length R (bits)'); ylabel('SQNR (dB)');
title('With dither: a flat noise floor, slightly higher but benign');
Figure 3.9.b. Results of quantization_sqnr.m. Left: the measured SQNR increases by about 6.02 dB per bit and follows the theoretical line, since each additional bit halves \(\Delta\) and reduces \(\sigma_e^2\) by a factor of four. Right: the error spectrum of a low-level sinusoid. Without dither the error is correlated with the input and consists of discrete harmonics; with dither these are replaced by a nearly flat noise floor.
EXAMPLE 3.5 · Specifying the front end of an audio converter
An audio system must capture the band 0–20 kHz with an SQNR of at least 90 dB. Choose the sampling rate and the word length, and specify the anti-aliasing filter. Repeat with a sampling rate four times higher, and compare the filter requirements.
1
Word length
From Eq. (3.32), \(R\ge90/6.02=14.95\), so at least 15 bits are required. A practical choice is \(R=16\), which gives 96 dB and is the standard word length for compact-disc audio.
2
Sampling at 44.1 kHz
The sampling theorem requires \(f_s>40\) kHz. With the compact-disc rate \(f_s=44.1\) kHz, components above \(f_s-20=24.1\) kHz are aliased into the signal band, and the anti-aliasing filter must attenuate them below the 96 dB noise floor while passing 20 kHz. This requires 96 dB of attenuation within a transition band of 4.1 kHz. A Butterworth filter would need an order of about sixty, and even an elliptic design is of high order, with considerable phase distortion near the band edge.
3
Sampling at 176.4 kHz
With \(f_s=176.4\) kHz, only components above \(176.4-20=156.4\) kHz are aliased into the signal band. The analog filter may therefore use the range from 20 kHz to 156.4 kHz, almost three octaves, to reach the required attenuation, and a sixth-order Butterworth filter is sufficient.
4
Completing the design
The remaining band-limiting is performed by a linear-phase discrete-time filter after the converter, followed by decimation by four to 44.1 kHz (Section 3.11). The oversampling also improves the SQNR within the signal band by 3 dB per doubling (Section 3.8.2), that is, by 6 dB, or one bit, for a factor of four.
This exchange between the complexity of the analog filter and the sampling rate is the reason that most modern audio converters oversample.
3.10 Sampling of discrete-time signals
The analysis developed for the sampling of continuous-time signals has a close counterpart for discrete-time signals, with a number of important applications. In analogy with Figure 3.2.b, a sequence is sampled by multiplying it by a periodic impulse train, as shown in Figure 3.10.a. The sampled sequence \(x_p[n]\) is equal to \(x[n]\) at integer multiples of the sampling period \(N\) and is zero at the intermediate samples:
Figure 3.10.a. Discrete-time sampling. The sequence \(x[n]\) is multiplied by the impulse train \(p[n]\) to give \(x_p[n]\). After Oppenheim & Willsky, Fig. 7.31.
By the multiplication property of the DTFT, the spectrum of \(x_p[n]\) is the periodic convolution of \(X(e^{j\omega})\) with the transform of \(p[n]\). The latter is an impulse train with impulses at the multiples of the discrete-time sampling frequency \(2\pi/N\),
Equation (3.35) is the discrete-time counterpart of Eq. (3.6) and is illustrated in Figure 3.10.b. The replicas are spaced by \(2\pi/N\). If \(X(e^{j\omega})=0\) for \(\omega_M<|\omega|\le\pi\), they do not overlap provided \(2\pi/N-\omega_M>\omega_M\), that is,
$$ \omega_M<\frac{\pi}{N}. $$
(3.36)
Figure 3.10.b. Effect in the frequency domain of impulse-train sampling of a discrete-time signal. (a) Spectrum of the original signal. (b) Spectrum of the sampling sequence. (c) Spectrum of the sampled signal with \(2\pi/N>2\omega_M\). (d) Spectrum of the sampled signal with \(2\pi/N<2\omega_M\), in which aliasing occurs. After Oppenheim & Willsky, Fig. 7.32.
In the absence of aliasing, \(X(e^{j\omega})\) is reproduced around \(\omega=0\) and around the integer multiples of \(2\pi\), and \(x[n]\) can be recovered from \(x_p[n]\) by a lowpass filter with gain \(N\) and a cutoff frequency greater than \(\omega_M\) and less than \(2\pi/N-\omega_M\), as in Figure 3.10.c. If aliasing occurs, the reconstructed sequence \(x_r[n]\) differs from \(x[n]\), but, as in continuous time, the two remain equal at the multiples of the sampling period: \(x_r[kN]=x[kN]\) for every integer \(k\).
Figure 3.10.c. Exact recovery of a discrete-time signal from its samples using an ideal lowpass filter. (a) Block diagram. (b) Spectrum of \(x[n]\). (c) Spectrum of \(x_p[n]\). (d) Ideal lowpass filter with gain \(N\) and cutoff \(\pi/N\). (e) Spectrum of the reconstructed sequence. After Oppenheim & Willsky, Fig. 7.33.
With \(h[n]\) the impulse response of the lowpass filter, the reconstruction is \(x_r[n]=x_p[n]*h[n]\). For an ideal filter with cutoff \(\omega_c\), \(h[n]=(N\omega_c/\pi)\sin(\omega_cn)/(\omega_cn)\), and
This is the discrete-time counterpart of the band-limited interpolation formula, Eq. (3.21). In practice the ideal filter is approximated, and discrete-time versions of the zero-order and first-order holds of Section 3.7 are frequently used.
EXAMPLE 3.6 · The largest sampling period for a sequence
A sequence obtained by sampling at 48 kHz contains no energy above 3 kHz. Determine the largest sampling period \(N\) for which it can be sampled without aliasing, and the equivalent rate of the retained samples.
1
Discrete-time band edge
With \(\omega=2\pi f/f_s\), the band edge is \(\omega_M=2\pi(3000)/48000=0.125\pi\).
2
Largest \(N\)
Equation (3.36) requires \(0.125\pi<\pi/N\), that is, \(N<8\), so the largest admissible value is \(N=7\). The value \(N=8\) places the band edge exactly on the boundary, which is the discrete-time counterpart of sampling at exactly the Nyquist rate.
3
Equivalent rate
With \(N=7\), the retained samples occur at an equivalent rate of \(48/7=6.86\) kHz, which exceeds the Nyquist rate of 6 kHz for a 3 kHz band.
4
Storage
The sequence \(x_p[n]\) still has one value per original sampling period, six of every seven being zero. The reduction in the number of stored values is obtained by decimation, considered in Section 3.11.
The discrete-time sampling theorem leads to the same conclusion as the continuous-time theorem applied at the reduced rate.
3.11 Changing the sampling rate: decimation, interpolation and rational conversion
In many applications it is inefficient to store or transmit the sampled sequence \(x_p[n]\) directly, since it is known to be zero between the sampling instants. The sequence is instead replaced by one that contains only every \(D\)th value, an operation called decimation. The reverse operation, which increases the sampling rate, is called interpolation. Both are simple operations on the index \(n\), and their effect is understood through the corresponding spectra. In this section \(U\) denotes the upsampling factor and \(D\) the downsampling factor, the sampling period \(N\) of Section 3.10 playing the role of \(D\). A cascade of the two operations changes the sampling rate by the factor \(U/D\). Some texts, and the MATLAB example below, use \(L\) and \(M\) for the two factors.
3.11.1 Decimation
The decimated sequence retains every \(D\)th sample of \(x_p[n]\):
$$ x_b[n]=x_p[nD]=x[nD], $$
(3.38)
the second form following because \(x_p[n]\) and \(x[n]\) are equal at the multiples of \(D\). The relation among \(x[n]\), \(x_p[n]\) and \(x_b[n]\) is shown in Figure 3.11.a.
Figure 3.11.a. Relation between \(x_p[n]\), obtained by sampling, and \(x_b[n]\), obtained by decimation. The figure uses the sampling period \(N\), written \(D\) in this section. After Oppenheim & Willsky, Fig. 7.34.
The DTFT of the decimated sequence is \(X_b(e^{j\omega})=\sum_kx_b[k]e^{-j\omega k}=\sum_kx_p[kD]e^{-j\omega k}\). Letting \(n=kD\), and noting that \(x_p[n]=0\) when \(n\) is not a multiple of \(D\), the sum may be taken over all \(n\):
Decimation therefore expands the spectrum of \(x_p[n]\) by the factor \(D\), so that the replicas spaced by \(2\pi/D\) in \(X_p(e^{j\omega})\) become replicas spaced by \(2\pi\). Figure 3.11.b shows this for \(D=2\). Combining Eq. (3.39) with Eq. (3.35) expresses the result in terms of the original spectrum:
Figure 3.11.b. Decimation by \(D=2\), sequences on the left and spectra on the right. The input is band-limited to \(|\omega|<\pi/2=\pi/D\). Keeping every second sample compresses the sequence in time, and by Eq. (3.40) the spectrum is expanded by \(D\) in frequency and scaled by \(1/D\). The expanded spectrum fills \(|\omega|<\pi\) and its copies at multiples of \(2\pi\) (grey) just touch, so there is no aliasing. A wider input band would overlap after expansion.
The decimated sequence is free of aliasing if \(X(e^{j\omega})=0\) for \(|\omega|\ge\pi/D\), which is the condition of Eq. (3.36). Figure 3.11.c shows what happens when it is violated. A decimator therefore consists of a lowpass anti-aliasing filter with cutoff \(\pi/D\) followed by the downsampler. If the input is known to contain empty bands, the filter may use them as transition bands; what matters is that no unwanted occupied band overlaps the wanted band after the frequency axis has been expanded by \(D\).
Figure 3.11.c. Aliasing in decimation by \(D=2\). By Eq. (3.40), \(X_b(e^{j\omega})\) is the sum of the expanded spectrum (\(k=0\)) and a copy of it shifted by \(2\pi\) (\(k=1\)). (a) The input extends to \(3\pi/4>\pi/D\). After expansion each term extends to \(3\pi/2\), the two terms overlap between \(\pi/2\) and \(3\pi/2\), and their sum differs from the expanded input. The overlap cannot be undone after downsampling. (b) A lowpass filter with cutoff \(\pi/D\), applied first, removes the input above \(\pi/2\). The two terms then meet at \(\pi\) without overlapping, and the band that is kept is reproduced without distortion.
3.11.2 Interpolation
The upsampler inserts \(U-1\) zeros between successive samples: \(x_u[n]=x[n/U]\) when \(n\) is an integer multiple of \(U\), and \(x_u[n]=0\) otherwise. The original sample values are unchanged; the sequence is expanded in time, and its spectrum is compressed in frequency:
The argument \(U\omega\) compresses each period of the spectrum by the factor \(U\), so that \(U\) copies, called images, appear in each interval of length \(2\pi\). The peak value of the DTFT is not divided by \(U\): a spectrum with unit peak still has images with unit peak, each of them narrower. A lowpass interpolation filter removes the images, and for a full-band input its ideal cutoff is \(\pi/U\).
The interpolation filter normally has passband gain \(U\). A constant input shows why. After zero insertion only one sample in \(U\) is nonzero, so the average value of the expanded sequence is \(1/U\), and a filter with a gain of \(U\) at zero frequency restores the constant output. The three stages are shown in Figure 3.11.d for \(U=2\).
Figure 3.11.d. Interpolation by \(U=2\), sequences on the left and spectra on the right. Inserting a zero between samples expands the sequence in time, and by Eq. (3.41) the spectrum is compressed by \(U\) in frequency with its peak unchanged. The compression brings the copy at \(2\pi\) down to \(\pi\), where it appears as an image (amber). The interpolation filter of Eq. (3.42), cutoff \(\pi/U\) and gain \(U\) (dashed green), removes the image and fills in the zero samples, giving \(y[n]\) with \(y[2n]=x[n]\).
Order of filtering and rate change
In decimation the filter precedes the removal of samples, whereas in interpolation it follows the insertion of zeros. For a rational rate change \(U/D\), the signal is first upsampled by \(U\), then processed by a single lowpass filter that both removes the images and protects the downsampler against aliasing, and finally downsampled by \(D\).
3.11.3 Rational conversion by \(U/D\)
A rational sample-rate converter is the cascade shown in Figure 3.11.e. Its lowpass filter performs two functions: it removes the images created by the upsampler, and it removes any remaining components that would be aliased by the downsampler.
The upsampler raises the sampling rate from \(F_{s,\mathrm{in}}\) to \(UF_{s,\mathrm{in}}\), the filter operates at this intermediate rate without changing it, and the downsampler lowers it by the factor \(D\). The output rate is therefore \(F_{s,\mathrm{out}}=(U/D)\,F_{s,\mathrm{in}}\), and the ratio
is the sampling-rate conversion factor. A factor greater than 1 raises the rate, and a factor less than 1 lowers it. To convert between two given rates, the ratio \(F_{s,\mathrm{out}}/F_{s,\mathrm{in}}\) is reduced to lowest terms and \(U\) and \(D\) are read from its numerator and denominator. A common factor would leave the conversion factor unchanged but raise the intermediate rate, and with it the cost of the filter. For example, conversion from 48 kHz to 36 kHz has \(36/48=3/4\), so that \(U=3\) and \(D=4\).
Figure 3.11.e. A rational sample-rate converter. The filter must be placed between the two rate-changing operations.
Normalized frequency in a multirate system
At each point in the system, \(\omega\) is normalized to the sampling rate at that point. A fixed continuous-time frequency therefore corresponds to different values of \(\omega\) before the upsampler, between the two rate changes, and after the downsampler, and each spectrum should be drawn on its own interval \(-\pi\le\omega\le\pi\).
Suppose that the input spectrum is zero outside \(|\omega|\le\omega_{\max}\). The filter specification is then obtained from the spectra as follows. Figure 3.11.f illustrates each step for the values of Example 3.7.
Upsample by \(U\). The wanted copy is compressed to \(|\omega|\le\omega_{\max}/U\), which gives the passband edge
$$\boxed{\omega_p=\frac{\omega_{\max}}{U}}.$$
Locate the nearest image. The images are centred at \(2\pi k/U\), and the nearest positive-frequency image begins at
If this image is the first unwanted occupied band, it defines the stopband edge \(\omega_{\mathrm{st}}\). The interval between \(\omega_p\) and \(\omega_{\mathrm{st}}\) contains no input energy and may be used as the transition band.
Complete the lowpass specification. With \(\omega_p\) and \(\omega_{\mathrm{st}}\) known,
The midpoint \(\omega_c\) is the natural cutoff frequency for a window-method FIR design (Lecture 7).
Set the gain. A passband gain of \(U\) preserves the amplitude of the signal in the time domain. This gain should be distinguished from the peak value of a plotted DTFT.
Check the downsampler. Downsampling expands the wanted band by \(D\), so that
The output is free of aliasing only if \(D\omega_p<\pi\), and any unwanted occupied band that would be aliased onto the wanted band must already have been attenuated by \(H(z)\).
Figure 3.11.f. The steps of the filter specification, positive frequencies, drawn for the values of Example 3.7: \(\omega_{\max}=\pi/2\), \(U=3\), \(D=4\). (a) Upsampling compresses the wanted band to \(\omega_p=\pi/6\) (step 1), and the nearest image, centred at \(2\pi/3\), begins at \(\omega_{\mathrm{st}}=\pi/2\) (step 2). The band between them, shaded green, contains no input energy. (b) The lowpass filter uses the empty band as its transition band of width \(\Delta\omega=\pi/3\), has its cutoff at the midpoint \(\omega_c=\pi/3\) (step 3), and passes \(|\omega|\le\omega_p\) with gain \(U\) (step 4). (c) After downsampling, the wanted band extends to \(D\omega_p=2\pi/3\), which is below \(\pi\), so the output is free of aliasing (step 5).
EXAMPLE 3.7 · Filter specification for a 3/4 rate converter
An input with unit peak spectrum is band-limited to \(|\omega|\le\pi/2\). It is upsampled by \(U=3\), filtered, and downsampled by \(D=4\). Determine the sampling-rate conversion factor, the filter edges, a suitable cutoff frequency, the output band edge, and the peak values of the spectra at each stage.
The output has three samples for every four input samples, so an input sampled at 48 kHz leaves at 36 kHz. The filter operates at the intermediate rate \(3F_{s,\mathrm{in}}\).
2
Passband edge
After upsampling, the wanted copy occupies \(|\omega|\le\omega_p=(\pi/2)/3=\pi/6\).
3
Stopband edge
The nearest image is centred at \(2\pi/U=2\pi/3\) and begins at \(\omega_{\mathrm{st}}=2\pi/3-\pi/6=\pi/2\). The transition width is \(\Delta\omega=\pi/3\), and the cutoff frequency is \(\omega_c=(\pi/6+\pi/2)/2=\pi/3\).
4
Output band edge
Downsampling by 4 expands the wanted band to \(D\omega_p=4\pi/6=2\pi/3<\pi\), so no aliasing occurs.
5
Gain and spectral peaks
The filter gain is \(G=U=3\). The peak values of the spectra are 1 for \(X\), 1 for \(Y_1\), 3 for \(Y_2\) after the filter, and \(3/4\) for \(Z\) after the factor \(1/D\) of Eq. (3.40). Figure 3.11.g shows the spectra at each stage.
The amplitude gain in the time domain is \(G/U=1\), although the peak value of the output DTFT is \(3/4\); the note that follows explains the difference.
Figure 3.11.g. Spectra at each stage of the converter of Example 3.7. The converter of Figure 3.11.e is drawn on the left with \(U=3\) and \(D=4\), and each signal is level with its spectrum. The input is band-limited to \(|\omega|\le\pi/2\). Upsampling compresses the wanted copy and creates images without changing their peak value. The filter of gain 3 retains only the wanted copy, and downsampling expands it to \(|\omega|\le2\pi/3\).
Spectral peak and signal amplitude
In Example 3.7 the peak values of the spectra are \(1\), \(1\), \(3\) and \(3/4\). The factor \(1/D\) in Eq. (3.40) accompanies the expansion of the frequency axis, and it does not mean that each retained sample is divided by \(D\).
With a filter gain of \(U=3\), the amplitude gain in the time domain is \(G/U=1\). The output therefore has the same amplitude as the input, although its DTFT, plotted against the new normalized frequency, has the peak value \(3/4\).
Procedure for sketching the spectra
State the overall rate change \(U/D\).
Sketch \(X(e^{j\omega})\) over \(-\pi\le\omega\le\pi\), labelling its band edge and its peak value.
Sketch \(Y_1(e^{j\omega})=X(e^{jU\omega})\): compress the band by \(U\) and repeat the images every \(2\pi/U\).
Read \(\omega_p\) from the edge of the wanted copy and \(\omega_{\mathrm{st}}\) from the beginning of the nearest unwanted occupied band.
Compute \(\Delta\omega\) and \(\omega_c\), and draw the lowpass specification with gain \(U\).
Remove the images to obtain \(Y_2\), and expand the frequency axis by \(D\) to obtain \(Z\).
Check that \(D\omega_p<\pi\), and distinguish the spectral peak values from the amplitude gain in the time domain.
MATLAB corner
The script below demonstrates decimation with and without an anti-aliasing filter, and interpolation by zero insertion followed by the removal of images. The input, sampled at 8 kHz, contains a wanted 300 Hz tone and an unwanted 3.2 kHz tone.
Goal: show that decimating by \(M=4\) without filtering aliases the 3.2 kHz tone to 800 Hz, and that lowpass filtering to \(\pi/M\) before decimation removes it.
rate_conversion_demo.m
MATLAB
%% rate_conversion_demo.m - decimation and interpolation, with and without filtering
% (Eqs. 3.48-3.50)
fs = 8000; t = (0:1/fs:0.05-1/fs).';
x = sin(2*pi*300*t) + 0.6*sin(2*pi*3200*t); % the 3.2 kHz tone will alias
M = 4;
% --- wrong: throw samples away with no anti-alias filter
x_bad = x(1:M:end);
% --- right: band-limit to pi/M first, then decimate
% --- interpolation by L: insert zeros, then remove the images
L = 3; x_up = zeros(L*numel(x_good), 1); x_up(1:L:end) = x_good;
g = L * fir1(96, 1/L); % gain L restores the amplitude
x_interp = filter(g, 1, x_up);
figure
pwelch(x_bad, [], [], [], fs/M); hold on
pwelch(x_good, [], [], [], fs/M);
legend('no anti-alias filter', 'filtered then decimated')
Figure 3.11.h. Expected result of rate_conversion_demo.m. Decimation by \(D=4\) reduces the sampling rate from 8 kHz to 2 kHz, and the new folding frequency is 1 kHz. Without an anti-aliasing filter the 3.2 kHz component is aliased to \(|3.2-2\times2|=0.8\) kHz, where it cannot be distinguished from a genuine 800 Hz component. When the input is filtered before samples are discarded, the 3.2 kHz component is removed and only the 300 Hz tone remains.
EXAMPLE 3.8 · Aliasing in a decimator
A sequence sampled at \(f_s=8\) kHz contains a wanted 300 Hz tone and an unwanted 3.2 kHz tone. It is decimated by \(D=4\) without an anti-aliasing filter. Determine the frequencies of the two tones after decimation, and the filter that would have prevented aliasing.
1
New sampling rate
After decimation the sampling rate is \(8/4=2\) kHz, and the folding frequency is 1 kHz.
2
The 300 Hz tone
The 300 Hz tone lies below 1 kHz and is unaffected.
3
The 3.2 kHz tone
From Eq. (3.13) with \(f_s=2\) kHz, \(f_a=3200-2000\times2=-800\) Hz, so that the tone appears at
$$|f_a|=800\ \text{Hz}.$$
4
Consequence
The aliased tone lies within the band of interest, 500 Hz from the wanted tone, and no subsequent processing can separate it from a genuine 800 Hz component.
5
Prevention
A discrete-time lowpass filter with cutoff \(\pi/D=\pi/4\), that is, 1 kHz at the original rate, applied before the samples are discarded, attenuates the 3.2 kHz tone while it can still be distinguished from the wanted signal.
Aliasing in a decimator is the discrete-time counterpart of aliasing at a sampler, and it is prevented in the same way.
?Problems with solutions
PROBLEM 3.1
A signal contains components at 300 Hz, 1.2 kHz and 3.6 kHz and is sampled at \(f_s=2\) kHz without an anti-aliasing filter. List the frequencies present in the reconstructed output.
1
Folding frequency
The folding frequency is \(f_s/2=1\) kHz. Each component appears at the frequency \(|f_a|\) given by Eq. (3.13).
2
Each component
300 Hz
→ 300 Hz
below the folding frequency, unchanged
1.2 kHz
→ 800 Hz
\(|1200-2000|=800\)
3.6 kHz
→ 400 Hz
\(|3600-2\times2000|=400\)
Result
The output contains components at 300, 400 and 800 Hz.
The aliased components are reordered as well as displaced, and nothing in the output distinguishes the genuine 300 Hz component from the aliased ones (Section 3.4.1).
PROBLEM 3.2
The signal \(x_c(t)=\cos(\Omega_0t+\pi/4)\), with \(\Omega_0=5\Omega_s/6\), is sampled with sampling frequency \(\Omega_s\) and reconstructed with an ideal lowpass filter of cutoff \(\Omega_s/2\). Determine \(x_r(t)\), and verify that \(x_r(nT)=x_c(nT)\).
1
Presence of aliasing
Since \(\Omega_s/2<\Omega_0<\Omega_s\), aliasing occurs and Eq. (3.12) applies.
2
Reconstructed signal
With \(\Omega_s-\Omega_0=\Omega_s/6\) and \(\phi=\pi/4\),
At \(t=nT\), \(\Omega_snT=2\pi n\). Then \(x_c(nT)=\cos(5\pi n/3+\pi/4)=\cos(2\pi n-\pi n/3+\pi/4)=\cos(\pi n/3-\pi/4)\), and \(x_r(nT)=\cos(\pi n/3-\pi/4)\). The two are equal, as Eq. (3.9) requires.
Result
\(x_r(t)=\cos(\Omega_st/6-\pi/4)\): the frequency is reduced from \(5\Omega_s/6\) to \(\Omega_s/6\), and the sign of the phase is reversed.
In the stroboscopic effect of Section 3.4.3, this change in the sign of the phase appears as a reversal of the apparent direction of rotation.
PROBLEM 3.3
A bandpass signal occupies 10.0–10.1 MHz. The lowpass sampling theorem would require \(f_s>20.2\) MHz. Show that \(f_s=400\) kHz can be used, and state the general condition.
1
Applicability of the lowpass condition
The condition \(f_s>2f_M\) of Eq. (3.7) was derived for a lowpass signal. For a narrow band far from zero frequency it is only necessary that the replicas of Eq. (3.6) should not overlap (Section 3.5).
2
The general condition
For a band \([f_L,f_H]\) with \(B=f_H-f_L\), Eq. (3.14) requires an integer \(n\) with
Here \(B=100\) kHz and \(\lfloor f_H/B\rfloor=101\). For \(n=51\) the interval is \(20.2/51=0.3961\) MHz \(\le f_s\le 20/50=0.400\) MHz, so \(f_s=400\) kHz is admissible. It lies at the upper end of the interval, where \(f_L=25f_s\) and the band is translated to 0–100 kHz, touching zero frequency.
4
Practical requirements
The anti-aliasing filter must be a good bandpass filter, since energy in any other Nyquist zone is folded onto the signal, and the aperture jitter must be small in relation to \(1/f_H\) rather than \(1/f_s\). A rate slightly inside the interval, such as 398 kHz, provides a margin at zero frequency.
Result
\(f_s=400\) kHz is admissible with \(n=51\) in Eq. (3.14); the admissible interval is 396.1–400 kHz.
Receivers commonly use this technique to translate a band to low frequencies without an analog mixer.
PROBLEM 3.4
Show that the zero-order hold attenuates the signal by 3.92 dB at \(f_s/2\) relative to zero frequency. Up to what fraction of \(f_s/2\) does the attenuation remain within 1 dB? What does this imply for an oversampled digital-to-analog converter?
1
Magnitude at \(f_s/2\)
From Eq. (3.24), \(|H_0(j\Omega)|/T=|\sin(\Omega T/2)/(\Omega T/2)|\). With \(\Omega=2\pi f\) and \(T=1/f_s\), the argument is \(\pi f/f_s\), and at \(f=f_s/2\)
Setting \(\sin(\pi\alpha/2)/(\pi\alpha/2)=10^{-1/20}=0.891\), with \(\alpha=f/(f_s/2)\), and solving numerically gives \(\alpha\approx0.52\).
3
Effect of oversampling
If the converter operates at four times the rate, the signal occupies only the lowest quarter of the interval up to the new \(f_s/2\). At \(\alpha=0.25\) the attenuation is only 0.22 dB.
Result
The attenuation is 3.92 dB at \(f_s/2\), and it remains within 1 dB up to about 0.52 of \(f_s/2\). With fourfold oversampling it is 0.22 dB at the edge of the signal band.
Oversampling reduces the droop within the signal band, so that little or no compensation of the form of Eq. (3.27) is required.
PROBLEM 3.5
(a) Show that the impulse response \(h_1(t)\) of the first-order hold, Eq. (3.25), is given by \(h_1(t)=\frac{1}{T}(h_0*h_0)(t+T)\), and use this result to derive Eq. (3.26). (b) Determine the attenuation of the first-order hold at \(\Omega_s/2\) relative to zero frequency, and compare it with that of the zero-order hold.
1
Convolution of two rectangles
The convolution of \(h_0(t)\) with itself is a triangle that rises from 0 at \(t=0\) to \(T\) at \(t=T\) and falls to 0 at \(t=2T\). Advancing it by \(T\) and dividing by \(T\) gives a triangle of unit height on \(-T\le t\le T\), which is \(h_1(t)\).
At \(\Omega=\pi/T\), \(H_1=\frac{1}{T}(2T/\pi)^2=4T/\pi^2\), while \(H_1(0)=T\). The ratio is \(4/\pi^2=0.405\), or \(-7.84\) dB, twice the attenuation in decibels of the zero-order hold.
Result
\(H_1(j\Omega)=\frac{1}{T}\big[\sin(\Omega T/2)/(\Omega/2)\big]^2\), with an attenuation of 7.84 dB at \(\Omega_s/2\), compared with 3.92 dB for the zero-order hold.
The squared sinc function also has double zeros at the multiples of \(\Omega_s\), so that the first-order hold attenuates the images more strongly than the zero-order hold.
PROBLEM 3.6
A 12-bit converter has \(X_m=5\) V. Determine \(\Delta\), the rms quantization noise and the SQNR in decibels. What SQNR results if the input swings only \(\pm0.5\) V?
The step size is fixed by the converter, so \(\sigma_e\) is unchanged, but the signal power falls by the factor \((0.5/5)^2=1/100\), or 20 dB:
$$\mathrm{SQNR}=72.2-20=52.2\ \text{dB}.$$
Result
\(\Delta=2.44\) mV, \(\sigma_e=0.705\) mV rms, and the SQNR is 72.2 dB at full scale and 52.2 dB, equivalent to about 8.7 bits, at \(\pm0.5\) V.
A signal that does not fill the range of the converter loses more than three bits of resolution, which is why the converter is normally preceded by an amplifier that matches the signal to its range.
PROBLEM 3.7
A sequence \(x[n]\) has a DTFT with \(X(e^{j\omega})=0\) for \(2\pi/9\le|\omega|\le\pi\). Determine the largest sampling period \(N\) for which \(x[n]\) can be sampled without aliasing, the corresponding discrete-time sampling frequency, and the range of cutoff frequencies of the ideal reconstruction filter.
1
Condition
The replicas in Eq. (3.35) are spaced by \(2\pi/N\). Since \(X(e^{j\omega})\) vanishes for \(|\omega|\ge2\pi/9\), adjacent replicas do not overlap if \(2\pi/N\ge2(2\pi/9)\), that is, \(N\le9/2\).
2
Largest \(N\)
The largest integer satisfying the condition is \(N=4\), and the discrete-time sampling frequency is \(2\pi/4=\pi/2\).
3
Reconstruction filter
The filter has gain \(N=4\) and a cutoff frequency \(\omega_c\) satisfying \(2\pi/9<\omega_c<\pi/2-2\pi/9\), that is, \(4\pi/18<\omega_c<5\pi/18\).
Result
\(N_{\max}=4\), with sampling frequency \(\pi/2\), and a reconstruction filter of gain 4 with \(4\pi/18<\omega_c<5\pi/18\).
Because the spectrum is already zero at \(|\omega|=2\pi/9\), the non-strict inequality is sufficient here, but \(N\) must still be an integer.
PROBLEM 3.8
An input with unit peak spectrum is zero outside \(|\omega|\le\pi/2\). It is converted by upsampling with \(U=4\), ideal lowpass filtering, and downsampling with \(D=3\). Determine the sampling-rate conversion factor, \(\omega_p\), the stopband edge \(\omega_{\mathrm{st}}\), \(\Delta\omega\), \(\omega_c\), the output band edge, the filter gain, and the peak value of the spectrum at each stage.
1
Rate and wanted copy
The sampling-rate conversion factor is \(U/D=4/3\). Upsampling compresses the wanted band to \(\omega_p=(\pi/2)/4=\pi/8\).
2
Image edge and filter specification
The nearest image is centred at \(2\pi/U=\pi/2\) and begins at \(\omega_{\mathrm{st}}=\pi/2-\pi/8=3\pi/8\). Hence \(\Delta\omega=\pi/4\) and \(\omega_c=(\pi/8+3\pi/8)/2=\pi/4\).
3
Output band and gain
Downsampling expands the wanted band to \(D\omega_p=3\pi/8<\pi\), so no aliasing occurs. The passband gain of the interpolation filter is \(G=U=4\).
4
Spectral peaks
The peak values of the spectra are \(1\), \(1\), \(4\) and \(4/3\) for \(X\), the upsampled sequence, the filtered sequence and the output. The amplitude gain in the time domain is \(G/U=1\).
Result
\(\omega_p=\pi/8\), \(\omega_{\mathrm{st}}=3\pi/8\), \(\Delta\omega=\pi/4\), \(\omega_c=\pi/4\), \(\omega_{\max,\mathrm{out}}=3\pi/8\), and \(G=4\).
The procedure is that of Section 3.11.3, applied with a larger upsampling factor.
Summary and key formulas
The principal results of the lecture are collected below.
Sampling and quantization. Sampling is reversible under the conditions of the sampling theorem; quantization is not, and its effect is described by the noise power \(\sigma_e^2=\Delta^2/12\).
Spectral replication. Impulse-train sampling replicates the spectrum of \(x_c(t)\) at intervals of \(\Omega_s\) and scales it by \(1/T\), Eq. (3.6).
The sampling theorem. A band-limited signal is uniquely determined by its samples if \(\Omega_s>2\Omega_M\), and it is recovered by an ideal lowpass filter of gain \(T\). The inequality is strict, as Example 3.1 shows.
Aliasing. If \(\Omega_s<2\Omega_M\) the replicas overlap. A sinusoid with \(\Omega_s/2<\Omega_0<\Omega_s\) is reconstructed at \(\Omega_s-\Omega_0\) with its phase reversed, and the stroboscopic effect is a visible example. Aliasing must be prevented by an anti-aliasing filter before sampling.
Bandpass sampling. A bandpass signal can be sampled at a rate determined by its bandwidth rather than by its highest frequency, provided \(f_s\) lies in one of the intervals of Eq. (3.14).
Frequency relation. The DTFT of \(x[n]\) is the spectrum of \(x_p(t)\) with the frequency axis scaled by \(T\), so that \(\omega=\Omega T\). The sampling frequency corresponds to \(\omega=2\pi\) and the folding frequency to \(\omega=\pi\).
Interpolation. Band-limited interpolation is exact but noncausal. The zero-order and first-order holds are simpler approximations, with attenuations of 3.92 dB and 7.84 dB at \(\Omega_s/2\). The droop of the zero-order hold can be compensated, or reduced by oversampling.
Quantization. Each additional bit improves the SQNR by about 6 dB at full scale. Dither removes the correlation between the error and the signal.
Sampling of sequences and rate conversion. Sampling a sequence with period \(N\) replicates its spectrum at intervals of \(2\pi/N\), and decimation then expands the spectrum by \(N\). Upsampling compresses the spectrum and creates images, which the interpolation filter removes. In a rational converter the single filter is placed between the upsampler and the downsampler.
Next, in Lecture 4: the \(z\)-transform. Sampling a complex exponential gives \(z=e^{sT}\), which maps the left half of the \(s\)-plane into the unit circle and the \(j\Omega\)-axis onto it.