0% found this document useful (0 votes)
32 views12 pages

(18-37524-1 - D) DSP Lab Report 2

(18-37524-1_D)Dsp lab report 2
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)
32 views12 pages

(18-37524-1 - D) DSP Lab Report 2

(18-37524-1_D)Dsp lab report 2
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/ 12

AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH

(AIUB)
Faculty of Engineering
Department of Electrical and Electronic Engineering

Digital Signal Processing LAB


SECTION: D LAB REPORT NO: 02 GROUP NO: DATE: 12/08/20

TITLE:

Submitted by:
NAME: SEN, SHUVRO SANKAR
ID: 18-37524-1 CONTACT:
SIGNATURE:

SUBMITTED TO:
TAHIA FAHRIN KARIM
FACULTY OF ENGINEERING
DEPARTMENT OF EEE

SEMESTER: SUMMER 2018-19

© Dept. of EEE & COE, FE, AMERICAN INTERNATIONAL UNIVERSITY-BANGLADESH (AIUB)


Experiment 2 Lab Manual

American International University- Bangladesh


Department of Electrical and Electronic Engineering
EEE3211: Digital Signal Processing (DSP) Laboratory

Title: Sampling and reconstruction of analog signals

Introduction:

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).

Analog A/D Digital D/A Analog


Input Converter Signal Converter Output
signal Processor Signal

Digital Digital
Input signal Input signal

To understand how the DSP system works, we need to know the relation between an analog
signal and its discrete time sampled version.

The objective of this laboratory is to illustrate the basic principles of sampling and
reconstruction. An analog signal will be generated and sampled using a defined sampling
frequency. Different reconstruction filters will be considered. The lab also examines the
representation of these signals in the frequency domain.

Theory and Methodology:

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
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

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 1


Experiment 2 Lab Manual

X a (F) xa (t)e j2 Ft dt

The inverse continuous time Fourier transform is given by

xa (t) X a (F)e j2 Ft dF

The discrete time Fourier transform is given by

X(f) x(n)e j2 fn
n
The inverse discrete time Fourier transform is given by

x(n) X ( f )e j2 fndf

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


X(f) Fs X a (( k)Fs )
f
k

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) Fs X a (F kFs )
X(
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 2B
Otherwise aliasing would result in x(n). The sampling rate of 2B for an analog band-
limited signal is called the Nyquist rate.
© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 2
Experiment 2 Lab Manual

Reconstruction

From the sampling theorem and the above examples it is clear that if we sample band limited

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 3


Experiment 2 Lab Manual

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)sin c(Fs (t nTs ))
n
sin( x)
Where sin c(x) is an interpolating function derived from an ideal low
pass
x
reconstruction 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
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 Post-Filter

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 0 t Ts
T
s
t
h1 (t) Ts t 2Ts
1 Ts

0 otherwise

Pre-lab Homework:

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 4


Experiment 2 Lab Manual
A digital communication link carries binary-coded words representing samples of an input signal

xa(t) = cos(2000 t) + 3cos(5000 t) + 5cos(9000 t)

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 5


Experiment 2 Lab Manual

The link is operated at 24,000bits/second and each input signal is quantized into 4096 different
voltage levels.

1) What is the Nyquist rate for this signal?

2) What is the sampling rate, sampling interval, folding frequency for this signal?

3) What is the discrete-time signal obtained after sampling? (Find out the simplest form)

4) Determine whether the discrete signal is periodic or not. Compute the fundamental period
if the signal is periodic.

5) What is the analog signal ya(t) that we can reconstruct from the samples if we use ideal
interpolation?

Apparatus:

1. Matlab

Precautions:

Use following matlab commands in the M-file before starting the lab.

1) Clear all

2) Close all

Experimental Procedure:

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. Let xa (t) e 10t .The continuous
time Fourier transform is given by

2 *10
X a (F) .
2
10 (2 F)
The code has given in the appendices.

Problems for Lab Report:

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.
© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 6
Experiment 2 Lab Manual
Ans: Because of the finite time available , a sample rate somewhat higher than this is necessary.

4. Repeat the whole experimental procedure using Fs = 10 samples/sec. Explain 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.
5. 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 with answers for report writing:

Codes Output
Analog signal and a) With Fs = 50 Hz
Sampled signal:
a) %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)
© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 7
Experiment 2 Lab Manual
stem(n,x)
xlabel('n')
ylabel('Discrete time
signal x(n)')
b) %Sampling xa(t) at Fs =
10 samples/sec.
clear all
tmin = -1;
tmax = 1;

% Analog signal
t = tmin:0.001:tmax;
xa = exp(-10*abs(t));
% Sampling rate b) with Fs = 10 Hz
(sample/second)
Fs = 10
% 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)')

Reconstructed Signal: a) With Fs = 50


%Reconstruction of xa(t).
t = tmin:0.001:tmax;
figure(2)
clf
subplot(211)
hold on
stem(n*Ts,x,'r')
for i = 1:size(x,2)
© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 8
Experiment 2 Lab Manual
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));
b) With Fs = 10

References:

1. John G. Proakis, and Dimitris G. Manolakis,Digital Signal Processing, New Delhi,


Prentice Hall of India, 2003.

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 9


Experiment 2 Lab Manual

Appendix A
%Sampling xa(t) at Fs = 50 samples/sec.
clear all
tmin = -1;
tmax = 1;
%ZOH Post-Filter
% 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))

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 1


0
Experiment 2 Lab Manual

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)
%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));

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 1


1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy