You are on page 1of 90

DIGITAL SIGNAL PROCESSING

LAB
(20EC6103)
III-B. TECH II-SEMSTER
(AR20)

STUDENT LABORATORY MANUAL


Prepared By
Mrs. B. PRIYANKA
Assistant Professor

DEPARTMENT OF ELECTRONICS & COMMUNICATION


ENGINEERING
RAGHU INSTITUTE OF TECHNOLOGY
(AUTONOMOUS)
(Approved by AICTE, New Delhi and Permanently Affiliated to JNTUK, Kakinada
Accredited by NAAC with 'A' Grade, Re-Accredited by NBA, Listed u/s 2(f) & 12(B) of UGC Act 1956)
Dakamarri (V), Bheemili (M), Visakhapatnam-531162, Andhra Pradesh
Phone: +91-8922-248003, 248013
Email:principal@raghuinstech.com website:raghuinstech.com
RAGHU INSTITUTE OF TECHNOLOGY
(AUTONOMOUS)
(Approved by AICTE, New Delhi & Permanently Affiliated to JNTUK, Kakinada)
Accredited by NBA (ECE, EEE, MECH, CSE) & NAAC With ‘A’ Grade,
Listed u/s 2(f) & 12(B) of UGC Act 1956
Dakamarri, Bheemunipatnam Mandal, Visakhapatnam Dist. – 531 162 (A.P.)
Phone: +91-8922-248003, 248013
Email:principal@raghuinstech.com website:raghuinstech.com

CERTIFICATE

Name of the Student :


Roll Number :
Name of the Laboratory : Digital Signal Processing
Lab Code : 20EC6103
Program : B. Tech
Department : Electronics & Communication Engineering
Year : III
Semester : II
Regulation : AR20
Academic Year :
Number of Experiments done :

Signature of Lab In-Charge(s) HOD – ECE


INDEX
Exp.
No. PAGE Marks/
Date Name of the Experiment Remarks
NO. Grade
RAGHU INSTITUTE OF TECHNOLOGY
Dakamarri (V), Bheemunipatnam (M), Visakhapatnam, A.P-531162
Email:principal@raghuinstech.com website:raghuinstech.com
Phone: +91-8922-248003,248013

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

VISION AND MISSION OF THE INSTITUTE

Vision

“Raghu Institute of Technology has a clear vision of becoming a leading institution of higher learning
in technical education in the world by building on the best of instructional infrastructure, enlisting the
service of expert faculty and strengthening strategic linkage with the industry and other educational
institutions”.

Mission

“Raghu Institute of Technology strives to train the students in technical education with moral values and
discipline among the students, so that their future is blossomed with good culture. The Institute aims to
chisel the students to be endowed with a perfect synthesis of human values, ancient wisdom and modern
thoughts that will enable to build their career”.

VISION AND MISSION OF THE DEPARTMENT

Vision

“Lead in the creation and development of intellectual and human capital in Electronics and
Communication Engineering and their applications in order to foster the technological, economic and
social enrichment of the State of Andhra Pradesh, the nation and the world”.

Mission

By imparting quality technical education to provide excellence in education for the students to
M1
compete internationally.
To make the students responsible towards the ethical, environmental and economic growth of
M2
the society.

i
To improve the level of perception of students which helps to disseminate knowledge essential
M3
to meet local & global needs in the field of Electronics and Communication Engineering.
M4 To develop consciousness in the young minds that can understand universal moral values.

PROGRAM EDUCATIONAL OBJECTIVES (PEOs)

1. Domain Knowledge: To have thorough knowledge and technical skills required to remain
productive.
2. Communication Skills & Employability: To apply technical knowledge and skills as Electronics
and Communication Engineer to provide effective solutions in industrial and governmental
organizations.
3. Lifelong Learning & Social Concern: To achieve success with awareness of entrepreneurship
skills along with ability for lifelong learning in pursuit of professional and social development that
meet the emerging and evolving demands for a successful career.

PROGRAM OUTCOMES (POs)

1. Engineering Knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering problems.
2. Problem Analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate consideration
for the public health and safety, and the cultural, societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with
an understanding of the limitations.

ii
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for
sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms
of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive clear
instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and leader
in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.

PROGRAM SPECIFIC OUTCOMES (PSOs)

1. Competence in design and analysis of Large-Scale Integrated Circuits, Embedded Systems to


develop various applications of IoT to contribute towards digitalization.
2. An ability to provide cost effective and appropriate solutions to complex industrial & real world,
Electronics and Communication Engineering problems using advanced tools and techniques.

iii
III Year-II semester L T P C
0 0 3 1.5

20EC6103: DIGITAL SIGNAL PROCESSING LAB

List of Experiments:

1. To find the linear and circular convolution for the given two sequences.
2. To find Auto correlation and Cross Correlation for the given two sequences.
3. Implementation of linear convolution using DFT (Overlap-add and Save method)
4. Computation of N-Point DFT of a sequence and to plot magnitude and phase spectrum.
5. Implementation of Decimation-in-time radix-2 FFT algorithm
6. Implementation of Decimation-in-frequency radix-2 FFT algorithm
7. Design of IIR filters (LPF/HPF) and demonstrates the filtering operation.
8. Design of FIR filters (LPF/HPF) and demonstrates the filtering operation.
9. Implementation of Decimation and Interpolation Process
10. Implementation of I/D sampling rate converters
11. To perform MAC operation using various addressing modes in DSP processors
12. Implementation of Up sampling and Down sampling operations in DSP processors

Equipment required for Laboratory:

1. MATLAB/SCI Lab/Equivalent Industrial standard licensed simulation software tool.

2. Computer systems with reputed specifications

3. DSP processor

iv
INSTRUCTIONS TO THE STUDENTS

Do’s

1. Always sit at your assigned computer unless a teacher moves you.

2. When you leave, make sure your computer is properly shut down

3. Always save the progress of your work

4. Observation book of the present lab experiment should be get corrected on the same day
and Record should be corrected on the next scheduled lab session

5.Sign in the log register after entering into the lab

6. Report any problem with your computer to the teacher / laboratory technician
immediately.

Don’ts

1. Do not wander around the room and distract other students

2. Do not use a flash drive on lab computers.

3. Do not upload, delete or alter any software on the lab PC.

4. Do not bring any food or drinks into the Lab

5. Don’t change the computer settings.

6. Don’t copy the work of other students

v
CONTENTS

S. No Name of the Experiment Page No


INTRODUCTION TO MATLAB 1-8
COMMON PROCEDURE TO RUN PROGRAM ON MATLAB 9
INTRODUCTION TO DSP PROCESSORS (TMS320C6713DSK) 62-67
INTRODUCTION CODE COMPOSOR STUDIO 68-70
1 To find the linear and circular convolution for the given two sequences. 10-15

2 To find Auto correlation and Cross Correlation for the given two sequences. 16-21

3 Implementation of linear convolution using DFT(Overlap-add and Save method) 22-27

4 Computation of N-Point DFT of a sequence and to plot magnitude and phase 28-31
spectrum.
5 Implementation of Decimation-in-time radix-2 FFT algorithm 32-35

6 Implementation of Decimation-in-frequency radix-2 FFT algorithm 36-39

7 Design of IIR filters(LPF/HPF) and demonstrates the filtering operation 40-44

8 Design of FIR filters(LPF/HPF) and demonstrates the filtering operation 45-52

9 Implementation of Decimation and Interpolation Process 53-58

10 Implementation of I/D sampling rate converters 59-61

To perform MAC operation using various addressing modes in DSP processors


11 71-75

12 Implementation of Up-sampling and Down sampling operations in DSP 76-81


processors

v
Department of Electronics & Communication Engineering Digital Signal Processing Lab

INTRODUCTION TO MATLAB

MATLAB (MATRIX LABORATORY):

MATLAB is a software package for high-performance language for technical computing. It integrates
computation, visualization, and programming in an easy-to-use environment where problems and
solutions are expressed in familiar mathematical notation. Typical uses include the following.

 Math and computation


 Algorithm development
 Data acquisition
 Modeling, simulation, and prototyping
 Data analysis, exploration, and visualization
 Scientific and engineering graphics
 Application development, including graphical user interface building

The name MATLAB stands for matrix laboratory. MATLAB was originally written to provide easy
access to matrix software developed by the LINPACK and EISPACK projects. Today, MATLAB
engines incorporate the LAPACK and BLAS libraries, embedding the state of the art in software for
matrix computation.

MATLAB has evolved over a period of years with input from many users. In university environments,
it is the standard instructional tool for introductory and advanced courses in mathematics, engineering,
and science. In industry, MATLAB is the tool of choice for high-productivity research, development,
and analysis.

MATLAB features a family of add-on application-specific solutions calledtoolboxes. Very important


to most users of MATLAB, toolboxes allow learning and applying specialized technology. Toolboxes
are comprehensive collections of MATLAB functions (M-files) that extend the MATLAB environment
to solve particular classes of problems. Areas in which toolboxes are available include Image
processing, signal processing, control systems, neural networks, fuzzy logic, wavelets, simulation, and
manyothers.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 1


Department of Electronics & Communication Engineering Digital Signal Processing Lab

The main features of MATLAB:

1. Advance algorithm for high performance numerical computation, especially in the Field matrix
algebra
2. A large collection of predefined mathematical functions and the ability to defineone’s own
functions.
3. Two-and three-dimensional graphics for plotting and displaying data.
4. A complete online help system
5. Powerful, matrix or vector oriented high level programming language for individual applications.
6. Toolboxes available for solving advanced problems in several application areas.

In the following sections, individual elements of MATLAB operations are explained in detail.

EXPRESSIONS:
Like most other programming languages, mat lab provides mathematical expressions, but unlike most
programming languages these expressions involve entire matrices. The building blocks of expressions
are
 Variables
 Numbers
 Operators
 Functions

HANDLING MATRICES:

MATLAB was mainly designed to deal with matrices in MATLAB a matrix is a rectangular array of
numbers so scalars can be interpreted to be 1x1 matrices and vectors are matrices with only one row or
column. MATLAB has other ways to store both numeric and non-numeric data, but in the beginning
of learning MATLAB, it is usually best to think of everything as a matrix. The operations in MATLAB
are designed to be as natural as possible. Where other programming languages work only with single
numbers, MATLAB allows with entire matrices quickly and easily.
ENTERING MATRICES AND ADDRESSING THE ELEMENTS:
The elements of matrix must be entered one-by-one in a list where the elements of row must be
separated with commas or blank spaces and rows are divided by semicolons.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 2


Department of Electronics & Communication Engineering Digital Signal Processing Lab

The whole list must be surrounded with square brackets, e.g.


>> A= [1 2 3;8 6 4;3 6 9]
After pressing “Enter” MATLAB displays the numbers entered in the command line
A= 123
864
369
Addressing an element of a matrix is also very easy. The n th element of the mth column in a matrix A
from above is A (n, m). So, typing
>>A (1,3) + A (2,1) + A (3,2)
Will compute the answer >> ans=17
The kth to lth elements of the mth to nth columns can be addressed by A(k:l,m:n), e.g.
>>A(2:3,1:2)
Ans = 8 6
3 6
Further examples:
>>A(1,1:2)
Addresses the first two elements of the first row.
Ans=12
>>A(:,2) =>Addresses all elements of second column.
Ans = 8
6
4
GENERATING MATRICES:
There are different ways to generate matrices. Assigning elements explicitly was presented in the
above topic. To create a row vector with 101 equidistant values starting at 0 and ending by -, this
method would be very tedious. So two other possibilities are shown below
>>X=linspace(0,pi,101)
Or
>>X=(0:0.01:1)*pi
In the first case, MATLAB function linspace is used to create X. The functions arguments are described
by:
linspace(first value, last value, number of values)
Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 3
Department of Electronics & Communication Engineering Digital Signal Processing Lab

With the default number of values =100.


In the second case, the colon notation(0:0.01:1) creates an array that starts at 0, increments by 0.01 and
ends at 1. Afterwards each element in this array is multiplied by pi to create the desired values in X.
Both of these array creation forms are common in MATLAB. While the colon notation form allows to
specify the increment between data elements directly, but not the number of elements, the MATLAB
function linspace allows to specify the number of data elements directly, but not the increment value
between these data elements.
The colon notation is very often used in MATLAB; therefore a closer look should be taken on it. (first
value: increment: last value) creates an array starting at first value, ending at last value with an
increment which can be negative as well, e.g.
>>V= (10:2:0)
V=10 8 6 4 2 0
If the increment is 1, then its usage is optional:
>>W= (5:10)
W=5 6 7 8 9 10
MATLAB also provides four functions that generates basic matrices: zeros, ones, rand and randn.
Some examples
>>B= zeros(3,4)
B= 0 0 0 0
0000
0000
>>C= ones(2,5)*6
C=6 6 6 6 6
66666
>>D= rand(1,5) generates uniformly distributed random elements.
D=0.5028 0.7095 0.4289 0.3046 0.1897
>>E= randn(3,3)generates normally –also called Gaussian – distributed random elements.
E= -0.4326 0.2877 1.1892
-1.6656 -1.1465 -0.0376

0.1253 1909 0.3273

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 4


Department of Electronics & Communication Engineering Digital Signal Processing Lab

CONCATENATION:
Concatenation is the process of joining small matrices to make bigger ones. In fact, the first matrix A
was created by concatenating its individual elements. The pair of square brackets, [ ], is the
Concatenation operator. For an example, start with the 3x3 matrix A, form
>>F= [A A+10;A*2 A*4].
The result is a 6x6 matrix, obtained by joining the four submatrices.
F= 1 2 3 11 12 13
8 6 4 18 16 14
3 6 9 13 16 19
2 4 6 4 8 12
16 2 8 32 24 16
6 12 19 12 24 38

FILE TYPES:
MATLAB has three types of files for storing information:
M-files are standard ASCII text files, with .m extension to the file name. There are two types of these
files: script file and function files. Most of the programs we write in mat lab are saved as M-files. All
built in functions in matlab are M-files, most of which reside on our computer in precompiled format.
Some built-in functions are provided with source code in readable M-files so that they can be copied
and modified.

Mat-files are binary data files, with .mat extension to the file name. Mat-files are created by mat lab
when we save data with the save command. The data is written in a special format that only mat lab
can read. Mat-files can be loaded in to mat lab with the load command.

M-FILES:
In MATLAB we write our programs in M-file. M-files are ordinary ASCII text files written in mat
lab’s language. They are called M-files because they must have ‘.m’ at the end of their name. M-files
can be created using any editor or word processing applications. There are two types of M-files –script
files and function files.
A script file is an M-file with a set of valid mat lab commands in it. A script file is executed by typing
the name of the file and the command line. It is equivalent to typing all the commands stored in the

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 5


Department of Electronics & Communication Engineering Digital Signal Processing Lab

script file, one by one, at the mat lab prompt. Naturally, script files work on global variables, i.e
variables currently present in the workspace. Results obtained from executing script files are left in the
workspace. A script file may contain any number of commands including those that call built-in
functions or function written by us. Script files are useful when we have to repeat the set of commands
several times.

A function file is also an M-file like a script file, except that the variables in the function file are all
local. Function files are like programs or subroutines in Fortran, procedures in Pascal, and functions in
C. A function file begins with a function definition line, which has a well defined list of inputs and
outputs. Without this line, the file becomes a script file.

MATLAB WINDOWS:

MATLAB works through three basic windows they are,


COMMAND WINDOW:
This is the main window. It is characterized by the MATLAB command prompt ‘>>’. When we launch
the application program, MATLAB puts us in this window. All command including those for running
user-written programs, are typed in this window at the MATLAB prompt. In MATLAB 6, this window
is a part of the MATLAB window that contains three other smaller windows.
WORKSPACE:
The sub window lists all variables that we have generated so far and shows their type and size. We can
do various things with these variables, such as plotting, by clicking on a variable and then using the
right button on the mouse to select our option.
COMMAND HISTORY:
All commands typed on the MATLAB prompt in the command window get recorded, even across
multiple sessions, in this window. We can select a command from this window with the mouse and
execute it in the command window by double clicking on it. We can also select a set of commands from
this window and create an M-file with the right click on the mouse.
CURRENT DIRECTORY:
This is where all our files from the current directory are listed. We can do file navigation here. We also
have several options of what we can do with a file once we select it. To see the option, click the right
button of the mouse after selecting a file. We can run M-files, rename them, delete them, etc.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 6


Department of Electronics & Communication Engineering Digital Signal Processing Lab

GRAPHICAL WINDOW:
The output of all graphics commands typed in the command window are flushed to the graphics or
Figure window, a separate gray window with white background colour. The user can create as many
figure windows as the system memory will allow.
EDIT WINDOW:
This is where we write, edit, create, and save our own programs in files called ‘M-files’. We can use
any text editor to carry out these tasks. On most systems, MATLAB provides its own built-in editor.
However, we can use our own editor by typing the standard file-editing command that we normally use
on our system.
FLOW CONTROL:
Computer programming languages offer possibilities to allow the programmer to control the flow of
command execution. This flow control is based on decision making structures. Some of the most
important structures are the for-loop, the while loop and the if-else-end-structure. Since the
constructions often affect several MATLAB commands, they are mostly used in m-files. The for-loop
repeats a group of statement a fixed, predetermined number of times. The general form of for-loop is
>>for x = array
Commands…..
End
The commands…between for and the end statements are executed one time for every column in
array. For
Example
>> for k = 1:10
z(k)=2*I;
End
>>z
z = [2 4 6 8 10 12 14 16 18 20]
it is good idea to indent the loops for readability, especially when they are nested.
>>for 1=1.5
for m=1:8
H(1,m) =1/1+m;
end
end
Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 7
Department of Electronics & Communication Engineering Digital Signal Processing Lab

WORKING WITH MATLAB:


For simple problems, entering requests at the MATLAB prompt in the command window is fast
and efficient. However, as the number of commands increases, or whenever a change of value of one
or more variables with a revaluation is desired, typing at the MATLAB prompt becomes tedious.
MATLAB allows to place MATLAB commands in a simple text file, and by telling MATLAB to open
this file, the stored commands are evaluated one-by-one as if they were just typed in. those files are
called m-files. There are two kinds of m-files:

 Scripts, which do not accept input arguments or return output arguments.


 Functions, which can accept input arguments and return output arguments.
Internal variables are local to the function. The only difference in the syntax of a script-file and a
function-file is the first line. The first line in function-file starts with the keyword function followed by
the list of output arguments, an equals sign, the name of the function and ending with the list of input
variables enclosed in parentheses and separated by commas. If the function has multiple output
arguments, the output argument list must be enclosed in a square brackets,
e.g.: Function[x,y,z]=cosytrans(theta, phi,rho)
In a script-file there is no predefined syntax for the first line.
To create or edit an M- file in the environment of Linux. The command nedit can be used to start a text
editor. The command nedit must be typed at a Linux command window. The use of this editor is very
simple and the most important commands can be found in top-down-menus.
Another important aspect the work with MATLAB should be mentioned here. The commands
presented in this paper were introduced without concluding semicolon. Therefore a response to the
commands occurs at the command prompt. So entering a new variable causes a repetition of the variable
name and its values. Sometimes it is most better avoid this repetition especially in large M files. Since
a load of information would appear on the screen and the really interesting data might get lost within
this load. To suppress this response a concluding semicolon must be entered after the command.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 8


Department of Electronics & Communication Engineering Digital Signal Processing Lab

COMMON PROCEDURE TO RUN PROGRAM ON MATLAB

1. Open MATLAB
2. In Menu bar, under ‘Home’ Tab, click on ‘Lay Out’ then ‘Default Layout’.
3. Under Tool Bar, click on ‘New Script’. (Ctrl+N)
4. Enter the MATLAB code. (In the Editor Window)
5. Click on ‘Save’ button. (Ctrl+S)
6. Enter the file (m-file) name without spaces and choose a proper destination folder.
7. Click on ‘Run’ button(F5)
8. Enter the inputs, if any. (in the command window)

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 9


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:1
LINEAR AND CIRCULAR CONVOLUTION
AIM:
To write a MATLAB code to find linear and circular convolution.
TOOLS REQUIRED:
Computer, MATLAB Software.
THEORY:
Convolution is a special operation, operated between two signals and whichincludes the following
operations.
 Folding.
 Shifting.
 Multiplication.
 Addition

Convolution sum is useful to obtain the response of discrete LTI system with input x(n)and
impulse response h(n).

To obtain the response, we have two types of convolutions.


 Linear Convolution.
 Circular Convolution.
Linear convoluted sequence y(n) between x(n) with duration N1and h(n) with duration N2 is defined
as

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 10


Department of Electronics & Communication Engineering Digital Signal Processing Lab

Where N = N1+N2 –1 is the duration of convoluted sequence y(n). DFT does not support linear
convolution, because of x(n) and h(n) are of different durations. That’s why we can go for circular
convolution.
Circular convolution y(n) between two sequences x(n) and h(n) are of finite duration and both of
length N is given as,

which is given by the formula,

Thus, if h(n) and x(n) are finite-length sequences of length N1 and N2, respectively, y(n)=h(n)*x(n)
is of length N1+N2-1, and the C-point circular convolution is equivalent to linear convolution
provided N ≥ N1+ N2 –1.

ALGORITHM FOR LINEAR CONVOLUTION:


1. Generate the first input sequence ‘x1(n)’.
2. Generate the Second input sequence ‘x2(n)’.
3. Find the lengths of x1(n) and x2(n).
4. Find the length of convolved sequence y(n).
5. Append zeros to make the length equal.
6. Perform linear convolution using the formula.
7. Display the convoluted output sequence.
8. Name x-axis and y-axis.
9. Plot the input and output sequences.
10. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE FOR LINEAR CONVOLUTION:


clc;
clear all;
close all;
x1= input ('enter the first sequence,x1(n)= ');
x2= input ('enter the second sequence,x2(n)= ');
n1= length(x1);

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 11


Department of Electronics & Communication Engineering Digital Signal Processing Lab

n2= length(x2);
N=n1+n2-1; %length of convolved sequence
X=[x1,zeros(1,N-n1)]; %zero padding to make sequences of length N
H=[x2,zeros(1,N-n2)]; %zero padding to make sequences of length N
y=zeros(1,N);
%performing linear convolution
for n=1:N
for k=1:n
y(n)=y(n)+X(k)*H(n-k+1);
end
end
disp('convolution of two sequences x1 and x2=');
disp(y);
subplot(2,2,1)
stem(x1);
xlabel('n --->')
ylabel('x1(n) --->')
title('INPUT SEQUENCE x1(n)')
subplot(2,2,2)
stem(x2);
xlabel('n --->')
ylabel('x2(n) --->')
title('INPUT SEQUENCE x2(n)')
subplot(2,2,3)
stem(y);
xlabel('n --->')
ylabel('x2(n) --->')
title('OUTPUT SEQUENCE y(n)')

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 12


Department of Electronics & Communication Engineering Digital Signal Processing Lab

INPUT:
Enter the first sequence, x1(n)=
Enter the second sequence, x2(n) =

OUTPUT:
Convolution of two sequences x1 and x2 =

ALGORITHM FOR CIRCULAR CONVOLUTION:


1. Generate the first input sequence ‘x1(n)’.
2. Generate the Second input sequence ‘x2(n)’.
3. Find the lengths of x1(n) and x2(n).
4. Find the length of convolved sequence y(n) which is the maximum values among the lengths
of x1(n) and x2(n).
5. Append zeros if required.
6. Perform circular convolution using the ‘mod’ operator.
7. Display the convoluted output sequence.
8. Name x-axis and y-axis.
9. Plot the input and output sequences.
10. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE FOR CIRCULAR CONVOLUTION:


clc;
clear all;
close all;
x1= input ('enter the first sequence, x1(n)= ');
x2= input ('enter the second sequence, x2(n)= ');
n1= length(x1);
n2= length(x2);

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 13


Department of Electronics & Communication Engineering Digital Signal Processing Lab

N=max(n1,n2);%length of sequence
x1=[x1 zeros(1,N-n1)]; %modified first sequence
x2=[x2 zeros(1,N-n2)]; %modified second sequence
for n=0:N-1
y(n+1)=0;
for i=0:N-1
j=mod(n-i,N);
y(n+1)=y(n+1)+x1(i+1)*x2(j+1); %shifting and adding
end
end
%to display and plot circular convolution
n=1:N;
disp('output sequence of circular convolution, y(n)= ');
disp(y); %to view output in command window
%plotting circular convolution
subplot(3,1,1);
stem(x1);
xlabel('n1---->');
ylabel('amplitude');
title('first sequence');
subplot(3,1,2);
stem(x2);
xlabel('n2---->');
ylabel('amplitude');
title('second sequence');
subplot(3,1,3);
stem(n,y);
xlabel('n--->');
ylabel('amplitude');

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 14


Department of Electronics & Communication Engineering Digital Signal Processing Lab

title('circular convolution sequence of x and h');

INPUT:
Enter the first sequence, x1(n) =
Enter the second sequence, x2(n) =
OUTPUT:
Output sequence of circular convolution, y (n) =

RESULT:

VIVA QUESTIONS:
1. Which is also known as regular convolution?
2. What is the length of convolved sequence?
3. What is the difference between convolution and correlation?
4. Give the expression for discrete convolution?
5. Discuss the need for linear and circular convolution.
6. What is zero padding?
7. How do you perform circular convolution?
8. For periodic signals what convolution is to be used?
9. Which is better linear or circular convolution?
10. What is the command you have to perform circular convolution in Matlab?Give its syntax

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 15


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:2
AUTO CORRELATION AND CROSS CORRELATION

AIM:

To write a MATLAB code to find the Auto correlation and Cross Correlation
for the given two sequences
TOOLS REQUIRED:
Computer, MATLAB Software.

THEORY:

The correlation of two functions or signals or waveforms is defined as the measure of similarity
between those signals. There are two types of correlations −
 Cross-correlation
 Autocorrelation

AUTOCORRELATION:
The autocorrelation function is defined as the measure of similarity or coherence between a signal and its
time delayed version. Therefore, the autocorrelation is the correlation of a signal with itself.
Autocorrelation sequence of x[n] is given by:

Some of the properties of autocorrelation are enumerated below –

1. The autocorrelation sequence is an even function i.e., r xx [ l] =r xx [−l]

2. At zero lag, i.e., at l=0, the sample value of the autocorrelation sequence has its maximum value (equal
to the total energy of the signal) i.e.,

3. A time shift of a signal does not change its autocorrelation sequence.

4. For power signals the autocorrelation sequence is given by:

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 16


Department of Electronics & Communication Engineering Digital Signal Processing Lab

and for periodic signals with period N it is:

and this rxx[l] is also periodic with N.

CROSS-CORRELATION:
The cross-correlation between two different signals is defined as the measure of similarity or coherence
between one signal and the time-delayed version of another signal.
A measure of similarity between a pair of energy signals x[n] and y[n] is given by the cross- correlation
sequence rxy[l] defined by:

The parameter ‘l’ called ‘lag’ indicates the time shift between the pair.

Comparing the equations for the linear convolution and cross correlation we find that,

convolving the reference signal with a folded version of sequence to be shifted (y[n]) results in cross
correlation output.

The properties of cross correlation are:

1)The cross-correlation sequence sample values are upper bounded by the inequality

2) The cross correlation of two sequences x[n] and y[n]=x[n-k] shows a peak at the value of k. Hence
cross correlation is employed to compute the exact value of the delay k between the 2 signals. Used in
radar and sonar applications, where the received signal reflected from the target is the delayed version of
the transmitted signal (measure delay to determine the distance of the target).

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 17


Department of Electronics & Communication Engineering Digital Signal Processing Lab

3) The ordering of the subscripts xy specifies that x[n] is the reference sequence That remains fixed in
time, whereas the sequence y[n] is shifted w.r.t x[n]. If y[n] is the reference sequence, then ryx [ l ]=rxy

[−l ] . Hence ryx[l] is obtained by time reversing the sequence rxy[l].

ALGORITHM FOR AUTO CORRELATION:


1. Generate the input sequence ‘x(n)’.
2. Find auto-correlation of input sequence using xcorr command
3. Display the correlated output sequence
4. Plot the input and output sequences.
5. Name x-axis and y-axis.
6. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE FOR AUTO CORRELATION:

clc;
close all;
clear all;
% input sequences
x=input('enter input sequence:');
subplot(1,2,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input sequence');
% auto correlation of input sequence
z=xcorr(x,x);
disp('The o/p auto correlated sequence z= ');
disp(z);
subplot(1,2,2);
stem(z);
xlabel('n');
ylabel('z(n)');
title('auto correlation of input sequence')

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 18


Department of Electronics & Communication Engineering Digital Signal Processing Lab

INPUT:
Enter input sequence:

OUTPUT:
The values of z are =

ALGORITHM FOR CROSS- CORRELATION:


1. Generate the first input sequence ‘x(n)’.
2. Generate the second input sequence ‘y(n)’.
3. Find cross-correlation of input sequences using xcorr command
4. Display the correlated output sequence
5. Plot the input and output sequences.
6. Name x-axis and y-axis.
7. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE FOR CROSS-CORRELATION:


clc; % clear screen
clear all; % clear workspace
close all; % close all figure windows
x = input('Enter the first sequence x(n) ='); % first sequence
y = input('Enter the second sequence y(n) ='); % second sequence
r = xcorr(x,y); % calculate cross correlation
disp('Cross Correlation Output = ');
disp(r); % display the output
n1 = length(x)-1; % graphical plot of first input sequence
t1 = 0:n1;
subplot(2,2,1);
stem(t1,x);

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 19


Department of Electronics & Communication Engineering Digital Signal Processing Lab

xlabel('n');
ylabel('x(n)');
title('plot of x(n)');
n2 = length(y)-1; % graphical plot of second input sequence
t2 = 0:n2;
subplot(2,2,2);
stem(t2,y);
xlabel('n')
ylabel('y(n)');
title('plot of y(n)');
N = max(n1,n2); % graphical plot of output sequence
k = -N:N;
subplot(2,1,2);
stem(k,r);
xlabel('n');
ylabel('r(n)');
title('cross correlation output');

INPUT:
Enter the first sequence x(n) =
Enter the second sequence y(n) =
OUTPUT:
Cross Correlation Output =

RESULT :

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 20


Department of Electronics & Communication Engineering Digital Signal Processing Lab

VIVA QUESTIONS:
1. Write mathematical formula to find auto correlation?
2. Define auto correlation?
3. Define correlation.
4. Difference between Auto correlation and convolution?
5. Difference between Auto correlation and cross correlation?
6. Write mathematical formula to find cross correlation?
7. What is the length of the resultant sequence of auto correlation?
8. List few applications of correlation.
9. Give the properties of auto correlation.
10. Define cross correlation.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 21


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:3
LINEAR CONVOLUTION USING DFT
(OVERLAP-ADD AND SAVE METHOD)

AIM:

To write a MATLAB code to find the Linear convolution using DFT in Overlap-add and

Overlap-save method.
TOOLS REQUIRED:
Computer, MATLAB Software.

THEORY:
Generally in discrete-time processing we talk about linearly convolving a sequence with a FIR filter. In
contrast, the FFT performs circular convolution with a filter of equal or lesser length. In computing the
DFT or FFT we often have to make linear convolution behave like circular convolution or vice versa.
Two methods that make linear convolution look like circular convolution are overlap-add and overlap-
save.

OVERLAP-ADD METHOD

This procedure cuts the signal up into equal length segments with no overlap. Then it zero-pads the
segments and takes the DFT of the segments. Part of the convolution result corresponds to the circular
convolution. The tails that do not correspond to the circular convolution are added to the adjoining tail of
the previous and subsequent sequence. This addition results in the aliasing that occurs in circular
convolution.

OVERLAP-SAVE METHOD

This procedure cuts the signal up into equal length segments with some overlap. Then it takes the DFT of
the segments and saves the parts of the convolution that correspond to the circular convolution. Because
there are overlapping sections, it is like the input is copied therefore there is not lost information in
throwing away parts of the linear convolution.

ALGORITHM FOR OVERLAP-ADD METHOD:


1. Generate the input sequence ‘x(n)’.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 22


Department of Electronics & Communication Engineering Digital Signal Processing Lab

2. Generate the impulse response sequence ‘h(n)’.


3. Find the lengths of input and impulse response sequences.
4. Find the length of each block before appending zeros.
5. Find the remainder using ‘rem’ operator.
6. Append zeros of required count.
7. Find the convolution between each input sequence of k blocks and impulse response.
8. Display output sequence after overlap adding.
9. Plot the input and output sequences.
10. Name x-axis and y-axis.
11. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE FOR OVERLAP-ADD METHOD:

clc;
clear all;
close all;
x=input('enter input sequence:');
h=input('enter impulse sequence:');
L=input('Enter length of each block before appending zeros:');
Nx=length(x);
M=length(h);
M1=M-1;
R=rem(Nx,L);
N=L+M1;
x=[x zeros(1,L-R)];
h=[h zeros(1,N-M)];
K=floor(Nx/L); %no.of blocks
y=zeros(K+1,N);
z=zeros(1,M1);
%dividing the sequence into k blocks
for k=0:K
xp=x(L*k+1: L*k+L);
xk=[xp z];
Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 23
Department of Electronics & Communication Engineering Digital Signal Processing Lab

y(k+1,:) =(cconv(xk,h,N));
end
yp=y';
[x,y]=size(yp);
for i=L+1:x
for j=1:y-1
temp1=i-L;
temp2=j+1;
temp3=yp(temp1,temp2)+yp(i,j);
yp(temp1,temp2)=temp3;
end
end
z=1;
for j=1:y
for i=1:x
if((i<=L & j<=y-1) | (j==y))
ypnew(z)=yp(i,j);
z=z+1;
end
end
end
y=ypnew;
disp('The output of x(n) convolution with h(n) in overlap add method is y(n)= ')
disp(y);
subplot(2,2,1)
stem(x);
xlabel('n --->')
ylabel('x(n) --->')
title('INPUT SEQUENCE x(n)')
subplot(2,2,2)
stem(h);
xlabel('n --->')

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 24


Department of Electronics & Communication Engineering Digital Signal Processing Lab

ylabel('h(n) --->')
title('IMPULSE SEQUENCE h(n)')
subplot(2,2,3)
stem(y);
xlabel('n --->')
ylabel('y(n) --->')
title('OUTPUT SEQUENCE y(n)')

INPUT:
enter input sequence:
enter impulse sequence:
Enter length of each block before appending zeros:

OUTPUT:
The output of x(n) convolution with h(n) in overlap add method is y(n)=

ALGORITHM FOR OVERLAP-ADD METHOD:


1. Generate the input sequence ‘x(n)’.
2. Generate the impulse response sequence ‘h(n)’.
3. Find the length of each block before appending zeros.
4. Find the lengths of input sequence.
5. Find the length ‘M’ of impulse response sequence.
6. Find number of blocks using ‘floor’ operator.
7. Append zeros of required count.
8. Divide the sequence into ‘k’ number of blocks.
9. Find the convolution between each input sequence of k blocks and impulse response.
10. Display output sequence after discarding ‘M-1’blocks.
11. Plot the input and output sequences.
12. Name x-axis and y-axis.
13. Make use of subplots to plot the input and output sequences in a single window.
Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 25
Department of Electronics & Communication Engineering Digital Signal Processing Lab

MATLAB CODE FOR OVERLAP-SAVE METHOD:


clc;
clear all;
close all;
x=input('enter input sequence:');
h=input('enter impulse sequence:');
N=input('Enter length of each block before appending zeros:');
if(N<length(h))
error('N must be >= length(h)')
end
Nx=length(x);
M=length(h);
M1=M-1;
L=N-M1;
x=[zeros(1,M-1),x,zeros(1,N-1)];
h=[h zeros(1,N-M)];
K=floor((Nx+M1-1)/(L)); %no.of blocks
Y=zeros(K+1,N); %Dividing the sequence into K blocks
for k=0:K
xk=x(k*L+1:k*L+N);
Y(k+1,:)=cconv(xk,h,N);
end
Y=Y(: ,M:N)'; %discard first M-1 blocks
disp('The output x(n)*h(n) in overlap save method is y(n)= ')
disp(Y);

INPUT:
enter input sequence:
enter impulse sequence:
Enter length of each block before appending zeros:

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 26


Department of Electronics & Communication Engineering Digital Signal Processing Lab

OUTPUT:
The output of x(n) convolution with h(n) in overlap save method is y(n)=

RESULT:

VIVA QUESTIONS:
1. Explain the significance of convolution.
2. Define linear convolution.
3. Give the properties of linear convolution.
4. What is overlap-add method?
5. What is overlap-save method?
6. Give the differences between overlap-add and overlap-save methods?
7. What is need of discrete Fourier Transform?
8. Write down the mathematical expression to perform DFT?
9. How linear convolution will be used in calculation of LTI system response?
10. How the linear convolution will be used to calculate the DFT of a signal?

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 27


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:4
N-POINT DFT

AIM:

To write a MATLAB code to compute N-point DFT of a given sequence and to plot magnitude and phase
spectrum.

TOOLS REQUIRED:
Computer, MATLAB Software.
THEORY:

Discrete Fourier Transform is the transformation used to represent the finite duration frequencies. DFT
of a discrete sequence x(n) is obtained by performing sampling operations in both time domain and
frequency domain. It is the frequency domain representation of a discrete digital signal. The DFT of a
sequence x (n) of length N is given by the following equation,

ALGORITHM FOR N-POINT DFT :


1. Find the value of N (Number of DFT points)
2. Generate the input sequence ‘x(n)’.
3. Find the lengths of input sequence.
4. Append zeros if No. DFT points needed is less than the input samples.
5. Perform DFT using the formula.
6. Display the output sequence.
7. Find magnitude and phase of the output sequence.
8. Plot the input, magnitude and phase response of output sequences.
9. Name x-axis and y-axis.
10. Make use of subplots to plot the input and output sequences in a single window.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 28


Department of Electronics & Communication Engineering Digital Signal Processing Lab

MATLAB CODE FOR N-POINT DFT:

%TO VERIFY DFT


clc;
clear all;
close all ;proj
N = input('Number of DFT points = ');
xn =input('Enter the sequence x(n) = '); %Get the sequence from user
ln =length(xn);
xn=[xn zeros(1,N-ln)]; %if No. DFT points needed is less than the input
%samples entered, zero padding will be done accordingly
xk = zeros(1,N); %initialize an array of same size as that of input sequence
%code block to find the DFT of the sequence
for k = 0:N-1
for n = 0:N-1
xk(k+1) = xk(k+1)+(xn(n+1)*exp((-1i)*2*pi*k*n/N));
end
end
%code block to plot the input sequence
n = 0:N-1;
subplot(2,2,1);
stem(n,xn);
xlabel('n ---->');
ylabel('Amplitude ---->');
title('Time domain Sequence ---->');
magnitude = abs(xk); %Find the magnitudes of individual DFT points
disp('DFT of the sequence=');
disp(xk);
disp('magnitude = ');
disp(magnitude);
%code block to plot the DFT sequence
n = 0:N-1;

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 29


Department of Electronics & Communication Engineering Digital Signal Processing Lab

subplot(2,2,2);
stem(n,magnitude);
xlabel('k ---->');
ylabel('Amplitude ---->');
title('magnitude response X(k) ---->');
phase = angle(xk); %Find the phases of individual DFT points
disp('Phase = ');
disp(phase);
%code block to plot the Phase Response
n = 0:N-1;
subplot(2,2,3);
stem(n,phase) ;
xlabel('k ---->');
ylabel('Phase response ---->');
title('Phase Response');

INPUT:
Number of DFT points =
Enter the sequence x(n) =

OUTPUT:
DFT of the sequence=

magnitude =

Phase =

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 30


Department of Electronics & Communication Engineering Digital Signal Processing Lab

RESULT:

VIVA QUESTIONS:
1. What is need of discrete Fourier Transform?
2. What is the difference between DFT and IDFT?
3. How to calculate output of DFT using MATLAB?
4. Give the defining equation for performing circular convolution using DFT.
5. Define signal, Give Examples for 1-D, 2-D, 3-D signals.
6. Define transform. What is the need for transform?
7. Differentiate DFT and DTFT
8. Explain mathematical formula for calculation of DFT.
9. What is meant by magnitude plot, phase plot, power spectrum?
10. Explain the applications of DFT.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 31


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:5
DECIMATION IN TIME RADIX-2 FFT ALGORITHM

AIM:

To write a MATLAB code to perform DFT using decimation in time radix-2 FFT algorithm.

TOOLS REQUIRED:
Computer, MATLAB Software.
THEORY:

The Fast Fourier transform (FFT) is a method(or algorithm) for computing the DFT with reduced number
of calculations.

In radix-2 FFT the N point sequence is decimated into 2 point sequences and the 2 point DFT for each
decimated sequence is calculated. From the results of 2 point DFTs, the 4 point DFTs can be calculated.
From the results of 4 point DFTs, the 8 point DFTs can be calculated, and so on until we get N point DFT.

No of complex multiplications and additions in DFT and in FFT:

For DFT:

The no of multiplications in DFT = N2.

The no of Additions in DFT = N (N-1).

For FFT:

The no of multiplication = N/2 log 2N.

The no of additions = N log2 N.

There are two algorithms in the computation of FFT


1. Decimation in time (DIT) FFT.
2. Decimation in Frequency (DIF) FFT.

In DIT-FFT algorithm the time domain sequence x(n) is decimated whereas in DIF-FFT the frequency
domain sequence X(k) is decimated.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 32


Department of Electronics & Communication Engineering Digital Signal Processing Lab

ALGORITHM FOR DECIMATION IN TIME RADIX-2 ALGORITHM:

1. Generate the input sequence ‘x(n)’.


2. Find the value of N (Number of DFT points)
3. Find the lengths of input sequence.
4. Append zeros if required.
5. Find bit reversed order of input sequence.
6. Perform DFT using FFT.
7. Display the output sequence.
8. Find magnitude and phase of the output sequence.
9. Plot the input, magnitude and phase response of output sequences.
10. Name x-axis and y-axis.
11. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE FOR DECIMATION IN TIME RADIX-2 ALGORITHM:

clc;
clear all;
close all;
x=input('Enter the sequence : ');
N=input('Enter the Point : ');
n=length(x);
x=[x zeros(1,N-n)];
y=bitrevorder(x);
M=log2(N);
for m=1:M
d=2^m;
for l=1:d:N-d+1
for k=0:(d/2)-1
w=exp(-1i*2*pi*k/d);
z1=y(l+k);
z2=y(l+k+d/2);

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 33


Department of Electronics & Communication Engineering Digital Signal Processing Lab

y(l+k)=z1+w*z2;
y(l+k+d/2)=z1-w*z2;
end
end
end
disp(“The DFT of a given sequence using radix-2 DIT-FFT is “)
disp(y);
subplot(3,1,1)
stem(abs(x));
title('Input Sequence');
subplot(3,1,2)
stem(abs(y));
title('Magnitude Response');
subplot(3,1,3)
stem(angle(y));
title('Phase Response');

INPUT:
Enter the sequence:
Enter the Point:

OUTPUT:
The DFT of a given sequence using radix-2 DIT-FFT is:

RESULT:

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 34


Department of Electronics & Communication Engineering Digital Signal Processing Lab

VIVA QUESTIONS:
1. What is decimation in time algorithm?
2. What is meant by bit reversed order?
3. Differentiate DFT and DTFT.
4. What are the advantages of FFT over DFT?
5. Differentiate DIT-FFT and DIF-FFT algorithms.
6. What is meant by radix?
7. What is meant by twiddle factor and give its properties?
8. How FFT is useful to represent a signal?
9. Compare FFT and DFT with respect to number of calculations required?
10. How is the original signal reconstructed from the FFT of a signal?

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 35


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:6
DECIMATION IN FREQUENCY RADIX-2 FFT ALGORITHM

AIM:

To write a MATLAB code to perform DFT using decimation in frequency radix-2 algorithm.

TOOLS REQUIRED:
Computer, MATLAB Software.
THEORY:

The fast Fourier transform (FFT) is a method(or algorithm) for computing the DFT with reduced number
of calculations.

In radix 2 FFT the N point sequence is decimated into 2 point sequences and the 2 point DFT for each
decimated sequence is calculated. From the results of 2 point DFTs, the 4 point DFTs can be calculated.
From the results of 4 point DFTs, the 8 point DFTs can be calculated, and so on until we get N point DFT.

No of complex multiplications and additions in DFT and in FFT :

For DFT:

The no of multiplications in DFT = N2.

The no of Additions in DFT = N (N-1).

For FFT:

The no of multiplication = N/2 log 2N.

The no of additions = N log2 N.

There are two algorithms in the computation of FFT


1. Decimation in time (DIT) FFT.
2. Decimation in Frequency (DIF) FFT.

In DIT-FFT algorithm the time domain sequence x(n) is decimated whereas in DIF-FFT the frequency
domain sequence X(k) is decimated.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 36


Department of Electronics & Communication Engineering Digital Signal Processing Lab

ALGORITHM FOR DECIMATION IN FREQUENCY RADIX-2 ALGORITHM:

1. Generate the input sequence ‘x(n)’.


2. Find the value of N (Number of DFT points)
3. Find the lengths of input sequence.
4. Append zeros if required.
5. Perform DFT using FFT.
6. Display the output sequence.
7. Find magnitude and phase of the output sequence.
8. Plot the input, magnitude and phase response of output sequences.
9. Name x-axis and y-axis.
10. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE FOR DECIMATION IN FREQUENCY RADIX-2 ALGORITHM:

clc;
clear all;
close all;
X=input('Enter the sequence : ');
N=input('Enter the Point : ');
n=length(X);
x=[X zeros(1,N-n)];
M=log2(N);
for m=1:M
d=2^(M-m+1);
for l=1:d:(N-d+1)
for k=0:(d/2)-1
w=exp(-1i*2*pi*k/d);
z1=x(l+k);
z2=x(l+k+d/2);
x(l+k)=z1+z2;
x(l+k+d/2)=(z1-z2)*w;
end

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 37


Department of Electronics & Communication Engineering Digital Signal Processing Lab

end
end
y=bitrevorder(x);
disp(y)
subplot(3,1,1)
stem(abs(X));
title('Input Sequence');
subplot(3,1,2)
stem(abs(y));
title('Magnitude Response');
subplot(3,1,3)
stem(angle(y));
title('Phase Response');

INPUT:
Enter the sequence:
Enter the Point:

OUTPUT:
The DFT of a given sequence using radix-2 DIF-FFT is:

RESULT:

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 38


Department of Electronics & Communication Engineering Digital Signal Processing Lab

VIVA QUESTIONS:
1. What is decimation in frequency algorithm?
2. What is meant by bit reversed order?
3. Differentiate DFT and DTFT.
4. What are the advantages of FFT over DFT?
5. Differentiate DIT-FFT and DIF-FFT algorithms.
6. What is meant by radix?
7. What is meant by twiddle factor and give its properties?
8. How FFT is useful to represent a signal?
9. Compare FFT and DFT with respect to number of calculations required?
10. How is the original signal reconstructed from the FFT of a signal?

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 39


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:7
IIR -LOW PASS FILTER AND HIGH PASS FILTER

AIM:
To write a MATLAB code to design Butterworth IIR Low Pass Filter and High Pass Filter
TOOLS REQUIRED:
Computer, MATLAB Software.
THEORY:

IIR filter is also known as Recursive filter, which will have at least one feedback path in its structure. This
feedback path is due to presence of a pole. A Butterworth filer will have flat-flat response in both bands
i.e., Pass band and stop bands.

For a Low pass filter, the pass band frequency so is lesser than that of stop band frequency. We can
provide max attenuation in the stop band gain but very little attenuation in the pass band gain. A proper
order of the filter has to be chosen so as to match with the ideal frequency response.

For a High pass filter, we will have stop band first, later provide pass band frequency so that it is lesser
than that of stop band frequency. We can provide max attenuation in the stop band gain but very little
attenuation in the pass band gain. A proper order of the filter has to be chosen so as to match with the
ideal frequency response.

ALGORITHM FOR BUTTERWORTH IIR LOW PASS FILTER:

1. Find the pass band and stop band frequency.


2. Find the pass band and stop band ripple.
3. Get the sampling frequency.
4. Calculate analog pass band edge frequencies ws and wp .
5. Find the order and 3 dB cut off frequencies using ‘buttord’ function.
6. Design nth order low pass Butterworth filter using ‘butter’ function.
7. Find the complex frequency response of the filter using ‘freqz’ function.
8. Plot magnitude and phase response of the filter.
9. Plot the input, magnitude, and phase response of output sequences.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 40


Department of Electronics & Communication Engineering Digital Signal Processing Lab

10. Name x-axis and y-axis.


11. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE TO DESIGN BUTTERWORTH IIR LOW PASS FILTER:

clc;
clear all;
close all;
fp=input('Enter the pass band frequency, fp= ');
fs=input('Enter the stop band frequency, fs= ');
rp=input('Enter the pass band ripple,rp= ');
rs=input('Enter the stop band ripple, rs= ');
f=input ('Enter the sample frequency= ');
wp=2*fp;
ws=2*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=buttord(w1,w2,rp,rs);
[B,A]=butter(N,WN,'LOW');
w=0:0.01:pi;
[H1,om]=freqz(B,A,w);
m=20*log10(abs(H1));
an=angle(H1);
subplot(2,1,1);
plot(om/pi,m);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('MAGNITUDE RESPONSE OF BUTTERWORTH IIR LPF');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 41


Department of Electronics & Communication Engineering Digital Signal Processing Lab

title('PHASE RESPONSE OF BUTTERWORTH IIR LPF');


grid;

INPUT:
Enter the pass band frequency, fp=
Enter the stop band frequency, fs=
Enter the pass band ripple,rp=
Enter the stop band ripple, rs=
Enter the sample frequency=

OUTPUT:

ALGORITHM FOR BUTTERWORTH IIR HIGH PASS FILTER:


1. Find the pass band and stop band frequency.
2. Find the pass band and stop band ripple.
3. Get the sampling frequency.
4. Calculate analog pass band edge frequencies ws and wp .
5. Find the order and 3 dB cut off frequencies using ‘buttord’ function.
6. Design nth order high pass Butterworth filter using ‘butter’ function.
7. Find the complex frequency response of the filter using ‘freqz’ function.
8. Plot magnitude and phase response of the filter.
9. Plot the input, magnitude, and phase response of output sequences.
10. Name x-axis and y-axis.
11. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE TO DESIGN BUTTERWORTH IIR HIGH PASS FILTER:

clc;
clear all;
close all;
fp=input('Enter the pass band frequency, fp= ');

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 42


Department of Electronics & Communication Engineering Digital Signal Processing Lab

fs=input('Enter the stop band frequency, fs= ');


rp=input('Enter the pass band ripple,rp= ');
rs=input('Enter the stop band ripple, rs= ');
f=input ('Enter the sample frequency= ');
wp=2*fp;
ws=2*fs;
w1=wp/f;
w2=ws/f;
[N,WN]=buttord(w1,w2,rp,rs);
[B,A]=butter(N,WN,'HIGH');
w=0:0.01:pi;
[H1,om]=freqz(B,A,w);
m=20*log10(abs(H1));
an=angle(H1);
subplot(2,1,1);
plot(om/pi,m);
xlabel(' (a) Normalised frequency');
ylabel(' Gain in dB');
title('MAGNITUDE RESPONSE OF BUTTERWORTH IIR HPF');
grid;
subplot(2,1,2);
plot(om/pi,an);
xlabel(' (b) Normalised frequency');
ylabel(' Phase in radians');
title('PHASE RESPONSE OF BUTTERWORTH IIR HPF');
grid;

INPUT:
Enter the pass band frequency, fp=
Enter the stop band frequency, fs=
Enter the pass band ripple,rp=
Enter the stop band ripple, rs=

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 43


Department of Electronics & Communication Engineering Digital Signal Processing Lab

Enter the sample frequency=

OUTPUT:

RESULT:

VIVA QUESTIONS:
1. What is an IIR filter?
2. How many types of IIR filters are there?
3. What is a Butterworth filter?
4. Name some techniques that convert analog filters into digital?
5. What are the inputs we provide for designing a filter?
6. Give the formula for order of the Butterworth filter?
7. How to find output of IIR filter for long input sequence?
8. Why IIR filters are called as recursive filters?
9. What are the advantages of IIR filters (compared to FIR filters)?
10. How to find out the order of a filter

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 44


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:8
FIR -LOW PASS FILTER AND HIGH PASS FILTER

AIM:
To write a MATLAB code to design FIR Low Pass Filter and High Pass Filter using windowing
Techniques.
TOOLS REQUIRED:
Computer, MATLAB Software.

THEORY:
FIR filters are digital filters with finite impulse response. They are also knownas non-recursive digital
filters as they do not have the feedback.

FIR filter has two important advantages over an IIR design:

Firstly, there is no feedback loop in the structure of an FIR filter. Due to not having a feedback loop, an
FIR filter is inherently stable. For an IIR filter, the stability need to be checked.

Secondly, an FIR filter can provide a linear-phase response. A linear-phase response is the main advantage
of an FIR filter over an IIR design otherwise, for the same filtering specifications; an IIR filter will lead
to a lower order.

FIR FILTER DESIGN

An FIR filter is designed by finding the coefficients and filter order that meet certain specifications, which
can be in the time-domain (e.g. a matched filter) and/or the frequency domain (most common). Matched
filters perform a cross-correlation between the input signal and a known pulse-shape. The FIR convolution
is a cross-correlation between the input signal and a time-reversed copy of the impulse-response.
Therefore, the matched-filter's impulse response is "designed" by sampling the known pulse-shape and
using those samples in reverse order as the coefficients of the filter.

When a particular frequency response is desired, several different design methods are common:

1. Window design method


2. Frequency Sampling method
3. Weighted least squares design

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 45


Department of Electronics & Communication Engineering Digital Signal Processing Lab

WINDOW DESIGN METHOD

In the window design method, one first designs an ideal IIR filter and then truncates the infinite impulse
response by multiplying it with a finite length window function. The result is a finite impulse response
filter whose frequency response is modified from that of the IIR filter.

ALGORITHM FOR FIR LOW PASS FILTER:

1. Find the pass band and stop band frequency.


2. Find the pass band and stop band ripple.
3. Get the sampling frequency.
4. Get the ‘beta’ value.
5. Calculate analog pass band edge frequencies ws and wp.
6. Find the order of the filter.
7. Select and find the desired impulse response using respective functions for rectangular,
triangular and kaiser filters.
8. Find the complex frequency response of the filter using ‘freqz’ function.
9. Plot magnitude and phase response of the filter.
10. Name x-axis and y-axis.
11. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE TO DESIGN FIR LOW PASS FILTER:

clc;
clear all;
close all;
rp=input('Enter passband ripple =');
rs=input('Enter the stopband ripple=');
fp=input('Enter passband frequency'=);
fs=input('Enter stopband frequency=');
f=input('Enter sampling frequency =');
beta=input('Enter beta value=');
wp=2*fp/f;
ws=2*fs/f;

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 46


Department of Electronics & Communication Engineering Digital Signal Processing Lab

num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs- fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
c=input('Enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n ');
if(c==1)
y=rectwin(n1);
disp('Rectangular window filter response');
end
if (c==2)
y=triang(n1);
disp('Triangular window filter response');
end
if(c==3)
y=kaiser(n1,beta);
disp('kaiser window filter response');
end
%LPF
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(o/pi,m);
title('LPF');
ylabel('Gain in dB-->');
xlabel('(a) Normalized frequency-->');
subplot(2,1,2);

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 47


Department of Electronics & Communication Engineering Digital Signal Processing Lab

plot(o/pi,an);
title('LPF');
ylabel('phase-->');
xlabel('(a) Normalized frequency-->');
INPUT
Enter passband ripple =
Enter the stopband ripple =
Enter passband frequency =
Enter stopband frequency =
Enter sampling frequency =
Enter beta value =
Enter your choice of window function 1. rectangular 2. triangular 3.kaiser :
OUTPUT:
1.Rectangular window filter response

2.Triangular window filter response

3. kaiser window filter response

ALGORITHM FOR FIR HIGH PASS FILTER:

1. Find the pass band and stop band frequency.


2. Find the pass band and stop band ripple.
3. Get the sampling frequency.
4. Get the ‘beta’ value.
5. Calculate analog pass band edge frequencies ws and wp.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 48


Department of Electronics & Communication Engineering Digital Signal Processing Lab

6. Find the order of the filter.


7. Select and find the desired impulse response using respective functions for rectangular,
triangular and kaiser filters.
8. Find the complex frequency response of the filter using ‘freqz’ function.
9. Plot magnitude response of the filter.
10. Name x-axis and y-axis.
11. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE TO DESIGN FIR HIGH PASS FILTER:

clc;

clear all;

close all;

rp=input('enter passband ripple=');

rs=input('enter the stopband ripple=');

fp=input('enter passband frequency=');

fs=input('enter stopband frequency=');

f=input('enter sampling frequency= ');

beta=input('enter beta value=');

wp=2*fp/f;

ws=2*fs/f;

num=-20*log10(sqrt(rp*rs))-13;

dem=14.6*(fs- fp)/f;

n=ceil(num/dem);

n1=n+1;

if(rem(n,2)~=0)

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 49


Department of Electronics & Communication Engineering Digital Signal Processing Lab

n1=n;

n=n-1;

end

c=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n ');

if(c==1)

y=rectwin(n1);

disp('Rectangular window filter response');

end

if (c==2)

y=triang(n1);

disp('Triangular window filter response');

end

if(c==3)

y=kaiser(n1,beta);

disp('kaiser window filter response');

end

%HPF

b=fir1(n,wp,'high',y);

[h,o]=freqz(b,1,256);

m=20*log10(abs(h));

plot(o/pi,m);

title('HPF');

ylabel('Gain in dB-->');

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 50


Department of Electronics & Communication Engineering Digital Signal Processing Lab

xlabel('(b) Normalized frequency-->');

INPUT:

enter passband ripple=

enter the stopband ripple=

enter passband frequency=

enter stopband frequency=

enter sampling frequency =

enter beta value=

OUTPUT:

Enter your choice of window function 1. rectangular 2. triangular 3. Kaiser:

1.Rectangular window filter response

2.Triangular window filter response

3. kaiser window filter response

RESULT:

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 51


Department of Electronics & Communication Engineering Digital Signal Processing Lab

VIVA QUESTIONS:
1. What is a FIR filter?
2. In which filters, can we expect linear phase characteristics?
3. What is the pass band frequency? Explain?
4. What is the stop band frequency? Explain?
5. What is frequency response and explain?
6. What is impulse response? Give its significance.
7. Define a low pass filter?
8. What is the cut off frequency? Explain?
9. What are windowing techniques in FIR filter?
10. Why do we use windowing techniques?

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 52


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:9
DECIMATION AND INTERPOLATION PROCESS

AIM:

To write a MATLAB code to implement the decimation and interpolation process.

TOOLS REQUIRED:

Computer, MATLAB Software.

THEORY:

The process of converting the sampling rate of a signal from one rate to another is called sampling rate
conversion (SRC). This technique is encountered in many application areas such as:

 Digital audio  Communication systems  Speech processing

 Antenna systems  Radar systems

Sampling rate may be changed upward or downward. Increasing the sampling rate is called interpolation
and decreasing the sampling rate is called decimation. Reducing the sampling rate by a factor of M is
achieved by discarding every M-1 samples or equivalently keeping every Mth sample. Increasing the
sampling rate by a factor of L(Interpolation by factor L ) is achieved by inserting L-1 zeros into the output
stream after every sample from the input stream of samples.

The most immediate reason to decimate is simply to reduce the sampling rate at the output of one system
so that another system operating at a lower sampling rate can be the 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 ina cheaper implementation.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 53


Department of Electronics & Communication Engineering Digital Signal Processing Lab

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 be the input the signal.

ALGORITHM FOR DECIMATION PROCESS:

1. Give the downsampling factor.


2. Find the length of the input signal.
3. Give the frequency of first sinusoidal.
4. Give the frequency of second sinusoidal.
5. Find the Sum of two sinusoidals.
6. Decimate the resultant signal by a down sampling factor ‘D’.
7. Plot the input and decimated output sequences.
8. Name x-axis and y-axis.
9. Make use of subplots to plot the input and output sequences in a single window.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 54


Department of Electronics & Communication Engineering Digital Signal Processing Lab

MATLAB CODE FOR IMPLEMENTATION OF DECIMATION PROCESS:


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 sinusoidal: ');

f2=input('enter the frequency of second sinusoidal: ');

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

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 55


Department of Electronics & Communication Engineering Digital Signal Processing Lab

INPUT:

enter the downsampling factor:

enter the length of the input signal:

enter the frequency of first sinusoidal:

enter the frequency of second sinusoidal:

OUTPUT:

ALGORITHM FOR INTERPOLATION PROCESS:

1. Give the downsampling factor.


2. Find the length of the input signal.
3. Give the frequency of first sinusoidal.
4. Give the frequency of second sinusoidal.
5. Find the Sum of two sinusoidals.
6. Interpolate the resultant signal by a up-sampling factor ‘L’.
7. Plot the input and interpolated output sequences.
8. Name x-axis and y-axis.
9. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE FOR IMPLEMENTATION OF INTERPOLATION PROCESS:


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
Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 56
Department of Electronics & Communication Engineering Digital Signal Processing Lab

f1=input('enter the frequency of first sinusoidal:');

f2=input('enter the frequency of second sinusoidal:');

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:

enter the length of the input signal:

enter the frequency of first sinusoidal:

enter the frequency of second sinusoidal:

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 57


Department of Electronics & Communication Engineering Digital Signal Processing Lab

OUTPUT:

RESULT:

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?
6. What is meant anti-aliasing?
7. What is the effect of anti-imaging filter?
8. What is meant by zero stuffing?
9. What is upsampling and downsampling?
10. What is the need of multi rate signal processing?

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 58


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:10
I/D SAMPLING RATE CONVERSION

AIM:
To write a MATLAB code to implement the I/D sampling rate conversion.
TOOLS REQUIRED:
Computer, MATLAB Software.
THEORY:
"Multirate" means "multiple sampling rates". A multirate DSP system uses multiple sampling rates within
the system. Whenever a signal at one rate has to be usedby a system that expects a different rate, the
rate has to be increased or decreased, and some processing is required to do so. Therefore "Multirate DSP"
refers to the art or science of changing sampling rates. "Resampling" means combining interpolation and
decimation to change the sampling rate by a rational factor. Resampling is done to interface two systems
with different sampling rates.
BLOCK DIAGRAM OF SAMPLING RATE CONVERSION:

ALGORITHM FOR I/D SAMPLING RATE CONVERSION:

1. Find the length of the input signal.


2. Give the frequency of first sinusoidal.
3. Give the frequency of second sinusoidal.
4. Give the upsampling factor.
5. Give the downsampling factor.
6. Find the Sum of two sinusoidals.
7. Resample the signal by upsampling and downsampling factors L, D.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 59


Department of Electronics & Communication Engineering Digital Signal Processing Lab

8. Plot the input and interpolated output sequences.


9. Name x-axis and y-axis.
10. Make use of subplots to plot the input and output sequences in a single window.

MATLAB CODE TO IMPLEMENT I/D SAMPLING RATE CONVERSION:

clc;

clear all;

close all;

N=input('enter the length of the input signal:');

f1=input('enter the frequency of first sinusoidal:');

f2=input('enter the frequency of second sinusoidal:');

L=input('enter the upsampling factor:');

D=input('enter the downsampling factor:');

n=0:N-1;

x=sin(2*pi*f1*n)+sin(2*pi*f2*n);

y=resample(x,L,D);

subplot(2,1,1);

stem(n,x(1:N));

title('inputsequence');

xlabel('time(n)');

ylabel('amplitude');

subplot(2,1,2);

m=0:N*L/D-1;

stem(m,y(1:N*L/D));

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 60


Department of Electronics & Communication Engineering Digital Signal Processing Lab

title('outputsequence');

xlabel('time(n)');

ylabel('amplitude');

INPUT:

enter the length of the input signal:

enter the frequency of first sinusoidal:

enter the frequency of second sinusoidal:

enter the upsampling factor:

enter the downsampling factor:

OUTPUT:

RESULT:

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.
6. What is meant anti-aliasing?
7. What is the effect of anti-imaging filter?
8. Define sampling rate.
9. What is the use of sampling rate convertors?
10. Explain advantages of anti-aliasing filters

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 61


Department of Electronics & Communication Engineering Digital Signal Processing Lab

INTRODUCTION TO DSP PROCESSORS (TMS320C6713DSK)


The C6713™ DSK builds on TI's industry-leading line of low cost, easy-to-use DSP Starter Kit
(DSK) development boards. The high-performance board features the TMS320C6713 floating-point
DSP. Capable of performing 1350 million floating-point operations per second (MFLOPS), the
C6713 DSP makes the C6713 DSK the most powerful DSK development board. The DSK is USB
port interfaced platform that allows efficiently developing and testing applications for the C6713.
The DSK consists of a C6713-based printed circuit board that will serve as a hardware reference
design for TI’s customers’ products. With extensive host PC and target DSP software support,
including bundled TI tools, the DSK provides ease- of-use and capabilities that areattractive to DSP
engineers.

The C6713 DSK has a TMS320C6713 DSP onboard that allows full-speed verification ofcode
with Code Composer Studio. The C6713 DSK provides:
 A USB Interface
 SDRAM and ROM
 An analog interface circuit for Data conversion (AIC)
 An I/O port
 Embedded JTAG emulation support
Connectors on the C6713 DSK provide DSP external memory interface (EMIF) and peripheral
signals that enable its functionality to be expanded with custom or third party daughter boards. The
DSK provides a C6713 hardware reference design that can assist you in the development of your
own C6713-based products. In addition to providing a reference for interfacing the DSP to various

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 62


Department of Electronics & Communication Engineering Digital Signal Processing Lab

types of memories and peripherals, the design also addresses power, clock, JTAG, and parallel
peripheral interfaces.
The C6713 DSK includes a stereo codec. This analog interface circuit (AIC) has the following
characteristics:
 High-Performance Stereo Codec

 90-dB SNR Multibit Sigma-Delta ADC (A-weighted at 48 kHz)


 100-dB SNR Multibit Sigma-Delta DAC (A-weighted at 48 kHz)
 1.42 V – 3.6 V Core Digital Supply: Compatible With TI C54x DSP

 Core Voltages

 V – 3.6 V Buffer and Analog Supply: Compatible Both TI C54x

 DSP Buffer Voltages

 8-kHz – 96-kHz Sampling-Frequency Support


 Software Control Via TI McBSP-Compatible Multiprotocol Serial Port
 I2C-Compatible and SPI-Compatible Serial-Port Protocols
 Glueless Interface to TI McBSPs
 Audio-Data Input/Output Via TI McBSP-Compatible Programmable Audio Interface
 I 2 S-Compatible Interface Requiring Only One McBSP for both ADC and DAC
 Standard I 2 S, MSB, or LSB Justified-Data Transfers 16/20/24/32-Bit Word Length

The 6713 DSK is a low-cost standalone development platform that enables customers to evaluate
and develop applications for the TI C67XX DSP family. The DSK also serves as a hardware
reference design for the TMS320C6713 DSP. Schematics, logic equations and application notes are
available to ease hardware development and reduce time to market. The DSK uses the 32-bit EMIF
for the SDRAM (CE0) and daughter card expansion interface (CE2 and CE3). The Flash is attached
to CE1 of the EMIF in 8-bit mode.
An on-board AIC23 codec allows the DSP to transmit and receive analog signals. McBSP0 is used
for the codec control interface and McBSP1 is used for data. Analog audio I/O is done through
four 3.5mm audio jacks that correspond to microphone input, line input, line output and headphone
output. The codec can select the microphone or the line input as the active input. The analog

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 63


Department of Electronics & Communication Engineering Digital Signal Processing Lab

output is driven to both the line out (fixed gain) and headphone (adjustable gain) connectors.
McBSP1 can be re-routed to the expansion connectors in software.
A programmable logic device called a CPLD is used to implement glue logic that ties the board
components together. The CPLD has a register based user interface that lets the user configure
the board by reading and writing to the CPLD registers. The registers reside at the midpoint of
CE1.The DSK includes 4 LEDs and 4 DIP switches as a simple way to provide the user with
interactive feedback. Both are accessed by reading and writing to the CPLD registers.

An included 5V external power supply is used to power the board. On-board voltage regulators
provide the 1.26V DSP core voltage, 3.3V digital and 3.3V analog voltages. A voltage supervisor
monitors the internally generated voltage, and will hold the boards in reset until the supplies are
within operating specifications and the reset button is released. If desired JP1 and JP2 can be used
as power test points for the core and I/O power supplies. Code Composer communicates with the
DSK through an embedded JTAG emulator with a USB host interface. The DSK can also be
used with an external emulator through the external JTAG connector.
TMS320C6713 DSP Features:
 Highest-Performance Floating-Point Digital Signal Processor (DSP):
 Eight 32-Bit Instructions/Cycle
 32/64-Bit Data Word
 300-, 225-, 200-MHz (GDP), and 225-, 200-, 167-MHz (PYP) Clock Rates
 3.3-, 4.4-, 5-, 6-Instruction Cycle Times
 2400/1800, 1800/1350, 1600/1200, and 1336/1000 MIPS /MFLOPS
 Rich Peripheral Set, Optimized for Audio
 Highly Optimized C/C++ Compiler
 Extended Temperature Devices Available
 Advanced Very Long Instruction Word (VLIW) TMS320C67x™ DSP Core
 Eight Independent Functional Units:
 Two ALUs (Fixed-Point)
 Four ALUs (Floating- and Fixed-Point)
 Two Multipliers (Floating- and Fixed-Point)
 Load-Store Architecture With 32 32-Bit General-Purpose Registers
 Instruction Packing Reduces Code Size

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 64


Department of Electronics & Communication Engineering Digital Signal Processing Lab

 All Instructions Conditional


 Instruction Set Features
 Native Instructions for IEEE 754
 Single- and Double-Precision
 Byte-Addressable (8-, 16-, 32-Bit Data)
 8-Bit Overflow Protection
 Saturation; Bit-Field Extract, Set, Clear; Bit-Counting; Normalization
 L1/L2 Memory Architecture
 4K-Byte L1P Program Cache (Direct-Mapped)
 4K-Byte L1D Data Cache (2-Way)

 256K-Byte L2 Memory Total: 64K-Byte L2 Unified Cache/Mapped RAM,and


192K-Byte Additional L2 Mapped RAM
 Device Configuration
 Boot Mode: HPI, 8-, 16-, 32-Bit ROM Boot
 Endianness: Little Endian, Big Endian
 32-Bit External Memory Interface (EMIF)
 Glue less Interface to SRAM, EPROM, Flash, SBSRAM, and SDRAM
 512M-Byte Total Addressable External Memory Space
 Enhanced Direct-Memory-Access (EDMA) Controller (16 Independent Channels)
 16-Bit Host-Port Interface (HPI)
 Two Multichannel Audio Serial Ports (McASPs)
 Two Independent Clock Zones Each (1 TX and 1 RX)
 Eight Serial Data Pins Per Port: Individually Assignable to any of the Clock Zones
 Each Clock Zone Includes:
 Programmable Clock Generator
 Programmable Frame Sync Generator
 TDM Streams From 2-32 Time Slots
 Support for Slot Size:8, 12, 16, 20, 24, 28, 32 Bits
 Data Formatter for Bit Manipulation
 Wide Variety of I2S and Similar Bit Stream Formats
 Integrated Digital Audio Interface Transmitter (DIT) Supports:
 S/PDIF, IEC60958-1, AES-3, CP-430 Formats

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 65


Department of Electronics & Communication Engineering Digital Signal Processing Lab

 Up to 16 transmit pins
 Enhanced Channel Status/User Data
 Extensive Error Checking and Recovery
 Two Inter-Integrated Circuit Bus (I2C Bus™) Multi-Master and Slave
 Interfaces
 Two Multichannel Buffered Serial Ports:
 Serial-Peripheral-Interface (SPI)
 High-Speed TDM Interface
 AC97 Interface
 Two 32-Bit General-Purpose Timers
 Dedicated GPIO Module With 16 pins (External Interrupt Capable)
 Flexible Phase-Locked-Loop (PLL) Based Clock Generator Module
 IEEE-1149.1 (JTAG ) Boundary-Scan-Compatible

APPLICATIONS OF DSP:

Digital signal processors are used for a wide range of applications, from communications
and controls to speech and image processing.

 Telecommunications
 Control systems
 Instrumentation
 Image processing
 Military
 Medical
 Networking

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 66


Department of Electronics & Communication Engineering Digital Signal Processing Lab

Block Diagram of TMS320C6713 DSK

Board Diagram of TMS320C6713 DSK

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 67


Department of Electronics & Communication Engineering Digital Signal Processing Lab

INTRODUCTION TO CODE COMPOSER STUDIO

Code Composer Studio™ (CCS or CC Studio) is the integrated development environment for TI's
DSPs, microcontrollers and application processors. CC Studio includes a suite of tools used to
develop and debug embedded applications. It includes compilers for each of TI's device families,
source code editor, project build environment, debugger, profiler, simulators and many other
features. CC Studio provides a single user interface taking users through each step of the application
development flow. Familiar tools and interfaces allow users to get started faster than ever before
and add functionalityto their application thanks to sophisticated productivity tools.

CC Studio version 4 (CCSv4) is based on the Eclipse open source software framework. CCSv4 is
based on Eclipse because it offers an excellent software framework for development environments
a standard framework many embedded software vendors. CCSv4 combines the advantages of the
Eclipse software framework with advanced embedded debug capabilities from TI resulting in a
compelling feature rich development environment for embedded developers.

FEATURES:

DEBUGGER:

CCStudio's integrated debugger has several capabilities and advanced breakpoints to simplify
development. Conditional or hardware breakpoints are based on full C expressions, local variables
or registers. The advanced memory window allows you to inspect each level of memory so that you
can debug complex cache coherency issues. CCStudio supports the development of complex
systems with multiple processors or cores. Global breakpoints and synchronous operations provide
control over multipleprocessors and cores.

PROFILING:

CCStudio's interactive profiler makes it easy to quickly measure code performance and ensure the
efficient use of the target's resources during debug and development sessions. The profiler allows
developers to easily profile all C/C++ functions in their application for instruction cycles or other
events such as cache misses/hits, pipeline stalls and branches.

Profile ranges can be used to concentrate efforts on high-usage areas of code during optimization,
helping developers produce finely-tuned code. Profiling is available for ranges of assembly, C++ or

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 68


Department of Electronics & Communication Engineering Digital Signal Processing Lab

C code in any combination. To increase productivity, all profiling facilities are available throughout
the development cycle.

SCRIPTING:

Some tasks such as testing need to run for hours or days without user interaction. To accomplish
such a task, the IDE should be able to automate common tasks. CCStudio has a complete scripting
environment allowing for the automation of repetitive tasks such as testing and performance
benchmarking. A separate scripting console allows you to type commands or to execute scripts
within the IDE.

IMAGE ANALYSIS AND VISUALIZATION:

CCStudio has many image analysis and graphic visualization. It includes the ability to graphically
view variables and data on displays which can be automatically refreshed. CCStudio can also look
at images and video data in the native format (YUV, RGB) both in the host PC or loaded in the
target board.

COMPILER:
TI has developed C/C++ compilers specifically tuned to maximize the processor's usage and
performance. TI compilers use a wide range of classical, application-oriented, and sophisticated
device-specific optimizations that are tuned to all the supported architectures.

Some of these optimizations include:

 Common sub-expression elimination


 Software pipelining
 Strength Reduction
 Auto increment addressing
 Cost-based register allocation
 Instruction predication
 Hardware looping
 Function In-lining
 Vectorization
TI compilers also perform program level optimizations that evaluate code performance at the
application level. With the program level view, the compiler is able to generate code similar to an

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 69


Department of Electronics & Communication Engineering Digital Signal Processing Lab

assembly program developer who has the full system view. This application level view is leveraged
by the compiler to make trade-offs that significantly increase the processor performance.

The TI ARM and Microcontroller C/C++ compilers are specifically tuned for code size and control
code efficiency. They offer industry leading performance and compatibility.

SIMULATION:

Simulators provide a way for users to begin development prior to having access to a development
board. Simulators also have the benefit of providing enhanced visibility into application
performance and behaviour. Several simulator variants are available allowing users to trade off
cycle accuracy, speed and peripheral simulation, with some simulators being ideally suited to
algorithm benchmarking and others for more detailed system simulation

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 70


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:11
MAC OPERATION USING VARIOUS ADDRESSING MODES
USING DSP PROCESSOR
AIM:
To perform MAC operation using various addressing modes of TMS320C6713 DSP processor.

TOOLS REQUIRED:
Computer, DSP Processor, CC studio software.
THEORY:
Addressing Modes of The TMS320C6713 DSP supports three types of addressing modes that enable
flexible access to data memory, to memory-mapped registers, to register bits, and to I/O space:
 The absolute addressing mode allows to reference a location by supplying all or part of an
address as a constant in an instruction.
 The direct addressing mode allows to reference a location using an address offset.
 The indirect addressing mode allows to reference a location using a pointer.
Each addressing mode provides one or more types of operands. An instruction that supports an
addressing-mode operand has one of the following syntax elements listed below.
Baddr:
When an instruction contains Baddr, that instruction can access one or two bits in an accumulator
(AC0–AC3), an auxiliary register (AR0–AR7), or a temporary register (T0–T3). Only the register bit
test/set/clear/complement instructions support Baddr.
Cmem:
When an instruction contains Cmem, that instruction can access a single word (16 bits)of data from
data memory..
Lmem:
When an instruction contains Lmem, that instruction can access a long word (32 bits) of data from
data memory or from a memory-mapped registers.
Smem:
When an instruction contains Smem, that instruction can access a single word (16 bits) of data from
data memory, from I/O space, or from a memory-mapped register. As you write the instruction, replace
Smem with a compatible operand.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 71


Department of Electronics & Communication Engineering Digital Signal Processing Lab

Xmem and Ymem:


When an instruction contains Xmem and Ymem, that instruction can perform two simultaneous 16-bit
accesses to data memory.
ABSOLUTE ADDRESSING MODE:
This mode uses the 7-bit register called DPH (high part of the extended data page register) and a 16-
bit unsigned constant to form a 23-bit data space address. This mode is used to access a memory
location or a memory-mapped register.
k23 absolute:
This mode enables you to specify a full address as a 23-bit unsigned constant. This mode is used to
access a memory location or a memory-mapped register.
I/O absolute:
This mode enables you to specify an I/O address as a 16-bit unsigned constant. This mode is used to
access a location in I/O space.
DIRECT ADDRESSING MODE:
This mode uses the main data page specified by DPH (high part of the extended data page register) in
conjunction with the data page register (DP).This mode is used to access a memory location or a
memory-mapped register.
SP direct:
This mode uses the main data page specified by SPH (high part of the extended stack pointers) in
conjunction with the data stack pointer (SP). This mode is used to access stack values in data memory.
Register-bit direct:
This mode uses an offset to specify a bit address. This mode is used to access one register bit or two
adjacent register bits.
PDP direct:
This mode uses the peripheral data page register (PDP) and an offset to specify an I/O address. This
mode is used to access a location in I/O space. The DP direct and SP direct addressing modes are
mutually exclusive. The mode selected depends on the CPL bit in status register ST1_67: 0 DP direct
addressing mode 1 SP direct addressing mode .The register-bit and PDP direct addressing modes are
independent of the CPL bit.
INDIRECT ADDRESSING MODE:
These modes may be used for linear addressing or circular addressing.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 72


Department of Electronics & Communication Engineering Digital Signal Processing Lab

AR indirect

This mode uses one of eight auxiliary registers (AR0–AR7) to point to data. The way the CPU
uses the auxiliary register to generate an address depends on whether accessing data space (memory
or memory-mapped registers), individual register bits, or I/O space.
Dual AR indirect

This mode uses the same address-generation process as the AR indirect addressing mode. This
mode is used with instructions that access two or more data-memory locations.
CDP indirect

This mode uses the coefficient data pointer (CDP) to point to data. The way the CPU uses CDP
to generate an address depends on whether accessing data space (memory or memory-mapped
registers), individual register bits, or I/O space.
Coefficient indirect

This mode uses the same address-generation process as the CDP indirect addressing mode. This
mode is available to support instructions that can access a coefficient in data memory at the same time
they access two other data-memory values using the dual AR indirect addressing mode.
Circular Addressing

Circular addressing can be used with any of the indirect addressing modes. Each of the eight
auxiliary registers (AR0–AR7) and the coefficient data pointer (CDP) can be independently
configured to be linearly or circularly modified as they act as pointers to data or to register bits.
This configuration is done with a bit (ARnLC) in status register ST2_67.

ASSEMBLY LANGUAGE PROGRAM TO PERFORM MAC OPERATIONS:

ADDITION:
INP1 .SET 0H
INP2 .SET 1H
OUT .SET 2H
.mmregs
.text
START:
LD
#140H,DP
RSBX CPL
NOP

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 73


Department of Electronics & Communication Engineering Digital Signal Processing Lab

NOP
NOP
NOP
LD INP1,A
ADD INP2,A
STL A,OUT
HLT: B HLT
INPUT:
Data Memory:

OUTPUT:
Data Memory:

SUBTRACTION:
INP1 .SET 0H
INP2 .SET 1H
OUT .SET 2H
.mmregs
.text
START:
LD #140H,DP
RSBX CPL
NOP
NOP
NOP
NOP
LD INP1,A
SUB INP2,A
STL A,OUT
HLT: B HLT
INPUT:
Data Memory:

OUTPUT:
Data Memory:

RESULT:

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 74


Department of Electronics & Communication Engineering Digital Signal Processing Lab

VIVA QUESTIONS:
1. What are the features of TMS320C6713 DSP?
2. What is the fastest member of the tms320c67xx family?
3. Which CPU architecture is fastest?
4. What is TMS 320 explain its architecture?
5. How many functional units are there in tms320c6x processor?
6. What is the total memory space of tms320c6x?
7. What is the memory architecture of DSP processor?
8. Which software tool is required to compile and run DSP assembly language program.
9. What are the applications of TMS320 DSP’s?
10. What is the difference between von neumann architecture and Harvard architecture?

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 75


Department of Electronics & Communication Engineering Digital Signal Processing Lab

EXPERIMENT NO:12
UP-SAMPLING AND DOWN-SAMPLING IN DSP PROCESSOR
AIM:
To perform the Decimation of given discrete sequence in TMS320C6713 KIT
TOOLS REQUIRED:
Computer, CCS v4,TMS320C6713 KIT,USB Cable,5V Adapter
THEORY:
Multi-rate signal processing studies digital signal processing systems which include sample rate
conversion. Multirate signal processing techniques are necessary for systems with different input
and output sample rates but may also be used to implement systems with equal input and output
rates.
DECIMATION:
The process of changing the sampling rate of a signal (resampling) is called downsampling if the
sample rate is decreased and upsampling if the sample rate is increased. Integer rate changes are
far more common than non-integer rate changes. In signal processing, downsampling (or
“subsampling”) is the process of reducing the sampling rate of a signal. This is usually done to
reduce the data rate or the size of the data. The downsampling factor (commonly denoted by M)
is usually an integer or a rational fraction greater than unity. This factor multiplies the sampling
time or, equivalently, divides the sampling rate.
INTERPOLATION:
The process of changing the sampling rate of a signal (resampling) is called downsampling if the
sample rate is decreased and upsampling if the sample rate is increased. Integer rate changes are
far more common than non-integer rate changes. Interpolation is a method of constructing new
data points within the range of a discrete set of known data points. Upsampling is the process of
increasing the sampling rate of a signal. For instance, upsampling raster images such as
photographs means increasing the resolution of the image.The upsampling factor (commonly
denoted by L) is usually an integer or a rational fraction greater than unity. This factor multiplies
the sampling rate or, equivalently, divides the sampling period.

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 76


Department of Electronics & Communication Engineering Digital Signal Processing Lab

PROCEDURE FOR BUILD A PROJECT ON DECIMATION USING TMS320C6713 DSP:


1. Open Code Composer Studio v4.
2. In Workspace Launcher.
 BROWSE → Select the project location and make one new folder, MAKE NEW FOLDER
→ Type the Workspace name, OK → OK.
3. FILE ⇒ NEW ⇒ CCS PROJECT
 Project name: Type your project name.
 Tick use default location. → NEXT
 Project type C6000.
 Tick Debug and Release. → NEXT → NEXT.
 Output type: Executable.
 Device Variant: generic – TMS320C6745.
 Device Endianness: little
 Code Generation Tools: TI v6.1.12.
 Run time support library: automatic.
 Target content: none. →FINISH
4.FILE ⇒ NEW ⇒ SOURCE FILE
 Source file: Type your projectname.c (.c extension is must).
 Type the program.
 FILE → SAVE.
5. Paste the following board library files in workspace location.
 Common folder (contains header files)
 Gel folder (contains gel file)
 Library folder (contains library files)
6. Paste the Linker file in the project location.
7. PROJECT ⇒ PROPERTIES ⇒ C/C++ BUILD → BASIC OPTION
 Target processor version (–silicon version, -mv): 6400+ →OK.
 IN C/C++ BUILD, → INCLUDE OPTIONS (Add dir to #include search path(–include_path,-
I)) select this add icon and add the following three path by individually –
“${Diag}../../common/header” – “${XDAIS_CG_ROOT}/packages/ti/xdais” –
“${C6000_CSL_CG_ROOT}/include”

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 77


