0% found this document useful (0 votes)
273 views68 pages

5th Sem Octave - DSP Manual

This document provides information about the Digital Signal Processing laboratory course for the 5th semester Electronics and Communication Engineering students. It includes the vision, mission and objectives of the institution and department. The course objectives are to simulate and analyze digital signals and systems using tools like MATLAB. The syllabus covers topics like sampling theorem, DFT, convolution, correlation, filter design and their implementation on hardware. The outcomes are that students will be able to understand digital signal concepts, model signals and systems, implement DSP using processors, realize digital filters and write programs to illustrate concepts.

Uploaded by

Kuldeep Karma
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)
273 views68 pages

5th Sem Octave - DSP Manual

This document provides information about the Digital Signal Processing laboratory course for the 5th semester Electronics and Communication Engineering students. It includes the vision, mission and objectives of the institution and department. The course objectives are to simulate and analyze digital signals and systems using tools like MATLAB. The syllabus covers topics like sampling theorem, DFT, convolution, correlation, filter design and their implementation on hardware. The outcomes are that students will be able to understand digital signal concepts, model signals and systems, implement DSP using processors, realize digital filters and write programs to illustrate concepts.

Uploaded by

Kuldeep Karma
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/ 68

Department of Electronics and Communication Engineering

Jnanaprabha, Virgo Nagar Post, Bengaluru- 560049

LABORATORY MANUAL
2022-2023

Semester :V

Subject : DIGITAL SIGNAL PROCESSING LABORATORY

Subject code : 18ECL57

Name of the Student : _________________________


University Seat Number : _________________________
Batch : _________________________
INSTITUTE VISION AND MISSION

VISION
The East Point College of Engineering and Technology aspires to be a globally acclaimed
institution, recognized for excellence in engineering education, applied research and
nurturing students for holistic development.

MISSION
M1: To create engineering graduates through quality education and to nurture innovation,
creativity and excellence in teaching, learning and research

M2: To serve the technical, scientific, economic and societal developmental needs of our
communities

M3: To induce integrity, teamwork, critical thinking, personality development and ethics in
students and to lay the foundation for lifelong learning
Department of Electronics and communication Engineering
DEPARTMENT VISION AND MISSION
VISION
The Department aspires to be a centre of excellence in Electronics and Communication
Engineering to develop competitive and ethical professionals through holistic development.
MISSION
M1: To impart quality education and provide a conducive environment for innovation and
Research
M2: To develop skills to meet the scientific, technological and socio-economic needs
M3: To inculcate professional ethics, team work, leadership qualities and lifelong learning

PROGRAM EDUCATIONAL OBJECTIVES (PEO’s):


PEO-1: To produce graduates to have successful professional career with the acquired
knowledge in Electronics and Communication Engineering to analyse, design, develop and
implement electronic systems
PEO-2: To produce graduates who apply their engineering skills and develop ingenious
solutions for real world problems
PEO-3: To produce graduates who can exhibit leadership qualities, ethical values and adapt to
current trends by engaging in lifelong learning.

PROGRAM SPECIFIC OUTCOMES (PSO’s):

PSO1: To conceptualise, model, design, simulate, analyse, develop, test electronic and
communication systems and solve technical problems arising in the field of Electronics and
Communication Engineering.

PSO2: To specialize in the areas of Electronics and Communication Engineering such as


Analog and Digital electronics, communication, Signal processing, VLSI systems, Embedded
Systems and IOT.

PSO3: To demonstrate building and testing of electronics and communication systems and
evaluate their performance and efficiency using appropriate tools and techniques.
COURSE LEARNING OBJECTIVES

Course Learning Objectives: This course will enable students to

 Simulate discrete time signals and verification of sampling theorem.


 Compute the DFT for a discrete signal and verification of its properties using
OCTAVE.
 Find solution to the difference equations and computation of convolution and
correlation along with the verification of properties.
 Compute and display the filtering operations and compare with the theoretical values.
 Implement the DSP computations on DSP hardware and verify the result.

COURSE OUTCOMES

 Understand the concepts of analog to digital conversion of signals and frequency


domain sampling of signals.
 Model the discrete time signals and systems and verify its properties and results.
 Implement discrete computations using DSP processor and verify the results.
 Realize the digital filters using a simulation tool and analyze the response of the filter
for an audio signal.
 Write programs using Matlab / Scilab/Octave to illustrate DSP concepts.
DIGITAL SIGNAL PROCESSING LABORATORY
Effective from Academic year 2022-2023
SEMESTER-V
Subject Code 18ECL57 CIE Marks 40

Number of Lecture Hours/Week 2 (Tutorial) +2 SEE Marks 60


(Laboratory)
Total Number of Lab Hours 32 Exam Hours 3 Hours

Credits – 2
Course Learning Objectives :
This course will enable students to
 Simulate discrete time signals and verification of sampling theorem.
 Compute the DFT for a discrete signal and verification of its properties using
OCTAVE.
 Find solution to the difference equations and computation of convolution and
correlation along with the verification of properties.
 Compute and display the filtering operations and compare with the theoretical
values.
 Implement the DSP computations on DSP hardware and verify the result.
Syllabus:
PART A
1 Verification of sampling theorem (use interpolation function).
2 Linear and circular convolution of two given sequences, Commutative, distributive
and associative property of convolution.
3 Auto and cross correlation of two sequences and verification of their properties
4 Solving a given difference equation.
5 Computation of N-point DFT of a given sequence and to plot magnitude and phase
spectrum (using DFT equation and verify it by built-in routine).
6 (i) Verification of DFT properties (like Linearity and Parseval’s theorem, etc.)
(ii) DFT computation of square pulse and Sinc function etc.
7 Design and implementation of Low pass and High pass FIR filter to meet the desired
specifications (using different window techniques) and test the filter with an audio
file. Plot the spectrum of audio signal before and after filtering.
8 Design and implementation of a digital HR filter (Low pass and High pass) to meet
given specifications and test with an audio file. Plot the spectrum of audio signal
before and after filtering.
PART B
9 Obtain the Linear convolution of two sequences.

10 Compute Circular convolution of two sequences

11 Compute the N-point DFT of a given sequence.

12 Determine the Impulse response of first order and second order system

13 Generation of sine wave and standard test signals

Course Outcomes:
At the end of this course, students should be able to:

1. Understand the concepts of analog to digital conversion of signals and frequency


