DSP Lab Manual 2022-2023
DSP Lab Manual 2022-2023
LABORATORY MANUAL
1
The Vision and Mission of Electrical and Electronics Engineering Department of
Guru Nanak Dev Engineering College, Bidar are as follows:
VISION
To be a premier department known for its quality education, cutting edge
research and accomplished graduates to serve the society.
MISSION
M1: To provide quality education and skills to the students of Electrical and
Electronics Engineering, with a focus to develop critical-thinking and problem-
solving skills to face the challenges in their career .
2
B.E ELECTRICAL AND ELECTRONICS ENGINEERING(EEE)
CHOICE BASED CREDIT SYSTEM (CBCS)
SEMESTER - VI
DIGITAL SIGNAL PROCESSING LABORATORY
Subject Code 18EEL67 IA 4
Marks 0
Number of Practical 03 Exam 0
Hours/Week Hours 3
Total Number of 42 Exam 6
Practical Hours Marks 0
Credits - 02
Sl. Experiments
No
1 Verification of Sampling Theorem both in time and frequency
domains
2 Evaluation of impulse response of a system
3 To perform linear convolution of given sequences
4 To perform circular convolution of given sequences using (a) the
convolution summation formula (b) the matrix method and (c)
Linear convolution from circular convolution with zero padding.
5 Computation of N – point DFT and to plot the magnitude and
phase spectrum.
6 Linear and circular convolution by DFT and IDFT method.
7 Solution of a given difference equation.
8 Calculation of DFT and IDFT by FFT
9 Design and implementation of IIR filters to meet given
specification (Low pass, high pass, band pass and band reject
filters)
10 Design and implementation of FIR filters to meet given
specification (Low pass, high pass, band pass and band reject
filters) using different window functions
11 Design and implementation of FIR filters to meet given
specification (Low pass, high pass, band pass and band reject
3
filters) using frequency sampling technique.
12 Realization of IIR and FIR filters
clc;
close all;
t=0:.001:.2;
Fmax=50;
x=cos(2*pi*Fmax*t);
subplot(4,1,1);
plot(t,x);
title('Analog sinusoid');
Fs=100; %equal to 2Fmax
%Fs=200; %greater than 2Fmax
%Fs=90; %less than 2Fmax
n=0:1/Fs:.2;
xn=cos(2*pi*Fmax*n);
subplot(4,1,2);
stem(n,xn);
title ('Discrete');
L=4;
ni=0:1/(L*Fs):.2;
xni=interp1(n,xn,ni,'cubic');
subplot(4,1,3);
stem(ni,xni);
hold on;
plot(ni,xni,'r');
legend('discrete','reconstructed');
title ('Interpolation');
subplot(4,1,4);
plot(t,x,'b',ni,xni,'r');
4
legend('analog','reconstructed');
Aliasing
Aliasing is the effect in which high frequency component in the spectrum
of the signal takes identity of lower frequency component in the spectrum
of its sampled version.
If fs < 2fmax then aliasing occurs and reconstruction is not possible.
Interpolation
Interpolation is one method for reconstruction of continuous time signal
for its samples. Interpolation increases the sampling rate. The
interpolation involves inserting samples with appropriate consideration to
the samples around the point of insertion.
5
Analog sinusoid
1
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Discrete
1
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Interpolation
1
discrete
reconstructed
0
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Fs=2Fmax
1
analog
reconstructed
0
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Analog sinusoid
1
0
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Discrete
1
0
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Interpolation
1
discrete
0
reconstructed
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Fs>2Fmax
1
analog
0
reconstructed
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
6
Analog sinusoid
1
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Discrete
1
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Interpolation
1
discrete
0
reconstructed
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
Fs<2Fmax
1
analog
0
reconstructed
-1
0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2
7
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.02 Date: / /2020
Ex: y(n)-y(n-1)=x(n)+x(n-1)
clc;
close all;
disp('impluse response of a given system');
b=input('enter the Nr coefficients of transfer function i.e… x
coefficients=');
a=input('enter the Dr coefficients of transfer function i.e… y
coefficients=');
n=input('enter length of unit sample response n=');
[h,t]=impz(b,a,n);
disp(h);
stem(t,h);
grid on;
xlabel('samples n','color','M');
ylabel('amplitude h(n)','color','M');
title('unit sample response','color','r');
8
2. Impulse Response of a given system
The response or output signal obtained from a discrete time system when
the input signal is a unit sample sequence is known as the unit sample
response (impulse response).
The output y(n) of an LTI system for an input signal x(n) can be obtained
by convolving the impulse response h(n) and input signal x(n)
y(n) =x (n)*h(n)
1+ z-1 1 z-1
H(z)= -------- = ------- + -------
1 - z-1 1- z-1 1- z-1
9
Result:
impluse response of a given system
enter the Nr coefficients=[1 1]
enter the Dr coefficients=[1 -1]
enter length of unit sample response n=4
1
2
2
2
1.8
1.6
1.4
amplitude h(n)
1.2
0.8
0.6
0.4
0.2
0
0 0.5 1 1.5 2 2.5 3
samples n
10
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.03 Date: / /2020
yn=convn(hn,xn);
disp('linear convolution is');
disp(yn);
xlen=length(xn)-1;
hlen=length(hn)-1;
ylen=length(yn)-1;
n=xs:1:xs+xlen;
subplot(3,1,1);
stem(n,xn);
grid on;
title('linear convolution','color','r');
ylabel('amplitude xn','color','m');
n=hs:1:hs+hlen;
subplot(3,1,2);
stem(n,hn);
grid on;
ylabel('amplitude hn','color','m');
ys=xs+hs;
n=ys:1:ys+ylen;
subplot(3,1,3);
stem(n,yn);
grid on;
ylabel('amplitude yn','color','m');
xlabel('samples n','color','m');
11
3. Linear Convolution of two given sequences
Let x(n) be the input to an LTI system and y(n) be the output of the
system. Let h(n) be the response of the system to an impulse. The output
y(n) can be obtained by convolving the impulse response h(n) and the
input signal x(n).
∞
y(n)= ∑ x(k)h(n-k)
k=-∞
h(n) 1 1 1
x(n)
1 1 1 1
1 1 1 1
1 1 1 1
y(n)= {1 2 3 2 1}
↑
12
Result:
enter the first sequence x(n)=[1 1 1]
enter the second sequence h(n)=[1 1 1]
enter the starting index of x(n)=-1
enter the starting index of h(n)=-1
linear convolution is
1 2 3 2 1
linear convolution
1
amplitude xn
0.5
0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
1
amplitude hn
0.5
0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
3
amplitude yn
0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
samples n
13
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.04 Date: / /2020
clc;
close all;
clear all;
x=input('enter the sequence x=');
h=input('enter the sequence h=');
N=input('enter the value of N=');
N1=length(x);
N2=length(h);
x=[x,zeros(1,(N-N1))];
h=[h,zeros(1,(N-N2))];
x
h
for n=1:N
y(n)=0;
for i=1:N
j=n-i+1;
if(j<=0)
j=N+j;
end
y(n)=y(n)+x(i)*h(j);
end
end
disp('The Circular convolution of x(n) and h(n) is');
y
14
4. Circular convolution of two given sequences
(Matrix Method)
Let x(n) and h(n) are finite duration sequences both of length N then the
output y(n) obtained by circular convolution is
N-1
y(n)=x(n) N h(n) = ∑ x(k)h((n-k))N n= 0,1,……N-1
k=0
y(1) 1 4 3 2 2
y(2) = 2 1 4 3 1
y(3) 3 2 1 4 2
y(4) 4 3 2 1 1
15
Result:
enter the sequence x(n)=[2 1 2 1]
enter the sequence h(n)=[1 2 3 4]
enter the value of N=4
x=
2 1 2 1
h=
1 2 3 4
y=
14 16 14 16
16
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.05 Date: / /2020
%Property 1
energy=sum(x.^2);
center_index=ceil(length(Rxx)/2);
Rxx_0=Rxx(center_index);
if ceil(Rxx_0) == energy
disp('Rxx(0) gives energy -- proved');
else
disp('Rxx(0) gives energy -- not proved');
end
%Property 2
if Rxx == fliplr(Rxx)
disp('Rxx is even');
else
disp('Rxx is not even');
end
17
5. Auto correlation of given sequence and verification of its
properties
Auto-correlation function gives the measure of similarity, match or
coherence between a signal & its delayed replica. For example in digital
communication, a set of data symbols is represented by a set of unique
discrete-time sequences. If one sequence is transmitted, the receiver has
to determine which particular sequence has been received by comparing
the received signal with every member of possible sequences from the
set. Similarly, in radar & sonar applications, the received signal reflected
from the target is the delayed version of the transmitted signal and by
measuring the delay; one can determine the location of the target. It is
given by
∞
rxx(l) = ∑ x(n)x(n-l) l = 0, ±1, ±2,…….
n=-∞
The parameter l called lag indicates the time shift between the pair.
∞
rxy(l) = ∑ x(n)x(-(l-n))
n=-∞
rxy(l) = x(l) * x(-l)
We find that correlation process is essentially the convolution of two data sequences
18
Result:
enter the sequence x(n)=[1 2 1 1]
the auto-correlation of x(n) is
Rxx =
1.5
0.5
0
0 0.5 1 1.5 2 2.5 3
x(n) n-->
8
auto correlation
6
0
-3 -2 -1 0 1 2 3
Rxx l-->
19
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.06 Date: / /2020
clc;
close all;
x=input('enter the sequence x(n)=');
y=input('enter the sequence y(n)=');
n=0:length(x)-1;
subplot(2,2,1)
stem(n,x);
xlabel('x(n) n-->');
ylabel('amplitude');
n1=0:length(y)-1;
subplot(2,2,2)
stem(n1,y);
xlabel('y(n) n-->');
ylabel('amplitude');
m=max(length(x),length(y));
Rxy=xcorr(x,y);
disp('cross-correlation of x(n) and y(n) is');
disp(Rxy);
nRxy=-m+1:m-1;
subplot(2,2,3:4);
stem(nRxy,Rxy,'r');
xlabel('Rxy l-->');
%property 1
Ex=sum(x.^2);
Ey=sum(y.^2);
Rxx=xcorr(x);
Ryy=xcorr(y);
center_index=ceil(length(Rxx)/2);
Rxx_0=Rxx(center_index);
center_index1=ceil(length(Ryy)/2);
Ryy_0=Ryy(center_index1);
20
if ceil(Rxx_0*Ryy_0) == (Ex*Ey)
disp('Rxy[l]<=sqrt(Rxx_0*Ryy_0)=sqrt(Ex*Ey) -- proved');
else
disp('Rxy[l]<=sqrt(Rxx_0*Ryy_0)=sqrt(Ex*Ey) -- not proved');
end
%property 2
Ryx=xcorr(y,x);
if Rxy == fliplr(Ryx)
disp('Rxy is even');
else
disp('Rxy is not even');
end
21
6. Cross-correlation of given sequence and verification of its
properties
The cross-correlation between two signals explains how much one signal
is related to the time-delayed version of another signal. It is given by
∞
rxy(l) = ∑ x(n)y(n-l) l = 0, ±1, ±2,…….
n=-∞
The parameter l called lag indicates the time shift between the pair.
∞
rxy(l) = ∑ x(n)y(-(l-n))
n=-∞
∞ ∞
Where Ex = ∑ |x(n)|2 Ey = ∑ |y(n)|2
n=-∞ n=-∞
2.
rxy(l) = ryx(-l)
Consider x(n) = {1,3,-2,1,2,-1,4,4,2} and y(n) = {2,-1,4,1,-2,3}
x(n) 1 3 -2 1 2 -1 4 4 2
y(-l) 3 -2 1 4 -1 2
-------------------------------------------------------------------------
2 6 -4 2 4 -2 8 8 4
-1 -3 2 -1 -2 1 -4 -4 -2 +
4 12 -8 4 8 -4 16 16 8 +
1 3 -2 1 2 -1 4 4 2 +
-2 -6 4 -2 -4 2 -8 -8 -4 +
3 9 -6 3 6 -3 12 12 6 +
-----------------------------------------------------------------------------------------
3 7 -11 14 13 -15 28 6 -2 21 12 12 6 4
↑
rxy(l) = {0,0,0,3,7,-11,14,13,-15,28,6,-2,21,12,12,6,4}
22
Result:
enter the sequence x(n)=[1 3 -2 1 2 -1 4 4 2]
enter the sequence y(n)=[3 -2 1 4 -1 2]
enter the starting index of x(n)=0
enter the starting index of y(n)=0
cross-correlation of x(n) and y(n) is
Rxy =
Columns 1 through 8
Columns 9 through 16
Column 17
6.0000
Ex =
56
Ey =
35
Rxx =
Columns 1 through 8
Columns 9 through 16
Column 17
23
2.0000
Rxx_0 =
56
Ryy_0 =
35
Rxy[l]<=sqrt(Rxx_0*Ryy_0)=sqrt(Ex*Ey) -- proved
Ryx =
Columns 1 through 7
Columns 8 through 14
Columns 15 through 17
Rxy is even
24
4 4
2 2
amplitude
amplitude
0 0
-2 -2
0 2 4 6 8 0 2 4 6
x(n) n--> y(n) n-->
40
Cross Correlation
30
20
10
-10
-8 -6 -4 -2 0 2 4 6 8
Rxy l-->
25
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.07 Date: / /2020
clc;
close all;
disp('implementation of general difference equation');
b=input('enter the x(n) coefficient b=');
a=input('enter the y(n) coefficient a=');
x=input('enter the input samples x=');
yi=input('enter the initial conditions for y');
xi=input('enter the initial conditions for x');
zi= filtic( b,a,yi,xi);
y=filter(b,a,x,zi);
disp(y);
n=0:length(x)-1;
stem(n,y);
xlabel('samples n');
ylabel('y(n)');
grid on;
title('implementation of difference equation');
26
7. Solving a given difference equation
27
Result:
implementation of general difference equation
enter the x(n) coefficint b=[1]
enter the y(n) coefficint a=[1 3]
enter the input samples x=[1 1 1 1]
enter the initial conditons for y[1]
enter the initial conditons for x[0]
-2 7 -20 61
60
50
40
30
y(n)
20
10
-10
-20
0 0.5 1 1.5 2 2.5 3
samples n
28
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.08a Date: / /2020
clc;
close all;
xn=input('enter the sequence x(n)=');
N=input('enter the value of N=');
n=0:N-1;
k=0:N-1;
disp('DFT of x(n) is');
Xk=fft(xn,N)
subplot(2,1,1);
stem(k,abs(Xk));
xlabel('k');
ylabel('magnitude of X(k)');
title('DFT of x(n)=X(k)');
phase=atan(imag(Xk)./real(Xk))*180/pi
subplot(2,1,2);
stem(k,phase);
xlabel('k');
ylabel('phase of X(k)');
29
8. Computation of N point DFT of a given sequence and to plot the
magnitude and phase spectrum
N−1
X[k] = ∑ x[n]WknN k= 0, 1, . . . , N − 1,
n=0
where WN = e−j2π/N.
IDFT:
N−1
x[n] =1/N ∑ X[k]W-knN n= 0, 1, . . . , N − 1,
k=0
where WN = e−j2π/N
30
Result:
enter the sequence x(n)=[0 1 2 3]
enter the value of N=4
DFT of x(n) is
Xk =
mag =
phase =
0 -45 0 45
DFT of x(n)=X(k)
6
4
magnitude of X(k)
0
0 0.5 1 1.5 2 2.5 3
k
50
phase of X(k)
-50
0 0.5 1 1.5 2 2.5 3
k
31
Result:
enter the sequence x(n)=[0 1 2 3]
enter the value of N=8
DFT of x(n) is
Xk =
Columns 1 through 5
Columns 6 through 8
mag =
phase =
DFT of x(n)=X(k)
6
5
magnitude of X(k)
0
0 1 2 3 4 5 6 7
k
100
50
phase of X(k)
-50
-100
0 1 2 3 4 5 6 7
k
32
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.08b Date: / /2020
clc;
close all;
Xk=input('enter the sequence X(k)=');
N=input('enter the value of N=');
n=0:N-1;
k=0:N-1;
disp('IDFT of X(k) is');
xn=ifft(Xk,N)
subplot(2,1,1);
stem(n,abs(xn));
xlabel('n');
ylabel('magnitude of x(n)');
title('IDFT of X(k)=x(n)');
subplot(2,1,2);
stem(n,angle(xn));
xlabel('n');
ylabel('phase of x(n)');
33
Result:
enter the sequence X(k)=[6 -2+2i -2 -2-2i]
enter the value of N=4
IDFT of X(k) is
xn =
0 1 2 3
IDFT of X(k)=x(n)
3
2.5
2
magnitude of x(n)
1.5
0.5
0
0 0.5 1 1.5 2 2.5 3
n
0.5
phase of x(n)
-0.5
-1
0 0.5 1 1.5 2 2.5 3
n
34
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.09 Date: / /2020
clc;
close all;
xn=input('enter the sequence x(n)=');
xlen=length(xn);
hn=input('enter the sequence h(n)');
hlen=length(hn);
N=xlen+hlen-1;
Xk=fft(xn,N);
Hk=fft(hn,N);
Yk=Xk.*Hk;
yn=ifft(Yk);
disp(yn);
n=0:1:N-1;
stem(n,yn);
xlabel('n-->');
ylabel('y(n)');
title('sequence resulting from linear convolution');
35
9. Linear convolution of two sequences using DFT and IDFT
36
Result:
enter the sequence x(n)=[1 2]
enter the sequence h(n)=[1 2 3]
xk =
hk =
yk =
linear convolution is
yn =
1 4 7 6
4
y(n)
0
0 0.5 1 1.5 2 2.5 3
n-->
37
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.10 Date: / /2020
clc;
close all;
N=input('enter the length of circular convolution N=');
xn=input('enter the sequence x(n)=');
xlen=length(xn);
hn=input('enter the sequence h(n)');
hlen=length(hn);
Xk=fft(xn,N);
Hk=fft(hn,N);
Yk=Xk.*Hk;
yn=ifft(Yk);
disp(yn);
n=0:1:N-1;
stem(n,yn);
xlabel('n-->');
ylabel('y(n)');
title('sequence resulting from circular convolution');
38
10. Circular convolution of two given sequences Using DFT & IDFT
DFT
If x(n) ←→ X(k)
DFT
And h(n) ←→ H(k)
DFT
Then x(n) N h(n) ←→ X(k) H(K)
y(n) = IDFT{Y(k)}
X(k) = {6 0 2 0}
H(k) = {10 -2+2j -2 -2-2j}
39
Result:
enter the length of circular convolution N=4
enter the sequence x(n)=[2 1 2 1]
enter the sequence h(n)=[1 2 3 4]
cricular convolution is
14 16 14 16
14
12
10
8
y(n)
0
0 0.5 1 1.5 2 2.5 3
n-->
40
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.12a Date: / /2020
41
12a. Butterworth lowpass IIR analog filter
% Given specifications are
% passband edge freq=1 kHz
% stopband edge freq=5 kHz
% passband attenuation=.1 db
% stopband attenuation=40 db
Ωp=2*pi*1000
Ωs=2*pi*5000
Ap=.1
As=40
Order N
1 log{(10.1As-1)/ (10.1Ap-1)}
N = --- ---------------------------------------
2 Log(Ωs/ Ωp)
N=4
Cut-off frequency
Ωc = Ωs/(10.1As-1)1/2N
Ωc = 9934.7 rad/sec
(Ωc)N
Ha(s) = --------------------------------
(s-s1)(s-s1*)(s-s2)(s-s2*)
42
Result
N =4
Wn = 9.9347e+003
num/den = 9741396185386870
---------------------------------------------------------------
s^4 + 25960.6547 s^3 + 336977796.7754 s^2 +
2562277980262.151 s + 9741396185386870
-5
-10
-15
-20
Gain,db
-25
-30
-35
-40
-45
-50
0 1000 2000 3000 4000 5000 6000
freq,Hz
43
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.12b Date: / /2020
44
12b. Butterworth lowpass IIR digital filter using Bilinear
transformation
Assume 2/T = 1
1 log{(10.1As-1)/ (10.1Ap-1)}
N = --- ---------------------------------------
2 Log(Ωs/ Ωp)
N=3
Ωc = Ωs/(10.1As-1)1/2N
Ωc = 0.6620 rad/sec
(Ωc)N
Ha(s) = --------------------------------
(s-s1)(s-s1*)(s-s2)(s-s2*)
45
Result:
N=3
Wn = 0.6620
B= 0 0 0 0.2901
num/den =
-10
-20
-30
Gain,db
-40
-50
-60
-70
-80
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
/,Hz
46
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.12c Date: / /2020
47
12c. Butterworth highpass IIR analog filter
Order N
1 log{(10.1As-1)/ (10.1Ap-1)}
N = --- ---------------------------------------
2 Log(Ωs/ Ωp)
N=5
Cut-off frequency
s → Ωp ΩHp
-----------
s
System function of highpass filter is given as
HHP = Han(s)|s→ Ωp ΩHp
-----------
s
48
Result:
N= 5
Wn = 1.5924
num/den =
+ 0.00059326
------------------------------------------------------------------
s^5 + 51073.2108 s^4 + 1304236429.337 s^3 + 20584098516049.44
s^2
+ 200779670279706940 s + 979214026939196640000
-10
-20
-30
Gain,db
-40
-50
-60
-70
-80
0 1000 2000 3000 4000 5000 6000
freq,Hz
49
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.12d Date: / /2020
50
12d. Butterworth highpass IIR digital filter using bilinear
transformation
%Given specifications are
% passband edge freq=700 Hz
% stopband edge freq=500 Hz
% passband attenuation=1 db
% stopband attenuation=32 db
% Sampling freq=2 KHz
Ap=1
As=32
Fp=700
Fs=500
Ft=2000
wp=2*pi*Fp/Ft = 2*pi*700/2000 = 0.7pi
ws=2*pi*Fs/Ft = 2*pi*500/2000 = .5pi
Ωpn = 1
Ωsn = Ωp/Ωs = 1.9626/1 = 1.9626
Order N
1 log{(10.1As-1)/ (10.1Ap-1)}
N = --- ------------------------------------
2 Log(Ωs/ Ωp)
N=7
Cut-off frequency
51
Normalized prototype lowpass butterworth filter system function:
1
Han(s) = ------------------------------------
sN + bN-1sN-1 +……+ b1s + 1
s → Ωp ΩHp
-----------
s
52
Result:
N=7
Wn = 1.1595
num/den =
+ 0.07069 z + 0.0059961
-10
-20
-30
Gain,db
-40
-50
-60
-70
0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3
/,Hz
53
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.12e Date: / /2020
54
12e. Type-I chebyshev lowpass IIR analog filter
% Given specifications are
% passband edge freq=1 kHz
% stopband edge freq=5 kHz
% passband attenuation=1 db
% stopband attenuation=40 db
Ωp=2*pi*1000
Ωs=2*pi*5000
Ap=1
As=40
Order N:
Cosh-1{(10.1As-1)/ (10.1Ap-1)}1/2
N = ---------------------------------------
Cosh-1(Ωs/ Ωp)
N=3
& Φk = Π + (2k+1) Π
--- -------------- k = 0,1,2……N-1
2 2N
Transfer function is
k
Ha(s) = ----------------------------------
(s-s1)(s-s2)……….(s-sN)
k
= ------------------------------------
sN + bN-1sN-1 +……+ b1s + 1
& k = bo for N odd
k = bo/√(1+ ε2) for N even
55
Result:
N= 3
Wn = 6.2832e+003
num/den =
121868727358.1179
--------------------------------------------------------
s^3 + 6209.931 s^2 + 48890434.5196 s + 121868727358.1179
-10
-20
Gain,db
-30
-40
-50
-60
0 1000 2000 3000 4000 5000 6000
freq,Hz
56
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.12f Date: / /2020
57
12f. Type-I Chebyshev lowpass IIR digital filter using bilinear
transformation
Ap = 1;
As = 15;
Fp = 250;
fs = 550;
ft = 2000;
wp = 2*pi*fp/ft = 2*pi*250/2000 = 0.25pi
ws = 2*pi*fs/ft = 2*pi*550/2000 = 0.55pi
Assume 2/T = 1
Cosh-1{(10.1As-1)/ (10.1Ap-1)}1/2
N = ---------------------------------------
Cosh-1(Ωs/ Ωp)
& Φk = Π + (2k+1) Π
--- -------------- k = 0,1,2……N-1
2 2N
58
Transfer function is
k
Ha(s) = ----------------------------------
(s-s1)(s-s2)……….(s-sN)
k
= ------------------------------------
sN + bN-1sN-1 +……+ b1s + 1
& k = bo for N odd
k = bo/√(1+ ε2) for N even
59
Result:
Omegap = 0.4142
Omegas = 1.1708
`
N =2
Wn = 0.4142
num/den =
-10
-20
-30
Gain,db
-40
-50
-60
-70
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
/,Hz
60
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.12g Date: / /2020
61
12g.Type-I Chebyshev highpass IIR analog filter
Ap=0.1
As=40
Ωp=2*pi*4000
Ωs=2*pi*1000
Cosh-1{(10.1As-1)/ (10.1Ap-1)}1/2
N = ---------------------------------------
Cosh-1(Ωs/ Ωp)
Transfer function is
k
Ha(s) = ------------------------------------
sN + bN-1sN-1 +……+ b1s + 1
& k = bo for N odd
k = bo/√(1+ ε2) for N even
62
Result:
N=4
Wn = 1
num/den =
- 2.9617e-020
----------------------------------------------------------------
s^4 + 61443.3445 s^3 + 2002668018.3419 s^2 + 34562406189280.35 s
+ 481572930645911940
-10
-20
-30
-40
Gain,db
-50
-60
-70
-80
-90
0 1000 2000 3000 4000 5000 6000
freq,Hz
63
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.12h Date: / /2020
64
12h.Type-I Chebyshev highpass IIR digital filter using bilinear
transformation
%Given specifications are
% passband edge freq = 700 Hz
% stopband edge freq = 500 Hz
% passband attenuation = 1 db
% stopband attenuation = 32 db
% sampling frequency = 2 khz
Ap=1
As=32
Fp=700
Fs=500
Ft=2000
wp=2*pi*Fp/Ft = 2*pi*700/2000 = 0.7pi
ws=2*pi*Fs/Ft = 2*pi*500/2000 = .5pi
Ωpn = 1
Ωsn = Ωp/Ωs = 1.9626/1 = 1.9626
Order N
Cosh-1{(10.1As-1)/ (10.1Ap-1)}1/2
N = ---------------------------------------
Cosh-1(Ωs/ Ωp)
Transfer function is
k
Ha(s) = ------------------------------------
sN + bN-1sN-1 +……+ b1s + 1
& k = bo for N odd
k = bo/√(1+ ε2) for N even
System function of highpass filter is given as
HHP = Han(s)|s→ Ωp ΩHp
-----------
s
H(z) using bilinear transformation:
65
Apply bilinear transformation to Ha(s) to get H(z). Bilinear
transformation is given by
2 1-z-1
S= -- ------ Assume (2/T)=1
-1
T 1+z
66
Result:
Omegap1 = 1
Omegas1 = 1.9626
N=4
Wn = 1
num/den =
-10
-20
Gain,db
-30
-40
-50
-60
0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3
/,Hz
67
DSP KIT PROCEDURE
1. To test the DSP starter kit double click on 6713 dsk diagnostic icon
which is displayed on the desk top. click on start it tests the
USB diagnostics,external memory,DSP memory,LED memory,
codec diagnostics,flash diagnostics,emulation diagnostics.
After testing it displays the diagnostic status pass,click on stop
close the window.
2. To start the code composer studio double click on 6713 DSK
CC studio_v 3.1 icon on the desk top.
Select the debug option in that we have to select connect which
Connects DSK boardto the system.
3. Start a new project using ‘project- new’
Target type – executable(.out)
Target – TMS 320 C67XX
Finish
4. Select file option in that new, source file .we have to write the
program and save it in a separate directory(c:\cc studio_v3.1\my
projects) with extension dot c(.c).
Dragout the project right click on source add file to project select the
file name c:\ cc studio_v3.1\my projects(in the form of note pad).
5. Add the linker command file hello.cmd right click on library
(path: c:\cc studio_v3.1\tutorial\dsk 6713\hello1\ hello.cmd files of
type linker command file)
6. Add the run time support library file rts 6700.lib right click on
library(path: c:\cc studio_v3.1\c6000\cg tools\lib\rts 6700.lib)
7. Compile the program using the
Project -- pull down the menu select compile option.
8. Build the program using the
Project -- pull down the menu select build option.
9. Load the program in program memory of DSP chip using the file--
pull down the menu select load program.
10.Select debug double click file name .out.
Select the debug option pull down the menu run the program.
It displays the result.
11.To view the output graphically
Select the view option
Graph – time/frequency
Start address – ‘y’(o/p program variable)
Display data size – 16 bit unsigned integer
Data plot style – line(curve) or bar(discrete) .
68
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.1 Date: / /2020
#include<stdio.h>
int y[10];
void main( )
{
int L = 4;
int M = 4;
int n,k;
int x[10] = {2,1,1,2,0,0,0,0};
int h[10] = {1,-1,-1,1,0,0,0,0};
for(n = 0; n<L+M-1; n++)
{
y[n] = 0;
for(k=0; k<=n; k++)
y[n]+= x[k] *h[n-k];
}
printf("linear convolution is\n");
for(n = 0; n<L+M-1; n++)
printf("%d\n",y[n]);
}
69
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.2 Date: / /2020
#include<stdio.h>
int y[30];
void main( )
{
int N1,N2,x[30],h[30],i,j,n,N;
70
j=N+j;
y[n]=y[n]+x[i]*h[j];
}
}
printf("Circular Convolution is\n");
for(i=0;i<N;i++)
printf("%d\t",y[i]);
}
71
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.3 Date: / /2020
#include<stdio.h>
#include<math.h>
void main()
{
int N=8,n,k;
float x[8]={1,1,1,1,0,0,0,0};
float pi = 3.1416;
float sumre, sumim;
float cosine =0,sine=0;
float out_real[8],out_imag[8];
72
GURU NANAK DEV ENGG. COLLEGE, BIDAR
EEE DEPARTMENT
Class: 6th sem Sub:DSP Lab Sub Code:18EEL67
Exp. No.4 Date: / /2020
#include<stdio.h>
#define order 1
#define len 4
float y[len],sum;
void main()
{
int n,k;
float a[order+1]={1,-1};
float b[order+1]={1,1};
for(n=0;n<len;n++)
{
sum=0;
for(k=1;k<=order;k++)
{
if((n-k)>=0)
sum=sum+(a[k]*y[n-k]);
}
if(n<=order)
y[n]=b[n]-sum;
else
y[n]=-sum;
printf("response[%d] =%f\n",n,y[n]);
}
}
VIVA QUESTIONS
Q1)State sampling theorem and write the condition for
reconstruction of analog signals.
73
2)What should be the minimum sampling frequency for
reconstruction.
3)What is sampling frequency.
4)Why sampling is required?
5)What is impulse response of a system?
6)What is the importance of impulse response?
7)Write the expression for circular convolution.
8) Write the circular convolution equation in matrix form.
9)What is zero padding?
10)What is the condition to evaluate linear convolution from circular
convolution?
11)What is DFT?Write the expression for it.
12)Why computation of DFT is required?
13)Write time shift property of DFT.
14)Write frequency shift property of DFT.
15)How a digital filter differs from an analog filter?
16)What is an IIR filter?
17)What is an FIR filter?
18)What is order of a filter.
19)Advantages of digital filter.
20)What is frequency transformation?
21)When a digital filter(system) is said to be stable.
22)What are all pole filters.
23)What is Butterworth characteristic?
24)Write the equation to find the order of a chebyshev filter.
25)Typical specifications required to design a digital filter.
26)What is a cascade structure?
27)What is a parallel structure?
28)What is periodic convolution?
74
29)Give examples of one dimensional signals.
30)Examples of two dimensional signals.
75
Digital Signal Processing Lab(18EEL67)
List of Experiments
76