You are on page 1of 45

CONTENTS

SL. NO. CONTENT PAGE NO.


1. Introduction

2. General information

2.1 General discipline in the lab


2.2 Attendance
2.3 Preparation and performance
2.4 Lab reports
2.5 Precaution
3. Details of Experiment

Index

3.1 Experiment-1
Extended Precision Addition & Subtraction of Two 64-Bit
Numbers Using DSP Trainer Kit.
3.2 Experiment-2
Multiplication & Convolution of Two 64-Bit Numbers Using
DSP Trainer Kit.
3.3 Experiment-3
To Plot Signals Both Continuous & Discrete Using
MATLAB.
3.4 Experiment-4
To Get Linear Convolution of Any Two Given Sequences(
Basically of Two 1x3 Matrix) Using MATLAB
3.5 Experiment-5
To Perform Auto Co-Relation of Any Two Given Sequences
(Basically Of Two 1x3 Matrix) Using MATLAB
3.6 Experiment-6
To Perform Cross Co-Relation of Any Two Given Sequences
(Basically of Two 1x3 Matrix) Using MATLAB
3.7 Experiment-7
To Perform Circular Convolution of Two Sequences Using
MATLAB.
3.8 Experiment-8
To Design A Fir Low pass Filter Using Different Windows
Technique.(Hamming, Blackman, Rectangular, Kaiser)
3.9 Experiment-9
To Design Butter worth Low Pass Filter For Given
Specifications
3.10 Experiment-10
To Design Butter worth High Pass Filter For Given
Specifications

1
GENERAL INSTRUCTION

INTRODUCTION:

Digital signal processing lab is a well-equipped laboratory of Electronics and


Communication Engg. Department. This lab is compulsory for B.Tech students of CSE,
ECE, EE. This laboratory provides an opportunity to enhance the practical knowledge
through its various experiments to be performed by the students. The list of experiments
to be performed is in accordance with BPUT, ODISHA. Most of the experiments have
engineering application and are the integral part of the engineering curriculum. This lab
manual describes the details of the experiments to be performed in the 5 th and 6th semester
by the students.

GENERAL INFORMATION:

The purpose of conducting experiments can be stated as follows:


 To get familiarization with the basic components, devices, electronic instruments,
modules, kits etc. used for conducting instrumentation circuits.
 Circuit drawing using standard symbols as practiced in Instrumentation
Technology.
 Making proper connection in the experimental kits/modules as per the circuit
diagram and connection of appropriate power supply for energizing the circuits.
 Conducting experiments as per the guidelines and writing of results of
observation.
 Verification of theoretical results through graphs or calculations.
 Hands on experience on the experimental setup.

GENERAL DISCIPLINE IN LAB:

 Students must turn up in time and contact concerned faculty for the experiment
they are supposed to perform.
 Students will not be allowed after ten minutes from the scheduled time.
 Attendance in the laboratory is compulsory. For any absence, students have to
write an application with sufficient reasons and proof as per the BPUT rules and
regulation & may be allowed with permission of concerned HOD.
 Students will not leave the class till the period is over.
 Students should come prepared for their experiment with lab record.

2
 Experimental results should be entered in the lab. Record and certified /signed by
concerned faculty/lab instructor.
 Students must get the connection of experimental setup verified before switching
on the power supply.
 After the experiment is over, the experimental kits/modules. Measuring tools and
any other tools for the experiments should be returned to the lab instructor.
 Students should maintain silence while performing the experiments. If necessity
arises for discussion amongst them, they should discuss with a very low pitch
without disturbing the adjacent groups.
 Students should not unnecessarily fiddle with the instruments knob or any other
pot. In the instruments which may disturb the calibration accuracy, range or zero
etc.
 Violating the above code of conduct may attract disciplinary action.

ATTENDANCE:

 Attendance in the lab class is compulsory. As an incentive, certain percentage of


lab marks is allotted for attendance in the internal evaluation of lab. Performance.
 Each group of students must write a satisfactory report for each lab experiments
in order to pass the course.
 The concerned faculty will duly record attendance.
 Students should complete the experiments on the day allotted for the same.
 Failure to do so or any absence on that day may result in loosing marks in the
evaluation process of the lab records.
 However, on genuine ground, alternate time slot may be given to complete the
experiment.
 Students should not attend a different lab group/section other than the one
assigned at the beginning of the session.
 On account of illness or some family problems, if a student misses the lab.
Classes, he /she may be assigned a different group to make up the losses in
consultation with the concerned faculty member/lab instructor.

PREPARATION AND PERFORMANCE:

 Students should come to the lab thoroughly prepared on the experiments they are
assigned to perform on that day.
 Faculty may check their preparation and understanding of the experiments. If not
found satisfactory, students may be debarred from doing the experiments.
 Students should record the experimental results and observation in the lab.
Record.

3
 Students must bring the Record (fair and rough) on each practical class with
written records of the last experiments performed complete in all respect.
 Students without Record will not be allowed to do the experiments and hence
loose their attendance.
 Any instrument damaged or tools lost during experiments may attract punishment
in the form of fine or suspension from class.

LAB REPORTS:

 Each student is required to write a complete report of the experiment he/she has