domain sampling of signals.
2. Model the discrete time signals and systems and verify its properties and results.
3. Implement discrete computations using DSP processor and verify the results.
4. Realize the digital filters using a simulation tool and analyze the response of the
filter for an audio signal.
5. Write programs using Matlab / Scilab/Octave to illustrate DSP concepts.
Index
Sl Program List CO PO RBT Page
No No
PART A
1 Verification of sampling theorem
CO1 PO3 L2 1
(use interpolation function).
2 Linear and circular convolution of two given
sequences, Commutative, distributive and CO2 PO3 L2 3
associative property of convolution.
3 Auto and cross correlation of two sequences and
CO2 PO3 L2 13
verification of their properties
4 Solving a given difference equation. CO2 PO3 L3 17
5 Computation of N-point DFT of a given sequence
and to plot magnitude and phase spectrum (using CO3 PO3 L2 19
DFT equation and verify it by built-in routine).
6 • Verification of DFT properties
(Like Linearity and Parseval’s theorem, etc.) CO4 PO3 L3 22
• DFT computation of square pulse and Sinc
function etc.
7 Design and implementation of Low pass and High
pass FIR filter to meet the desired specifications CO4,
(using different window techniques) and test the PO3 L3 28
CO5
filter with an audio file. Plot the spectrum of audio
signal before and after filtering.
8 Design and implementation of a digital HR filter
(Low pass and High pass) to meet given CO4,
PO3 L3 30
specifications and test with an audio file. Plot the CO5
spectrum of audio signal before and after filtering.
PART B
9 Determine the Impulse response of first order and
CO4 PO3 L2 38
second order system
10 Obtain the Linear convolution of two sequences. CO3 PO3 L3 40
11 Compute Circular convolution of two sequences CO4 PO3 L3 42
12 Compute the N-point DFT of a given sequence CO4 PO3 L2 44
13 Generation of sine wave and standard test signals CO3 PO3 L3 45
ADDITIONAL LAB PROGRAMS
1 Generation of DTMF signals CO1 PO4 L3 50
2 Implementation of decimation process CO5 PO4 L3 55
3 Implementation of Interpolation process CO5 PO4 L3 58
Viva questions 61
DSP Lab Manual (18ECL57) 2022-23

OCTAVE PROGRAMS

1. Verification of Sampling theorem.

clc;
clear all;
close all;

T=.02; % Time Period of 50 Hz signal


t=0:.00005:.02;

f= 1/T;
x=2*sin(2*pi*t/T);
subplot(2,2,1);
plot(t,x);
title('Continuous signal');
xlabel('t');
ylabel('x(t)');

ts1=0.002; %> NR
ts2=0.01; %=NR
ts3=0.1;%< NR

n=0:10;
xts1=2*sin(2*pi*n*ts1/T);
subplot(2,2,2);
stem(n,xts1);
title('Greater than NR');
xlabel('n');
ylabel('x(n)');

n=0:10;
xts2=2*sin(2*pi*n*ts2/T);
subplot(2,2,3);
stem(n,xts2);
title('Equal to R');
xlabel('n');
ylabel('x(n)');

Department of ECE, EPCET 1


DSP Lab Manual (18ECL57) 2022-23

Output plot:

Department of ECE, EPCET 2


DSP Lab Manual (18ECL57) 2022-23

2A. Linear convolution of two given sequences, Commutative, distributive and associative property of
convolution.

clc;
clear all;
close all;
x=input('enter the first sequence')
y=input('enter the second sequence')
c=conv(x,y)
subplot(3,1,1)
t=0:length(x)-1;
stem(t,x)
xlabel('n')
ylabel('x(n)')
grid on
subplot(3,1,2)
t=0:length(y)-1
stem(t,y)
xlabel('n')
ylabel('y(n)')
grid on
subplot(3,1,3)
t=0:length(c)-1
stem(t,c)
xlabel('n')
ylabel('c(n)')
grid on

Output:

Enter the first sequence [1 1 1 1 1]

x=
1 1 1 1 1

Enter the second sequence [1 2 3 4]

y=
1 2 3 4

c=
1 3 6 10 10 9 7 4

Department of ECE, EPCET 3


DSP Lab Manual (18ECL57) 2022-23

Linear Convolution Properties:

I) Commutative Property

clc;
clear all;
close all;
x=input('enter the first sequence=');
h=input('enter the second sequence=');
y1=conv(x,h);
disp('convolution of two sequences x(n) and h(n) is y1(n)=');
disp(y1);
y2=conv(h,x);
disp('convolution of two sequences h(n) and x(n) is y2(n)=');
disp(y2);
if (y1==y2)
disp('commutative property holds good under convolution');
else
disp('commutative property does not hold good under convolution');
end

II) Associative Property

clc;
clear all;
close all;
x=input('enter the first sequence=');
h1=input('enter the second sequence=');
h2=input('enter the third sequence=');
y1=conv(x,h1);
y2=conv(y1,h2);

disp('convolution of (x(n)*h1(n))*h2(n) is given by y2(n)=');


disp(y2)
y3=conv(h1,h2);
y4=conv(x,y3);
disp('convolution of x(n)*(h1(n)*h2(n))is given by y4(n)=');
disp(y4);
if(y2==y4)
disp('Associative property holds good under convolution');
else
disp('Associative property does not hold good under convolution');
end

Department of ECE, EPCET 4


DSP Lab Manual (18ECL57) 2022-23

III) Distributive Property

clc;
clear all;
close all;
x=input('enter the first sequence=');
n=input (‘enter the time index sequence:’);
h1=input('enter the second sequence=');
h2=input('enter the third sequence=');
h3=h1+h2;
y1=conv(x,h3);

disp('convolution of x(n)*(h1(n))+h2(n)) is given by y1(n)=');


disp(y1)
y2=conv(x,h1);
y3=conv(x,h2);
y4=y2+y3;
disp('convolution of [x(n)*h1(n)]+[x(n)*h2(n)]is y4(n)');
disp(y4);

if (y1==y4)
disp('Distributive property holds good under convolution');
else
disp('Distributive property does not hold good under convolution');
end

Output:

Enter the first sequence: [1 0 1 0]

Enter the time index sequence: [-3 -2 -1 0]

Enter the second sequence: [1 1 1 1]

Enter the time index sequence: [-2 -1 0 1]

% output

1 1 2 2 1 1 0

-5 -4 -3 -2 -1 0 1

1 1 2 2 1 1 0

1 1 2 2 1 1 0

Department of ECE, EPCET 5


DSP Lab Manual (18ECL57) 2022-23

Commutative prop proved

Enter the 3rd seq:[1 0 1 0]


Enter the time index seq:[-3 -2 -1 0]
1 1 3 3 3 3 1 1 0 0
1 1 3 3 3 3 1 1 0 0

Associative prop proved

Enter the first sequence: [1 0 1 0]


Enter the time index sequence: [-3 -2 -1 0]
Enter the second sequence: [1 1 1 1]
Enter the time index sequence: [-2 -1 0 1]

2 1 4 2 2 1 0
2 1 4 2 2 1 0

Distributive prop proved

% Figure Window

Department of ECE, EPCET 6


DSP Lab Manual (18ECL57) 2022-23

Linear Convolution Properties:

I) Commutative Property

clc;
clear all;
close all;

x=input('enter the first sequence=');


h=input('enter the second sequence=');
y1=conv(x,h);
disp('convolution of two sequences x(n) and h(n) is y1(n)=');
disp(y1);
y2=conv(h,x);
disp('convolution of two sequences h(n) and x(n) is y2(n)=');
disp(y2);
if (y1==y2)
disp('commutative property holds good under convolution');
else
disp('commutative property does not hold good under convolution');
end

II) Associative Property

clc;
clear all;
close all;

x=input('enter the first sequence=');


h1=input('enter the second sequence='); h2=input('enter the third sequence='); y1=conv(x,h1);
y2=conv(y1,h2);
disp('convolution of (x(n)*h1(n))*h2(n) is given by y2(n)=');
disp(y2)
y3=conv(h1,h2);
y4=conv(x,y3);

disp('convolution of x(n)*(h1(n)*h2(n))is given by y4(n)=');


disp(y4);
if(y2==y4)
disp('Associative property holds good under convolution'); else
disp('Associative property does not hold good under convolution');
end

Department of ECE, EPCET 7


DSP Lab Manual (18ECL57) 2022-23

III) Distributive Property

clc;
clear all;
close all;

x=input('enter the first sequence=');


n=input (‘enter the time index sequence:’);
h1=input('enter the second sequence=');
h2=input('enter the third sequence=');
h3=h1+h2;
y1=conv(x,h3);

disp('convolution of x(n)*(h1(n))+h2(n)) is given by y1(n)=');


disp(y1)
y2=conv(x,h1);
y3=conv(x,h2);
y4=y2+y3;
disp('convolution of [x(n)*h1(n)]+[x(n)*h2(n)]is y4(n)');
disp(y4);

if (y1==y4)
disp('Distributive property holds good under convolution');
else
disp('Distributive property does not hold good under convolution');
end

Output:

Enter the first sequence: [1 0 1 0]


Enter the time index sequence: [-3 -2 -1 0]
Enter the second sequence: [1 1 1 1]
Enter the time index sequence: [-2 -1 0 1]

% output
1 1 2 2 1 1 0
-5 -4 -3 -2 -1 0 1
1 1 2 2 1 1 0
1 1 2 2 1 1 0
Commutative prop proved

Department of ECE, EPCET 8


DSP Lab Manual (18ECL57) 2022-23

Enter the 3rd seq:[1 0 1 0]


Enter the time index seq:[-3 -2 -1 0]
1 1 3 3 3 3 1 1 0 0
1 1 3 3 3 3 1 1 0 0

Associative prop proved

Enter the first sequence: [1 0 1 0]


Enter the time index sequence: [-3 -2 -1 0]
Enter the second sequence: [1 1 1 1]
Enter the time index sequence: [-2 -1 0 1]

2 1 4 2 2 1 0
2 1 4 2 2 1 0

Distributive prop proved

% Figure Window

Department of ECE, EPCET 9


DSP Lab Manual (18ECL57) 2022-23

2B. Circular convolution of two given sequences, Commutative, distributive and associative property of
convolution.

x1=input('Enter the 1st seq:');


x2=input('Enter the 2nd seq:');
N1=length(x1);
N2=length(x2);
N=max(N1,N2);
X1=[x1,zeros(1,N-N1)];
X2=[x2,zeros(1,N-N2)];
Y=cconv(X1,X2,N);

disp('circular convolution');
disp(Y);
n=0:N-1;
figure;
subplot(3,1,1);
stem(n,X1);
xlabel('time');
ylabel('amplitude');
title('1st seq');
subplot(3,1,2);
stem(n,X2);
xlabel('time');
ylabel('amplitude');
title('2nd seq');
subplot(3,1,3);
stem(n,Y);
xlabel('time');
ylabel('amplitude');
title('circular convolution');
disp(n);

% Commutative property

Y1=cconv(X1,X2,N);
Y2=cconv(X2,X1,N);
disp(Y1);
disp(Y2); if(Y1==Y2)
disp('commmutative prop proved');
else
disp('commmutative prop not proved');
end;

Department of ECE, EPCET 10


DSP Lab Manual (18ECL57) 2022-23

%Associative property

x3=input('Enter the 3RD seq:');


N3=length(x3);
YC=length(Y1);
N6=max(YC,N3);
X3=[x3,zeros(1,N6-N3)];
Y3=cconv(Y1,X3,N6);
disp(Y3);
X4=cconv(X2,X3,N6);
Y4=cconv(X1,X4,N6);
disp(Y4);
if(Y3==Y4)
disp('associative prop proved');
else
disp('associative prop not proved'); end;

% Distributive property

Y5=cconv(X1,(X2+X3),N6);
disp(Y5);
X5=cconv(X1,X3,N6);
Y6=Y1+X5;
disp(Y6); if(Y5==Y6)
disp('distributive prop proved');
else
disp('distributive prop not proved'); end;

Output:
% input

Enter the 1st seq: [0 1 0 1]

Enter the 2nd seq: [1 1 1 1]

Circular convolution

2 2 2 2

% output
0 1 2 3
2 2 2 2
2 2 2 2

Commutative prop proved

Department of ECE, EPCET 11


DSP Lab Manual (18ECL57) 2022-23

Enter the 3rd seq: [1 0 1]

4 4 4 4
4 4 4 4

Associative prop proved

2 4 2 4
2 4 2 4

Distributive prop proved

Output Plot:

Department of ECE, EPCET 12


DSP Lab Manual (18ECL57) 2022-23

3A. Cross correlation of two sequences and verification of their properties.

x=input('enter the first sequence')


y=input('enter the second sequence')
z=xcorr(x, y)
disp(z)
subplot(2,2,3)
t=0:length(z)-1
stem(t,z)
xlabel('n')
ylabel('amplitude')
title('cross correlation')
grid on;

%properties
energy=((sum(x.^2)+sum(y.^2))./2)
co=ceil(length(z)./2);
zo=z(co)
if zo==energy
disp('zo gives energy proved') else
disp('zo gives energy not proved')
end
zright=z(co:1:length(z))
zleft=z(co:-1:1)
if zright==zleft
disp('z is even')
else
disp('z is odd')
end
subplot(2,2,1)
t=0:length(x)-1
stem(t,x)
xlabel('n')
ylabel('x(n)')
title('first input')
grid on;

subplot(2,2,2)
t=0:length(y)-1
stem(t,y)
xlabel('n')
ylabel('y(n)')
title('second input')
grid on;

Department of ECE, EPCET 13


DSP Lab Manual (18ECL57) 2022-23

Output:
enter the first sequence[1 2 3 1]
x=12 31

enter the second sequence[4 3 2 2]


y=4322

z=

t=0 1 2 3 4 5 6

energy = 24
zo = 18

zo gives energy not proved


zright = 18 19 15 4

zleft = 18.0000 13.0000 6.0000 2.0000


z is odd

Department of ECE, EPCET 14


DSP Lab Manual (18ECL57) 2022-23

3B. Auto correlation of two sequences and verification of their properties.

x=input('enter the first sequence')


z=xcorr(x)
disp(z)

subplot(2,2,3)
t=0:length(z)-1
stem(t,z)
xlabel('n')
ylabel('amplitude')
title('cross correlation') grid on;

%properties

energy=sum(x.^2)
co=ceil(length(z)./2);
zo=z(co)
if (zo = = energy)
disp('zo gives energy proved')
else
disp('zo gives energy not proved')
end

zright=z(co:1:length(z))
zleft=z(co:-1:1)
if zright==zleft
disp('z is even')
else
disp('z is odd')
end
subplot(2,2,1)
t=0:length(x)-1
stem(t,x)
xlabel('n')
ylabel('x(n)')
title('first input')
grid on;

Output:

enter the first sequence [1 2 3 4]


x =1 2 3 4

z=
4.0000 11.0000 20.0000 30.0000 20.0000 11.0000 4.0000

Department of ECE, EPCET 15


DSP Lab Manual (18ECL57) 2022-23

4.0000 11.0000 20.0000 30.0000 20.0000 11.0000 4.0000

t=

01 2 3 4 5 6

energy = 30
zo = 30
zo gives energy proved
zright =

30.0000 20.0000 11.0000 4.0000

zleft =

30.0000 20.0000 11.0000 4.0000


z is even

Department of ECE, EPCET 16


DSP Lab Manual (18ECL57) 2022-23

Department of ECE, EPCET 17


DSP Lab Manual (18ECL57) 2022-23

4. Solving a given difference equation.

b=input('enter the numerator co-efficient')


a=input('enter the denominator co-efficient')
n=input('enter the input sequence')
y=filter(b, a, n)
disp(y)
t=0:length(y)-1
stem(t,y)
xlabel('sample')
ylabel('amplitude')
title('diff equation')
grid on

Output1:

Enter the numerator co-efficient [1]


b=1

Enter the denominator co-efficient [1 3]


a=1 3

Enter the input sequence [1 1 1 1 1]


n=
1 1 1 1 1
y=
1 -2 7 -20 61
1 -2 7 -20 61
t=
0 1 2 3 4

Department of ECE, EPCET 18


DSP Lab Manual (18ECL57) 2022-23

Output2:

Enter the numerator co-efficient [1,-1, 0]


b=
1 -1 0
Enter the denominator co-efficient [1,-3/4, 1/8]

a=
1.0000 -0.7500 0.1250

Enter the input sequence [1 1 1 1 1 1 1]


n=
1 1 1 1 1 1 1
y=
1.0000 0.7500 0.4375 0.2344 0.1211 0.0615 0.0310
1.0000 0.7500 0.4375 0.2344 0.1211 0.0615 0.0310
t=
0 1 2 3 4 5 6

Department of ECE, EPCET 19


DSP Lab Manual (18ECL57) 2022-23

5. Computation of N point DFT of a given sequence and to plot magnitude and phase spectrum (using
DFT equation and verify it by built-in routine).

Program using equation method:

clc;
clear all;
close all;

x=input('enter the input sequence')


N=input('enter the number of samples')
n=0:N-1
for k=0:N-1
w=exp((-j.*2.*3.142.*k.*n)./N);
a=w.*x;
X(k+1)=sum(a);
end

disp(X)
magnitude=abs(X)
phase=angle(X)

subplot(2,1,1)
t=0:length(X)-1
stem(t,magnitude)
xlabel('period')
ylabel('magnitude of X(K)')
grid on

subplot(2,1,2)
t=0:length(X)-1
stem(t,phase)
xlabel('period')
ylabel('phase of X(k)')
grid on

Program using built in method:

clc;
clear all;
close all;

xn=input('Enter the input sequence');


N=input('Enter the number of points in DFT');
xk=dft(xn,N);

Department of ECE, EPCET 20


DSP Lab Manual (18ECL57) 2022-23

disp(„DFT X(k) is‟);


disp(X(k));

magxk=abs(X(k));
disp(„Magnitude of X(k)‟);
disp(mag X(k));
phasexk=angle(X(k));
disp(„Phase angle of X(k)‟);
disp(phase X(k));

%Plotting results
k=0:N-1;
subplot(2,1,1);
stem(k,mag X(k));

title(„Magnitude of DFT');
xlabel('frequency');
ylabel('magnitude');
subplot(2,1,2);
stem(k,phase X(k));
title('Phase of DFT');
xlabel('frequency');
ylabel('phase in radians');

Output:

Enter the input sequence [1 0 -1 0]


Enter the number of points in DFT 4
DFT X(k) is
0.0000 + 0.0000i 2.0000 + 0.0000i 0.0000 - 0.0000i 2.0000 + 0.0000i

Magnitude of X(k)
0 2.0000 0.0000 2.0000

Phase angle of X(k)


0 0.0000 -1.5708 0.0000

Department of ECE, EPCET 21


DSP Lab Manual (18ECL57) 2022-23

Output Plot:

Department of ECE, EPCET 22


DSP Lab Manual (18ECL57) 2022-23

6A. Verification of DFT properties (like Linearity and Parseval’s theorem, etc.)

clc;
clear all;
close all;

x1=input('Enter 1st sequence');


x2=input('Enter 2nd sequence');
a=input('Enter a constant value');
b=input('Enter b constant value');

x3=a*x1+b*x2;

y1=fft(x3); disp('LHS=');
disp(y1);

X1=fft(x1);
X2=fft(x2);

Y2=a*X1+b*X2; disp('RHS=');disp(Y2);

if(y1==Y2)

disp('DFT linear property is proved'); else

disp('DFT linear property is not proved'); end;

Output:
%% Input/output

Enter 1st sequence [1 0 1 0]

Enter 2nd sequence [1 0 1 1]

Enter a constant value 1

Enter b constant value 1

LHS=

5.0000 + 0.0000i 0.0000 + 1.0000i 3.0000 + 0.0000i 0.0000 - 1.0000i

RHS=

5.0000 + 0.0000i 0.0000 + 1.0000i 3.0000 + 0.0000i 0.0000 - 1.0000i

DFT linear property is proved

Department of ECE, EPCET 23


DSP Lab Manual (18ECL57) 2022-23

% Parsevals theorem

clc;
close all;
clear all;

x=input('Enter 1st sequence');


y=input('Enter 2nd sequence');

y1=conj(y);
N=length(x);
El=0;
for n=1:N El=El+x(n)*y1(n);
end;
disp('The energy El='); disp(El);
X=fft(x);
Y=fft(y);
Y1=conj(Y);
Er=0;
for k=1:N Er=Er+X(k)*Y1(k)/N;
end;
disp('The energy Er='); disp(Er);
if (El==Er);
disp('Parsevals is proved');
else
disp('Parsevals is not proved');
end;

Output:

%% Input/output

Enter 1st sequence [1 0 1 0]

Enter 2nd sequence [1 0 1 1]

The energy El=

The energy Er=

Parsevals is proved

Department of ECE, EPCET 24


DSP Lab Manual (18ECL57) 2022-23

%% Multiplication in time domain

clc;
close all;
clear all;

x1=input('enter 1st seq');


x2=input('enter 2nd seq');
N=length(x1);
Ml=x1.*x2;

disp('multiplication of x1 and x2 in time domain');


disp(Ml);

X1=fft(x1);
X2=fft(x2);
Mr=(cconv(X1,X2,N))/N;

disp('circular convolution in freq domain');


disp(ifft(Mr));
if(Ml==(ifft(Mr)))
disp('mult prop is proved'); else
disp('mult prop not proved');
end;

Output:

%%Input / Output

enter 1st seq[1 0 1 1] enter 2nd seq[1 1 1 1]

multiplication of x1 and x2 in time domain 1 0 1 1

circular convolution in freq domain 1 0 1 1

mult prop is proved

%% Circular convolution

clc;
clear all;
close all;

x1=input('enter 1st seq');


x2=input('enter 2nd seq');
N=length(x1);

Department of ECE, EPCET 25


DSP Lab Manual (18ECL57) 2022-23

cl=cconv(x1,x2,N);
disp('circular convolution in time domain=');
disp(cl);
X1=fft(x1);
X2=fft(x2);
X3=X1.*X2;
cr=(ifft(X3));
disp('circular convolution in time domain is equal to multiplication in freq domain');
disp(cr);
if(cl==cr)
disp('circular convilution is proved');
else
disp('circular convolution not proved');
end;

Output:

Enter 1st seq[1 0 -1 0]

Enter 2nd seq[1 0 1 1]

Circular convolution in time domain=

0 -1 0 1
Circular convolution in time domain is equal to multiplication in freq domain

0 -1 0 1

Circular convolution prop is proved

Department of ECE, EPCET 26


DSP Lab Manual (18ECL57) 2022-23

6B. DFT computation of square pulse and Sinc function.

%Matlab Code To Find DFT Of Sinc Pulse

clear all;
close all;
t=-pi:0.05:pi;
x=sinc(t);
X=fft(x);
X1=fftshift(X);
subplot(2,1,1);
stem(x);
title('time domain');
subplot(2,1,2);
plot(abs(X1));
title('freq domain');

Output Plot:

Department of ECE, EPCET 27


DSP Lab Manual (18ECL57) 2022-23

%Matlab Code To Find DFT Of Square Pulse

clc;
clear all;
close all;

x=[zeros(1,32),ones(1,64),zeros(1,32)];
X=fft(x);
X1=fftshift(X);
subplot(2,1,1);
plot(x);
title('time domain');
subplot(2,1,2);
plot(abs(X1));
title('freq domain');

Output Plot:

Department of ECE, EPCET 28


DSP Lab Manual (18ECL57) 2022-23

7. Design and implementation of FIR filter to meet given specifications (using different window
techniques).

clc;
clear all;
close all;
w1=input('Enter the pass band edge frequency in rads,w1=');
w2=input('Enter the stop band edge frequency in rads,w2=');
k1=input('Enter the pass band attenuation in dB,k1=');
k2=input('Enter the stop band attenuation in dB,k2=');
wt=(w2-w1);

n=ceil((8*pi)/wt);
if rem(n,2)==0
n=n+1;
end;
disp('The order of the filter is =');
disp(n);

w=hamming(n);
figure(1);
stem(w);
title('Plot of window function');
xlabel('n----------->');
ylabel('w(n)--------->');
disp('The hamming window coefficients are');
disp(w);
hn=fir1(n,wt);
figure(2);
freqz(hn,1,512); grid on;
xlabel('Normalized frequency');
ylabel('Gain in dBs');
title('Frequency response of the FIR Filter');
disp('The unit sample response of FIR filter is h(n)');
disp(hn);

Example: To design a low pass FIR filter using hamming window for the following specifications.

Passband edge frequency=0.5 rads,


Stopband edge frrquency=1 rad
Passband attenuation=1 dB and Stopband attenuation=50 dB.

Department of ECE, EPCET 29


DSP Lab Manual (18ECL57) 2022-23

Result:

Enter the pass band edge frequency in rads,w1=0.5


Enter the stop band edge frequency in rads,w2=1
Enter the pass band attenuation in dB,k1=1
Enter the stop band attenuation in dB,k2=50

The order of the filter is =


51

The hamming window coefficients are 0.0800


0.0836
0.0945
.
.
0.0945
0.0836
0.0800

The unit sample response of FIR filter is h(n)


Columns 1 through 7

0.0007 0.0008 -0.0009 -0.0011 0.0014 0.0018 -0.0023 Columns 8 through 14

-0.0029 0.0037 0.0046 -0.0056 -0.0068 0.0083 0.0100


Columns 50 through 52

-0.0009 0.0008 0.0007

Output Plot:

Department of ECE, EPCET 30


DSP Lab Manual (18ECL57) 2022-23

8A. Design and implementation of IIR (Butterworth) filter to meet given specifications.

clc;
clear all;
close all;
f1=input('Enter the Passband frequency in Hz,f1=');
f2=input('Enter the Stopband frequency in Hz,f2=');
k1=input('Enter the Passband attenuation in dB,k1=');
k2=input('Enter the Stopband attenuation in dB,k2=');
fs=input('Enter the Sampling frequency in Hz,fs=');
T=1/fs;

w1=(2*pi*f1*T);
w2=(2*pi*f2*T);
wp=(2)*tan((w1)/2);
ws=(2)*tan((w2)/2);

[n,wn]=buttord(wp,ws,k1,k2,'s');
disp('The order of the filter is=');
disp(n);

disp('Cut off frequency is =');


disp(wn);
[nu,de]=butter(n,wn,'s');
[b,a]=bilinear(nu,de,1);
[h,w]=freqz(b,a);

semilogx((w*fs)/(2*pi),20*log10(abs(h)));
axis([0 10000 -10 0])

xlabel('w in rads----------------->');
ylabel('20*abs(Hejw)------------------>');
title('Frequency response of the filter');
disp('The Numerator coefficients of H(s) are=');
disp(nu);

disp('The Denominator coefficients of H(s) are=');


disp(de);
disp('The Numerator coefficients of H(Z) are='); disp(b);
disp('The Denominator coefficients of H(Z) are='); disp(a);

Example:

To design a lowpass butterworth filter for the following specifications.


Passband frequency=200Hz, Stopband frequency=300Hz
Passband attenuation=1dB, Stopband attenuation=4dB Sampling frequency=2000Hz

Department of ECE, EPCET 31


DSP Lab Manual (18ECL57) 2022-23

Result:

Enter the Passband frequency in Hz,f1=200


Enter the Stopband frequency in Hz,f2=300
Enter the Passband attenuation in dB,k1=1
Enter the Stopband attenuation in dB,k2=4
Enter the Sampling frequency in Hz,fs=2000

The order of the filter is=


2

Cut off frequency is = 0.9190

The Numerator coefficients of H(s) are= 0 0 0.8446

The Denominator coefficients of H(s) are= 1.0000 1.2997 0.8446

The Numerator coefficients of H(Z) are= 0.1135 0.2269 0.1135

Output Plot:

Department of ECE, EPCET 32


DSP Lab Manual (18ECL57) 2022-23

8B. Design and implementation of IIR (Chebyshev) filter to meet given specifications.

clc;
clear all;
close all;
f1=input('Enter the Passband frequency in Hz,f1=');
f2=input('Enter the Stopband frequency in Hz,f2=');
k1=input('Enter the Passband attenuation in dB,k1=');
k2=input('Enter the Stopband attenuation in dB,k2=');
fs=input('Enter the Sampling frequency in Hz,fs=');
T=1/fs;

w1=(2*pi*f1*T);
w2=(2*pi*f2*T);
wp=(2)*tan((w1)/2);
disp(wp);
ws=(2)*tan((w2)/2);
disp(ws);

[n,wn]=cheb1ord(wp,ws,k1,k2,'s');
disp('The order of the filter is=');
disp(n);
disp('Cut off frequency is =');
disp(wn); [nu,de]=cheby1(n,k1,wn,'s');
[b,a]=bilinear(nu,de,1);
[h,w]=freqz(b,a);
semilogx((w*fs)/(2*pi),20*log10(abs(h)));
axis([0 10000 -10 0])
xlabel('w in rads----------------->');
ylabel('20*abs(Hejw)------------------>');
title('Frequency response of the filter');
disp('The Numerator coefficients of H(s) are=');
disp(nu);
disp('The Denominator coefficients of H(s) are=');
disp(de);
disp('The Numerator coefficients of H(Z) are=');
disp(b);
disp('The Denominator coefficients of H(Z) are='); disp(a);

Example:

To design a lowpass Chebyshev filter for the following specifications.


Passband frequency=100Hz, Stopband frequency=500Hz
Passband attenuation=2, Stopband attenuation=20dB Sampling frequency=4000Hz

Department of ECE, EPCET 33


DSP Lab Manual (18ECL57) 2022-23

Result:
Enter the Passband frequency in Hz,f1=100
Enter the Stopband frequency in Hz,f2=500
Enter the Passband attenuation in dB,k1=2
Enter the Stopband attenuation in dB,k2=20
Enter the Sampling frequency in Hz,fs=4000
0.1574
0.8284
The order of the filter is= 2
Cut off frequency is = 0.1574
The Numerator coefficients of H(s) are = 0 0 0.0162
The Denominator coefficients of H(s) are = 1.0000 0.1265 0.0204
The Numerator coefficients of H(Z) are = 0.0038 0.0076 0.0038
The Denominator coefficients of H(Z) are = 1.0000 -1.8625 0.8816

Output Plot:

Department of ECE, EPCET 34


DSP Lab Manual (18ECL57) 2022-23

INTERFACING PROGRAMS

PROCEDURE TO RUN NON REAL TIME SYSTEMS

Step 1: Debug → Connect.

Step 2:Creat a new project

Project → New →Project Creation → C:\CCstudio_v3.1\MyProject\Project name

Project Type → Executable(.out)

Target → TMS320C67XX

Step3:

Add library file

Go to project → Add files to project → C:\CCstudio_v3.1\C600\cgtools\rts6700

File type → Obiect and library files

Step4:

Add Linker Command file( .cmd)

Go to Project → Add files to project→

→ C:\CCstudio_v3.1\tutorial\dsk6713\hello1\hello

File type →Linker command file

Step5:

Create source file

File→new→Source file →Type the program

→ Save in C:\CCstudio_v3.1\MyProject\Project name\filename.c

File type → C/C++source file(.c)

Department of ECE, EPCET 35


DSP Lab Manual (18ECL57) 2022-23

Step6:

Add source File to project

Go to Project→Add files to project→ C:\CCstudio_v3.1\MyProject\Project Name\filename.c

Click on the file name so that it gets added to the project Step7:

Compile source file

Go to Project → Compile

Step 8:

Rebuild source file

Go to Project→ Rebuild all

Step 9:

To down load source file to the DSK

File → Load program

Debug(.out file) → Filename.out/Projectname.out.

Doubleclick on any of the above so that it will be loaded to the kit

Step10:

To run the source file

Debug→Run

Step11:

Output can be viewed on the output screen/graph

To view the graph

View→Graph→Time/Frequency

Department of ECE, EPCET 36


DSP Lab Manual (18ECL57) 2022-23

CODE COMPOSER STUDIO

The Code Composer Studio (CCS) provides an integrated development environment (IDE) to incorporate the
software tools. CCS includes tools for code generation, such as a C compiler, an assembler, and a linker. It has
graphical capabilities and supports real-time debugging. It provides an easy-to-use software tool to build and
debug programs. The C compiler compiles a C source program with extension .c to produce an assembly
source file with extension .asm. The assembler assembles an.asm source file to produce a machine language
object file with extension .obj. The linker combines object files and object libraries as input to produce an
executable file with extension out. This executable file represents a linked common object file format (COFF),
popular in Unix-based systems and adopted by several makers of digital signal processors. This executable file
can be loaded and run directly on the C6713 processor. To create an application project, one can “add” the
appropriate files to the project.

Compiler/linker options can readily be specified. A number of debugging features are available, including
setting breakpoints and watching variables, viewing memory, registers, and mixed C and assembly code,
graphing results, and monitoring execution time. One can step through a program in different ways (step into,

Department of ECE, EPCET 37


DSP Lab Manual (18ECL57) 2022-23

or over, or out). Real-time analysis can be performed using real-time data exchange (RTDX) associated with
DSP/BIOS .RTDX allows for data exchange between the host and the target and analysis in real time without
stopping the target. Key statistics and performance can be monitored in real time. Through the Joint Team
Action Group (JTAG), communication with on-chip emulation support occurs to control and monitor program
execution. The C6713 DSK board includes a JTAG emulator interface.

Department of ECE, EPCET 38


DSP Lab Manual (18ECL57) 2022-23

9A. Impulse response of first order system.


#include <stdio.h>
float y[2]={0,0};
float x[2]={0,0};
float impulse[3]={1,0,0};
main()
{
int j;
float a[1]={1};
float b[2]={1, -0.5};
for(j=0;j<2;j++)
{
x[0]=impulse[j];
y[0] = (a[0] *x[0]) +(a[1]* x[1] ) - (y[1]*b[1]);
printf("%f\n",y[0]);
y[1]=y[0];
x[1] = x[0];
}
}

Example:
To find the impulse response of a first order system.

Result:
The response of the system is
1.0000
0.5000

Department of ECE, EPCET 39


DSP Lab Manual (18ECL57) 2022-23

9B. Impulse response of second order system.

#include <stdio.h>
float y[3]={0,0,0};
float x[3]={0,0,0};

float impulse[5]={1,0,0,0,0};
main()

int j;

float a[3]={0.1311, 0.2622, 0.1311};


float b[3]={1, -0.7478, 0.2722};
for(j=0;j<3;j++)

x[0]=impulse[j];

y[0] = (a[0] *x[0]) +(a[1]* x[1] ) +(x[2]*a[2]) - (y[1]*b[1])-(y[2]*b[2]);


printf("%f\n",y[0]);

y[2]=y[1];

y[1]=y[0];

x[2]=x[1]; x[1] = x[0];

Example:

To find the impulse response of a second order system.

Result:

The response of the system is 0.131100, 0 .360237, 0.36479

Department of ECE, EPCET 40


DSP Lab Manual (18ECL57) 2022-23

10. Linear convolution of two sequences.

#include<stdio.h>
int x[15]={1,2,3,4,5,6,0,0,0,0,0,0}; /*Input Signal Samples*/
int h[15]={1,2,3,4,5,6,0,0,0,0,0,0}; /*Impulse Response Co-efficients*/
int y[20];
main()
{ int m=6; /*Length of i/p samples sequence*/
int n=6; /*Length of impulse response Co-efficients */
int i=0,j;
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
printf("The linear convolution for the two given sequences is\n");
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}
Example:
To find the linear convolution for the given sequences x(n)={1 2 3 4 5 6} and h(n)={ 1 2 3 4 5 6}
Result:
The linear convolution for the two given sequences is
1 4 10 20 35 56 70 76 73 60 3

Department of ECE, EPCET 41


DSP Lab Manual (18ECL57) 2022-23

Output Plot:

Plot of the input sequences x(n) and h(n)

Plot of the linearly convoluted sequence y(n)

Department of ECE, EPCET 42


DSP Lab Manual (18ECL57) 2022-23

11. Circular convolution of two sequences.

#include<stdio.h>
#include<math.h> int y[10];
main()
{
int x[2]={1,-1};
int h[4]={1,0,-1,0}; int N=4;
int k,i,n; for(n=0;n<N;n++)
{
y[n]=0;
for(k=0;k<N;k++)
{
i=(n-k)%N; if(i<0) i=i+N;
y[n]+=x[k]*h[i];
}
printf("%d\n",y[n]);
}
}

Output:
%Length of the first sequence: 2
%Length of the second sequence: 4
%The first sequence: 1 -1
%The second sequence: 1 0 -1 0

y[0]=1
y[1]=-1
y[2]=-1
y[3]=1

Department of ECE, EPCET 43


DSP Lab Manual (18ECL57) 2022-23

Output Plot:

Department of ECE, EPCET 44


DSP Lab Manual (18ECL57) 2022-23

12. N-point DFT of a given sequence.

#include <stdio.h>
#include<math.h>
void main(void)
{
int N=4;
int x[4]={1,0,-1,0};
float pi=3.1416;
float sumre=0,sumim=0; float cosine=0,sine=0;
float out_re[4]={0,0}, out_im[4]={0,0};
int n=0,k=0;
for (k=0;k<N;k++)
{
sumre=0;
sumim=0;
for (n=0;n<N;n++)
{
cosine=cos(2*pi*k*n/N);
sine=sin(2*pi*k*n/N);
sumre=sumre+x[n]*cosine; sumim= sumim-x[n]*sine;
}
out_re[k]=sumre; out_im[k]=sumim;
printf("x[%d]=%7.3f%7.3fj\n",k,out_re[k],out_im[k]);
}
}

Result:

[0]0.0000.000
[1]2.0000.000
[2]0.000-0.000
[3]2.0000.000

Department of ECE, EPCET 45


DSP Lab Manual (18ECL57) 2022-23

13. A. Generation of Sine wave.

#include "L138_LCDK_aic3106_init.h"
#define LOOPLENGTH 48
#define BUFLENGTH 256

int16_t sine_table1[LOOPLENGTH] = { 0, 1305, 2588, 3827, 5000, 6088, 7071, 7934, 8660,
9239, 9659, 9914, 10000, 9914, 9659, 9239, 8660, 7934, 7071, 6088, 5000,
3827, 2588, 1305, 0, -1305, -2588, -3827, -5000, -6088, -7071, -7934,
-8660, -9239, -9659, -9914, -10000, -9914, -9659, -9239, -8660, -7934,
-7071, -6088, -5000, -3827, -2588, -1305 };

int16_t sine_ptr = 0; //pointer to LUT


int16_t buffer[BUFLENGTH];

int16_t buf_ptr = 0;

interrupt void interrupt5(void) //ISR


{
int16_t sample;

sample = sine_table1[sine_ptr]; //Read Sample table from 0


output_left_sample(sample); //output sample data which has been read
sine_ptr = (sine_ptr+1)%LOOPLENGTH; // increment sine table to next sample
buffer[buf_ptr] = (int16_t)(sample); // Save the Sample data into the buffer
buf_ptr = (buf_ptr+1)%BUFLENGTH; // increment Buffer

return;
}

Department of ECE, EPCET 46


DSP Lab Manual (18ECL57) 2022-23

int main(void)
{

L138_initialise_intr(FS_48000_HZ,ADC_GAIN_0DB, DAC_ATTEN_0DB,LCDK_LINE_INPUT); //
initilize the Codec
while (1);

Output:

Department of ECE, EPCET 47


DSP Lab Manual (18ECL57) 2022-23

13. B. Generation of Square wave.

#include "L138_LCDK_aic3106_init.h"
#define LOOPLENGTH 64

int16_t square_table[LOOPLENGTH] =
{10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
-10000,-10000,-10000,-10000,-10000,-10000,-10000,-10000,
-10000,-10000,-10000,-10000,-10000,-10000,-10000,-10000,
-10000,-10000,-10000,-10000,-10000,-10000,-10000,-10000,
-10000,-10000,-10000,-10000,-10000,-10000,-10000,-10000};

int16_t loopindex = 0;

interrupt void interrupt4(void) // interrupt service routine


{
output_left_sample(square_table[loopindex++]);
if (loopindex >= LOOPLENGTH)
loopindex = 0;
return;
}

int main(void)
{
L138_initialise_intr(FS_8000_HZ,ADC_GAIN_0DB,DAC_ATTEN_0DB,LCDK_LINE_INPUT);
while(1);
}

Department of ECE, EPCET 48


DSP Lab Manual (18ECL57) 2022-23

Output:

Department of ECE, EPCET 49


DSP Lab Manual (18ECL57) 2022-23

Additional Lab Programs

Program 1: GENERATION OF DTMF SIGNALS


Theory: The DTMF stands for “Dual Tone Multi Frequency”, and is a method of representing digits
with tone frequencies, in order to transmit them over an analog communications network, for
example a telephone line. In telephone networks, DTMF signals are used to encode dial trains and
other information. Dual-tone Multi-Frequency (DTMF) signaling is the basis for voice
communications control and is widely used worldwide in modern telephony to dial numbers and
configure switchboards. It is also used in systems such as in voice mail, electronic mail and telephone
banking. A DTMF signal consists of the sum of two sinusoids - or tones - with frequencies taken
from two mutually exclusive groups. These frequencies were chosen to prevent any harmonics from
being incorrectly detected by the receiver as some other DTMF frequency. Each pair of tones
contains one frequency of the low group (697 Hz, 770 Hz, 852 Hz, 941 Hz) and one frequency of the
high group (1209 Hz, 1336 Hz, 1477Hz) and represents a unique symbol.

Frequency 1209 Hz 1336 Hz 1477 Hz


697 Hz 1 2 3
770 Hz 4 5 6
852 Hz 7 8 9
941 Hz * 0 #

Department of ECE, EPCET 50


DSP Lab Manual (18ECL57) 2022-23

PROGRAM:
Clc;
Clear all;
Close all;
t = -2:0.05:2;
x=input('enter the input number');
fr1=697;
fr2=770;
fr3=852;
fr4=941;
fc1=1209;
fc2=1336;
fc3=1477;
fc4=1633;
y0 = sin(2*pi*fr4*t) + sin(2*pi*fc2*t); %0
y1 = sin(2*pi*fr1*t) + sin(2*pi*fc1*t); %1
y2 = sin(2*pi*fr1*t) + sin(2*pi*fc2*t); %2
y3 = sin(2*pi*fr1*t) + sin(2*pi*fc3*t); %3
y4 = sin(2*pi*fr2*t) + sin(2*pi*fc1*t); %4
y5 = sin(2*pi*fr2*t) + sin(2*pi*fc2*t); %5
y6 = sin(2*pi*fr2*t) + sin(2*pi*fc3*t); %6
y7 = sin(2*pi*fr3*t) + sin(2*pi*fc1*t); %7
y8 = sin(2*pi*fr3*t) + sin(2*pi*fc2*t); %8
y9 = sin(2*pi*fr3*t) + sin(2*pi*fc3*t); %9
y_start = sin(2*pi*fr4*t) + sin(2*pi*fc1*t); % *
y_canc = sin(2*pi*fr4*t) + sin(2*pi*fc3*t); % #
if (x==1)
plot(t,y1)
xlabel('time(t)')

Department of ECE, EPCET 51


DSP Lab Manual (18ECL57) 2022-23

ylabel('amplitude')
elseif (x==2)
plot(t,y2)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==3)
plot(t,y3)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==4)
plot(t,y4)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==5)
plot(t,y5)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==6)
plot(t,y6)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==7)
plot(t,y7)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==8)
plot(t,y8)
xlabel('time(t)')
ylabel('amplitude')

