You are on page 1of 82

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

DIGITAL SIGNAL
PROCESSING
LAB MANUAL

DEPARTMENT OF ECE
LORDS INSTITUTE OF ENGINEERING &TECHNOLOGY

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 1

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

(EC 05177) DIGITAL SIGNAL PROCESSING LAB

LIST OF EXPERIMENTS:
1. To study the architecture of DSP chips TMS 320C SX/6X Instructions.
2. To verify linear convolution.
3. To verify the 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 FET 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.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 2

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

INDEX
S.No.
1

Description
To study the architecture of DSP chips TMS 320C

Page No.
1-30

SX/6X Instructions.
2

To verify linear convolution.

31-38

To verify the circular convolution

39-45

To design FIR filter (LP/HP) using windowing

46-55

technique.
a) Using rectangular window
b) Using triangular window
c) Using Kaiser window
5

To implement IIR filter (LP/HP) on DSP processors.

56-63

N-point FET algorithm.

64-75

MATLAB program to generate sum of sinusoidal


signals.

76-80

MATLAB program to find frequency response of analog

81-86

LP/HP filters.

To compute power density spectrum of a sequence.

87-90

10.

To find the FFT of given 1-D signal and plot.

91-95

11

ADD ON EXPERIMENTS
Design of FIR filter using Hamming window

96-99

DESIGN EXPERIMENT
12

Design of IIR filter

100-104

1. ARCHITECTURE AND INSTRUCTION SET OF


LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 3

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

DSP CHIP-TMS320C6713
FEATURES OF HIGHEST-PERFORMANCE FLOATING POINT DIGITAL SIGNAL
PROCESSOR TMS320C6713

VLIW Parallel Architecture

Rich Addressing modes

Two general purpose register files (A0-A15 & BO-B15)

32/64 Bit Data Word

Rich Instruction Set

Eight 32-bit instructions/Cycle

32/64-bit data word

4.4-, 6.7-ns institution cycle time

1800 MIPS/1350 MFLOPS

Rich Peripheral Set, Optimized for Audio

Highly Optimized C/C++ compiler

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 4

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

11 C6000 OVERVIEW

Internal
Memory

P
E
R
I
P
H
E
R
A
L
S

External
Memory

CPU

C6000 OVERVIEW
Memory
A0

B0
.D1

.D2

.M1

.M2

.L1

.L2

.S1

.S2

A15

8 functional units
.D (data) 32-bit operands
.L (ALU) 32-or-40-bit operands
.S (shift) 32-or-40 bit operands
.M (multiply) 16x16bit integer
or 32x32 bit floating point
2 register files (32-bit)
All 6 units can be used in parallel
each cycle
B15

Controller / Decoder

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 5

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

TMS320C67x Block Diagram

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 6

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

TMS320C6713 ARCHITECTURE

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 7

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

CPU (DSP Core)

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 8

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

TMS320C6713 DSP FEATURES:


Highest-Performance Floating-Point Digital Signal Processor (DSP)

Eight 32-bit instructions/cycle


32/64 bit data word
300-, 225-, 200-MHz (GDP), and 225-, 200-, 167-MHz (PYP) clock rates
3.3-, 4.4-, 5-, 6-instruction cycle times
2400/1800, 1800/1350, 1600/1200, and 1336/1000 MIPS / MFLOPS
Rich peripheral set, optimized for audio
Highly optimized C/C++ compiler

Advanced very long instruction word (VLIW) TMS320C67XTM DSP core


Eight independent functional units :
Two ALUs (fixed-point)
Four ALUs (floating and fixed-point)
Two multipliers (floating and fixed-point)
Load-store architecture with 32 32-bit general-purpose registers.
Instruction packing reduces code size
All instructions conditional
Instruction set features
Native instructions for IEEE 754
Single and double precision
Byte-addressable (8-, 16-, 32-bit data)
8-bit overflow protection
Saturation; bit-field extract, set, clear; bit-counting, normalization
L1/L2 Memory Architecture
4K-byte LIP program cache (direct-mapped)
4K-byte LID data cache (2-way)
256K-byte L2 memory total : 64K-byte L2 unified cache/mapped RAM, and 192K-byte
additional L2 mapped RAM
Device Configuration
Boot Mode:HPI< 8-, 16-, 32-bit ROM boot
Endianness: Little Endian, Big Endian
32-Bit External Memory Interface (EMIF)
Glueless interface to SRAM, EPRIM, Flash, SBSRAM, and SDRAM

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 9

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

512M-byte total addressable external memory space


Enhanced direct-memory-access (EDMA) controller (16 independent channels)
16-bit host-port interface (HPI)
Two Multichannel Audio Serial Ports (McASPs)
Two independent clock zones each (1 TX and 1 RX)
Eight serial data pins per port:
Individually assignable to any of the clock zones
Each clock zone includes:
Programmable clock generator
Programmable frame sync generator
TDM streams from 2-32 time slots
Support for Slot Size :
8, 12, 16, 20, 24, 28, 32 bits
Data formatter for bit manipulation
Wide variety of 12S and similar bit stream formats
Integrated digital audio interface transmitter (DIT) supports:
S/PDIF, IEC60958-1, AES-3, CP-430 formats
Upto 16 transmit pins
Extensive error checking and recovery
Two linear-integrated circuit bus (I2C BusTM) multi-master and slave interfaces
Two multichannel buffered serial ports:
Serial-peripheral-interface (SPI)
High-speed TDM interface
AC97 interface
Two 32-bit general-purpose timers
Dedicated GPIO module with 16 pins (external interrupt capable)
Flexible phase-locked-loop (PLL) based clock generator module
IEEE-1149.1 (JTAG) boundary-scan compatible
Package options :
208-pin powerPADTM plastic (low-profile) quad flatpack (PYP)
272-BGA packages (GDP and ZDP)
0.13-m/6-level copper metal process
CMOS technology
3.3-V I/Os, 1.2 -V internal (GDP & PYP)
3.3-V I/Os, 1.4-V Internal (GDP) (300 MHz only)

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 10

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

INTRODUCTION TO CODE COMPOSER STUDIO


Code Composer is the DSP industrys first fully integrated development environment (IDE) with
DSP specific functionality. With a familiar environment liked MS-based C++TM, code composer
lets you edit, build, debug, profile and manage projects from a single unified environment. Other
unique features graphical signal analysis, injection/extraction of data signals via file I/O multiprocessor debugging, automated testing and customization via a C-interpretive scripting language
and much more.
CODE COMPOSER FEATURES INCLUDE:

IDE
Debug IDE
Advanced watch windows
Integrated editor
File I/O, probe points, and graphical algorithm scope probes
Advanced graphical signal analysis
Interactive profiling
Automated testing and customization via scripting
Visual project management system
Compile in the background while editing and debugging
Multi-processor debugging
Help on the target DSP

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 11

DEPARTMENT OF ECE

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

DIGITAL SIGNAL PROCESSING LAB

Page 12

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

EXPT.NO.2

TO VERIFY LINEAR CONVOLUTION USING


TMS320 C6713 DSP PROCESSOR
AIM : To very the linear convolution operation using DSK code composer studio.
EQUIPMENTS NEEDED :
Host (PC) with windows (95/98/me/XP/NT/2000).
TMS320C6713 DSP starter kit (DSK).
INTRODUCTION :
Linear convolution involves the following operations.
1. Folding
2. Multiplication
3. Addition
4. Shifting
These operation can be represented by a mathematical expression as follows:

y[ii] =

k-w

x[k]h[n k]

x [ ] = input signal samples


h [ ] = impulse response co-efficient
y [ ] = convolution output
n = no. of input samples
h = no. of impulse response co-efficient

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 13

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

ALGORITHM TO IMPLEMENT C OR ASSEMBLY PROGRAM FOR


CONVOLUTION
Eg :

x [n] = {1, 2, 3, 4}
H [k] = {, 2, 3, 4}

Where; n=4, k=4,

; values of n & k should be a multiple of 4.


If n & k are not multiples of 4, pad with zeros to make multiples of 4

r = n+k-1

; size of output sequence


= 4+4+-1
=7

r=
0
______

n = o (x[0]h[0]

x[0]h[1]

x[0]h[2]

x[0]h[3]

x[1]h[1]

x[1]h[2]

x[1]h[3]

x[2]h[0]

x[2]h[1]

x[2]h[2]

x[2]h[3]

x[3]h[0]

x[3]h[1]

x[3]h[2]

x[3]h[3]

x[1]h[0]

Output :

y[r] = {1, 4, 10, 20, 25, 24, 16}

Note : at the end of input sequences pad n and k no. of zeros

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 14

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

ASSEMBLY PROGRAM TO IMPLEMENT LINEAR


CONVOLUTION
conv.asm:
global _main
X

.half 1,2,3,4,0,0,0,0

;input1, M =4

.half 1,2,3,4,0,0,0,0

;input2, N =4

.bss y,14,2

;OUTUT, R=M+N-1

;at the end of input sequences pad M and N no. of zeros


_main:
MVKL.S1 X,A4
MVKH.S1 X,A4
MVKL.S2 H,B4
MVKH.S2 H,B4
MVKL.S1 Y,A5
MVKH.S1 Y,A5
MVK .32 7,B2

;POINTER TO X
;POINTER TO H
;POINTER TO Y
;R=M+N-1

;MOVE THE VALUE OF R TO B2 FOR DIFFERENT LENGTH OF I/P SEQUENCES


ZERO .L1

A7

ZERO .L1

A3

;I=0

LL2:
ZERO .L1 A2
ZERO .L1 A8

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

LDH

.d1*a4[a8],a6

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

MV

.s2x A8,B5

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

SUB

.l2 a3,b5,b7

LL1:

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 15

DEPARTMENT OF ECE

LDH

DIGITAL SIGNAL PROCESSING LAB

.D2*B4[B7],B6
NOP4

[B0]

[A2]

MP5

.M1X A6, B6, A7

ADD

.L1 A8, A8

ADD

.L1 A2, A7,A2

CMPLT

.L2 X B5, A3,B0

B
NOP 5

.S2

STH .D1
ADD
CMPLT

A2,*A5[A3]
.L1 A3, 1,A3
.L1X A3, B2, A2

LL1

.S1 LL2
NOP 5
B

B3

NOP 5

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 16

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

C PROGRAM TO IMPLEMENT LINEAR CONVOLUTION


#include<stdio.h>
main()
{

int m=4;

/*length of i/p samples sequences*/

Int n=4;

/*length of impulse response co-efficients*/

Int i=0,j;
int x[10]={1,2,3,4,0,0,0,0}; /*input signal samples*/
int h[10]={1,2,3,4,0,0,0,0}; /*input response co-efficients*/
/* at the end of input sequences pad m and n no. of zeros*/
int y[10];
for (i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=I;j++)
y[i]+=x{j}*h[i-j};
}
for(i=0;i<m+n-1;i++)
print(%d/n,y[i]);
}

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 17

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

PROCEDURE :
Open code composer studio, make sure the dsp kit is turned on.
Start a new project using project-new pull down menu, save it in a separate directory
(c:\ti\myprojects) with name iconv.pjt.
Add the source files conv.asm.
To the project using project->add files to project pull down menu.
Add the linker command file hello.cmd.
(path:c\ti\tutorial\dsk6713\hello1\hello.cmd)
Add the run time support library file rts6700.lib.
9path: c:\ti\c6000\cgtools\lib\rts6700.lib)
Compile the program using the project-compile pull down menu or by clicking the
shortcut icon on the left side of program window.
Build the program using the project-build pull down menu or by clicking the shortcut
icon on the left side of program window.
Load the program (iconv.out) in program memory of dsp chip using the file-load
program pull down menu.
To view output graphically
Select view -> graph -> time and frequency

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 18

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

RESULT :
Configure the graphical window as shown below
INPUT
x[n] = {1, 2, 3, 4,0,0,0,0}
h[k] = {1, 2, 3, 4,0,0,0,0}

OUTPUT :

NOTE :
1. To execute the above program follow procedure to work on code composer studio
2. To view graphical output follow the above procedure.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 19

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

LINEAR CONVOLUTION QUESTIONS


1. What is the requirement for convolution?
2. What is the difference between convolution & correlation?
3. What is meant by impulse response?
4. Is it possible to represent any discrete time signal in terms of impulses? If yes, represent
by using example.
5. Draw the h(2n-k) & h(n-2k) for the following sequence
h(n) = {4 3 2 1} assume (i) k = 3 (ii) k = 5.

6. Write the expressions for LTI system convolution formula and causal LTI system
convolution formula.
7. What us the length of linear convolution if length of input and impulse responses are N1
and N2 respectively?
8. What is the difference between continuous and discrete convolution?

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 20

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

EXPT.NO.3

TO VERIFY CIRCULAR CONVOLUTION USING


TMS320C6713 DSP PROCESSOR
AIM : To verify the circular convolution operation using dsk code composer studio.
EQUIPMENTS NEEDED:
Host (pc) with windows (95/98/me/xp/nt/2000).
Tms320c6713 dsp starter kit (dsk).

ALGORITHM:
Steps for circular convolution
Steps for circular convolution are the same as the usual convolution, expect all index calculations
are down mod N = on the wheel
Steps for cyclic convolution
Step1:plot f[m] and h[-m]

f[I}

h [N-I}

f[0}
f[N-I}

h[0}
h[I}

Subfigure 1.1 Subfigure 1.2