performed and bring to lab class for evaluation in the next working lab.
 Report should be written very clearly and lab record should be maintained neatly.
 The lab must contain the following
 Duly completed title page.
 Each report should include connection diagram (where applicable),
graphs, trace papers, equations, calculations, flow charts etc.
 Standard symbols should be used to draw the diagrams.
 Calculations and comparison with appropriate equations and comments.
 Observation can be included explaining your experience in conducting
the experiments.

PRECAUTION:-

 Switch on the PC and turn off at the end of the lab properly with switching
off the UPS.
 Outside floppy disks, CDs and pen drives are strictly prohibited without
prior permission of the concerned faculty to avoid virus infection.
 Choose the block parameters of simulink suitably to get proper waveform
and results.
 Connect the cables properly to get the desired result.

4
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

Introduction to DSP kit (TMS320C50)

INTRODUCTION:
It is needless to say that in order to utilize the full feature of the DSP chip
TMS320C50, the DSP engineer must have a complete knowledge of the DSP device.
This chapter is an introduction to the hardware aspects of the TMS320C50. The
important units of TMS320C50 are discussed.

THE DSP CHIP TMS320C50:

The TMS320C50 is a 16- bit fixed point digital signal processor that combines the
flexibility of a high speed controller with the numerical capability of an array processor,
thereby offering an in expensive alternative to mustachio bit slice processors.
The TMS320C50 optimizes speed by implementing functions in hardware that other
processor implement through microcode or software. This Hardware intensive approach
provides the design engineer with processing power previously unavailable on a single
chip. The TMS320C50is the third generation digital signal processor in TMS320C50
family, its powerful instruction set, inherent flexibility, high speed number-crunching &
innovative architecture have made this high – performance, cost-effective processor the
ideal solution to many telecommunications, computer, commercial industrial, & military
application.

KEY FEATURES OF TMS320C50:

The key features of the Digital Signal Processor TMS320C50 are:

* 35-/50-ns single – cycle fixed – point instruction execution time (28.6/20MIPS)


* Upward source – code compatible with all C1X & C2X devices
* RAM – based memory operation (C50)
* 9K x16 – bit single cycle on – chip program / data RAM (C50)
* 2K x 16 – bit single cycle on chip boot ROM (C50)
* 1056 x 16- bit dual – accesses on– chip data RAM

5
* 224K x 16 – bit maximum addressable external memory space (64K program, 64K
data, 64K I /O, & 32K global)
* 32- bit arithmetic logic unit (ALU), 32-bit accumulator (ACC), & 32-bit accumulator
buffer (ACCB).
* 16-bit parallel logic unit (PLU)
* 16x16-bit parallel multiplier with a 32-bit product capability.
* Single-cycle multiply/accumulate instructions
* Eight auxiliary registers with a dedicated auxiliary register arithmetic unit for indirect
addressing.
* Eleven context-switch registers (shadow registers) for storing strategic CPU-controlled
registers during an interrupt service routine.
* Eight-level hardware stack
* 0-to 16-bit left and right data barrel-shifters & a 64-bit incremental data shifter
* Two indirectly addressed circular buffers for circular addressing
* Single-instruction repeat & block repeat operations for program code
* Block memory move instructions for better program/data management
* Full-duplex synchronous serial port for direct communication between the C5x &
another serial device
* Time-division multiple-access (TDM) serial port
* Interval timer with period, control, & counter registers for software stop, start, & reset
* 64K parallel I/O ports, 16 of which are memory mapped
*Sixteen software programmable wait- state generators for programs, data, & I/O
memory spaces.

ARCHITECTURE:

A detailed architectural block diagram of TMS320C50 is illustrated in the presiding


figure. The TMS320C50 utilizes a modified Harvard architecture for speed & flexibility.
In a strict Harvard architecture, program & data memory are in tow separate spaces,
permitting a full overlap of instruction fetch & execution. The TMS320 family’s
modification of the Harvard architecture allows transfer between program & data spaces,
thereby increasing the flexibility of the device. This modification permits coefficient
stored in program coefficients stored in program memory to be read into the data RAM,
eliminating the need for a separate coefficients stored in program memory to be read into
immediate instructions & subroutines based on computed values.

32-BIT ACCUMMULATOR:

The TMS320C50 contains a 32-bit ALU & accumulator for support of double-
precision, two’s complement arithmetic. The ALU is a general purpose arithmetic unit
that operates on 16-bit words taken from the data RAM or derived from immediate
instructions. In addition to the usual arithmetic instructions, the ALU can perform
Boolean operations, providing the bit manipulation ability required of a high-speed
controller. The accumulator stores the output from the ALU & is often an input to the
ALU. Its word length is 32-bit. The accumulator divided into a high-order word (bits 31

6
through 16) & a low- order word (bits 15 through 0). Instructions are provided for storing
& loading the high & lower order accumulator words to memory.

16 X16 –BIT PARALLEL MULTIPLIER:

The multiplier performs a 16 x 16- bit two’s complement multiplication with a 32-bit
result in a single instruction cycle. The multiplier consists of three units: the T-registers,
P-register, & multiplier array. The 16-bit T-Register temporarily stores the multiplicand&
the P-Register stores the 32-bit product. Multiplier values either come from the data
memory or are derived immediately from the MPY (multiply immediate) instruction
word. The fast on-chip multiplier allows the device to perform fundamental operations
such as convolution, correlation, & filtering. Two multiply/ accumulate instructions in the
instruction set fully utilize the computational bandwidth of the multiplier, allowing both
operands to be processed simultaneously.