Department of Electronics & Communication Engineering Digital Signal Processing Lab

8. FILE ⇒ NEW ⇒ TARGET CONFIGURATION FILE


 file name: projectname. ccxml (.ccxml extension is must)
 Connection: Texas Instrument XDS100 v1 USB Emulator.
 Device: TMS320C6713. (Tick the TMS320C6713)→ SAVE → TARTGET
CONFIGURATION → C674X_0 → BROWSE, browse the workspace location, open the gel
folder and select the GEL file. → OPEN → SAVE.
9. In C/C++ Project window, Right click the project ⇒ REBUILD PROJECT.
10. Connections
 Connect the USB cable, PC to TMS320C6713 KIT.
 Connect the 5v adapter.
 Power on the kit.
11. TARGET ⇒ DEBUG ACTIVE PROJECT.
12. TARGET ⇒ RUN.
PROGRAM FOR DECIMATION USING TMS320C6713 DSP:
#include
#include
#include
int x[100],h[100],y[100],c1[100],y1[100];
void main()
{
int a,b,d;
int i,j,z;
printf("\n Enter the No of input vector:");
scanf("%d",&a);
printf("\n Enter sampling value:");
scanf("%d",&b);
printf("Enter values for i/p x(n):\n");
for(i=1;i<=a;i++)
scanf("%d",&x[i]);
j = 1;
for (i=1;i<=a;i++)
{
Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 78
Department of Electronics & Communication Engineering Digital Signal Processing Lab

y[i] = x[j];
j = j+b;
}
d = a/b;
z = round(d);
for(i=1;i<=z;i++)
printf("\n The first order decimation values are y[%d]=%d",i,y[i]);
printf( "\n***ALL Tests Passed***\n" );
}
INPUT:
Enter the No of input vector: ⇒ Enter.
Enter sampling value: ⇒ Enter.
Enter values for i/p x(n): – ⇒ Enter.
OUTPUT:

The first order decimation values are y[1]=


The first order decimation values are y[2]=
The first order decimation values are y[3]=
The first order decimation values are y[4]=
The first order decimation values are y[5]=
***ALL Tests Passed***
PROGRAM FOR INTERPOLATION USING TMS320C6713 DSP:
#include
#include
#include
Int tx[50],th[50],ty[50];
Void main()
{
int ta,tb,tc,td;
int ti,tj,txx,tcc,tz;
printf(“\n Enter the input vector values:”);
scanf(“%d”,&ta);
printf(“\n Enter sampling values:”);
Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 79
Department of Electronics & Communication Engineering Digital Signal Processing Lab

scanf(“%d”,&tb);
printf(“Enter values for i/p x(n):\n”);
for(ti=1;ti<=ta;ti++)
scanf(“%d”,&tx[ti]);
tc = tb -1;
txx = 0;
for (ti=1;ti<=ta;ti++)
{
ty[ti+txx] = tx[ti];
tcc = ti+txx
tz = ti;
for (tj = 1 ;tj<=tc ;tj++)
{
ty[tcc+1] = 0;
ti = ti+1;
tcc =tcc+1;
}
txx = tcc-tz;
ti = ti-tc;
}
td = ta*tb;
for(ti=1;ti<=td;ti++)
printf(“\n The Value of output ty[%d=%d’,ti,ty[ti]);
printf(“\n***ALL Tests Passed***\n” );
}
INPUT:

Enter the input vector values: ⇒ Enter.


Enter sampling value: ⇒ Enter.
Enter values for i/p x(n): ⇒ Enter.

OUTPUT:
The Value of output ty[1]=
Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 80
Department of Electronics & Communication Engineering Digital Signal Processing Lab

The Value of output ty[2]=


The Value of output ty[3]=
The Value of output ty[4]=
The Value of output ty[5]=
The Value of output ty[6]=
The Value of output ty[7]=
The Value of output ty[8]=
The Value of output ty[9]=
The Value of output ty[10]=
The Value of output ty[11]=
The Value of output ty[12]=
The Value of output ty[13]=
The Value of output ty[14]=
The Value of output ty[15]=
The Value of output ty[16]=
The Value of output ty[17]=
The Value of output ty[18]=
The Value of output ty[19]=
The Value of output ty[20]=
***ALL Tests Passed***
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?
6. What is meant anti-aliasing?
7. What is the effet of anti-imaging filter?
8. What is meant by zero stuffing?
9. What is upsampling and downsampling?
10. What is the need of multi rate signal processing?

Raghu Institute of Technology (Autonomous), Dakamarri , Visakhapatnam 81

You might also like