ECE438 - Laboratory 4a: Sampling and Reconstruction of Continuous-Time Signals
ECE438 - Laboratory 4a: Sampling and Reconstruction of Continuous-Time Signals
1 Introduction
It is often desired to analyze and process continuous-time signals using a computer. However, in
order to process a continuous-time signal, it must first be digitized. This means that the
continuous-time signal must be sampled and quantized, forming a digital signal that can be
stored in a computer. Analog systems can be converted to their discrete-time counterparts, and
these digital systems then process discrete-time signals to produce discrete-time out- puts. The
digital output can then be converted back to an analog signal, or reconstructed, through a digital-
to-analog converter. Figure 1 illustrates an example, containing the three general components
described above: a sampling system, a digital signal processor, and a reconstruction system.
When designing such a system, it is essential to understand the effects of the sampling and
reconstruction processes. Sampling and reconstruction may lead to different types of distortion,
including low-pass filtering, aliasing, and quantization. The system designer must insure that
these distortions are below acceptable levels, or are compensated through additional processing.
Questions or comments concerning this laboratory should be directed to Prof. Mireille Boutin, School of
Electrical and Computer Engineering, Purdue University, West Lafayette IN 47907
1.1 Sampling Overview
Sampling is simply the process of measuring the value of a continuous-time signal at certain
instants of time. Typically, these measurements are uniformly separated by the sampling period,
Ts. If x(t) is the input signal, then the sampled signal, y[n], is as follows:
y[n] = x(t)|t=nTs .
A critical question is the following: What sampling period, Ts, is required to accurately
represent the signal x(t)? To answer this question, we need to look at the frequency domain
representations of y[n] and x(t). Since y[n] is a discrete-time signal, we represent its fre-
quency content with the discrete-time Fourier transform (DTFT), Y (ejω). However, x(t) is a
continuous-time signal, requiring the use of the continuous-time Fourier transform (CTFT),
denoted as X(f ). Fortunately, Y (ω) can be written in terms of X(f ):
Y (ω) = 1 X(f )|f = ω−2πk
Σ∞
Ts k=−∞ 2πTs
.
Σ∞
=1 . (1)
Σ
ω − 2πk
Ts k=−∞ X 2πTs
Consistent with the properties of the DTFT, Y (ω) is periodic with a period 2π. It is
formed by rescaling the amplitude and frequency of X(f ), and then repeating it in frequency
every 2π. The critical issue of the relationship in (1) is the frequency content of X(f ). If X(f
) has frequency components that are above 1/(2Ts), the repetition in frequency will cause
these components to overlap with (i.e. add to) the components below 1/(2Ts). This causes an
unrecoverable distortion, known as aliasing, that will prevent a perfect reconstruction of X(f
). We will illustrate this later in the lab. The 1/(2Ts) “cutoff frequency” is known as the
Nyquist frequency.
To prevent aliasing, most sampling systems first low pass filter the incoming signal to ensure
that its frequency content is below the Nyquist frequency. In this case, Y (ω) can be related to
X(f ) through the k = 0 term in (1):
. Σ
Y (ω) = 1 X ω
Ts 2πTs for ω ∈ [−π, π] .
jω
Here, it is understood that Y (e ) is periodic with period 2π. Note in this expression that
Y (ejω) and X(f ) are related by a simple scaling of the frequency and magnitude axes. Also
note that ω = π in Y (ejω) corresponds to the Nyquist frequency, f = 1/(2Ts) in X(f ).
Sometimes after the sampled signal has been digitally processed, it must then converted back
to an analog signal. Theoretically, this can be done by converting the discrete-time signal to a
sequence of continuous-time impulses that are weighted by the sample values. If this continuous-
time “impulse train” is filtered with an ideal low pass filter, with a cutoff frequency equal to the
Nyquist frequency, a scaled version of the original low pass filtered signal will result. The
spectrum of the reconstructed signal S(f
. ) is given by
Y (2πf T ) for |f | < 1
S(f ) = 2Ts (2)
s
0 otherwise.
1.2 Sampling and Reconstruction Using Sample-and-Hold
|P (f )| = Ts|sinc(f/fs)| . (4)
Finally, the magnitude of the frequency response of the N-th order Butterworth filter is
given by
1
. ΣN . (5)
f
|Hb(f )| = 1 + fc
We may calculate the complete magnitude response of the sample-and-hold system by
combining the effects of the Butterworth filters in equation (5), the ideal sampling system in
equation (3), and the sample-and-hold pulse width in equation (4). This yields the final
expression 1
|H(f )| = |Hb(f )P (f )
Ts Hb(f )|
2
1 |sinc(f/f )| .
=
. ΣN s
1 + ff
Notice that the expression |sinc(f/f s
frequencies close to the Nyquist rate.)| produces a roll-off
Generally,
c
in frequency
this roll-off which will attenuate
is not desirable.
INLAB REPORT:
Do the following using Ts = 1 sec, fc = 0.45 Hz, and N = 20. Use Matlab to produce the plots
(magnitude only), for frequencies in the range: f = -1:0.001:1.
• Compute and plot the magnitude response of the system in Figure 2 without the sample-
and-hold device.
• Compute and plot the magnitude response of the complete system in Figure 2.
• Comment
response ofonthe
thesample-and-hold
shape of the twoaffect
magnitude responses.
the design How might
considerations of the magnitude
a high quality audio
CD player?
2 Simulink Overview
Simulink Blocks
In this lab we will use Simulink to simulate the effects of the sampling and reconstruction
processes. Simulink treats all signals as continuous-time signals. This means that “sampled”
signals are really just continuous-time signals that contain a series of finite-width pulses. The
height of each of these pulses is the amplitude of the input signal at the beginning of the pulse. In
other words, both the sampling action and the zero-order-hold reconstruction are done at the
same time; the discrete-time signal itself is never generated. This means that the impulse-
generator block is really a “pulse-generator”, or zero-order-hold device. Remember that, in
Simulink, frequency spectra are computed on continuous-time signals. This is why many aliased
components will appear in the spectra.
In this section, we will experiment with the sampling and reconstruction of signals using a
pulse generator. This pulse generator is the combination of an ideal impulse generator and a
perfect zero-order-hold device.
In order to run the experiment, first download the required Lab4Utilities. Once Matlab is
started, type “Lab4”. A set of Simulink blocks and experiments will come up as shown in Fig 3.
Signal Impulse
Generator Spectrum
Generator
Analyzer
Mux
Mux
Scope
Figure 4: Simulink model for sampling and reconstruction using an impulse generator.
Before starting this experiment, use the MATLAB command close all to close all figures
other than the Simulink windows. Double click on the icon named Sampling and Reconstruc-
tion Using An Impulse Generator to bring up the first experiment as shown in Figure 4. In this
experiment, a sine wave is sampled at a frequency of 1 Hz; then the sampled discrete- time signal
is used to generate rectangular impulses of duration 0.3 sec and amplitude equal to the sample
values. The block named Impulse Generator carries out both the sampling of the sine wave and
its reconstruction with pulses. A single Scope is used to plot both the input and output of the
impulse generator, and a Spectrum Analyzer is used to plot the output pulse train and its
spectrum.
First, run the simulation with the frequency of input sine wave set to 0.1 Hz (initial setting of
the experiment). Let the simulation run until it terminates to get an accurate plot of the output
frequencies. Then print the output of Scope and the Spectrum Analyzer. Be sure to label your
plots.
INLAB REPORT:
Submit the plot of the input/output signals and the plot of the output signal and its frequency
spectrum. On the plot of the spectrum of the reconstructed signal, circle the aliases, i.e. the
components that do NOT correspond to the input sine wave.
Ideal impulse functions can only be approximated. In the initial setup, the pulse width is 0.3
sec, which is less then the sampling period of 1 sec. Try setting the pulse width to
0.1 sec and run the simulation. Print the output of the Spectrum Analyzer.
INLAB REPORT:
Submit the plot of the output frequency spectrum for a pulse width of 0.1 sec. Indicate on your
plot what has changed and explain why.
Set the pulse width back to 0.3 sec and change the frequency of the sine wave to 0.8 Hz.
Run the simulation and print the output of the Scope and the Spectrum Analyzer.
Network
Analyzer
Figure 5: Initial Simulink model for sampling and reconstruction using a sample-and-hold. This
system only measures the frequency response of the analog filters.
INLAB REPORT:
Submit the plot of the input/output signals and the plot of the output signal and its fre- quency
spectrum. On the frequency plot, label the frequency peak that corresponds to the lowest
frequency (the fundamental component) of the output signal. Explain why the lowest frequency
is no longer the same as the frequency of the input sinusoid.
Leave the input frequency at 0.8 Hz. Now insert a filter right after the impulse generator. Use
a 10th order Butterworth filter with a cutoff frequency of 0.5 Hz. Connect the output of the filter
to the Spectrum Analyzer and the Mux. Run the simulation, and print the output of Scope and the
Spectrum Analyzer.
INLAB REPORT:
Submit the plot of the input/output signals and the plot of the output signal and its frequency
spectrum. Explain why the output signal has the observed frequency spectrum.
In this section, we will sample a continuous-time signal using a sample-and-hold and then
reconstruct it. We already know that a sample-and-hold followed by a low-pass filter does not
result in perfect reconstruction. This is because a sample-and-hold acts like a pulse generator
with a pulse duration of one sampling period. This “pulse shape” of the sample-and-hold is what
distorts the frequency spectrum (see Sec 1.2).
To start the second experiment, double click on the icon named Sampling and Recon-
struction Using A Sample and Hold. Figure 5 shows the initial setup for this exercise. It contains
4 Scopes to monitor the processing done in the sampling and reconstruction system. It also
contains a Network Analyzer for measuring the frequency response and the impulse response of
the system.
The Network Analyzer works by generating a weighted chirp signal (shown on Scope 1) as an
input to the system-under-test. The frequency spectrum of this chirp signal is known. The
analyzer then measures the frequency content of the output signal (shown on Scope 4). The
transfer function is formed by computing the ratio of the output frequency spectrum to the input
spectrum. The inverse Fourier transform of this ratio, which is the impulse response of the
system, is then computed.
In the initial setup, the Sample-and-Hold and Scope 3 are not connected. There is no sampling
in this system, just two cascaded low-pass filters. Run the simulation and observe the signals on
the Scopes. Wait for the simulation to end.
INLAB REPORT:
Submit the figure containing plots of the magnitude response, the phase response, and the
impulse response of this system. Use the tall mode to obtain a larger printout by typing
orient(’tall’) directly before you print.
Double-click the Sample-and-Hold and set its Sample time to 1. Now, insert the Sample-
and-Hold in between the two filters and connect Scope 3 to its output. Run the simulation and
observe the signals on the Scopes.
INLAB REPORT:
Submit the figure containing plots of the magnitude response, the phase response, and the
impulse response of this system. Explain the reason for the difference in the shape of this
magnitude response versus the previous magnitude response. Give an analytical expression for
the behavior of the magnitude plot for frequencies below 0.45 Hz.