SHIFTERS:

A 16-bit scaling shifter is available at the accumulator input. This shifter produces left
shift of 0 to 16-bits on the input data to accumulator.
TMS320C50 also contains a shifter at the accumulator output. This shifter provides a left
shift of 0 to 7, on the data from either the ACCH or ACCL register. In addition one
shifter at the P-register can shift the product by 1 or 4-bits left or 6-bits right, before
transferring the product to accumulator.

DATA AND PROGRAM MEMORY:

Since the TMS320C50 uses Harvard architecture, data and program memory reside in
two separate spaces. Additionally TMS320C50 is 64kKW each of program, Data and I/O
memory. The 64KW of data memory is divided into 512 pages with each page containing
128 words. Only one page can be active at a time. One data page selection is done by
setting data single access Data/Program RAM. The1056 words of on chip data memory is
divided as three blocks B0, B1, & B2, of which B0 can be configured as program or data
RAM.
Out of the 64KW of total program memory, TMS320C50 has 2K words of on-chip
program ROM.
The TMS320C50 offers two modes of operation defined by the state of the MC/MP pin,
the microcomputer mode, on-chip ROM is mapped into the memory space with up to 2K
words of memory available. In the microprocessors mode all 64K words of program
memory are external.

7
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO- 01
AIM OF THE EXPERIMENT: -

Write a program for extended precision addition of two 64-bit numbers & Write a
program for extended precision subtraction of two 64-bit numbers.

EQUIPMENTS REQUIRED:-

1. Micro 50 EB DSP Trainer kit.


2. Keyboard

I) ADDITION .

PROGRAM: -

ADDRESS OPCODE MNEMONICS OPERAND


C000 BD00 LDP #100H
C001 6A01 LACC 0001,10
C002 6200 ADDS 0000
C003 6204 ADDS 0004
C004 6105 ADD 0005,10
C005 9008 SACL 0008
C006 9809 SACH 0009
C007 6A03 LACC 0003,10
C008 6002 ADDC 0002
C009 6206 ADDS 0006
C00A 6107 ADD 0007,10
C00B 9010 SACL 000A
C00C 9811 SACH 000B
C00D 7980 B C00D

8
I NPUT: -

[8000]: -? [8004]: -?
[8001]: -? [8005]: -?
[8002]: -? [8006]: -?
[8003]: -? [8007]: -?

OUTPUT: -

[8008]: -? [800A]: -?
[8009]: -? [800B]: -?

CONCLUSION: -

The result of extended precision addition is stored in memory location from


8008H to 800BH.

9
II) SUBTRACTION

PROGRAM: -
ADDRESS OPCODE MNEMONICS OPERAND
C000 BD00 LDP #100H
C001 6A01 LACC 0001,10
C002 6200 ADDS 0000
C003 6604 SUBS 0004
C004 6505 S UB 0005,10
C005 9008 SACL 0008
C006 9809 SACH 0009
C007 1002 LACC 0002,0
C008 6406 SUBB 0006
C009 6103 ADD 0003,10
C00A 6507 SUB 0007,10
C00B 900A SACL 000A, 0
C00C 980B SACH 000B, 0
C00D 7980 B C00D

I NPUT: -
[8000]: -? [8004]: -?
[8001]: -? [8005]: -?
[8002]: -? [8006]: -?
[8003]: -? [8007]: -?

OUTPUT: -

[8008]: -? [800A]: -?
[8009]: -? [800B]: -?

CONCLUSION: -

The result of extended precision subtraction is stored in memory location 8008H to


800BH.

10
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO:-02

AIM OF THE EXPERIMENT: -


Write a program to perform multiplication of two integer numbers & Write a program to
illustrate the linear convolution of two sequences X (n) and H (n)

. X(n) = {1,3,1,3} H(n) = { 1,2,1,0 }

EQUIPMENTS REQUIRED:-

1. Micro 50 EB DSP Trainer kit.


2. Keyboard.

I) MULTIPLICATION:

PROGRAM: -

ADDRESS OPCODE MNEMONICS OPERAND


C000 BD00 LDP #100H
C001 BF80, 037A LACC #037AH, 0
C003 9000 SACL 0000,0
C004 BF80, 012E LACC #012EH, 0
C006 9001 SACL 0001,0
C007 7300 LT 0000
C008 5401 MPY 0001
C009 BE03 PAC
C00A 9002 SACL 0002,0
C00B 9803 SACH 0003,0
C00C 7980 B C00C

11
I NPUT: -

[8000]: - 37A
[8001]: - 12E

OUTPUT: -

[8002]: -?
[8003]: -?

CONCLUSION: -

The result of multiplication of two numbers 037A and 012E is stored in memory location
8002H and 8003H.

12
II)LINEAR CONVOLUTION :
PROGRAM:
ADDRESS OPCODE MNEMONICS OPERAND
C000 BC02 LDP #0002H
C001 BF0B, 8200 LAR 3, #8200H
C003 B407 LAR 4, #0007
C004 BF09, 8100 LAR 1, #8100H
C006 8B89 MAR *, 1
C007 10A0 LACC *+
C008 9050 SACL 050H
C009 BF0A, 0153 LAR 2,0153H
C00B 8B8A MAR *, 2
C00C BE59 ZAP
C00D BB03 RPT #0003
C00E A390, C100 MACD 0C100, *-
C010 BE04 APAC
C011 8B8B MAR *, 3
C012 90A0 SACL *+
C013 8B8C MAR *, 4
C014 7B90,C006 BANZ C006, *-
C016 7980 B C016
C017 C016
I NPUT: -
X (n) data memory H (n) program memory
[8100] = 0001 [c100] = 0001
[8101] = 0003 [c101] = 0002
[8102] = 0001 [c102] = 0001
[8103] = 0003 [c103] = 0000
OUTPUT: -
[8200] =?
[8201] =?
[8202] =?
[8203] =?
[8204] =?
[8205] =?
[8206] =?
CONCLUSION: -
Hence the illustration of Linear Convolution is done..

13
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO- 03

AIM OF THE EXPERIMENT:-


To plot different types of signals (both continuous and discrete) using
matlab.
OBJECTIVES
To write MATLAB programs for generating discrete and continuous plots for the
functions or signals
i) unit impulse signal
ii) unit step signal
iii) unit ramp signal
iv) sinusoidal signal
EQUIPMENTS &SOFTWARE REQUIRED:-

i) Matlab R2010A
ii) Personal Computer (Dual Core, 2GB RAM)
iii) Plat form – Window 2010

MATLAB KEYWORDS USED

i)linspace ii)stem iii)subplot iv)zeros v)xlabel,ylabel vi)title vii)clc

THEORY:
Signal:- A signal is defined as any physical quantity that varies with time,space,or any
other independent variable.
Example:-x(t)=t2+5
Signals can be of two types.
i) Continuous time signal
ii) Discrete time signal
i) Continuous Time Signal: A signal that varies continuously with time is called
continuous time signal. It is represented as x(t),where t is independent variable. For
example- sinusoidal signal.

14
ii)Discrete Time Signal: Asignal that has values at discrete instants of time is known as
discrete time signal. The signal is not defined for fractional or non-integer value of time.
It can be obtained by sampling a continuous signal.

Some elementary discrete time signals are

1.Unit Sample Sequence((n))


It is defined as
(n)= 1, for n=0
0, for n0
It is zero every where except n=0 and at n=0 it is one.

2.Unit Step Signal


It is defined as
u(n)= 1, for n≥0
0, for n<0
It is zero every where except n<0 ..
3.Unit Ramp Signal
It is defined as
ur(n)= n, for n≥0
0, for n<0

PROGRAM:

clc
clear all
%Program to create Discrete time signal
%Program to generate unit step function
a=[zeros(1,50),ones(1,51)];
x=[-50:1:50];
subplot(2,2,1)
stem(x,a)
xlabel('n')
ylabel('u(n)')
title('unit step function')
%Program to create unit impulse function
a=[zeros(1,15),1,zeros(1,15)]
x=[-15:1:15]

15
subplot(2,2,2)
stem(x,a)
xlabel('n')
ylabel('unitimpulse')
title('unit impulse sequence')
%Program to generate unit ramp signal
a=[zeros(1,5),0:10];
x=-5:1:10;
subplot(2,2,3)
stem(x,a)
xlabel('n')
ylabel('Ur(n)')
title('unit ramp function')
%Program to create continuous signal(sinosodial)
t=linspace(0,2*pi,90)
x=sin(2*t)
subplot(2,2,4)
plot(t,x)
xlabel('t')
ylabel('sint')
title('continuous signal')

PLOTS FOR DIFFERENT SIGNALS

CONCLUSION
The signals both discrete and continuous forms are generated and printed

16
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO- 04
AIM OF THE EXPERIMENT:-

To get linear convolution of any two given sequences using matlab.

OBJECTIVES:-

i) Generate a random signal ‘x’ and a system impulse response ‘h’ with a nr of
samples.
ii) Find the convolution sum without using the inbuilt matlab function ‘conv’
iii) Plot the output ‘y’ using stem command and take printout of it.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer (Dual Core, 2GB RAM)
iii) Plat form – Windows 2010

MATLAB KEYWORDS USED


i)linspace ii)stem iii)subplot iv)zeros v)xlabel,ylabel vi)title
vii)clc viii) length ix)input

THEORY:

The formula that gives the response y(n) of the LTI system as a function of the input
signal x(n) and the unit sample (impulse) response h(n) is called a convolution sum.We
say that the input x(n) is convoluted with the impulse response h(n) to yield the output
y(n).
Convolution between x(n) and h(n) is represented as y(n)=x(n)*h(n),where ‘*’ denotes
convolution operation.
Mathematically convolution is represented as

y(n)= ∑ x(k)h(n-k)
k=-∞

17
Process to compute convolution :-

i) Folding- Fold h(k) about k=0 to obtain h(-k)


