Вы находитесь на странице: 1из 108

DIGITAL SIGNAL PROCESSING LAB MANUAL

DIGITAL SIGNAL PROCESSING LAB


LAB MANUAL

DEPARTMENT OF ELECTRONICS AND


COMMUNICATION ENGINEERING

NRI INSTITUTE OF TECHNOLOGY


(Approved by AICTE, New Delhi: Affiliated to JNTUK, Kakinada)
POTHAVARAPPADU (V), (via) Nunna, Agiripalli (M),
Krishna District, A.P. PIN: 521212 Ph: 08656-324999
Website: nrigroupofcolleges.com e-mail: nrigroupofcolleges@gmail.com

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

LIST OF EXPERIMENTS
1 To study the architecture of DSP chips – TMS 320C 5X/6X Instructions
2 Linear Convolution
3 Circular Convolution
4 To design FIR filter (LP/HP) using windowing technique
a) Using rectangular window
b) Using triangular window
c) Using Kaiser window
5 To Implement IIR filter (LP/HP) on DSP Processors
6 N-point FFT algorithm.
7 MATLAB program to generate sum of sinusoidal signals
8 MATLAB program to find frequency response of analog LP/HP filters
9 To compute power density spectrum of a sequence
10 To find the FFT of given 1-D signal and plot
CODE COMPOSER STUDIO
1 sum of sinusoidal signals
2 Linear Convolution
3 frequency response of analog LP/HP filters
ADDITIONAL EXPERIMENTS BEYOND THE JNTUK SYLLABUS
11 Implementation of Decimation and interpolation process
12 Implementation of I/D sampling rate converters
13 DTMF(Dual Tone Multi Frequency) signal generation

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Evaluation of Marks for the Laboratory Exam


Internal Marks - 25
 For Laboratory courses there should be continuous evaluation during the semester for

25 Internal Marks. The distribution of Internal Marks is given below.

S.No Criteria Marks


1 Day to Day Performance 10M
2 Record 5M
3 Internal Examination 10M
Total Marks 25M

External Lab Exam - 50

 Each semester end lab Examination shall be evaluated by an External Examiner along
with an Internal Examiner

S.No Criteria Marks


1 Prepractical(Write-Up) 15M
2 Execution 15M
3 Post practical(Output) 10M
4 Viva 10M
Total Marks 50M

Total Lab Exam Marks – 75

 Each semester Total Final lab Examination marks is the sum of marks obtained in
both internal and external Exams.
S.No Criteria Marks
1 Internal Examination 25M
2 External Examination 70M
Total Marks 75M

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

INSTRUCTIONS TO THE STUDENT

1. Students are required to attend all labs.


2. Students will work individually in hardware laboratories and in computer laboratories.
3. While coming to the lab bring the lab manual cum observation book, record etc.
4. Take only the lab manual, calculator (if needed) and a pen or pencil to the work area.
5. Before coming to the lab, prepare the pre-lab questions. Read through the lab
experiment to familiarize yourself with the components and assembly sequence.
6. Utilize 3 hours time properly to perform the experiment (both in software and
hardware) and note down the readings properly. Do the calculations, draw the graph
and take signature from the instructor.
7. If the experiment is not completed in the prescribed time, the pending work has to be
done in the leisure hour or extended hours.
8. You have to submit the completed record book according to the deadlines set up by
your instructor.
9. For practical subjects there shall be a continuous evaluation during the semester for
25 sessional marks and 50 end examination marks.
10. Of the 25 marks for internal, 15 marks shall be awarded for day-to-day work,record
and 10 marks to be awarded by conducting an internal laboratory test.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

INTRODUCTION TO MATLAB AND ITS BASIC


COMMANDS

MATLAB:
This is very important tool used for making long complicated calculations and
plotting graphs of different functions depending upon our requirement. Using MATLAB an
m-file created in which the basic operations are performed which the basic operations are
performed which leads to simple short and simple computations of very complicated
problems in no or very short time.
Important functions performed by MATLAB are give as follows:
 Matrix computations
 Vector Analysis
 Differential equations computations
 Integration is possible
 Computer language programming
 Simulations
 Graph Plotations
 2D and 3D plotting
Befits:
 Simple to use
 Fast computations are possible
 Wide working range
 Solutions of matrix any order
 Desired operations are performed in matrices
 Different programming languages can be used
 Simulation is possible

LIBRARY FUNCTIONS:
clc
 Clear Command Window.
 clc clears all input and output from the Command Window display, giving you a
"clean screen."

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Close all
 Remove specified figure
 close deletes the current figure or the specified figure(s). It optionally returns the
status of the close operation.
 close deletes the current figure

clear all

 Remove items from workspace, freeing up system memory


 clear removes all variables from the workspace, releasing them from system memory.
 clear name removes just the M-file or MEX-file function or variable name from your
base workspace. If called from a function, clear name removes name from both the
function workspace and in your base workspace.
ones
 Create array of all ones
 Y = ones(n) returns an n-by-n matrix of 1s. An error message appears if n is not a
scalar.
 Y = ones(m,n) or Y = ones([m n]) returns an m-by-n matrix of ones.

zeros

 Create array of all zeros


 B = zeros(n) returns an n-by-n matrix of zeros. An error message appears if n is not a
scalar.
 B = zeros(m,n) or B = zeros([m n]) returns an m-by-n matrix of zeros.

plot

 2-D line plot


 plot(Y) plots the columns of Y versus the index of each value when Y is a real
number. For complex Y, plot(Y) is equivalent to plot(real(Y),imag(Y)).
subplot

 Create axes in tiled positions

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

 subplot divides the current figure into rectangular panes that are numbered rowwise.
Each pane contains an axes object which you can manipulate using Axes Properties.
Subsequent plots are output to the current pane.
 h = subplot(m,n,p) or subplot(mnp) breaks the figure window into an m-by-n matrix
of small axes, selects the pth axes object for the current plot, and returns the axes
handle. The axes are counted along the top row of the figure window, then the second
row, etc.

xlabel, ylabel, zlabel

 Label x-, y-, and z-axis


 Each axes graphics object can have one label for the x-, y-, and z-axis. The label
appears beneath its respective axis in a two-dimensional plot and to the side or
beneath the axis in a three-dimensional plot.
 xlabel('string') labels the x-axis of the current axes.

title

 Add title to current axes


 Each axes graphics object can have one title. The title is located at the top and in the
center of the axes.
 title('string') outputs the string at the top and in the center of the current axes.
 title(fname) evaluates the function that returns a string and displays the string at the
top and in the center of the current axes.

stem

 Plot discrete sequence data


 A two-dimensional stem plot displays data as lines extending from a baseline along
the x-axis. A circle (the default) or other marker whose y-position represents the data
value terminates each stem.
 stem(Y) plots the data sequence Y as stems that extend from equally spaced and
automatically generated values along the x-axis. When Y is a matrix, stem plots all
elements in a row against the same x value.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

 stem(X,Y) plots X versus the columns of Y. X and Y must be vectors or matrices of


the same size. Additionally, X can be a row or a column vector and Y a matrix with
length(X) rows.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

REPRESENTATION OF BASIC SIGNALS:

% sine wave
t=0:0.01:0.5;
a=2;
b=a*sin(2*pi*2*t);
subplot(3,3,1);
stem(t,b);
xlabel('time');
ylabel('Amplitude');
title ('sinewave');
% Cosine wave
t=0:0.01:0.5;
a=2;
b=a*cos(2*pi*2*t);
subplot(3,3,2);
stem(t,b);
xlabel('time');
ylabel('Amplitude');
title ('Cos wave');
% Square wave
t=0:0.01:0.5;
a=2;
b=a*square(2*pi*2*t);
subplot(3,3,3);
stem(t,b);
xlabel('time');
ylabel('Amplitude');
title ('square wave');
% Exponential waveform
t=0:0.01:0.5;
a=2; b=a*exp(2*pi*2*t);
subplot(3,3,4);
stem(t,b);

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

xlabel('time');
ylabel('Amplitude');
title ('exponential wave');
%sawtooth
t=0:0.01:0.5;
a=2;
b=a*sawtooth(2*pi*2*t);
subplot(3,3,5);
stem(t,b);
xlabel('time');
ylabel('Amplitude');
title ('sawtooth wave');
% unit step signal
n=-5:5;
a = [zeros(1,5),ones(1,6)];
subplot(3,3,6);
stem(n,a);
Xlabel ('time');
Ylabel ('amplitude');
title('Unit step');
% unit impulse
n=-5:5;
a = [zeros(1,5),ones(1,1),zeros(1,5)];
subplot(3,3,7);
stem(n,a);
Xlabel ('time');
Ylabel ('amplitude');
title('Unit impulse');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Model Graph:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

ARCHITECTURE OF 6713 DSP PROCESSOR EXPT. NO : 1

DATE :

INTRODUCTION TO DSP PROCESSORS


A signal can be defined as a function that conveys information, generally about the
state or behavior of a physical system. There are two basic types of signals viz Analog
(continuous time signals which are defined along a continuum of times) and Digital (discrete-
time).
Remarkably, under reasonable constraints, a continuous time signal can be adequately
represented by samples, obtaining discrete time signals. Thus digital signalprocessing is an
ideal choice for anyone who needs the performance advantage of digital manipulation along
with today’s analog reality. Hence a processor which is designed to perform the special
operations(digital manipulations) on the digital signal within very less time can be called as a
Digital signal processor. The difference between a DSP processor, conventional
microprocessor and a microcontroller are listed below.

Microprocessor or General Purpose Processor such as Intel xx86 or Motorola 680xx


Family Contains – only CPU
-No RAM
-No ROM
-No I/O ports
-No Timer
Microcontroller such as 8051 family
Contains - CPU
- RAM
- ROM
-I/O ports
- Timer &
- Interrupt circuitry
Some Micro Controllers also contain A/D, D/A and Flash Memory
DSP Processors such as Texas instruments and Analog Devices
Contains - CPU

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

- RAM
-ROM
- I/O ports
- Timer
Optimized for – fast arithmetic
- Extended precision
- Dual operand fetch
- Zero overhead loop
- Circular buffering

The basic features of a DSP Processor are

Feature Use
Fast-Multiply accumulate Most DSP algorithms, including filtering,
transforms, etc. are
multiplication- intensive
Multiple – access memory Many data-intensive DSP operations
architecture require reading a program instruction
and multiple data items during each
instruction cycle for best performance
Specialized addressing modes Efficient handling of data arrays and
first-in, first-out buffers in memory
Specialized program control Efficient control of loops for many
iterative DSP algorithms. Fast interrupt
handling for frequent I/O operations.
On-chip peripherals and I/O On-chip peripherals like A/D converters
interfaces allow for small low cost system designs.
Similarly I/O interfaces tailored for
common peripherals allow clean
interfaces to off-chip I/O devices.
ARCHITECTURE OF 6713 DSP PROCESSOR
This chapter provides an overview of the architectural structure of the TMS320C67xx
DSP, which comprises the central processing unit (CPU), memory, and on-chip peripherals.
The C67xE DSPs use an advanced modified Harvard architecture that maximizes processing

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

power with eight buses. Separate program and data spaces allow simultaneous access to
program instructions and data, providing a high degree of parallelism. For example, three
reads and one write can be performed in a single cycle. Instructions with parallel store and
application-specific instructions fully utilize this architecture. In addition, data can be
transferred between data and program spaces. Such Parallelism supports a powerful set of
arithmetic, logic, and bit-manipulation operations that can all be performed in a single
machine cycle. Also, the C67xx DSP includes the control mechanisms to manage interrupts,
repeated operations, and function calling.

Figure: BLOCK DIAGRAM OF TMS 320VC 6713

Bus Structure

-bit buses (four


program/data

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

buses and four address buses):


_ The program bus (PB) carries the instruction code and immediate operands from program
memory.
_ Three data buses (CB, DB, and EB) interconnect to various elements, such as the CPU, data
address generation logic, program address generation logic, on-chip peripherals, and data
memory.
_ The CB and DB carry the operands that are read from data memory.
_ The EB carries the data to be written to memory.
_ Four address buses (PAB, CAB, DAB, and EAB) carry the addresses needed for instruction
execution.
The C67xx DSP can generate up to two data-memory addresses per cycle using the
two auxiliary register arithmetic units (ARAU0 and ARAU1). The PB can carry data
operands stored in program space (for instance, a coefficient table) to the multiplier and adder
for multiply/accumulate operations or to a destination in data space for data move
instructions (MVPD and READA). This capability, in conjunction with the feature of dual-
operand read, supports the execution of single-cycle, 3-operand instructions such as the FIRS
instruction. The C67xx DSP also has an on-chip bidirectional bus for accessing on-chip
peripherals. This bus is connected to DB and EB through the bus exchanger in the CPU
interface. Accesses that use this bus can require two or more cycles for reads and writes,
depending on the peripheral’s structure.

Central Processing Unit (CPU)


The CPU is common to all C67xE devices. The C67x CPU contains:
_ 40-bit arithmetic logic unit (ALU)
_ Two 40-bit accumulators
_ Barrel shifter
_ 17 × 17-bit multiplier
_ 40-bit adder
_ Compare, select, and store unit (CSSU)
_ Data address generation unit
_ Program address generation unit

Arithmetic Logic Unit (ALU)


The C67x DSP performs 2s-complement arithmetic with a 40-bit arithmetic logic unit

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

(ALU) and two 40-bit accumulators (accumulators A and B). The ALU can also perform
Boolean operations. The ALU uses these inputs:
_ 16-bit immediate value
_ 16-bit word from data memory
_ 16-bit value in the temporary register, T
_ Two 16-bit words from data memory
_ 32-bit word from data memory
_ 40-bit word from either accumulator

The ALU can also function as two 16-bit ALUs and perform two 16-bit operations
simultaneously.

Figure: ALU UNIT

Accumulators

Accumulators A and B store the output from the ALU or the multiplier/adder block.
They
can also provide a second input to the ALU; accumulator A can be an input to the
multiplier/adder. Each accumulator is divided into three parts:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

_ Guard bits (bits 39–32)


_ High-order word (bits 31–16)
_ Low-order word (bits 15–0)
Instructions are provided for storing the guard bits, for storing the high- and the loworder
accumulator words in data memory, and for transferring 32-bit accumulator words in or out
of data memory. Also, either of the accumulators can be used as temporary storage for the
other.