Department of ECE, EPCET 52


DSP Lab Manual (18ECL57) 2022-23

elseif (x==9)
plot(t,y9)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==0)
plot(t,y0)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==11)
plot(t,y_start)
xlabel('time(t)')
ylabel('amplitude')
elseif (x==12)
plot(t,y_canc)
xlabel('time(t)')
ylabel('amplitude')
else
disp('enter the correct input')
end
INPUT:
Enter the input number = 7
Output Waveform:

Department of ECE, EPCET 53


DSP Lab Manual (18ECL57) 2022-23

VIVA QUESTIONS:
1. Expand DTMF?
2. Define frequency groups for all symbols?
3. Define DTMF?
4. Give the applications of DTMF?
5. Define low frequency group and high frequency group?
Exercise:
1. Generate DTMF signal for the symbols 5, 8, 3 and #.

Department of ECE, EPCET 54


DSP Lab Manual (18ECL57) 2022-23

Program 2: IMPLEMENTATION OF DECIMATION PROCESS


Theory: “Decimation” is the process of reducing the sampling rate.
“Downsampling” is a more specific term which refers to just the process of throwing away samples,
without the lowpass filtering operation. The most immediate reason to decimate is simply to reduce
the sampling rate at the output of one system so a system operating at a lower sampling rate can input
the signal. But a much more common motivation for decimation is to reduce the cost of processing:
the calculation and/or memory required to implement a DSP system generally is proportional to the
sampling rate, so the use of a lower sampling rate usually results in a cheaper implementation.