ii) Shifting- Shift h(-k) by n0 to right (left) if n0 is positive(negative),to get h(n0
-k)
iii) Multiplication- Multiply x(k) by h(n0 -k) to obtain product sequence
vn0 (k) =x(k) h(n0 -k)
iv) Summation:- Sum all the values of the product sequence vn0 (k) to obtain the
value of the output at time n= n0
Properties of convolution:-

i) Commutative law-
x(n)*h(n)=h(n)*x(n)
ii)Associative law-
[ x(n)*h1(n)]*h2(n)= x(n)*[h1(n)*h2(n)]
iii)Distributive law-
x(n)*[h1(n)+h2(n)]= x(n)*h1(n)+x(n)*h2(n)

PROGRAM: -

clc
clear all
x=input('enter the 1st seq')
h=input('enter the second seq')
m=length(x)
p=length(h)
n=m+p-1
x=[x,zeros(1,p-1)]
z=zeros(1,p)
for i=1:n

for j=p:-1:2
z(j)=z(j-1)
end
z(1)=x(i)
sum=0
for k=1:p;
sum=sum+z(k)*h(k)
end

18
y(i)=sum
end
disp('the result is');y
subplot(3,1,1)
stem(x)
xlabel('time')
ylabel('amp')
title('x(n)')
subplot(3,1,2)
stem(h)
xlabel('time')
ylabel('amp')
title('h(n)')
subplot(3,1,3)
stem(y)
title('y(n)')

PLOTS FOR LINEAR CONVOLUTION

CONCLUSION: -

We got the result of linear convolution of two sequences and printed the output.

19
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO-05

AIM OF THE EXPERIMENT:


To perform circular convolution of two sequences using matlab

OBJECTIVES:-
i) To generate two sequences x1 & x2 containing a number of samples.
ii) To find circular convolution between x1 &x2 using matlab applying the logic of
concentric circle method.
iii) To plot x1,x2 and circular convolution of both.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer (Dual Core, 2GB RAM)
iii) Plat form – Windows 2010

MATLAB KEYWORDS USED


i)linspace ii)stem iii)subplot iv)zeros v)xlabel,ylabel vi)title vii)clc viii) length
ix)input x) max

THEORY:

If x1(n) &x2(n) are two sequences having L&M number of samples respectively then
circular convolution between x1(n) &x2(n) is denoted as
x3(n)= x1(n) N x2(n) and x3(n) contains max(L,M) number of samples.
Two methods are there, Concentric circle method and Matrix multiplication method.
It can not be used to find the response of a filter without zero padding.

PROGRAM

20
%Circuar convolution of two sequencel
clc
clear all
x1=input('enter the first sequence')
x2=input('enter the second sequence')
n1=length(x1)
n2=length(x2)
n=max(n1,n2)
n3=n1-n2
if n3>0
x2=[x2,zeros(1,n3)]
else
x1=[x1,zeros(1,-n3)]
end
for a=1:n
y(a)=0
for i=1:n
j=a-i+1
if(j<=0)
j=n+j
end
y(a)=y(a)+(x1(i)*x2(j))
end
end
disp('result is');y
subplot(3,1,1)
stem(x1)
xlabel('n')
ylabel('x1(n)')
title('input x1(n)')
subplot(3,1,2)
stem(x2)
xlabel('n')
ylabel('x2(n)')
title('input x2(n)')
subplot(3,1,3)
stem(y)
xlabel('n')
ylabel('y(n)')
title('output y(n)')

PLOTS FOR CIRCULAR CONVOLUTION

21
CONCLUSION: -

We got the result of linear convolution of two sequences and printed the output.

22
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO-06

AIM OF THE EXPERIMENT:


Comparision between linear and circular convolution of two sequences
using matlab.

OBJECTIVES:-
i) To generate two sequences x1 & x2 containing a number of samples.
ii) To find circular convolution between x1 &x2 using function file and script file.
iii) To find linear convolution between the same two sequences.
iv) To plot both linear and circular convolution.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer (Dual Core, 2GB RAM)
iii) Plat form – Windows 2010
MATLAB KEYWORDS USED

i)linspace ii)stem iii)subplot iv)zeros v)xlabel,ylabel vi)title vii)clc viii) length


ix)input x) max

THEORY
Linear Convolution-
i) If x(n) has ‘l’ samples and h(n) has’m’samples then y(n) result has ‘m+l-1’
number of samples.
ii) There is no modulo-N operation.
iii) It is used to find the response of a filter.

Circular convolution-
i) Here output y(n) has max(l,m) number of samples .
ii) Shifting operation is done here in circular manner by computing index of one

23
iii) sequense modulo N.
iv) It cann’t be used to find response of a filter without zero padding.

PROGRAM
% FUNCTION FILE
function y=my_circonv(x1,x2)%function file declaration
%This gives circular convolution of x1,x2
%To call this:-y=my_circonv(x1,x2)
%The file is stored under the function name(my_circonv)
%y=output,x1=input,x2=input
n1=length(x1)
n2=length(x2)
n=max(n1,n2)
n3=n1-n2
if n3>0
x2=[x2,zeros(1,n3)]
else
x1=[x1,zeros(1,-n3)]
end
for a=1:n
y(a)=0
for i=1:n
j=a-i+1
if(j<=0)
j=n+j
end
y(a)=y(a)+(x1(i)*x2(j))
end
end
disp('result is');y