Barrel Shifter

The C67x DSP barrel shifter has a 40-bit input connected to the accumulators or to
data memory (using CB or DB), and a 40-bit output connected to the ALU or to data memory
(using EB). The barrel shifter can produce a left shift of 0 to 31 bits and a right shift of 0 to
16 bits on the input data. The shift requirements are defined in the shift count field of the
instruction, the shift count field (ASM) of status register ST1, or in temporary register T
(when it is designated as a shift count register).The barrel shifter and the exponent encoder
normalize the values in an accumulator in a single cycle. The LSBs of the output are filled
with 0s, and the MSBs can be either zero filled or sign extended, depending on the state of
the sign-extension mode bit (SXM) in ST1. Additional shift capabilities enable the processor
to perform numerical scaling, bit extraction, extended arithmetic, and overflow prevention
operations.

Multiplier/Adder Unit

The multiplier/adder unit performs 17 _ 17-bit 2s-complement multiplication with a


40-
bit addition in a single instruction cycle. The multiplier/adder block consists of several
elements: a multiplier, an adder, signed/unsigned input control logic, fractional control logic,
a zero detector, a rounder (2s complement), overflow/saturation logic, and a 16-bit temporary
storage register (T). The multiplier has two inputs: one input is selected from T, a data-
memory operand, or accumulator A; the other is selected from program memory, data
memory, accumulator A, or an immediate value. The fast, on-chip multiplier allows the C54x
DSP to perform operations efficiently such as convolution, correlation, and filtering. In
addition, the multiplier and ALU together execute multiply/accumulate (MAC) computations

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

and ALU operations in parallel in a single instruction cycle. This function is used in
determining the Euclidian distance and in implementing symmetrical and LMS filters, which
are required for complex DSP algorithms. See section 4.5, Multiplier/Adder Unit, for more
details about the multiplier/adder unit.

Figure: MULTIPLIER/ADDER UNIT

These are the some of the important parts of the processor and you are instructed to go
through the detailed architecture once which helps you in developing the optimized code for
the required application.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPT. NO : 2
LINEAR CONVOLUTION DATE :

AIM :

Write a program in MATLAB to compute the response of a discrete LTI system with
input sequence x(n) and impulse response h(n) by using linear convolution.

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:

Convolution is a special operation, operated between two signals and which includes
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).

x(n) h(n) y(n)


. y(n)  x(n)  h(n)   x(m)h(n  m)
m  

It is also used to compute the impulse response of cascaded discrete LTI system with
individual systems having impulse responses h1(n), h2(n), h3(n).

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

x(n) h1(n) h1(n) h1(n) y(n)

h(n)  h (n)  h (n)  h (n).


1 2 3

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

N 1
y(n)   x(m)h(n  m)
m0

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.

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

PROGRAM:

MATLAB PROGRAM:

x=input('Enter the input sequence x(n)=');

h=input('Enter the impulse response h(n)=');

y=conv(x,h);

N1=length(x);

N2=length(h);

N=length(y);

disp('Input Sequence x(n)::');

disp(x);

disp('Impulse Response h(n)::');

disp(h);

disp('Output of discrete LTI system is');

disp(y);

n=0:1:N1-1;

subplot(2,2,1);

stem(n,x);

title('Input sequence x(n)');

xlabel('discrete Time n');

ylabel('Amplitude');

n=0:1:N2-1;

subplot(2,2,2);

stem(n,h);

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

title('Impulse Response h(n)');

xlabel('discrete Time n');

ylabel('Amplitude');

n=0:1:N-1;

subplot(2,2,3);

stem(n,y);

title('Response of discrete LTI system');

xlabel('discrete Time n');

ylabel('Amplitude');

EXPECTED RESULTS:

Enter the input sequence x(n)=[1 2 3 4]


Enter the impulse response h(n)=[4 3 2 1]
Input Sequence x(n)::
1 2 3 4
Impulse Response h(n)::
4 3 2 1
Output of discrete LTI system is
4 11 20 30 20 11 4

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

MODEL GRAPH:

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPT. NO : 3
CIRCULAR CONVOLUTION DATE :

AIM:

Write a program in MATLAB to compute the response of a discrete LTI system with
input sequence x(n) and impulse response h(n) by using Circular convolution.

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:

Convolution is a special operation, operated between two signals and which includes
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).

x(n)
h(n) y(n)


. y(n)  x(n)  h(n)   x(m)h(n  m)
m  

It is also used to compute the impulse response of cascaded discrete LTI system with
individual systems having impulse responses h1(n), h2(n), h3(n).

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

x(n) h1(n) h1(n) h1(n) y(n)

h(n)  h (n)  h (n)  h (n).


1 2 3

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

N 1
y(n)   x(m)h(n  m)
m0

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.

DFT supports only circular convolution, because of x(n) and h(n) are equal durations.
Circular convoluted sequence y(n) between x(n) and h(n) with equal duration N is defined as

N 1
y(n)   x(m)h(n  m)
m0

In this case if x(n) and h(n) are of different durations, then zero padding is required to
obtain the response of discrete LTI system.

COMPUTATION:

Following steps are required to compute the response of discrete LTI system with
input x(n) and impulse response h(n)

 Convert the input sequence x(n) duration N1 to N1+N2 –1 by padding with N2 –1


number of zeros.
 Convert the impulse response sequence h(n) duration N2 to N1+N2 –1 by padding
with N1 –1 number of zeros

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

 Keep the input sequence x(m) as it is and fold the impulse response h(m).
 Shift the folded version sequence, h(-m) by n units to get h(n-m).
 Multiply the input sequence x(m) and h(n-m).
 Finally compute the sum over the range 0 to N1+N2 –2.

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

PROGRAM:

MATLAB PROGRAM:

clc; clear all; close all;


x=input('Enter the input sequence x(n)=');
h=input('Enter the impulse response sequence h(n)=');
m=length(x);
n=length(h);
if(m>n)
h=[h zeros(1,m-n)];
elseif(m<n)
x=[x zeros(1,n-m)];
else
display('No need of zero padding');
end
m1=length(x);
n1=length(h);
p=max(m1,n1);

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

y=cconv(x,h,p);
y1=length(y);
display('Input sequence x(n)');
disp(x);
display('Impulse sequence h(n)');
disp(h);
display('Output sequence y(n)');
disp(y);
t=0:1:m1-1;
subplot(2,2,1);
stem(t,x);
xlabel('Discrete Time');
ylabel('Amplitude');
title('Input Sequence');
t=0:1:n1-1;
subplot(2,2,2);
stem(t,h);
xlabel('Discrete Time');
ylabel('Amplitude');
title('Impulse response');
t=0:1:y1-1;
subplot(2,2,3);
stem(t,y);
xlabel('Discrete Time');
ylabel('Amplitude');
title('Response of discrete LTI System');

EXPECTED RESULTS:

Enter the input sequence x(n)=[1 2 3 4]

Enter the impulse response sequence h(n)=[1 2]

Input sequence x(n)


1 2 3 4

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Impulse sequence h(n)


1 2 0 0
Output sequence y(n)
9 4 7 10

MODEL GRAPH:

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

FIR Filters EXPT. NO : 4


DATE :

AIM:

Write a program in MATLAB to design FIR filter(LP/HP) using windowing