Algorithm:
Step I : Define down sampling factor and input frequencies f1 and f2
Step II : Represent input sequence with frequencies f1 and f2
Step III : Perform the decimation on input signal using matlab command decimate.
Step IV : Plot the input and output sequence

Department of ECE, EPCET 55


DSP Lab Manual (18ECL57) 2022-23

PROGRAM:
Clc;
Clear all;
Close all;
D=input('enter the downsampling factor');
L=input('enter the length of the input signal');
f1=input('enter the frequency of first sinusodal');
f2=input('enter the frequency of second sinusodal');
n=0:L-1; x=sin(2*pi*f1*n)+sin(2*pi*f2*n);
y=decimate(x,D,'fir');
subplot(2,1,1);
stem(n,x(1:L));
title('input sequence');
xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m=0:(L/D)-1;
stem(m,y(1:L/D));
title('Decimated sequence');
xlabel('time(n)');
ylabel('amplitude');

INPUT:
enter the downsampling factor = 5
enter the length of the input signal = 100
enter the frequency of first sinusoidal = 0.01
enter the frequency of second sinusoidal = 0.03

Department of ECE, EPCET 56


DSP Lab Manual (18ECL57) 2022-23

Output Waveforms:

VIVA QUESTIONS:
1. Explain about multi rate digital signal processing.
2. List the Applications of multi rate digital signal processing.
3. Define interpolation.
4. Define decimation.
5. Define aliasing
Exercise:
1. Perform Decimation on the input signal x(n)=cos(2*pi*30*n).