%SCRIPT FILE
%Comparision between circular & linear convolution
%This is a script file

x1=input('enter the first sequrnce')


x2=input('enter the second sequence')
x3=conv(x1,x2)
x4=my_circonv(x1,x2)%The function file is called here
%function file is stored under the name my_circonv
subplot(2,1,1)
stem(x3)
xlabel('n')
ylabel('y(n)')
title('linear convolution')
subplot(2,1,2)

24
stem(x4)
xlabel('n')
ylabel('x3(n)')
title('circular conv')

PLOTS FOR CIRCULAR CONVOLUTION VS LINEAR CONVOLUTION

CONCLUSION: -

We got the result of linear convolution of two sequences and circular convolution of two
sequences and printed the both.

25
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO:- 06

AIM OF THE EXPERIMENT:


To perform cross correlation of any two sequences using matlab.
OBJECTIVES:-
i) To generate two sequences x1 & x2 containing a number of samples and to find
cross correlation using xcorr(A,B)
ii) To plot cross correlation.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer (Dual Core, 2GB RAM)
iii) Plat form – Windows 2010
MATLAB KEYWORDS USED

i)linspace ii)stem iii)subplot iv)zeros v)xlabel,ylabel vi)title vii)clc viii) length


ix)input x) xcorr
THEORY:
Cross correlation- Suppose we have two real signal sequences x(n) and y(n) each of
which has finite energy(3 here).The cross correlation of x(n) and y(n) is a sequence
rxy(l),which is defined as n=∞
rxy(l)= ∑x(n)y(n-l) l=0,±1, ±2,…
n=-∞

or equivalently as as
n=∞
rxy(l)= ∑x(n+l)y(n) l=0,±1, ±2,…
n=-∞

The index l is the (time) shift(or lag) parameter and subscripts xy in the cross correlation
sequence rxy(l) indicate the sequences being correlated.The order of subscripts with x
proceeding y,indicates the direction in which one sequence is shifted related to the other.
Properties-
rxy(l)= ryx(-l)
Relation between convolution and correlation-

26
rxy(l)= x(l)*y(l)

PROGRAM:-
%Cross correlation between two sequence
clc
clear all
x=input('enter the first sequence')
y=input('enter the second sequence')
r=xcorr(x,y)
subplot(3,1,1)
stem(x)
xlabel('n')
ylabel('x(n)')
title('input x(n)')
subplot(3,1,2)
stem(y)
xlabel('n')
ylabel('y(n)')
title('input y(n)')
subplot(3,1,3)
stem(r)
xlabel('n')
ylabel('rxy(l)')
title('cross correlation')

PLOTS FOR CROSS CORRELATION

CONCLUSION: -
We got the cross correlation of two sequences and the output is printed.

27
AIM OF THE EXPERIMENT:
To perform auto correlation of any two sequences using matlab.
OBJECTIVES:-
i) To generate a sequences containing a number of samples and to find auto
correlation using xcorr(A, A).
ii) To plot auto correlation.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer (Dual Core, 2GB RAM)
iii) Plat form – Windows 2010
MATLAB KEYWORDS USED

i)linspace ii)stem iii)subplot iv)zeros v)xlabel,ylabel vi)title vii)clc viii) length


ix)input x) xcorr
THEORY:
Auto Correlation- The autocorrelation of a sequence is a correlation of a sequence with
itself.The autocorrelation of a sequence x(n) is defined by
n=∞
rxx(l)= ∑x(n)x(n-l) l=0,±1, ±2,…
n=-∞

or equivalently
n=∞
rxx(l)= ∑x(n+l)x(n) l=0,±1, ±2,…
n=-∞
Properties-

rxx(l)= rxx(-l)
Relation between convolution and correlation-

rxx(l)=x(l)*x(-l)
PROGRAM:-
%Auto correlation between two sequence
clc
clear all
x=input('enter the input sequence')
r=xcorr(x,x)
subplot(2,1,1)
stem(x)

28
xlabel('n')
ylabel('x(n)')
title('input x(n)')
subplot(2,1,2)
stem(r)
xlabel('n')
ylabel('rxy(l)')
title('Auto correlation')
PLOTS FOR AUTO CORRELATION

CONCLUSION: -
We got the auto correlation of two sequences and the output is printed.

29
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO:- 07

AIM OF THE EXPERIMENT:


To find circular convolution of two sequences using DFT and IDFT

OBJECTIVES:-

To find discrete time fourier transform of two given sequences.


To find the inverse discrete Fourier transform of the multiplication of the two discrete
Fourier transforms.
To plot the above result which is the circular convolution of the two input sequences.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer (Dual Core, 2GB RAM)
iii) Plat form – Windows 2010
MATLAB KEYWORDS USED

i)linspace ii)stem iii)subplot iv)zeros v)xlabel,ylabel vi)title vii)clc viii) length


ix)input x) fft xi)ifft

THEORY:

Let x1(n) and x2(n) are finite duration sequences both of length N with DFTs X1(k)
and X2(k). Now we find a sequence x3(n) for which the DFT is X3(k).
where
X3(k).= X1(k) X2(k) …(i)
We know
N-1
x3((n))N= ∑ x1((m))Nx2((n-m))N
m=0
For 0≤n≤N-1, x3((n))N =x3(n),similarly x1((m))N= x1(m)