techniques for a given cutoff frequency and number of samples.

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:

A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system


whose output is based on the weighted summation of a finite number of past inputs. An FIR
transversal filter structure can be obtained directly from the equation for discrete-time
convolution.

In this equation, x(k) and y(n) represent the input to and output from the filter at time
n. h(n-k) is the transversal filter coefficients at time n. These coefficients are generated by
using FDS (Filter Design Software or Digital filter design package). FIR – filter is a finite
impulse response filter. Order of the filter should be specified. Infinite response is truncated
to get finite impulse response. placing a window of finite length does this. Types of windows
available are Rectangular, Barlett, Hamming, Hanning, Blackmann window etc. This FIR
filter is an all zero filter.

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

PROGRAM:

MATLAB Program:

%%%%%%%Rectangular Window – LPF %%%%%%%

clc; close all; clear all;


rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
% Finding order of filter
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*((fs-fp)/f);
n=ceil(num/dem);
n1=n+1;
%Rectangular Window
y=rectwin(n1);
b=fir1(n,wp,'low',y);
[x1 y1]=freqz(b);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

title('Magnitude Response of FIR Filter');


subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');
EXPECTED RESULTS:

Enter Passband ripple=0.05


Enter Stopband ripple=0.04
Enter Passband cutoff frequency=1000
Enter Stopband cutoff frequency=1500
Enter Sampling Frequency=8000

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

%%%%%%%Rectangular Window – HPF %%%%%%%

clc; close all; clear all;


rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
% Finding order of filter
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*((fs-fp)/f);
n=ceil(num/dem);
n1=n+1;
%Rectangular Window
y=rectwin(n1);
b=fir1(n,wp,'high',y);
[x1 y1]=freqz(b);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:
Enter Passband ripple=0.07
Enter Stopband ripple=0.06
Enter Passband cutoff frequency=1000
Enter Stopband cutoff frequency=1500
Enter Sampling Frequency=8000

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

%%%%%%%%%%%Triangular Window-LPF%%%%%%%%
clc; close all; clear all;
rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
% Finding order of filter
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*((fs-fp)/f);
n=ceil(num/dem);
n1=n+1;
%Triangular Window
y=triang(n1);
b=fir1(n,wp,'low',y);
[x1 y1]=freqz(b);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:
Enter Passband ripple=0.06
Enter Stopband ripple=0.05
Enter Passband cutoff frequency=1000
Enter Stopband cutoff frequency=1500
Enter Sampling Frequency=8000

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

%%%%%%%%%%%%%Trinagular Window-HPF%%%%%%%%%
clc; close all; clear all;
rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
% Finding order of filter
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*((fs-fp)/f);
n=ceil(num/dem);
n1=n+1;
%Triangular Window
y=triang(n1);
b=fir1(n,wp,'high',y);
[x1 y1]=freqz(b);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:
Enter Passband ripple=0.04
Enter Stopband ripple=0.03
Enter Passband cutoff frequency=1500
Enter Stopband cutoff frequency=2000
Enter Sampling Frequency=7000

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

%%%%%%%%%%%Kaiser Window-LPF%%%%%%%%%%

clc; close all; clear all;


rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
% Finding order of filter
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*((fs-fp)/f);
n=ceil(num/dem);
n1=n+1;
%Kaiser Window
y=kaiser(n1);
b=fir1(n,wp,'low',y);
[x1 y1]=freqz(b);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:
Enter Passband ripple=0.05
Enter Stopband ripple=0.04
Enter Passband cutoff frequency=1500
Enter Stopband cutoff frequency=2000
Enter Sampling Frequency=8000

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

%%%%%%%%%%Kaiser Window-HPF%%%%%%%

clc; close all; clear all;


rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
% Finding order of filter
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*((fs-fp)/f);
n=ceil(num/dem);
n1=n+1;
%Kaiser Window
y=kaiser(n1);
b=fir1(n,wp,'high',y);
[x1 y1]=freqz(b);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:
Enter Passband ripple=0.04
Enter Stopband ripple=0.03
Enter Passband cutoff frequency=1000
Enter Stopband cutoff frequency=1500
Enter Sampling Frequency=7000

MODEL GRAPH:

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

IIR Filters EXPT. NO : 5


DATE :

AIM:

Write a program in MATLAB to design IIR (LP/HP) filters for the given
specifications pass band frequency, stop band frequency, gain at pass band frequency and
gain at stop band frequency.

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:

The IIR filter can realize both the poles and zeroes of a system because it has a
rational transfer function, described by polynomials in z in both the numerator and the
denominator:

The difference equation for such a system is described by the following:

M and N are order of the two polynomials. bk and ak are the filter coefficients. These filter
coefficients are generated using FDS (Filter Design software or Digital Filter design
package). IIR filters can be expanded as infinite impulse response filters. In designing IIR
filters, cutoff frequencies of the filters should be mentioned. The order of the filter can be

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

estimated using butter worth polynomial. That’s why the filters are named as butter worth
filters. Filter coefficients can be found and the response can be plotted.

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

PROGRAM:

MATLAB PROGRAM :
%%%%%%%%%Butterworth Filter-LPF%%%%%%%%%
clc; close all; clear all;
rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
[n,wc]=buttord(wp,ws,rp,rs);
[a b]=butter(n,wc,'low');
[x1 y1]=freqz(a,b,256);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

EXPECTED RESULTS:
Enter Passband ripple=0.15
Enter Stopband ripple=60
Enter Passband cutoff frequency=1500
Enter Stopband cutoff frequency=3000
Enter Sampling Frequency=7000

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

%%%%%%%%%Butterworth Filter-HPF%%%%%%%%%
clc; close all; clear all;
rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
[n,wc]=buttord(wp,ws,rp,rs);
[a b]=butter(n,wc,'high');
[x1 y1]=freqz(a,b,256);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:
Enter Passband ripple=0.15
Enter Stopband ripple=60
Enter Passband cutoff frequency=1500
Enter Stopband cutoff frequency=3000
Enter Sampling Frequency=8000

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

%%%%%%%% Chebyshev Type-I -LPF%%%%%%%%

clc; close all; clear all;


rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
[n,wc]=cheb1ord(wp,ws,rp,rs);
[a b]=cheby1(n,wc,rp,'low');
[x1 y1]=freqz(a,b,256);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:
Enter Passband ripple=0.3
Enter Stopband ripple=30
Enter Passband cutoff frequency=1000
Enter Stopband cutoff frequency=1500
Enter Sampling Frequency=8000

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

%%%%%%%% Chebyshev Type-I -HPF%%%%%%%%


clc; close all; clear all;
rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
[n,wc]=cheb1ord(wp,ws,rp,rs);
[a b]=cheby1(n,wc,rp,'high');
[x1 y1]=freqz(a,b,256);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:

Enter Passband ripple=0.4


Enter Stopband ripple=40
Enter Passband cutoff frequency=1500
Enter Stopband cutoff frequency=2000
Enter Sampling Frequency=8000

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

%%%%%%%% Chebyshev Type-II -LPF%%%%%%%%


clc; close all; clear all;
rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
[n,wc]=cheb2ord(wp,ws,rp,rs);
[a b]=cheby2(n,wc,rp,'low');
[x1 y1]=freqz(a,b,256);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:

Enter Passband ripple=0.35