Department of ECE, EPCET 57


DSP Lab Manual (18ECL57) 2022-23

Program 3: IMPLEMENTATION OF INTERPOLATION PROCESS


Theory: “Upsampling” is the process of inserting zero-valued samples between original samples to
increase the sampling rate. (This is called “zero-stuffing”.) “Interpolation”, is the process of
upsampling followed by filtering. The filtering removes the undesired spectral images. The primary
reason to interpolate is simply to increase the sampling rate at the output of one system so that
another system operating at a higher sampling rate can input the signal.

Algorithm:
Step I : Define up sampling factor and input frequencies f1 and f2
Step II : Represent input sequence with frequencies f1 and f2
Step III: Perform the interpolation on input signal using matlab command interp.
Step IV : Plot the input and output signal/sequence.

Department of ECE, EPCET 58


DSP Lab Manual (18ECL57) 2022-23

PROGRAM:
Clc;
Clear all;
Close all;
L=input('enter the upsampling factor');
N=input('enter the length of the input signal'); % Length should be greater than 8
f1=input('enter the frequency of first sinusodal');
f2=input('enter the frequency of second sinusodal');
n=0:N-1;
x=sin(2*pi*f1*n)+sin(2*pi*f2*n);
y=interp(x,L);
subplot(2,1,1)
stem(n,x(1:N))
title('input sequence');
xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m=0:N*L-1;
stem(m,y(1:N*L))
title('output sequence ');
xlabel('time(n)');
ylabel('amplitude');
INPUT:
enter the upsampling factor = 5
enter the length of the input signal = 9
enter the frequency of first sinusoidal = 0.1
enter the frequency of second sinusoidal = 0.3

Department of ECE, EPCET 59


DSP Lab Manual (18ECL57) 2022-23

Output Waveforms:

VIVA QUESTIONS:
1. Explain about multi rate digital signal processing.
2. List the Applications of multi rate digital signal processing.
3. Define interpolation.
4. Define decimation.
5. Define aliasing.
Exercise:
1. Perform interpolation on the input signal x(n)=cos(2*pi*30*n).

Department of ECE, EPCET 60


DSP Lab Manual (18ECL57) 2022-23

VIVA Questions
1. What is Matlab?
2. What are the applications of Matlab?
3. State sampling theorem.
4. What is meant by Nyquist rate and Nyquist criteria?
5. Explain scaling and superposition properties of a system.
6. What is meant by linearity of a system and how it is related to scaling and superposition?
7. What is impulse function?
8. What is meant by impulse response?
9. What is energy signal ? How to calculate energy of a signal?
10. What is power signal ? How to calculate power of a signal?
11. Differentiate between even and odd signals.
12. Explain time invariance property of a system with an example.
13. What is memory less system?
14. When a system is said to have memory?
15. What is causality?
16. Explain linear convolution and circular convolution.
17. What is the length of linear and circular convolutions if the two sequences are having the
unequal lengths?
18. What are Fourier series and Fourier transform?
19. What are the advantages and special applications of Fourier transform, Fourier series, Z-
transforms and Laplace transform?
20. Differentiate between DTFT and DFT. Why it is advantageous to use DFT in computers
rather than DTFT?

Department of ECE, EPCET 61

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