30
So N-1
x3(n)= ∑ x1(m)x2((n-m))N …(ii)
m=0
Eq.(ii) represents the circular convolution of x1(n) and x2(n) represented as

x3(n)= x1(n) x2(n) …(iii)


N
From Eq(ii) and (iii) we find

DFT[x1(n) x2(n)] = X1(k) X2(k)


N .

PROGRAM:-
%Circular convolution using DFT
clc
clear all
x1=input('enter the first sequence')
x2=input('enter the second sequence')
n1=length(x1)
n2=length(x2)
n4=max(n1,n2)
n=n1-n2
if n>0
x2=[x2,zeros(1,n)]
else x1=[x1,zeros(1,-n)]
end
X1=fft(x1,n4)
X2=fft(x2,n4)
X3=X1.*X2
n3=length(X3)
x3=ifft(X3,n3)
subplot(3,1,1)
stem(x1)
xlabel('n')
ylabel('x1(n)')
title('first input sequence')
subplot(3,1,2)
stem(x2)
xlabel('n')
ylabel('x2(n)')

31
title('Second input sequence')
subplot(3,1,3)
stem(x3)
xlabel('n')
ylabel('x3(n)')
title('Circonv output sequence')

PLOTS FOR FIR CIRCULAR CONVOLUTION

CONCLUSION:
We obtain the result of circular convolution using DFT method.

32
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO-08

AIM OF THE EXPERIMENT


Design of FIR filters
OBJECTIVES:-

i) To design FIR filters linear phase characteristics.


ii) To plot the corresponding time and frequency domain
iii) To plot the magnitude response and the phase response of a filter

EQUIPMENTS &SOFTWARE REQUIRED:-

i) Matlab R2010A
ii) Personal Computer (Dual Core, 2GB RAM)
iii) Plat form – Windows 2010
THEORY:
A filter may be required to have a given frequency response or a specific response to an
impulse,step,ramp or simulate an analog signal.Digital filters areclassified as either FIR
or IIR.
The response of FIR filters depends only on the present and past input samples.
FIR filters have an exact linear phase,are always stable,the design methods are generally
linear,they can be realized efficiently in hardware.
The filter start up duration are finite.FIR filters are employed in filtering problems
where linear phase characteristics within the passband of the filter is required.
Linear phase filters are those filters in which the phase delay and group are constant.
MATLAB KEYWORDS USED

i)linspace ii)stem iii)subplot iv)zeros v)xlabel,ylabel vi)title vii)clc viii) length


ix)abs x) boxcar xi)fir1 xii)hann xiii)triang

33
PROGRAMS:-

%Design of FIR lowpass fillter


clc
clear all
w1=boxcar(23+1)
wn=0.5
b=fir1(23,wn,w1)
a=1
[H,w]=freqz(b,a)
mag=abs(H)
db=20*log((mag+eps)/max(mag))
pha=angle(H)
grd=grpdelay(b,a,w)
%For plotting
subplot(2,2,1)
plot(w/(2*pi),mag);grid
xlabel('frequency in pi units')
title('magnitude responce')
subplot(2,2,2)
plot(w/(2*pi),db);grid
xlabel('frequency in pi units')
ylabel('db')
title('log magnitude responce')
subplot(2,2,3)
plot(w/(2*pi),pha);grid
xlabel('frequency in pi units')
ylabel('phase in pi units')
title('phase response')
subplot(2,2,4)
plot(w/(2*pi),grd);grid
xlabel('frequency in pi units')
ylabel('delay in samples')
title('grup delay')

34
PLOTS FOR FIR LOWPASS FILTER

%Designof Fir highpass filter


clc
clear all
w1=hann(31+2)
wn=0.5
b=fir1(31,wn,'high',w1)
a=1
[H,w]=freqz(b,a)
mag=abs(H)
db=20*log((mag+eps)/max(mag))
pha=angle(H)
grd=grpdelay(b,a,w)
subplot(2,2,1)
plot(w/(2*pi),mag);grid
title('magnitude response')
subplot(2,2,2)
plot(w/(2*pi),db);grid
title('log magnitude response')
xlabel('frequency in pi units')
ylabel('db')
subplot(2,2,3)
plot(w/(2*pi),pha);grid
title('phase response')
xlabel('frequency in pi units')
ylabel('phase in pi units')
subplot(2,2,4)

35
plot(w/(2*pi),grd);grid
title('group delay')
xlabel('frequency in pi units')
ylabel('delay in sample')

PLOTS FOR FIR HIGH PASS FILTER

36
37
%Designof Fir bandstop/bandreject filter
clc
clear all
w1=triang(42+2)
wn=[0.5 0.8]
b=fir1(41,wn,'stop')
a=1
[H,w]=freqz(b,a)
mag=abs(H)
db=20*log((mag+eps)/max(mag))
pha=angle(H)
grd=grpdelay(b,a,w)
subplot(2,2,1)
plot(w/(2*pi),mag);grid
title('magnitude response')
subplot(2,2,2)
plot(w/(2*pi),db);grid
title('log magnitude response')
xlabel('frequency in pi units')
ylabel('db')
subplot(2,2,3)
plot(w/(2*pi),pha);grid
title('phase response')
xlabel('frequency in pi units')
ylabel('phase in pi units')
subplot(2,2,4)
plot(w/(2*pi),grd);grid
title('group delay')
xlabel('frequency in pi units')
ylabel('delay in sample')

