0% found this document useful (0 votes)
3 views7 pages

lab2

The document outlines an experiment on sampling and reconstruction of analog signals in a Digital Signal Processing Lab. It covers the principles of sampling, the Nyquist rate, and methods for reconstructing signals, including zero-order-hold and first-order-hold interpolation. The experiment involves sampling a specific analog signal at different frequencies and analyzing the effects on the signal's spectrum and reconstruction accuracy.

Uploaded by

miraz09191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

lab2

The document outlines an experiment on sampling and reconstruction of analog signals in a Digital Signal Processing Lab. It covers the principles of sampling, the Nyquist rate, and methods for reconstructing signals, including zero-order-hold and first-order-hold interpolation. The experiment involves sampling a specific analog signal at different frequencies and analyzing the effects on the signal's spectrum and reconstruction accuracy.

Uploaded by

miraz09191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

American International University-Bangladesh

Department of Electrical and Electronic Engineering


Digital Signal Processing Lab
Experiment #2

Experiment : Sampling and reconstruction of analog signals

Objectives :
1. To study the sampling principle and the effect of sampling on
the frequency-domain quantities
2. To study several approaches of reconstruction

Introduction :

Analog A/D Digital D/A Analog


input converter Signal converter output
signal processor signal

Digital Digital
input input
signal signal

In many DSP applications, real world analog signals are converted into discrete signals
using sampling and quantization operations (collectively called analog-to-digital conversion or
ADC). These discrete signals are processed by digital signal processors, and the processed signals
are converted into analog signals using a reconstruction operation (called digital-to-analog
conversion or DAC).

To understand how the DSP system works, we need to know the relation between an analog
signal and its discrete time sampled version. In time domain, relation between an analog signal and
a sampled discrete time signal is given by
x(n) = xa (nTs )
where Ts is sampling interval. However, in the frequency domain, the relation between spectra of an
analog signal and its discretized version is more complicated. Here we can use using Fourier
analysis to explain this relation and then address the reconstruction operation as follows:
The continuous time Fourier transform is given by


X a (F ) = ∫x
−∞
a (t )e − j 2πFt dt .

The inverse continuous time Fourier transform is given by



x a (t ) =
−∞
∫X a ( F )e j 2πFt dF .

The discrete time Fourier transform is given by



X(f ) = ∑ x ( n)e
n = −∞
− j 2πfn
.

The inverse discrete time Fourier transform is given by



x a (t ) =
−∞
∫X a ( F )e j 2πFt dF .

The relation between Xa(F) and X(f) is given by



X ( f ) = Fs ∑X
k = −∞
a (( f − k ) Fs ) .

where Fs is a sampling frequency = 1/Ts. In other words, X(f) consists of infinite numbers of copies
of scaled Xa(F) separated by frequency interval f = 1. From the relation between discrete time and
analog frequencies
F
f =
Fs
we get

F
X( ) = Fs ∑ X a ( F − kFs )
Fs k = −∞

F
in which X ( ) consists of infinite numbers of copies of scaled Xa(F) separated by interval F =
Fs
Fs .

Sampling Principle

In order to avoid aliasing, a band-limited signal xa(t) with bandwidth B can be reconstructed
from its sample values x(n) = xa(nTs) if the sampling frequency Fs = 1/Ts is greater than twice the
bandwidth B of xa(t).

Fs > 2 B

Otherwise aliasing would result in x(n). The sampling rate of 2B for an analog band-limited signal
is called the Nyquist rate.

Reconstruction
From the sampling theorem and the above examples it is clear that if we sample band-
limited xa(t) above its Nyquist rate, then we can reconstruct xa(t) from its samples
x(n). Using an interpolation formula:

xa (t ) = ∑ x(n)sinc(F (t − nT ))
n = −∞
s s
sin(πx)
where sinc( x) = is an interpolating function derived from an ideal low pass reconstruction
πx
filter. However, since an ideal low pass reconstruction filter cannot be implemented, we usually
estimated the ideal low pass filter by the following methods:

• Zero-order-hold (ZOH) interpolation: In this interpolation a given sample value is held


for the sample interval until the next sample is received.

xa (t ) = x(n), nTs ≤ t < (n + 1)Ts

which can be obtained by filtering the impulse train through an interpolating filter of the
form

⎧1 0 ≤ t<Ts
h0 (t ) = ⎨
⎩0 otherwise

which is a rectangular pulse. The resulting signal is a piecewise-constant (staircase)


waveform which requires an appropriately designed analog post-filter for accurate
waveform reconstruction.

x(n) Æ ZOH
Æ xa(t) Æ Post-Filter
Æ xa(t)

• First-order-hold (FOH) interpolation: In this case the adjacent samples are joined by
straight lines. This can be obtained by filtering the impulse train through

⎧ t
⎪1 + T 0 ≤ t < Ts
⎪⎪ s

h1 (t ) = ⎨ t
⎪1 − T Ts ≤ t < 2Ts
⎪ s