Enter Stopband ripple=35
Enter Passband cutoff frequency=1500
Enter Stopband cutoff frequency=2000
Enter Sampling Frequency=9000

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

%%%%%%%% Chebyshev Type-II -HPF%%%%%%%%


clc; close all; clear all;
rp=input('Enter Passband ripple=');
rs=input('Enter Stopband ripple=');
fp=input('Enter Passband cutoff frequency=');
fs=input('Enter Stopband cutoff frequency=');
f=input('Enter Sampling Frequency=');
wp=2*fp/f;
ws=2*fs/f;
[n,wc]=cheb2ord(wp,ws,rp,rs);
[a b]=cheby2(n,wc,rp,'high');
[x1 y1]=freqz(a,b,256);
mag=20*log(abs(x1));
ang=angle(x1);
subplot(2,1,1);
plot(y1/pi,mag)
xlabel('Frequency');
ylabel('Gain in dB');
title('Magnitude Response of FIR Filter');
subplot(2,1,2);
plot(y1/pi,ang)
xlabel('Frequency');
ylabel('Phase in radius');
title('Phase Response of FIR Filter');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:
Enter Passband ripple=0.4
Enter Stopband ripple=40
Enter Passband cutoff frequency=1000
Enter Stopband cutoff frequency=1500
Enter Sampling Frequency=8000

MODEL GRAPH:

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

N-POINT FFT ALGORITHM EXPT. NO : 6


DATE :

AIM

Write a program in MATLAB to compute the Fast Fourier Transform of a given


discrete sequence x(n).

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:

The Fast Fourier Transform is useful to map the time-domain sequence into a
continuous function of a frequency variable. The FFT of a sequence {x(n)} of length N is
given by a complex-valued sequence X(k).

The above equation is the mathematical representation of the DFT. As the number of
computations involved in transforming a N point time domain signal into its corresponding
frequency domain signal was found to be N2 complex multiplications, an alternative
algorithm involving lesser number of computations is opted. When the sequence x(n) is
divided into 2 sequences and the DFT performed separately, the resulting number of
computations would be N2/2

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Consider x(2n) be the even sample sequences and x(2n+1) be the odd sample
sequence derived form x(n).

an other (N/2)2 multiplication's finally resulting in (N/2)2 + (N/2)2


= N2/4 + N2/4 = N2/2Computations

Further solving

Dividing the sequence x(2n) into further 2 odd and even sequences would reduce the
computations.
WN - is the twiddle factor

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Employing this equation, we deduce

The time burden created by this large number of computations limits the usefulness of
DFT in many applications. Tremendous efforts devoted to develop more efficient ways of
computing DFT resulted in the above explained Fast Fourier Transform algorithm. This
mathematical shortcut reduces the number of calculations the DFT requires drastically. The
above mentioned radix-2 decimation in time FFT is employed for domain transformation.
Dividing the DFT into smaller DFTs is the basis of the FFT. A radix-2 FFT divides
the DFT into two smaller DFTs, each of which is divided into smaller DFTs and so on,
resulting in a combination of two-point DFTs. The Decimation -In-Time (DIT) FFT divides
the input (time) sequence into two groups, one of even samples and the other of odd samples.
N/2 point DFT are performed on the these sub-sequences and their outputs are combined to
form the N point DFT.

Figure: N-Point DFT

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

The above shown mathematical representation forms the basis of N point FFT and is called
the Butterfly Structure.

Figure: 2 – 8 POINT DFT

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

PROGRAM:

MATLAB PROGRAM:

clc; clear all; close all;


x=input('Enter Input Sequence=');
n=length(x);
y=fft(x,n);
m=20*log(y);
a=angle(y);
z=ifft(y);
display('Input sequence x(n)=');
disp(x);
display('FFT Sequence y(n)=');
disp(y);
display('Magnitude Response of FFT');
disp(m);
display('Phase Response of FFT');
disp(a);
display('InverseFFT');
disp(z);
t=0:1:n-1;
subplot(3,1,1);
stem(t,x);
xlabel('Discrete Time');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

ylabel('Amplitude');
title('Input Sequence');
subplot(3,1,2);
stem(t,y);
xlabel('Discrete Time');
ylabel('Amplitude');
title('FFT Sequence');
subplot(3,1,3);
stem(t,m);
xlabel('Discrete Time');
ylabel('Amplitude');
title('Magnitude Response');
figure
subplot(1,2,1);
stem(t,a);
xlabel('Discrete Time');
ylabel('Amplitude');
title('Phase Response');
subplot(1,2,2);
stem(t,z);
xlabel('Discrete Time');
ylabel('Amplitude');
title('Magnitude Response');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:
Enter Input Sequence=[1 2 3 4]
Input sequence x(n)=
1 2 3 4
FFT Sequence y(n)=

10.0000 -2.0000 + 2.0000i -2.0000 -2.0000 - 2.0000i

Magnitude Response of FFT

46.0517 20.7944 +47.1239i 13.8629 +62.8319i 20.7944 -47.1239i

Phase Response of FFT


0 2.3562 3.1416 -2.3562

InverseFFT
1 2 3 4

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

SUM of SINUSOIDAL SIGNAL GENERATION EXPT. NO : 7


DATE :

AIM:

Write a program in MATLAB to generate two sinusoidal signals and its sum.

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:

A signal can be defined as a physical quantity, which varies with respect to one or
more independent variables. Mathematically signal can be defined as a function, which varies
with respect to time and conveys some information. Information may be temperature,
Voltage, Current, Power etc. Based on variation of amplitude of a signal, signals are
classified into two categories.

 Continuous Time Signals


 Discrete Time Signals
Continuous time signals are those for which the signal amplitude is continuously
varies with respect to continuous variation in time.

Example :

Continuous Time Signal x(t)


1
Amplitude

-1
0 20 40 60 80 100
Continuous Time (t)

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Discrete time signals are those for which the signal amplitude is discretely varies with
respect to discrete variation in time.
Example :

Discrete Time Signal x(n)


1

0.5
Amplitude

-0.5

-1
0 10 20 30 40 50 60 70 80 90 100
Discrete Time (n)

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

PROGRAM:

MATLAB PROGRAM:

clc; clear all; close all;


t=0:0.01:pi;
y1=sin(t);
y2=sin(2*t);
y3=sin(3*t);
y=y1+y2+y3;
subplot(2,2,1);
plot(t,y1);
xlabel('Discrete Time');
ylabel('Amplitude');
title('1st-sine signal');
subplot(2,2,2);
plot(t,y2);
xlabel('Discrete Time');
ylabel('Amplitude');
title('2nd-sine signal');
subplot(2,2,3);
plot(t,y3);
xlabel('Discrete Time');
ylabel('Amplitude');
title('3rd-sine signal');
subplot(2,2,4);
plot(t,y);
xlabel('Discrete Time');
ylabel('Amplitude');
title('sum of sinusoidal signals');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

MODEL GRAPH:

MATLAB PROGRAM:

clc; clear all; close all;


t=0:0.01:pi;
y1=sin(t);
y2=sin(2*t);
y3=sin(3*t);
y4=sin(4*t);
y=y1+y2+y3+y4;
plot(t,y1,t,y2,t,y3,t,y4,t,y);
legend('y1','y2','y3','y4','y');
xlabel('Discrete Time');
ylabel('Amplitude');
title('sum of sinusoidal signals');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