38
PLOTS FOR FIR BANDSTOP FILTER

CONCLUSION: -
By conducing this experiment we plotted response of various filter types.

39
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO-09
AIM OF THE EXPERIMENT:-

Design of IIR filter.

OBJECTIVES:-

i) To find out order and cutoff frequency of digital filter.


ii) Plot magnitude,phase response and group delay.
iii) To design the specified chebyshev filter.

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer (Dual Core, 2GB RAM)
iii) Plat form – Windows 2010

THEORY:
Infinite impulse response(IIR) filters are a type of digital filters.Thus the design of an
IIR filter involves design of a digital filter in analog domain and transforming the design
in digital domain.IIR filter can be designed by using the impulse invariance method.Here
the desired impulse response of a digital filter is obtained by uniformly sampling impulse
response of equivalent analog filter.

IIR filters can be designed using the bilinear trans formation technique.The
magnitude response of Chebyshev filter has equiripple passband maximally flat
stopband.By increasing the filter order N, the Chebyshev response approximates the ideal
response.The phase response of Chebyshev filteris more nonlinear than the Butterworth
filter for a given filter length ‘N’.

MATLAB KEYWORDS USED

i)linspace ii)stem iii)subplot iv)zeros v)xlabel,ylabel vi)title vii)clc viii) length

40
ix)freqz x) cheb10rd xi)cheby1

PROGRAM: -
%Design of Chebyshev filter
clc
clear all
wp=0.6*pi
ws=0.4586
rp=1
rs=15
%To find order and frequency
[N,wn]=cheb1ord((wp/pi),(ws/pi),rp,rs)
%To design the filter
[b,a]=cheby1(N,rp,wn,'high')
[H,w]=freqz(b,a)
mag=abs(H)
db=20*log((mag+eps)/max(mag))
pha=angle(H)
grd=grpdelay(b,a,w)
subplot(2,2,1)
plot(w/(2*pi),mag);grid
title('magnitude response')
subplot(2,2,2)
plot(w/(2*pi),db);grid
title('log magnitude response')
xlabel('frequency in pi units')
ylabel('db')
subplot(2,2,3)
plot(w/(2*pi),pha);grid
title('phase response')
xlabel('frequency in pi units')
ylabel('phase in pi units')
subplot(2,2,4)
plot(w/(2*pi),grd);grid
title('group delay')
xlabel('frequency in pi units')
ylabel('delay in sample')

41
PLOTS FOR CHEBYSHEV FILTER

CONCLUSION: -

We got the magnitude and phase response of Chebyshev filter and the output is printed

42
BHUBANESWAR COLLEGE OF ENGINEERING, BHUBANESWAR
Department of Electronics and Communication Engineering

DIGITAL SIGNAL PROCESSING LAB

Branch: ECE Sem:5th

EXPERIMENT NO-10
AIM OF THE EXPERIMENT
To find linear convolution of two sequences using overlap save method.
OBJECTIVES:-
i) To generate a random sequence.
ii) To find linear convolution using overlap save method

EQUIPMENTS &SOFTWARE REQUIRED:-


i) Matlab R2010A
ii) Personal Computer (Dual Core, 2GB RAM)
iii) Plat form – Windows 2010
THEORY:
Let the length of input sequence is ‘L’and the length of impulse response is ‘M’.In
this method input sequence is divided into blocks of data of size N=L+M-1.Each block
consists of last M-1 data points of previous block followed by ‘L’new data points to form
a data sequence of length N=L+M-1. For the first block,the first M-1 points are set to
zero
MATLAB KEYWORDS USED

i)linspace ii)stem iii)subplot iv)zeros v)xlabel,ylabel vi)title vii)clc viii) length

PROGRAM: -
%Function file for overlap save
function y=ovrlsav(x,h,N)
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)]

43
h=[h zeros(1,N-M)]
k=floor((Nx+M1)/(L))
Y=zeros(k+1,N)
for k=0:k
xk=x(k*L+1:k*L+N)
y(k+1,:)=circonv(xk,h,N)
end
y=y(:,M:N)'
y=(y(:))'

%Another function file for circular convolution


function y=circonv(x,h,N)%function file declaration
%This gives circular convolution of x,h
%To call this:-y=circonv(x,h,N)
%The file is stored under the function
name(circonv)
%y=output,x=input,h=input,N=Nr of samples in output
n1=length(x)
n2=length(h)
N=max(n1,n2)
n3=n1-n2
if n3>0
h=[h,zeros(1,n3)]
else
x=[x,zeros(1,-n3)]
end
for a=1:N
y(a)=0
for i=1:N
j=a-i+1
if(j<=0)
j=N+j
end
y(a)=y(a)+(x(i)*h(j))
end
end
disp('result is');y

%Script file

44
x=[3 -1 0 1 3 2 0 1 2 1]
h=[1 1 1]
N=5
y=ovrlsav(x,h,N)

CONCLUSION: -
We got the result of circular convolution using overlapsave method

45

You might also like