⎪⎩ 0 otherwise

Experiment :

To study the effect of sampling on the spectrum of the discrete signal, we will sample at
two different sampling frequencies and then reconstruct the signals as follows:
−10 t
Let xa (t ) = e . The continuous time Fourier transform is given by
⎛ 2 *10 ⎞
X a ( F ) = ⎜⎜ 2 ⎟.
2 ⎟
⎝ 10 + (2πF ) ⎠
1. Sampling xa(t) at Fs = 50 samples/sec.

clear all
tmin = -1;
tmax = 1;
% Analog signal
t = tmin:0.001:tmax;
xa = exp(-10*abs(t));
% Sampling rate (sample/second)
Fs = 50
% Sample period
Ts = 1/Fs
% Discrete time signal
n = tmin/Ts:tmax/Ts;
x = exp(-10*abs(n*Ts));
%Display signals in time domain
figure(1)
subplot(211)
plot(t,xa)
title('Analog and discrete time signals')
xlabel('time (sec)')
ylabel('Analog signal x(t)')
subplot(212)
stem(n,x)
xlabel('n')
ylabel('Discrete time signal x(n)')

% Computing Fourier transform


% Analog frequency (Hert)
F = -100:0.1:100;
W = (2*pi*F);
%Discrete time frequency (Circle/sample)
f = F/Fs;
w = 2*pi*f;
%Analog spectrum for continuous time Fourier transform
XaF = 2.*(10./(10^2+W.^2));
%Discrete time fourier transform
XF = x*exp(-j*n'*w);
%Display spectra in frequency domain
figure(2)
subplot(311)
plot(F,abs(XaF))
title('Spectra of signals')
xlabel('Freq (circle/sec)')
ylabel('Original Xa(F)')
subplot(312)
plot(F,abs(XF))
xlabel('Freq (circle/sec)')
ylabel('X(F/Fs)')
subplot(313)
plot(f,abs(XF))
xlabel('Freq (circle/sample)')
ylabel('X(f)')
% Display spectra in the fundamental range
figure(3)
subplot(211)
plot(F,abs(XF))
title('Spectra in the fundamental range')
xlabel('Freq (circle/sec)')
ylabel('X(F/Fs)')
v = axis;
v(1:2) = [-Fs/2 Fs/2];
axis(v)
subplot(212)
plot(f,abs(XF))
xlabel('Freq (circle/sample)')
ylabel('X(f)')
v = axis;
v(1:2) = [-1/2 1/2];
axis(v)

Explain whether experimental results are consistent with theoretical results.

2. Reconstruction of xa(t).

t = tmin:0.001:tmax;
figure(4)
clf
subplot(211)
hold on
stem(n*Ts,x,'r')
for i = 1:size(x,2)
xsinc(i,:) = x(i)*sinc(Fs*(t -(i+min(n)-1)*Ts));
plot(t,xsinc(i,:))
end
title('Signal reconstruction')
xlabel('time (second)')
ylabel('x(n)*Sinc(Fs*(t-nTs))')
hold off
xar = sum(xsinc);
subplot(212)
plot(t,xar,'b-',t,xa,'r:')
legend('Reconstructed signal','Original signal')
ylabel('Reconstructed signal xa(t)')
xlabel('time (second)')
% reconstruction error
maxerror = max(abs(xa - xar));

Explain the property of a sinc function that can use to reconstruct the signal without interfering
other sinc functions.

3. Repeat step 1 and 2 using Fs = 10 samples/sec. Explain that why using Fs = 50 samples/sec
is better than using Fs = 10 samples/sec. Locate the area where the spectra are most likely
to overlap other resulting in aliasing.
4. Consider an analog signal xa(t) = sin(20πt), 0 ≤ t ≤ 1. It is sampled at Ts = 0.01, 0.03, 0.05,
0.07 and 0.1 sec intervals to obtain x(n).

a. For each Ts plot x(n).


b. Reconstruct the analog signal ya(t) from the samples x(n) using the sinc
interpolation (use ∆t = 0.001) and determine the frequency in ya(t) from your plot.
c. Comment on your results.
_________________________________________________________________________

Questions:
1. What is the MATLAB function that would be used to plot a staircase (ZOH) interpolation
of the analog signal.
2. What is the MATLAB function that would be used to plot a linear (FOH) interpolation of
the analog signal.
3. From the experiment, describe why the minimum sampling rate must be at least twice the
bandwidth of an analog signal.

________________________________________________________________________________________
Name:______________________________________________________________ID:________________

1. From the figure in Page 1, explain briefly a function of each part of the DSP system.

2. For a discrete time signal in the figure below, draw the results of using zero-order-hold and first-order-
hold interpolation.
Z e ro -O rd e r-H o ld

-2
0 2 4 6 8 1 0 1 2 1 4 1 6 1 8

F irs t -O rd e r-H o ld

-2
0 2 4 6 8 1 0 1 2 1 4 1 6 1 8

3. What knowledge do you get from this lab?

You might also like