MODEL GRAPH:

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

CHARACTERISTICS OF ANALOG LPF/HPF EXPT. NO : 8

DATE :

AIM:

Write a program in MATLAB to obtain the frequency response of simple analog RC


low pass and high pass filters.

COMPONENTS REQUIRED:

 Personal Computer
 MATLAB software.

THEORY:

Filter is a frequency selective device, which allows only specified band of frequencies
of a input signal and attenuate all other unwanted frequencies of input signal. Based on the
frequency response of the filter, filters are classified into four types.

1. Low Pass Filter (LPF)


2. High Pass Filter (HPF)
3. Band Pass filter (BPF)
4. Band Stop Filter/Band Elimination Filter/Band Reject Filter (BSF/BEF/BRF)
Low Pass Filter: Low pass filter allows only low frequencies of input signal and
attenuate all other high frequencies of input signal. A simple RC low pass filter shown below

x(t) or X(s) I(s) C y(t) or Y(s)

Where

x(t) : Input Signal


y(t) : Output signal
X(s) : Input in s-domain

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Y(s) : Output in s-domain


I(s) : current through the circuit
1/sC : Capacitive reactance
X(s)
Loop equation I(s) 
1
R
sC

1
 Y(s)  I(s).
sC
X(s)  1 
 Y(s)  . 
1  sC 
R
sC
X(s)
 Y(s)  .
RCs  1
Y(s) 1
  .
X(s) RCs  1
1
 H(s)  .
1  sRC
1
 H(j ω) 
1  jω R C
1
 H(j ω)  and
1  (ω RC ) 2
 H(j ω )  Tan 1 (ωωRC

Characteristics of LPF: H(j)

Ideal characteristics

1 Practical characteristics

0 c 

Where c is cut-off frequency

High Pass Filter: High pass filter allows only high frequencies of input signal and attenuate
all other low frequencies of input signal. A simple RC high pass filter shown below

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

x(t) or X(s) I(s) R y(t) or Y(s)

Where

x(t) : Input Signal


y(t) : Output signal
X(s) : Input in s-domain
Y(s) : Output in s-domain
I(s) : current through the circuit
1/sC : Capacitive reactance

X(s)
Loop equation I(s) 
1
R
sC

 Y(s)  I(s). R
X(s)
 Y(s)  .R
1
R
sC
sRCX(s)
 Y(s)  .
RCs  1
Y(s) sRC
  .
X(s) RCs  1
sRC
 H(s)  .
1  sRC
jRC
 H(j ω) 
1  jω R C
ω RC
 H(j ω)  and
1  (ω RC ) 2
 H(j  )  Tan 1 ( ωRC)

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Characteristics of HPF:

H(j)

Ideal characteristics

Practical characteristics

0 c 

Band Pass Filter: Band pass filter allows only a certain band of frequencies and
attenuate all other unwanted frequencies of input signal.

Characteristics of BSF:

 H(j)

Ideal characteristics

Practical characteristics

0 c1 c2 

Band Stop Filter: Band stop filter allows entire band of frequencies of input signal,
except a certain band of input signal.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Characteristics of BPF:

 H(j)

1 Ideal
characteristics

Practical characteristics

0 c1 c2 

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

PROGRAM:

MATLAB PROGRAM:

clc; clear all; close all;


disp('Input data for Simple RC Analog LPF:');
R=input('Enter the Resistance value of LPF in Kilo Ohms:');
C=input('Enter the Capacitor value of LPF in micro Faradays:');
L=input('Enter the Frequency Range:');
R=1000*R;
C=C/1000000;
W=0:1:L;
k=W*R*C;

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

ks=k.*k;
S=sqrt(1+ks);
MSofLPF=S.^-1;
MSofHPF=k.*(S.^-1);
display('Amplitude of Magnitude Spectrum of LPF');
disp(MSofLPF);
display('Amplitude of Magnitude Spectrum of HPF');
disp(MSofHPF);
subplot(2,1,1);
plot(W,MSofLPF);
title('Response of LPF');
xlabel('Frequency');
ylabel('Amplitude');
subplot(2,1,2);
plot(W,MSofHPF);
title('Response of HPF');
xlabel('Frequency');
ylabel('Amplitude');

EXPECTED RESULTS:

Input data for Simple RC Analog LPF:

Enter the Resistance value of LPF in Kilo Ohms: 10

Enter the Capacitor value of LPF in micro Faradays: 10

Enter the Frequency Range: 100

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

MODEL GRAPH:

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

POWER SPECTRAL DENSITY EXPT. NO : 9

DATE :

AIM :

Write a program in MATLAB to compute power spectral density of given sequence


x(n).

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:

Spectrum is a Latin word for image. Auto correlation function(ACF) is a measure of


similarity between a signal and time delayed version of the same signal. Cross correlation
function(CCF) is a measure of similarity between a signal and time delayed version of the
different signal. Frequency domain representation of a ACF of non-periodic signal is known
as Energy Spectral Density(ESD). Frequency domain representation of a ACF of periodic
signal is known as Power Spectral Density(PSD). For a non-periodic signals ESD & ACF
forms Fourier transformable pairs. For a periodic signals PSD & ACF forms Fourier
transformable pairs. The power spectral density is a measurement of the energy at various
frequencies.

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

PROGRAM:

MATLAB PROGRAM:

clc; clear all; close all;


t = 0:0.001:0.6;
x = sin(2*pi*50*t)+sin(2*pi*120*t);
y = x + 2*randn(size(t));
figure,plot(1000*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)');
Y = fft(y,512);
%The power spectral density, a measurement of the energy at various
frequencies, is:
Pyy = Y.* conj(Y) / 512;
f = 1000*(0:256)/512;
figure,plot(f,Pyy(1:257))
title('Frequency content of y');
xlabel('frequency (Hz)');
MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

FFT of 1-D SIGNAL EXPT. NO : 10

DATE :

AIM:

Write a program in MATLAB to obtain the FFT on 1-D signal.

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:

1D, an important concept in linear system analysis is that of the Fourier transform.
The Fast Fourier Transform is useful to map the time-domain sequence into a continuous
function of a frequency variable. The FFT of a sequence {x(n)} of length N is given by a
complex-valued sequence X(k).

The above equation is the mathematical representation of the DFT. As the number of
computations involved in transforming a N point time domain signal into its corresponding
frequency domain signal was found to be N2 complex multiplications, an alternative
algorithm involving lesser number of computations is opted. When the sequence x(n) is
divided into 2 sequences and the DFT performed separately, the resulting number of
computations would be N2/2

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Consider x(2n) be the even sample sequences and x(2n+1) be the odd sample
sequence derived form x(n).

an other (N/2)2 multiplication's finally resulting in (N/2)2 + (N/2)2


= N2/4 + N2/4 = N2/2Computations

Further solving

Dividing the sequence x(2n) into further 2 odd and even sequences would reduce the
computations.
WN - is the twiddle factor

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Employing this equation, we deduce

The time burden created by this large number of computations limits the usefulness of
DFT in many applications. Tremendous efforts devoted to develop more efficient ways of
computing DFT resulted in the above explained Fast Fourier Transform algorithm. This
mathematical shortcut reduces the number of calculations the DFT requires drastically. The
above mentioned radix-2 decimation in time FFT is employed for domain transformation.
Dividing the DFT into smaller DFTs is the basis of the FFT. A radix-2 FFT divides
the DFT into two smaller DFTs, each of which is divided into smaller DFTs and so on,
resulting in a combination of two-point DFTs.

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

PROGRAM:

MATLAB PROGRAM:

clc; clear all; close all;


t=0:0.05:pi;
x=sin(2*pi*2*t);
y=fft(x);
y1=abs(y);
z=ifft(y);
subplot(3,1,1);
plot(t,x);
xlabel('Discrete Time');
ylabel('Amplitude');
title('Sine Signal');
subplot(3,1,2);
plot(t,y1);
xlabel('Discrete Time');
ylabel('Amplitude');
title('Absolute FFT of Sine Signal');
subplot(3,1,3);
plot(t,z);
xlabel('Discrete Time');
ylabel('Amplitude');
title('InverseFFT of Sine Signal');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

MODEL GRAPH:

RESULT:

The FFT of 1-D signal is calculated and sequence is plotted.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

ADDITIONAL EXPERIMENTS
OTHER THAN JNTU-K
SYLLABUS

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

IMPLEMENTATION OF DECIMATION EXPT. NO: 11


AND INTERPOLATION PROCESS DATE :

AIM:

Write a program in MATLAB to implement decimation and interpolation process for


given sequence by factor L and M.

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:
Decimation is the process of reducing the sampling frequency of a signal to a lower
sampling frequency that differs from the original frequency by an integer value. Decimation
also is known as down-sampling. The lowpass filtering associated with decimation removes
high-frequency content from the signal to accommodate the new sampling frequency.
Decimation is useful in applications in which the Nyquist frequency of a signal is much
higher than the highest frequency of the signal. Decimation filters help you remove the
excess bandwidth and reduce the sampling frequency of the signal. Decimation filters also
help you reduce the computational resources required for processing and storing the signal.
During the analog-to-digital (A/D) conversion process, decimation filters also can reduce the
variance of quantization noise in a signal and maintain the signal power, thus improving the
signal-to-noise ratio (SNR).
Upsampling is the process of increasing the sampling rate of a signal and upsampling
images faster 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.
The process of increasing the sampling rate is called interpolation. Interpolation is
upsampling followed by appropriate filtering(n). Obtained by interpolating y(n) , is generally
represented as:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

y(n)=x(n/L)
The simplest method to interpolate by a factor of L is to add L-1 zeros in between the
samples, multiply the amplitude by L and filter the generated signal, with a so-called anti-
imaging low pass filter at the high sampling frequency.
PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

PROGRAM:

a) MATLAB PROGRAM –DECIMATION :