Step 2: spin h[-m= n times anti clock wise (counter-clockwise) to get h [n-m]
(i.e. simply rotate the sequence, h[n], clockwise by n steps)
h[N-I}
h[N}
h[N+I}

Figure 2 : step2

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 21

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Step 3 : Pointwise multiply the [m] wheel and the h[n-m] wheel. Sum=y[n]
Step 4: Repeat for all 0 < n < N-1
Example 1 : convolve (n = 4)
f[n}

h[n}
1

1
0

n
Subfigure 3.1

1
0

Subfigure 3.2

h[-m] =
h[((-m))N]
1
n
Figure 4

Multiple [m] and sum to yield : y[0] = 3

h[1-m]
h[((1-m))N]
1
n
Figure 5

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 22

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Multiply [m] and sum to yield : y[1] = 5

h[2-m]
h[((2-m))N]
1
n
Figure 6

Multiple [m] and sum to yield : y[2] = 3

h[3-m]
h[((3-m))N]
1
n

Figure 7
Multiple [m] and sum to yield : y[3] = 1

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 23

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Program to implement circular convolution


#include<stdio.h>
int m,n,x[30],h[30],y[30],i,j,temp[30],k,x2[30],a[30];
void main()
{
printf( enter the length of the first sequence\n);
scanf(%d,&m);
printf( enter the length of the second sequence\n)
scanf(%d,&n);
printf( enter the first sequence\n);
for(i=o;i<m;i++)
scanf(%d,&x[i]);
printf( enter the second sequence\n);
for(j=0;j<n;j++)
scanf(%d,&h[j]);
if(m-n!=0)

/&if length of both sequences are not eqal*/

{
If(m>n)

/* pad the smaller seqeucne with zero*/

{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 24

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++)

/*folding h(n) to h(-n)*/

a[j]=h[n-j];
/*circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++]
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf( the circular convolution is\n);
for(i=0;i<n;i++)
printf(%d\t,y[i]);
}

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 25

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

PROCEDURE :
Open code computer studio, make sure the DSK kit is turned on.
Start a new project using project-new pull down menu, save it in a separate directory
(c:\ti\myprojects) with name cir conv.pjt.
Add the source files circular convolution.C.
To the project using project-> add files to project pull down menu.
Add the linker command file hello.cmd.
(path:c:\ti\tutorial\dsk6713\hello1\hello.cmd)
Add the run time support library file rts6700.lib
(path: c:\ti\c6000\cgtools\lib\rts6700.lib)
Compile the program using the project-compile pull down menu or by clicking the
shortcut icon on the left side of program window.
Build the program using the project-build pull down menu or by clicking the shortcut
icon on the left side of program window.
Load the program (iconv.out) in program memory of dsp chip using the file-load
program pull down menu.

RESULT:
IN PUT:
Eg:
OUTPUT:

x[4]={3, 2, 10}
h[4]=(1, 1, 0,0}
y[4]=(3, 5, 3, 0}

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 26

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

CIRCULAR CONVOLUTION QUESTIONS


1. Why we need circular convolution?
2. What is the difference between circular and linear convolution?
3. What is the length of output sequence after circular convolution if the lengths of input and
impulse responses are M1 and M2 respectively?
4. State the circular convolution property of DFT?
5. Where we required convolution properly?
6. What does zero padding mean? Where we required this concept?
7. What is difference between linear shifting and circular shifting of signal? Show with
example.
8. What is difference between linear and circular folding of signal? Show with example.
9. What is the advantage with sectioned convolution?

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 27

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

EXPERIMENT NO.4.1 (USING C-LANGUAGE)

FIR FILTER (WINDOWING TECHNIQUES) DESIGN


USING TMS320C6713 DSP PROCESSOR
[RECTANGULAR/TRIANGULAR/KAISER WINDOW]
AIM:
The aim of this laboratory exercise is to design and implement a digital hr filter and observe its
frequency response. In this experiment we design a simple IIR filter so as to stop or attenuate
required band of frequencies components and pass the frequency components, which are outside
the required band.
EQUIPMENTS NEEDED:

Host (PC) with windows(95/98/Me/XP/NT/2000)


TM320C6713 DSP Starter Kit (DSK)
Oscilloscope and Function generator.

DESIGNING AN FIR FILTER:


Following are the steps to design linear phase FIR filters Using Windows Method.
I.

Clearly specify the filter specifications.


Eg: order
= 30;
Sampling rate
= 8000 samples/sec
Cut off Freq.
= 400 Hz.

II.

Compute the cut-off frequency Wc


Eg: Wc = 2*pie* fc / Fs
2*pie* 400/8000
= 0.1*pie

III.

Compute the desired impulse response h d(n) using particular Window.


Eg: b_rect1=fir1(order, Wc, high, boxcar(31));

IV.

Convolve input sequence with truncated impulse response x (n)*h(n).

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 28

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

FLOW CHART TO IMPLEMENT FIR FILTER :


Start

Initialize the DSP Board

Take a new input in data


from the analog in of codec in
data

Initialize Counter = 0
Initialize Output = 0, i=0

Output += coeff[N-i]*val[i]
Shift the input value by one

No
Is the loop
Cnt=order
Poll the ready bit,
When asserted
Output += coeff[0]*data
Put the data in vil arrav.

Write the value output to


Analog output of the codec

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 29

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Coefficients for FIR Low Pass Kaiser filter:


Cutoff-500Hz
Float
b_kali[31]=(-0.000019,-0.000170,-0.000609,-0.001451,-0.002593,-0.003511,0.003150,0.0000000,0.007551,0.020655,0.039383,0.062306,0.086494,0.108031,0.122944,
0.128279, 0.122944,0.108301,0.086494, 0.062306,0.039383,0.020655,0.007551,0:000000,
-0.003150,-0.003511,-0.002593,-0.001451,-0.000609,-0.000170,-0.000019};
Cutoff-1000Hz
Float b_kai2[31]={0.000035,-0.000234,-0.000454,0.000000,0.001933,0.004838,0.005671,
0.007410,0.000000,0.017764,0.020126,-0.015895,-0.060710,0.034909,0.105263,0289209,0.374978,
0.289209,0.105263,-0.034909,-0.060710,-0.015895,0.020126,017764,0.000000,-0.007410,
-0.003421, 0.001046,0.0014140.000246-0.000166,-0.0000461.

Coefficients for FIR Low Pass Rectangular filter:


Cutoff-500Hz
float b_rect1[31]=(-0.008982,-0.017782,-0.025020,-0.029339,-0.029569,-0.024895,0.014970,0.000000,0.019247,0.041491,0.065053,0.088016,0.108421,0.124473,0.134729
0.138255,0.134729,0.124473,0.108421,0.088016,0.065053,0.041491,0.019247,0.000000,
-0.014970,-0.24895,-0.029569,-0.029339,-0.025020,0-017782,-0.008982};
Cutoff-1000Hz
float b_rect2[31]={-0.015752,-0.023869,0.018176,0.000000,0.021481,0.033416,0.026254,-0.000000,-0.033755,-0.055693,0.047257,0.000000,0.078762,0.167080,0.0236286,0.262448,
0.236296.0.167080,0.078762,0.000000,-0.047257,-0.055693,-0.0337550.000000,0.026254
0.033416,0.021481,0.000000,-0.018176,0.023869,-0.015752};
Cutoff-1500Hz
float b_rect2[31]={-0.020203,-0.016567,0.009656,0.027335,0.011411,-0.023194,0.033672
0.000000,0.043293,0.038657,-0.025105,-0.082004,0.041842,0.115971,0.303048,0.386435,
0.303048,0.115971,-0.041842,-0.082004,-0.025105,0.038657,0.043293,0.000000,0.033672
-0.023194,0.011411,0.027335,0.009656,-0.016567,-0.020203};

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 30

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Coefficients for FIR Low Pass Triangular filter:


Cutoff-500Hz
float b_tri1[31]={0.000000,-0.001185,-0.003336,-0.005868,-0.007885,-0.0082980.005988,
0.000000,0.010265,0.024895,0.043368,0.064545,0.086737,0.107877,0.125747,0.138255,
0.125747,0.107877,0.086737,0.064545,0.043368,0.024895,0.010265,0.000000,0.005988,
-0.008298,-0.007885,-0.005868,-0.0033336,-0.001185,0.000000};
Cutoff-1000Hz
float
b_tri2[31]={0.000000,-0.001591,-0.002423,0.000000,0.005728,0.011139,0.010502
0.000000,-0.018003,-0.033416,0.031505,0.000000,0.063010,0.144802,0.220534,0.262448,
0.220534,0.144802,0.063010,0.000000,-0.031505,-0.033416,-0.018003,0.000000,0.01502,
0.01139,005728,0.000000,-0.002423,-0.001591,0.0000000];
Cutoff-1500Hz
float b_rect3[31]={0.000000,-0.001104,0.001287,0.005467,0.003043,-0.007731,0.013469.

,-

Coefficients for FIR High Pass Kaiser filter:


Cutoff-400Hz
float b_kai1[31]=(0.000050,0.000223,0.000520,0.000831,0.000845,-0.000000,0.002478,
-0.007437,-0.015556,-0.027071,-0.041538,-0.057742,-0.073805,-0.087505,-0.096739,
0.899998,-0.096739,-0.087505,-0.073805,-0.057742,-0.041538,-0.027071,-0.015556,
-0.007437,-0.002478,-0.000000,0.000845,0.000831,0.000520,0.00223,0.000050};
Cutoff-800Hz
float b_kai2[31]={-0.000000,-.000138,-0.000611,-0.001345,-0.001607,0.000000,0.004714,
0.012033,0.018287,0.016731,0.000000,-0.035687,-0.086763,-0.1415880.184011,0.800005,
-0.0184011,-0.141588,-0.086763,0.035687,0.000000,0.016731,0.018287,0.012033,0.004714,
-0.000000,-0.001607,-0.001345,-0.000611,-0.000138,0.00000};
Cutoff-1200Hz
float b_kai3[31]={-0.000050,-0.000138,0.000198,0.001345,0.002212,-0.000000,0.0064898,
-0.012033,-0.005942,0.016731,0.041539,0.035687,-0.028191,-0.141589,0.253270,0.700008,
-0.253270,-0.141589,-0.028191,0.035687,0.041539,0.016731,-0.005942,-0.012033,-

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 31

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

0.006489,-0.000000,0.002212,0.001345,0.000198,-0.000138,-0.00005};
Coefficients for FIR High Pass Rectangular filter:
Cutoff-400Hz
float b_rct1[31]=(0.021665,0.022076,0.020224,0.015918,0.009129,-0.000000,0.011158,
-0.023877,-0.037558,-0.051511,-0.064994,-0.077266,-0.087636,-0.095507,.100422,0.918834,
-0.100422,-0.095507,-0.087636,-0.077266,-0.0694994,-0.051511,-0.037558,-0.023877,
-0.011158,-0.00000,0.009129,0.015918,0.020224,0.022076,0.0216665};
Cutoff-800Hz
float b_rect2[31]={0.000000,-0.013457,-0.023448,-0.025402,-0.017127,0.000000,0.020933,
0.038103,0.043547,0.031399,0.000000,-0.047098,0.101609,-0.152414,0.188394,0.805541,
0.188394,-0.152414,-0.101609,0.047098,0.000000,0.031399,0.043547,0.038103,0.020933,
-0.000000,-0.017127,-0.025402,-0.023448,-0.013457,0.00000};
Cutoff-1200Hz
float b_recti3[31]={-0.020798,-0.013098,0.007416,0.024725,0.022944,-0.000000,0.028043,
-0.037087,-0.013772,0.030562,0.062393,0.045842,-0.032134,-0.148349,0.252386,0.686050,
-0.252386,-0.148349,-0.032134,0.045842,0.062393,0.030562,-0.013772,-0.037087,0.028043,
-0.000000,0.022944,0.024725,0.007416,-0.013098,-0.020798};
Coefficients for FIR High Pass Triangular filter:
Cutoff-400Hz
float b_tri1[31]=(0.000000,0.001445,0.002648,0.003127,0.002391,-0.000000,0.004383,
-0.010943,-0.019672,-0.030353,-0.042554,-0.055647,-0.068853,-0.081290,-0.092048,
0.902380,-0.092048,-0.081290,-0.068853,-0.055647,-0.042554,-0.030353,-0.019672,
-0.01943,-0.004383,-0.000000,0.002391,0.003127,0.002648,0.001445,0.000000};
Cutoff-800Hz
float b_tri2[31]={0.000000,-0.000897,-0.003126,-0.005080,-0.004567,0.000000,0.008373
0.017782,0.023225,0.018839,0.000000,-0.034539,-0.081287,-0.132092,0.175834,0.805541,
-0.175834,-0.132092,-0.081287
0.034539,0.000000,0.018839,0.023225,0.017782,0.008373,
-0.000000,-0.004567,-0.005080,-0.003126,-0.000897,0.000000};
Cutoff-1200Hz
float b_tri3[31]={0.00000,-0.00904,0.001021,0.005105,0.006317,-0.000000,0.011581,-0.017868,-0.007583,0.018931,0.042944,0.034707,-0.026541,-0.132736,0.24196,0.0708287,
-0.243196,0.132736,-0.026541,0.034704,0.042944,0.018931,-0.007583,-0.017868,-

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 32

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

0.011581,-0.000000,0.006317,0.005105,0.001021,-0.000901,0.000000};
C PROGRAM TO IMPLEMENT FIR FILTER:
fir.c
#include filtercfg.h
#include dsk6713.h
#include dsk6713_aic23.h
float filter_Coeff[] = {0.000000,-0.001591,-0.002423,0.000000,0.005728,
0.011139,0.010502,-0.000000,-0.018003,-0.033416,-0.031505,0.00000,
0.063010,0.144802,0.220534,0.262448,0.220534,0.144802,0.063010,0.000000,
-0.031505,-0.033416,-0.018003,-0.000000,0.010502,0.011139,0.005728,
0.000000,-0.002423,-0.001591,0.000000};
static short in_buffer[100];
DSK6713_AIC23_Coding config = {\
0x0017, /*0 dsk6713_aic23_leftinvol leftline input channel volume*/\
0x0017, /*1 dsk6713_aic23_rightinvol right line input channel volume*/\
0x00d8, /*2 dsk6713_aic23_lefthpvol left channel headphone volume*/\
0x00d8, /*3 dsk6713_aic23_righthpvol right channel headphone volume*/\
0x0011, /*4 dsk6713_aic23_anapath analog audio path control */\
0x0000, /*5 dsk6713_aic23_digpath digital audio path control */\
0x0000, /*6 dsk6713_aic23_powerdown power down control */\
0x0043, /*7 dsk6713_aic23_digif digital audio interface format */\
0x0081, /*8 dsk6713_aic23_ samplerate sample rate control */\
0x0001, /*9 dsk6713_aic23_ digact digital interface activation */\
};
/*
main() main code routine, initializes BSL and generates tone
*/
void main()
{
DSK6713_AIC23,CodecHandle hCodec;
Uint32|_input, r_input,1_output, r_output;
/* Initialize the board support library, must be called first */
DSK6713_init();

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 33

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

/* Start the codec */


hCodec = DSK6713_AIC23_openCodec(0,&config);
DSK6713_AIc23_setreq(hCodec, 1);
while(1)
{ /* Read a sample to the left channel */
while (!DSK6713_AIC23_read(hCodec,&1_input));
/* Read a sample to the right channel */
while (!DSK6713_AIC23_read(hCodec,&r_input));
1_output=(Int16)FIR_FILTER(&filter_Coeff,1_input);
r_output=1,output;
/* Send a sample to the left channel */
while (!DSK6713_AIC23_write(hCodec,&1_output));
/* Send a sample to the right channel */
while (!DSK6713_AIC23_write(hCodec,&r_output));
}
/* Close the codec */
DSK6713_AIC23_closeCodec(hCodec);
}
Signed int FIL_FILTER(float * h, signed int x)
{
int i=0;
signed long output=0;
in_buffer[0] = x; /* new input at buffer[0] */
for(i=30;i>0;i- -)
in_buffer[i] = in_buffer[i-1]; /*shuffle the buffer */
for(i=0;i<32;i++)
output = output + h[i] * in_buffer[i];
return(output);
}

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 34

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

PROCEDURE:
Switch on the DSP board.
Open the Code Composer Studio.
Create a new project
Project -> New (File Name. pjt, Eg: FIR.pjt)
Initialize on board codec.
Kindly refer the Topic Configuration of 6713 Codec using BSL
Add the given above C source file to the current project (remove codec.c source file from
the project if your have already added).
Connect the speaker jack to the input of the CRO.
Build the program.
Load the generated object file (*.out) on to Target board.
Run the program using F5.
Observe the waveform that appears on the CRO screen.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 35

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

RESULT:
FREQUENCY RESPONSE
High Pass FIR filter (Fc=800Hz). t

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 36

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Frequency in Hertz

FIR FILTER QUESTIONS


1. What are the advantages of FIR as compared to IIR?
2. How many types of FIR design methods are used in real time?
3. What is meant by Gibbs Phenomenon? Where we found such type of effect in FIR filters?
4. What are the advantages and disadvantages of Rectangular window FIR filter as compared
to remaining window techniques?
5. Which window technique having less peak amplitude of side lobe as compared to all?
6. What do you understand by linear phase response?
7. To design all types of filters what would be the expected impulse response?
8. What are the properties of FIR filter?
9. How the zeros in FIR filter is located?
10. What are the desirable characteristics of the window?
11. What are the specifications required to design filter?

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 37

DEPARTMENT OF ECE

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

DIGITAL SIGNAL PROCESSING LAB

Page 38

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

EXPT.NO.4.2.a

MATLAB PROGRAM TO FIND FREQUENCY RESPONSE OF FIR


LOW PASS FILTER USING RECTANGULAR WINDOW
AIM:
To find the magnitude and phase response of FIR low pass filter using rectangular.
PROGRAM:
n=20;
fp=200;
fq=300;
fs=1000;
fn=2*fp/fs
window=rectwin(n+1)
b=fir1(n,fn,window);
[H,W] = freqz(b,1,128)
gain=abs(H);
an=angle(H);
subplot(2,1,1);
plot(w/pi,gain);
title(magnitude response of lpf);
xlabel(normalized frequency------->);
ylabel(gain in db------->);
subplot(2,1,2);
plot(w/pi,an);
title(phase response of lpf);
x-label(normalized frequency----->);
ylabel(angle-------->);
RESULT:
The magnitude and the phase response of FIR low pass filter using rectangular window is
observed & waveforms are plotted.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 39

DEPARTMENT OF ECE

window=
1
0
1
1
b = -0.0000
-0.0352
-0.4181
-0.3164
-0.0000

DIGITAL SIGNAL PROCESSING LAB

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1 1 1
-0.0244 0.0279 0.0527 -0.0000 -0.0791 -0.0652 0.0978 0.3164
-0.0978 -0.0791 -0.0000 0.0527 0.0279 -0.0244 -0.0352

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 40

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

EXPT.NO.4.2.b

MATLAB PROGRAM TO FIND FREQUENCY RESPONSE OF FIR


LOW PASS FILTER USING TRIANGULAR WINDOW
AIM:
To find the magnitude and phase response of FIR low pass filter using triangular window.
PROGRAM:
n=20;
fp=200;
fq=300;
fs=1000;
fn=2*fp/fs
window=triang(n+1)
b=fir1(n,fn,window);
[H,W] = freqz(b,1,128)
gain=abs(H);
an=angle(H);
subplot(2,1,1);
plot(w/pi,gain);
title(magnitude response of lpf);
xlabel(normalized frequency------->);
ylabel(gain in db------->);
subplot(2,1,2);
plot(w/pi,an);
title(phase response of lpf);
x-label(normalized frequency----->);
ylabel(angle-------->);
RESULT:
The magnitude and the phase response of FIR low pass filter using traingular window is observed
& waveforms are plotted.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 41

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

window= 0.0909 0.1818 0.2727 0.3636 0.4545 0.5455 0.6364 0.7273 0.8182
0.9091 1.0000 0.9091 0.8182 0.7273 0.6364 0.5455 0.4545 0.3636 0.2727
0.1818 0.0909
b = -0.0000
-0.4181
-0.0000

-0.0064
-0.2876

-0.0067 0.0102 0.0240 -0.0000


0.0474 -0.0503 -0.0000 0.0240

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

-0.0503
0.0102

-0.0474 0.0800 0.2876


-0.0067 -0.0064

Page 42

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

EXPT.NO.4.2.c

MATLAB PROGRAM TO FIND FREQUENCY RESPONSE OF FIR


LOW PASS FILTER USING BLACKMAN WINDOW
AIM:
To find the magnitude and phase response of FIR low pass filter using blackman.
THEORY:
INTRODUCTION
In the previous chapter we studied the design of IIR filter and its properties. In many digital
processing applications FIR filters are preferred over the IIR counterparts. The following are the
main advantages of the FIR filter over IIR filter.
1. FIR filters are always stable.
2. FIR filters with exactly linear phase can easily be designed.
3. FIR filters can be realized in both recursive and non-recursive structures.
4. FIR filters are free of limit cycle oscillations, when implemented on a finite word length
digital system.
5. Excellent design methods are available for various kinds of FIR filters
The disadvantages of FIR filter are:
1.

The implementation of narrow transition band FIR filters are very costly, as it requires
considerably more arithmetic operations and hardware components such as multipliers,
address and delay elements.

2. Memory requirement and execution time are very high.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 43

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Linear Phase FIR filters:


The transfer function of a FIR causal filter is given by
N-1

H (z) =

n=0 h(n) z

-n

where h(n) is the impulse response of the filter.


N-1

jw

H (e ) =

n=0 h(n) e

-jwn

The Fourier transform of h(n) is


(in
degrees)
H(ejw)
|H(ejw)|db

15

30

45

60

75

0.9428
-0.5
90
16
-15.9

1.0067
0.058
105
0.0516
-25.7

1.08
0.67
120
0.529
-5.53

0.9426
-0.513
135
0.9426
-0.513

0.529
-5.53
150
1.08
0.67

0.0516
-25.7
165
1.0067
0.058

180
0.9428
-0.5

The magnitude vs plot of a lowpass filter is shown in figure. We find that there are ripples in
the passband and in stopband. These ripples are due to truncation of the infinite series into a finite
one. This effect known as Gibbs phenomenon, discussed in detail in section.
Design of FIR filters using windows:
The design frequency response Hd (ejw) of a filter is periodic in frequency and can be expanded in
a Fourier series. The resultant series is given by

jw

Hd (e ) =
hd (n) e-jwn
n=-

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 44

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

where
1

hd(n) =2

H(ejw)e-jwn dw

and known as Fourier coefficients having infinite length. One possible way of obtaining FIR
filter is to truncate the infinite Fourier series at n = +

N-1

where N is the length of the


2
desired sequence. But abrupt truncation of the Fourier series results in oscillation in the passband
and stopband. These oscillations are due to slow convergence of the Fourier series and this effect
is known as the Gibbs phenomenon. To reduce these oscillations, the Fourier coefficients of the
filter are modified by multiplying the infinite impulse response with a finite weighing sequence
(n) called a window where
N-1

(n) = (-n) 0 for |n| < 2

N-1

= 0 for |n| > 2

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 45

DEPARTMENT OF ECE

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

DIGITAL SIGNAL PROCESSING LAB

Page 46

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

FILTER COEFFICIENTS OF FIR FILTERS


Type
1. Lowpass filter with cutoff
frequency c

Coefficients of zero phase filter

wc

Coefficients of linear filter with delay =

wc

hd (0) =
w cn
hd (n) =sinn

|n| > 0

hd(n) =

sin wcn (n-)

(n-)

=
2. Highpass filter with cutoff
frequency c

hd (n) = 1 -
|n| > 0

wc2 - wc1
3. Bandpass filter with cutoff
hd (0)=
frequencies c1 and c2

= (n -)

|sin(n-) sin (n-)c| n

wc2 - wc1

hd(n) =

|sin(c2 n) sin (c1 n)]|n|>0

for n =

- sin wcn

hd(n) =

for n

wc

wc

hd (0) 1 = c
hd (n) =

for n =

for n =

= (n - )

[sin c2 (n ) sin c1 (n )]

wc2 - wc1

4. Bandreject filter with cutoff


hd (0) 1
frequencies c1 and c2

wc2 - wc1

hd(n) = 1 -

|sin(c1 n) sin (c2 n)]|