clc; clear all; close all;
N=input('enter sample value');
n=0:N-1;
m=input('enter down sampling factor');
x=sin(2*pi*0.043*n)+sin(2*pi*0.031*n);
y=decimate(x,m,'fir');
subplot(2,1,1);
stem(n,x(1:N));
xlabel('time');
ylabel('amp');
title('input sequence');
t=0:(N/m)-1;
subplot(2,1,2);
stem(t,y(1:N/m));
xlabel('time');
ylabel('amp');
title('output sequence');

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

b) MATLAB PROGRAM - INTERPLOATION:


clc; clear all; close all;
N=input('enter sample value');
n=0:N-1;
L=input('enter up sampling factor');
x=sin(2*pi*0.043*n)+sin(2*pi*0.031*n);
y=interp(x,L);
subplot(2,1,1);
stem(n,x(1:N));
xlabel('time');
ylabel('amp');
title('input sequence');
t=0:(N*L)-1;
subplot(2,1,2);
stem(t,y(1:N*L));
xlabel('time');
ylabel('amp');
title('output sequence');

EXPECTED RESULTS:

DECIMATION:

Enter sample value = 65


Enter down sampling factor = 3

INTERPOLATION:
Enter sample value = 50
Enter up sampling factor = 2

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

MODEL GRAPH:

DECIMATION:

INTERPOLATION:

RESULT:

The decimator and interpolation for a given sequence is observed.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

IMPLEMENTATION OF I/D SAMPLING EXPT. NO: 12


RATE CONVETERS DATE :
AIM:

Write a program in MATLAB to implement sampling rate conversion by a rational form.

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:
"Up sampling" is the process of inserting zero-valued samples between original
samples to increase the sampling rate. (This is called "zero-stuffing".) Up sampling adds to
the original signal undesired spectral images which are centered on multiples of the original
sampling rate. "Interpolation", in the DSP sense, is the process of up sampling followed by
filtering. (The filtering removes the undesired spectral images.) As a linear process, the DSP
sense of interpolation is somewhat different from the "math" sense of interpolation, but the
result is conceptually similar: to create "in-between" samples from the original samples. The
result is as if you had just originally sampled your signal at the higher rate.

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

PROGRAM:

clc; clear all;close all;


N=input('Enter the sample value');
n=0:N-1;
l=input('Enter up sampling factor');
m=input('Enter down sampling factor');
x=sin(2*pi*0.043*n)+sin(2*pi*0.03*n);
y=resample(x,l,m);
subplot(2,1,1);
stem(n,x(1:N));
xlabel('time');
ylabel('amplitude');
title('input sequence');
t=0:(N*l/m)-1;
subplot(2,1,2);
stem(t,y(1:N*l/m));
xlabel('time');
ylabel('amplitude');
title('input sampling sequence');

EXPECTED RESULTS:

Enter the sample value = 20


Enter up sampling factor = 5
Enter down sampling factor = 2

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

MODEL GRAPH:

RESULT:

Sampling rate conversion by a rational form is performed using MATLAB

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

DTMF SIGNAL GENERATION EXPT. NO: 13

DATE :

AIM:

Write a program in MATLAB to generate Dual Tone Multiple Frequency (DTMF)


Signals.

COMPONENTS REQUIRED :

 Personal Computer
 MATLAB software.

THEORY:

Dual Tone Multiple Frequency (DTMF) Signals.

PROCEDURE:

1. Open the MATLAB software by double clicking the icon on desktop.

2. Open the new M-file by using file menu

3. Write the program in new file

4. Click on save and run the icon

5. Perform error check which displayed on command window

6. Plot the waveforms which displays on figure window.

7. Note down the values, which displays on the work space.

PROGRAM:

clc; clearall; closeall;


number = input('enter a phone number with no spaces','s');
fs = 8192;
T = 0.5; % T stores how for how long a tone will be played
x= 2*pi*[697 770 852 941];
y= 2*pi*[1209 1336 1477 1633];

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

t=[0:1/fs:T]';
tx=[sin(x(1)*t),sin(x(2)*t),sin(x(3)*t),sin(x(4)*t)]/2;
ty=[sin(y(1)*t),sin(y(2)*t),sin(y(3)*t),sin(y(4)*t)]/2;
for k=1:length(number)
switch number(k)
case '1'
tone = tx(:,1)+ty(:,1);
sound(tone);
stem(tone);
case '2'
tone = tx(:,1)+ty(:,2);
sound(tone);
stem(tone);
case '3'
tone = tx(:,1)+ty(:,3);
sound(tone);
stem(tone);
case '4'
tone = tx(:,2)+ty(:,1);
sound(tone);
stem(tone);
otherwise
disp('invalid number');
end
pause(2.70) ;
end;