=n

for n =

(n - )

[sin c1 (n ) sin c2 (n )]

After multiplying window sequence w(n) with hd(n), we get a finite duration sequence h(n) that satisfies the desired magnitude
response.
LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 47

DEPARTMENT OF ECE

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

DIGITAL SIGNAL PROCESSING LAB

Page 48

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

N-1
h(n) = hd(n)w(n) for all |n| <
2
N-1
= 0 for |n| >
2
The frequency response H(ejw) so the filter can be obtained by convolution of Hd(ejw) and W (ejw)
given by
1
jw

H(e ) =
2

Hd(ej)W (ej(w-))d

= Hd(ejw) * W (ejw)

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 49

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Because both Hd(ejw) and Wd(ejw) are periodic function, the operation often called as periodic
convolution.
The window technique is shown in figure. The desired frequency response and its Fourier
coefficients are shown in figure

respectively. The figure

shows

finite

window

sequence w(n) and its Fourier transform W(ejw). The Fourier transform of a window consists of a
central lobe and side lobes. The central lobe contains most of the energy of the window. To get
an FIR filter, the sequence h d(n) and w(n) are multiplied and a finite length non-causal sequence
shows h(n) and its Fourier transform H(ejw). The frequency

h(n) is obtained. The figure

response H(ejw) is obtained using Eq. . The realizable sequence g(n) in Fig