EXPECTED RESULTS:
Number = 01234

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

MODEL GRAPH:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

RESULT:

Dual Tone Multiple Frequency (DTMF) Signals are generated by using MAT LAB.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

CODE COMPOSER
STUDIO

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

GENERATION OF SUM OF SINUSOIDAL EXPT. NO: 1

SIGNALS DATE :

AIM:
Write a program in C to generate two sinusoidal signals and its sum.

COMPONENTS REQUIRED :

1. Personal Computer

2. CCS 6.1 software

3. DSK Trainer Kit(TMS320C6713)

THEORY:

A signal can be defined as a physical quantity, which varies with respect to one or
more independent variables. Mathematically signal can be defined as a function, which varies
with respect to time and conveys some information. Information may be temperature,
Voltage, Current, Power etc. Based on variation of amplitude of a signal, signals are
classified into two categories.

1. Continuous Time Signals


2. Discrete Time Signals
Continuous time signals are those for which the signal amplitude is continuously
varies with respect to continuous variation in time. Discrete time signals are those for which the
signal amplitude is discretely varies with respect to discrete variation in time.

PROCEDURE:

PROGRAM:

CCS PROGRAM:

#include<stdio.h>

#include<math.h>

#define freq 500

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

float x1[127],x2[127],x[127];

void main()

int t;

for(t=0;t<127;t++)

x1[t]=sin(2*3.14*freq*t/24000);

x2[t]=sin(2*3.14*freq*t/14000);

x[t]=x1[t]+x2[t];

printf(“\n%f”,x1[t]);

printf(“\n%f”,x2[t]);

printf(“\n%f”,x[t]);

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

MODEL GRAPH:

First sine signal:

Second Sine signal:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Sum of x1+x2 signals:

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPT. NO: 2
LINEAR CONVOLUTION
DATE :

AIM:
Write a program in C to compute the response of a discrete LTI system with input
sequence x(n) and impulse response h(n) by using linear convolution.

COMPONENTS REQUIRED :

3. Personal Computer

4. CCS 6.1 software

5. DSK Trainer Kit(TMS320C6713)

THEORY:

Convolution is a special operation, operated between two signals and which includes
the following operations.

1. Folding.
2. Shifting.
3. Multiplication.
4. Addition
Convolution sum is useful to obtain the response of discrete LTI system with input
x(n) and impulse response h(n).

x(n)
h(n) y(n)


. y(n)  x(n)  h(n)   x(m)h(n  m)
m  

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

1. Linear Convolution.
2. Circular Convolution.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

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

N 1
y(n)   x(m)h(n  m)
m0

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.

DFT supports only circular convolution, because of x(n) and h(n) are equal durations.
Circular convoluted sequence y(n) between x(n) and h(n) with equal duration N is defined as

N 1
y(n)   x(m)h(n  m)
m0

In this case if x(n) and h(n) are of different durations, then zero padding is required to
obtain the response of discrete LTI system.

PROGRAM:

CCS PROGRAM:

#include<stdio.h>

int x[15],h[15],y[15];

main()

int i,j,m,n;

printf("\n enter value for m"); scanf("%d",&m);

printf("\n enter value for n"); scanf("%d",&n);

printf("Enter values for i/p x(n):\n");

for(i=0;i<m;i++)

scanf("%d",&x[i]); printf("Enter Values for i/p h(n) \n");

for(i=0;i<n; i++)

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

scanf("%d",&h[i]);

for(i=m;i<=m+n-1;i++)

x[i]=0;

for(i=n;i<=m+n-1;i++)

h[i]=0;

for(i=0;i<m+n-1;i++)

y[i]=0;

for(j=0;j<=i;j++)

y[i]=y[i]+(x[j]*h[i-j]);

for(i=0;i<m+n-1;i++)

printf("\n The Value of output y[%d]=%d",i,y[i]);

MODEL GRAPH:

Input Sequence:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Impulse Response:

Response of LTI System:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

Output:
Enter value of input sequence = 4
Enter value of impulse response = 4
Enter values for input sequence x(n)= 1 2 3 4
Enter values for impulse response h(n)= 4 3 2 1
The values of output y[0]=4
The values of output y[1]=11
The values of output y[2]=20
The values of output y[3]=30
The values of output y[4]=20
The values of output y[5]=11
The values of output y[6]=4

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

FREQUENCY RESPONSE OF ANALOG EXPT. NO : 3

LPF/HPF DATE :

AIM:

Write a program in C program to obtain the frequency response of simple analog RC


low pass and high pass filters.

COMPONENTS REQUIRED:

3. Personal Computer

4. CCS 6.1 software

5. DSK Trainer Kit(TMS320C6713)

THEORY:

Filter is a frequency selective device, which allows only specified band of frequencies
of a input signal and attenuate all other unwanted frequencies of input signal. Based on the
frequency response of the filter, filters are classified into four types.

1. Low Pass Filter (LPF)


2. High Pass Filter (HPF)
3. Band Pass filter (BPF)
4. Band Stop Filter/Band Elimination Filter/Band Reject Filter (BSF/BEF/BRF)
Low Pass Filter: Low pass filter allows only low frequencies of input signal and
attenuate all other high frequencies of input signal.

High Pass Filter: High pass filter allows only high frequencies of input signal and attenuate
all other low frequencies of input signal.

Band Pass Filter: Band pass filter allows only a certain band of frequencies and attenuate
all other unwanted frequencies of input signal.

Band Stop Filter: Band stop filter allows entire band of frequencies of input signal,
except a certain band of input signal.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

PROGRAM:

CCS PROGRAM:

#include<studio.h>
#include<math.h>
int w,L;
float r,c,k,ks,lpf[1000],hpf[1000];
void main()
{
Printf(“Enter resistor value of filter, r=”);
Scanf(“%f”, &r);
Printf(“Enter capacitor value of filter, c=”);
Scanf(“%f”, &c);
Printf(“Enter frequency repo value of filter, L=”);
Scanf(“%d”, &L);
Printf(“\n Analog filter”);
Printf(“Resistor(r)=%f”,r);
Printf(“Capacitor(c)=%f”,c);
r=1000*r;
c=c/1000000;
for(w=0;w<L,w++)
{
K=w*r*c;
Ks=k*k;
lpf[w]=1/sqrt(1+ks);
hpf[w]=k/sqrt(1+ks);
}
Printf(“Magnitude response of LPF\n”);
For(w=0;w<=L;w++)
Printf(“lpf[%f]=%f”,w,lpf[w]);
Printf(“Magnitude response of HPF\n”);
For(w=0;w<=L;w++)
Printf(“hpf[%f]=%f”,w,hpf[w]);
}

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

MODEL GRAPH:

Low Pass Filter-Magnitude Response:

High Pass-Magnitude Response:

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU


DIGITAL SIGNAL PROCESSING LAB MANUAL

EXPECTED RESULTS:

Enter resistor value of filter in kilo ohms:10


Enter capacitor value of filter in microfarads:10
Enter range of freq response:100

RESULT:

Program is executed successfully and results are obtained as per the expected values.

NRI INSTITUTE OF TECHOLOGY,POTHAVARAPADDU

Вам также может понравиться