can

be

obtained by shifting h(n) by a number of samples, where =


From Eq.

we find that the frequency response of the filter H(ejw) depends on the frequency

response of window W(ejw). Therefore, the window, chosen for truncating the infinite impulse
response should have some desirable characteristics. They are
1.

The central lobe of the frequency response of the window should contain most of the
energy and should be narrow.

2. The highest side lobe level of the frequency response should be small.
3. The side lobes of the frequency response should decrease in energy rapidly as w tends to
Rectangular window
The rectangular window sequence is given by
wR(N) = 1 FOR (n-1) / 2 < N < (n 1) / 2
= 0 otherwise
An example is shown in figure
for N = 25

N = 25
-12

-10

-8

-6

-4

-2

10

12

Rectangular window
LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 50

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

The spectrum of the rectangular window is given by


The transfer function of a FIR causal filter is given by
N1
2

WR (ejw) =
e -jwn
n = -N 1
2
= ejw(N-1)/2 + ..+ejw + 1 + e-jw + .. + e-jw(N-1)/2
= ejw(N-1)/2 [1+e-jw ++ e-jw(N-1]
=e

jw(N-2) / 2

1 ejwN
1- e-jw

1 + + .

N-1

1 - N
= 1-

ejwN/2 (1 - e-jwN/2)
=
ejw/2 (1 - e-jw)
ejwN/2 - e-jwN/2
=
ejw/2 1 - e-jw/2
wN_
sin 2
=
sin

w_
2

The frequency spectrum for N = 25 is shown in

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 51

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Frequency response of rectangular window N = 25 (b) log magnitude response of rectangular


window for N = 25.
The frequency response is real and its zero occur when

Nw_
2

2k_
= k or w = N where k is an

integer
2_
2_
and - N
is called the main lobe and the other lobes
N
are known as side lobes. The main lobe of the response is the portion that lies between the first
2_
two zero crossings. The side lobes are defined as the portion of the response for w < - N
2_
or
w >
. As the window is made longer the main lobe becomes narrower and
N
higher, and the side lobe become more concentrated around w = 0. The main lobe width for the
4_
rectangular window is equal toN
. The higher side lobe level is equal to approximately 22% of
the main lobe amplitude or 13dB relative to the maximum value at w = 0.
The response for w between

Digital Signal Processing

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 52

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

(a) Frequency response of rectangular window N = 51 (b) log magnitude response of rectangular
window for N = 51.

Frequency response of LPF using rectangular window for N = 25.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 53

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Log magnitude response of LPF using rectangular window for N = 25.


Let the desired response Hd(ejw) and its infinite Fourier coefficients are shown in figure

and

figure respectively. To get a finite impulse response filter we multiply hd(n) with a rectangular
window, i.e.,
h(n) = hd (b) wR(n)
The frequency response off the truncated filter can be obtained by periodic convolution.
1
jw

H(e ) =
2

Hd(e-jw) WR(ej(w-))d
-

From we find that the frequency response differs from the desired response in many ways. It does
not follow quick transitions in the desired response. The desired response of a lowpass filter
changes abruptly from passband to stopband, but the frequency response changes slowly. This
region of gradual change is called filters transition region, which is due to the convolution of the
desired response with the window responses main lobe. The width of the transition region
depends on width of the main lobe. As the filter length N increases, the main lobe becomes
narrower decreasing the width of the transition region.
The convolution of the desired response and the window responses sidelobes gives rise to the
ripples in both passband and stopband. The amplitude of the ripples is dictated by the amplitude
of the sidelobes. The amplitude of the ripples is dictated by the amplitude of the sidelobes. For
the rectangular window, the amplitude of the sidelobes is unaffected by the length of the window.
So increase in length N will not reduce the ripples, but increase its frequency. J.W.Gibbs showed
that a finite length lowpass filter will posses an 8.9% maximum ripple no matter how long the
filter is made. This effect where maximum ripple occurs just before and after the transition band
is known as Gibbs phenomenon.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 54

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

The Gibbs phenomenon can be reduced by using a less abrupt truncation of filter coefficients.
This can be achieved using a window function that tapers smoothly towards zero at both ends.
One such type of window is triangular window.
The Triangular or Barlett window
The N-point triangular window is given by
2|n|
wT(n) = 1 -

for (N 1) /2 < n < (N 1) / 2


N-1

The Fourier transform of the triangular window is

WT(ejw) =

N - 1_
sin 4

2
w

w_
sin 2

Triangular window sequence


The frequency spectrum for N = 25 and N = 51 are shown in figure and figure respectively. The
sidelobe level is smaller than that of rectangular window being reduced from 13dB to 25 dB.
However, the main lobe width is now or twice that of the rectangular window.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 55

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

From the figure we can find that triangular window produces a smooth magnitude
response in both passband and stopband. But it has the following disadvantages, when compared
to magnitude response obtained by using rectangular window.
1. The transition region is more.
2. The attenuation in stopband is less

(a) Frequency response of triangular window N = 25 (b) Log magnitude response of triangular
window for N = 25.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 56

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

(a) Frequency response of triangular window N = 51 (b) Log magnitude response of triangular
window for N = 51.

Frequency response of LPF using Traingular window for N = 25

Log magnitude response of LPF using Triangular window for N = 25.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 57

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Because of these characteristics, the triangular window is not usually a good choice.
Raised cosine window
The raised cosine window multiplies the central Fourier coefficients by approximately unity and
smoothly truncate the Fourier coefficients toward the ends of the filter.
The window sequence is of the form
2n
w(n) = + (1 ) cos

for (N-1)/2 < n < (N 1) / 2


N-1

= 0 otherwise
The frequency response w(n) is given by

N-1
2

(ejw) =
n=-

N-1

+ (1 ) cos

n= -

e-jwn

2
N-1
2

2n__
N-1

N-1
2

N-1

e-jwn +

(1 )__
e-j(w-2/N-1)n
2
n = - N-1
2

(1 - )__
2 n=-

B
N-1
2

e-j(w+2/N-1)n

N-1
2
C

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 58

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

A = ejw(N-1)/2 + ..+ ejw + 1 + e-jw + .e-jw(N-1)/2


+ r + r2 . N terms
( - rN)
= 1-r

ejw(N-1)/2 [1-e-jwN]
=
1 e-jw
ejwN/2 -e-jwN/2
=

ejwN/2 -e-jwN/2
=

e-jw/2 e-jw/2
wN
sin 2
=
w
sin2

2j
.

2j

ejw/2 e-jw/2

(1 )
[ej(w-2/(N-1)(N-1)/2 + ..+ej(w-2/(N-1) + 1

B=
2

+ e-j(w-2/(N-1))(N-1)/2 [ 1-e-j(w-2/(N-1))(N-1/2]
1

ej(w-2/(N-1)) (N-1)/2 [1 ej(w-2/(N-1))N]

=
2

1 e-j(w-2/(n-1))

ej(w-N/2-/N((N-1)) [1 ej(w-2/(N-1))N]

=
2
1

ej(w/2-/(N-1)) [1-e-j(w-2/(N-1))]
ej(wN/2-/N((N-1)) e -j(wN/2-N/(N-1))]

=
2

ej(w/2-/(N-1)) e-j(w/2-/(N-1))]

sin(wN/2 - N/(N 1))

=
2

sin(w/2 - N/(N 1))

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 59

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

similarly
1

sin(wN/2 + N/(N 1))

C=
2

sin(w/2 + / (N 1))
sin wN/2

jw

W (e ) =

+
2

(1 )

1 sin(wN/2 - N/(N 1))


2

sin(w/2 - /(N 1))

sin(wN/2 + N/(N 1))

+
2

sin(w/2 + /(N 1))

Hanning window:
The Hanning window sequence can be obtained by substituting = 0.5 in Eq.
WHn (n) = 0.5 + 0.5 cos 2n / (N-1) for (N 1)/2 < n < (N 1) / 2
The frequency response of Hanning window is
sin wN/2
jw

WHn (e ) = 0.5

sin(wN/2 - N/(N 1))


+ 0.25

2 w/2

sin(w/2 - /(N 1))

(wN/2 + N/(N 1))


+ 0.25
sin(w/2 + /(N 1))
The window sequence wHn(n) and its frequency response is shown in figure and figure
respectively. The main lobe width of Hanning window is twice that of the rectangular window,
which results in a doubling of the transition region of the filter. The magnitude of the side lobe
level is -31dB, which is 18 dB lower over that of rectangular window. That is, the first side lobe
of Hanning window spectrum is approximately one tenth that of the rectangular window. This
results is smaller

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 60

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

(a) Frequency response of Hanning window for N = 25 (b) Log magnitude response of Hanning
window for N = 25
Ripples in both passband and stopband of the lowpass filter designed using Hanning window.
The maximum stopband attenuation of the filter is 44 dB which is 23 dB lower than the filter
designed using rectangular window. At higher frequencies of the stopband attenuation is even
greater.
Hamming window
The equation for Hamming window can be obtained by substituting = 0.54 in Eq.
WH

(n) = 0.54 + 0.46 cos (2n / N-1 for (N 1)/2 < n < (N 1) / 2
=
0 otherwise

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 61

DEPARTMENT OF ECE

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

DIGITAL SIGNAL PROCESSING LAB

Page 62

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Digital Signal Processing


The frequency response of Hamming window is
sin wN/2
sin(wN/2 - N/(N 1))
WH (ejw) = 0.54
+ 0.23
sin w/2
sin(w/2 - /(N 1))
(wN/2 + N/(N 1))
+ 0.23
sin(w/2 + /(N 1))
The window sequence and its magnitude response WH(e- jw) is shown in figure

and figure

respectively. The peak side lobe level is down about 41 dB from the main lobe peak, an
improvement of 10 dB relative to the Hanning window. The magnitude and log magnitude
response of lowpass filter designed using Hamming window are shown in figure and
respectively. The first side lobe peak is -53dB, an improvement

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 63

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

(a) Frequency response of Hamming window for N = 25 (b) Log magnitude response of
Hamming window for N = 25
of 9 dB with respect to Hanning window filter. However, at higher frequencies the stopband
attenuation is low when compared to that of Hanning window.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 64

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

PROGRAM:
LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 65

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

n=20;
fp=200;
fq=300;
fs=1000;
fn=2*fp/fs
window=Blackman(n+1)
b=fir1(n,fn,window);
[H,W] = freqz(b,1,128)
gain=abs(H);
an=angle(H);
subplot(2,1,1);
plot(w/pi,gain);
title(magnitude response of lpf);
xlabel(gain in db------->);
ylabel(gain in db------->);
subplot(2,1,2);
plot(w/pi,an);
title(phase response of lpf);
x-label(normalized frequency----->);
ylabel(angle-------->);
RESULT:
The magnitude and the phase response of FIR low pass filter using Blackman window is observed
& waveforms are plotted.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 66

DEPARTMENT OF ECE

window=
-0.0000 0.0092
0.8492
0.9602
0.2008
0.1014
b =

0.0000
-0.0000
0.3999
-0.0000
0.0000

0.0402
1.0000
0.0402
-0.0003
-0.0386
0.2906
0.0101

DIGITAL SIGNAL PROCESSING LAB

0.1014
0.9602
0.0092

0.2008
0.8492
-0.0000

-0.0009
-0.0430
0.0794
0.0027

0.3400
0.6892

0.0027
0.0794
-0.0430
-0.0009

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

0.5098
0.5098

0.6892
0.3400

0.0101
0.2906
-0.0386
-0.0003

Page 67

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

EXPT.NO.4.2.d

MATLAB PROGRAM TO FIND FREQUENCY RESPONSE OF FIR


LOW PASS FILTER USING HAMMING WINDOW
AIM:
To find the magnitude and phase response of FIR low pass filter using hamming window.
PROGRAM:
n=20;
fp=200;
fq=300;
fs=1000;
fn=2*fp/fs
window=hamming(n+1)
b=fir1(n,fn,window);
[H,W] = freqz(b,1,128)
gain=abs(H);
an=angle(H);
subplot(2,1,1);
plot(w/pi,gain);
title(magnitude response of lpf);
xlabel(normalized frequency------->);
ylabel(gain in db------->);
subplot(2,1,2);
plot(w/pi,an);
title(phase response of lpf);
x-label(normalized frequency----->);
ylabel(angle-------->);
RESULT:
The magnitude and the phase response of FIR low pass filter using hamming window is observed
& waveforms are plotted.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 68

DEPARTMENT OF ECE

window= 0.0800
1.0000 0.9775
0.1025 0.0800
b = -0.0000
-0.4008
-0.0000

-0.0035
-0.2695

DIGITAL SIGNAL PROCESSING LAB

0.1025 0.1679 0.3979 0.5400 0.6821 0.8104 0.9121 0.9775


0.9121 0.8104 0.6821 0.5400 0.3979 0.2696 0.1679
-0.0039 0.0072 0.0201 -0.0000
0.0506 -0.0517 -0.0000 0.0201

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

-0.0517
0.0072

-0.0506 0.0855 0.2695


-0.0039 -0.0035

Page 69

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

EXPT.NO.4.2.e

MATLAB PROGRAM TO FIND FREQUENCY RESPONSE OF FIR


LOW PASS FILTER USING HANNING WINDOW
AIM:
To find the magnitude and phase response of FIR low pass filter using hanning window.
PROGRAM:
n=20;
fp=200;
fq=300;
fs=1000;
fn=2*fp/fs
window=hann(n+1);
b=fir1(n,fn,window);
[H,W] = freqz(b,1,128);
gain=abs(H);
an=angle(H);
subplot(2,1,1);
plot(w/pi,gain);
title(magnitude response of lpf);
xlabel(normalized frequency------->);
ylabel(gain in db------->);
subplot(2,1,2);
plot(w/pi,an);
title(phase response of lpf);
x-label(normalized frequency----->);
ylabel(angle-------->);
RESULT:
The magnitude and the phase response of FIR low pass filter using Hanning window is observed
& waveforms are plotted.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 70

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

window= 0.0800 0.1025 0.1679 0.2696 0.3979 0.5400 0.6821 0.8104 0.9121
0.9775 1.0000 0.9775 0.9121 0.8104 0.6821 0.5400 0.3979 0.2696
0.1679 0.1025 0.0800
b = -0.0000
-0.4008
-0.0000

-0.0035
-0.2965

-0.0039 0.0072 0.0201


0.0855 -0.0506 0.0517

-0.0000
-0.0000

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

-0.0517
0.0201

-0.0506 0.0855 0.2965


0.0072 -0.0039 -0.0035

Page 71

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

EXPT.NO.4.2.f

MATLAB PROGRAM TO FIND FREQUENCY RESPONSE OF FIR


HIGH PASS FILTER USING BLACKMAN WINDOW
AIM:
To find the magnitude and phase response of FIR high pass filter using blackman.
THEORY:
PROGRAM:
n=20;
fp=200;
fq=300;
fs=1000;
fn=2*fp/fs
window=Blackman(n+1)
b=fir1(n,fn,window);
[H,W] = freqz(b,1,128)
gain=abs(H);
an=angle(H);
subplot(2,1,1);
plot(w/pi,gain);
title(magnitude response of lpf);
xlabel(gain in db------->);
ylabel(gain in db------->);
subplot(2,1,2);
plot(w/pi,an);
title(phase response of lpf);
x-label(normalized frequency----->);
ylabel(angle-------->);
RESULT:
The magnitude and the phase response of FIR high pass filter using Blackman window is
observed & waveforms are plotted.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 72

DEPARTMENT OF ECE

window=
-0.0000 0.0092
0.8492
0.9602
-0.2008 0.1014
b = 0.0000
-0.0000
0.3999
-0.0000
0.0000

0.0402
1.0000
0.0402
-0.0003
-0.0386
0.2906
0.0101

DIGITAL SIGNAL PROCESSING LAB

0.1014
0.9602
0.0092
-0.0009
-0.0430
0.0794
0.0027

0.2008
0.8492
-0.0000
0.0027
0.0794
-0.0430
-0.0009

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

0.3400
0.6892

0.5098
0.5098

0.6892
0.3400

0.0101
0.2906
-0.0386
-0.0003

Page 73

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

EXPT.NO.5.1 (USING C-LANGUAGE)

IIR FILTER DESIGN USING TMS3206C713 DSP PROCESSOR


AIM:
The aim of this laboratory exercise is to design and implement a Digital IIR Filter and observe its
frequency response. In this experiment we design a simple IIR filter so as to stop or attenuate
required band of frequencies components and pass the frequency components which are outside
the required band.
EQUIPMENTS NEEDED:
Host (PC) with window (95/98Me/XP/NT/2000).

TMS320C6713 DSP Starter Kit (DSK).

Oscilloscope and function generator.

INTRODUCTION:
GENERAL CONSIDERATIONS:
In the design of frequency selective filters, the desired filter characteristics are specified in the
frequency domain in terms of the desired magnitude and phase response of the filter. In the filter
design process, we determine the coefficients of a causal IIR filter that closely approximates the
desired frequency response specifications.
IMPLEMENTATION OF DISCRETE-TIME SYSTEMS:
Discrete time Linear Time-Invariant (LTI) systems can be described completely by constant
coefficient linear difference equations. Representing a system in terms of constant coefficient
linear difference equation is its time domain characterization.

In the design of a simple

frequency-selective filter, we would take help of some basic implementation methods for
realizations of LTI systems described by linear constant coefficient difference equation.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 74

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

BACKGROUND CONCEPTS:
An infinite impulse response (IIR) filter possesses an output response to an impulse which is of an
infinite duration. The impulse response is infinite since there is feedback in the filter, that is if
you put in an impulse, then its output must produced for infinite duration of time.
ALGORITHM TO IMPLEMENT:
We need to realize the butter worth band pass IIR filter by implementing the difference equation
y[n] = bo[n]+b1x[n-1]+ b2x[n-2]-a1y[n-1]-a2y[n-2] where b0 b2 a0 a2 are feed forward and
feedback word coefficients respectively [Assume 2nd order of filter]. These coefficients are
calculated using MATLAB.A direct form I implementation approach is taken.

Step 1 Initialize the McBSP, the DSP board and the on board codec.
Kindly refer the Topic Configuration of 6713Codec using BSL

Step 2 Initialize the discrete time system, that is, specify the initial conditions.
Generally zero initial conditions are assumed.

Step 3 Take sampled data from codec while input is fed to DSP kit from the signal
generator. Since Codec is stereo, take average of input data read from left and right
channel. Store sampled data at a memory location.

Step 4 Perform filter operation using above said difference equation and store filter
Output at a memory location.

Step 5 Output the value to codec (left channel and right channel) and view the output at
Oscilloscope.

Step 6 Go to step 3.

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 75

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

FLOWCHART FOR IRR IMPLEMENTATION :


Start

Initialize the DSP Board

Set initial conditions of discrete


time system by making x[0]-x
[2] and y[0]- y[2] equal to zeros
and a0-a2, b0-b2 with
MATLAB filter coefficients

Take a new input and store it in x[0]

Do y[-3]= y[-2], y[-2]=y [-1]


and y[-1] = output,
x[-3] = x[-2], x[-2]= x[-1]

Output = x[0]b0+x[-1]b1+
X[-2]b2 y[-1]a1 y[-2]a2

x[-1]= x[0]
poll for ready bit
Write output to analog i/o

Stop

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 76

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Flowchart for implementing IIR filter


C PROGRAM TO IMPLEMENT IIR FILTER
#include filtercfg.h
#include dsk6713.h
#include dsk6713_aic23.h
Const signed int filter_Coeff[] =
{
//12730,-12730,12730,2767,-18324,21137/*HP 2500*/
//312,312,312,32767,-27943,24367 /*LP 800*/
//1455,1455,1455,32767,-23140,21735
/*LP 2500*/
//9268,-9268,9268,32767,-7395,18367
/*HP 4000*/
7215,-7215,7215,32767,5039,6171,
/*HP 7000*/
} ;
/* Codec configuration settings */
sDSK713_AIC23_Config config = { \
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL left line input channel volume */\
0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL right line input channel volume */\
0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL left line headphone volume */\
0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL right channel headphone volume */\
0x0011, /* 4 DSK6713_AIC23_ANAPATH analog audio path control */
\
0x0000, /* 5 DSK6713_AIC23_DIGPATH digital audio path control */
\
0x0000, /* 6 DSK6713_AIC23_POWERDOWN power down control */
\
0x0043, /* 7 DSK6713_AIC23_DIGIF digital audio interface format */ \
0x0081, /* 8 DSK6713_AIC23_SAMPLERATE sample rate control * /
\
0x0001, /* 9 DSK6713_AIC23_DIGACT digital interface activation * / \
};
/*
main() Main code routine, initializes BSL and generates tone
*/
Void main ()
{
DSK6713_AIC23_codecHandle hCodec;
int 1_input, r_input, 1_output, r_output;
/* Initialize the board support library, must be called first */

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 77

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

DSK6713_int();
/* Start the codec */
hCodec = DSK6713_AIC23_openCodec(0,&config);
DSK6713_AIC23_setFreq(hCodec, 3);
while(1)
{

/* Read a sample to the left channel * /


while (!DSK6713_AIC23_read(hCodec,&r_input));
1_output=IIR_FIKTER(&filter_Coeff,1_input);
t_output=1_output;
/* Send a sample to the left channel * /
while (!DSK6713_AIC23_write(hCodec,1_output));
/ * Send a sample to the right channel * /
while (!DSK6713_AIC23_read(hCodec, r_output));

}
/* Close the codec */
DSK6713_AIC23_closeCodec(hCodec);
}
signed int IIR_FILTER(const signed int*h, signed int x 1)
{
static signed int x[6] = [ 0, 0, 0, 0, 0, 0 }; /* x(n), x(n-1), x(n-2). Must be static */
static signed int y[6] = [ 0, 0, 0, 0, 0, 0 }; /* y(n), y(n-1), y(n-2). Must be static */
int temp=0
temp = (short int) x 1; /* Copy input to temp */
x[0] = (signed int) temp; /* Copy input to x[stages][0] */
temp = ( (int)h[0] * x[0]) ; /* B0 * x(n) * /
temp + = ( (int)h[1] * x[1])*; /* B1/2 * x(n-1) */
temp + = ( (int)h[1] * x[1]); /* B1/2 * x(n-1) */
temp + = ( (int)h[2] * x[2]); /* B2 * x(n-2) */
LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 78

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

temp - = ( (int)h[4]) * y[1[); /* A1/2 * y(n-1) */


temp - = ( (int)h[4]) * y[1[); /* A1/2 * y(n-1) */
temp - = ( (int)h[5]) * y[2[); /* A2 * y(n-2) */
/* Divide temp by coefficients{A0] 8/
Temp >>=15;
if ( tempt > 32767 )
{
temp> = 32767 ;
}
else if (temp <-32767)
{
temp = -32767;
}
y[0] = temp
/* Shuffle values along one place for next time */
y[2] = y[1]; /* y(n-2) = y(n-1) * /
y[1] = y[0]; /* y(n-1) y(n) */
x[2] = x[1]; /* x(n-2) = x(n-1) * /
x[1] = x[0]; /* x(n-1) x(n) */
/* temp is used as input next time through */
Return (temp<<2)
}
PROCEDURE :
Switch on the DSP board.
Open the Code Composer Studio.
Create a new project.
Project -> New (File Name. pjt, Eg: FIR.pjt)
Initialize on board codec.
Kindly refer the Topic Configuration of 6713 Codec using BSL
Add the given above C source file to the current project (remove codec.c source file
from the project if you have already added).
Connect the speaker jack to the input of the CRO.
LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 79

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

Build the program.


Load the generated object file (*out) on to Target board.
Run the program using FS.
Observe the waveform that appears on the CRO screen.
RESULTS:

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 80

DEPARTMENT OF ECE

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

DIGITAL SIGNAL PROCESSING LAB

Page 81

DEPARTMENT OF ECE

DIGITAL SIGNAL PROCESSING LAB

IIR FILTER QUESTIONS


1. What is meant by IIR filter?
2. What is the difference between recursive and non-recursive systems?
3. Write the difference equation for IIR system.
4. What are the mapping techniques in IIR filter design? Discuss the advantage and
disadvantages of them.
5. What are IIR analog filters? What are the advantages and disadvantages of them?
6. What is the disadvantage in impulse invariance method?
7. What does warping effect mean? Where are found this effect? How can ve eliminate
warping effect.
8. Explain the pole mapping procedure of impulse invariant and bilinear transformation
method.
9. For given same specification which difference we found in Butter worth and tchebyshew
filter.
10. What is the difference between type I and type II Tchebyshev filters?
11. Where the poles are located for Butter worth and tchebyshev filters?
12. What is meant by spectral transformation?
13. Why we need spectral transformation in IIR filter?

LORDS INSTITUTE OF ENGINEERING & TECHNOLOGY

Page 82

You might also like