Sie sind auf Seite 1von 56

INDEX

S.NO NAME OF THE EXPERMENT PAGE.NO


1) Linear Convolution of two Sequences. 2 - 6
2)
Circular Convolution of two Sequences. 7 - 11
3)
Discrete Fourier Transform. 12 - 15
4)
Sinusoidal signal generation and its Sum. 16 - 20
5)
Characteristics of analog LPF &HPF. 21 - 27
6)
Design of IIR BUTTERWORTH LPF. 28 - 34
7)
Design of IIR CHEBYSHEV LPF. 35 - 40
8)
Design of FIR Low Pass Filter using all windows. 41 - 46
9)
Design of FIR High Pass Filter using all windows. 47 - 52
10
)
Power Density Spectrum of a sequence. 53 - 55
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 1
1. AIM :
Write a program in C and MATLAB to compute the response of a discrete LTI
system with input sequence x(n) and impulse response h(n) by using linear
convolution. Verify the same on TMS320C6711 DSP kit.
2. COMPONENTS & TOOLS REQUIRED :
2.1 TMS 320C 6711 Kit,
2.2 Full version CCS s/w,
2.3 DSK 6711 s/w,
2.4 MATLAB s/w.
3. THEORY:
Convolution is a special operation, operated between two signals and which
includes the following operations.
Folding.
Shifting.
Multiplication.
Addition
Convolution sum is useful to obtain the response of discrete LTI system with
input x(n) and impulse response h(n).
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 2
LINEAR CONVOLUTION
EXPT. NO : 1
DATE :
x(n) y(n)
.



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

x(n) y(n)
(n).
3
h (n)
2
h (n)
1
h h(n)
To obtain the response, we have two types of convolutions.
Linear Convolution.
Circular Convolution.
Linear convoluted sequence y(n) between x(n) with duration N1and h(n) with
duration N2 is defined as


1 N
0 m
m) x(m)h(n y(n)
Where N = N1+N2 1 is the duration of convoluted sequence y(n).
DFT does not support linear convolution, because of x(n) and h(n) are of
different durations. Thats why we can go for circular convolution.
4. COMPUTATIONAL ALGORITHM:
Following steps were required to compute the response of discrete LTI system
with input x(n) and impulse response h(n)
Keep the input sequence x(m) as it is and fold the impulse response
h(m).
Shift the folded version sequence, h(-m) by n units to get h(n-m).
Multiply the input sequence x(m) and h(n-m).
Compute the sum over wide range.
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 3
h(n)
h
1
(n) h
1
(n) h
1
(n)
5. PROGRAM:
5.1 C PROGRAM:
#include<stdio.h>
int x[20],h[20],y[20],N1,N2,n,m;
void main()
{
printf("Enter the length of input sequence x(n)\t:N1=");
scanf("%d",&N1);
printf("Enter the length of impulse response h(n)\t:N2=");
scanf("%d",&N2);
printf("Enter %d samples for input sequence x(n):\n",N1);
for(n=0;n<N1;n++)
scanf("%d",&x[n]);
printf("Enter %d samples for impulse response h(n):\n",N2);
for(n=0;n<N2;n++)
scanf("%d",&h[n]);
printf("Input sequence \nx(n)=");
for(n=0;n<N1;n++)
printf("\t%d",x[n]);
printf("\nImpulse Response \nh(n)=");
for(n=0;n<N2;n++)
printf("\t%d",h[n]);
for(n=0;n<N1+N2-1;n++)
{
y[n]=0;
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 4
for(m=0;m<=n;m++)
y[n]=y[n]+x[m]*h[n-m];
}
printf("\nResponse of LT1 system is\ny(n)=");
for(n=0;n<N1+N2-1;n++)
printf("\t%d",y[n]);
}
5.2 MATLAB PROGRAM:
x=input('Enter the input sequence x(n)=');
h=input('Enter the impulse response h(n)=');
y=conv(x,h);
N1=length(x);
N2=length(h);
N=length(y);
disp('Input Sequence x(n)::');
disp(x);
disp('Impulse Response h(n)::');
disp(h);
disp('Output of discrete LTI system is');
disp(y);
disp('press "ENTER" for input sequence x(n)');
pause
n=0:1:N1-1;
subplot(2,2,1);
stem(n,x);
title('Input sequence x(n)');
xlabel('discrete Time n');
ylabel('Amplitude');
disp('press "ENTER" for impulse Response h(n)');
pause
n=0:1:N2-1;
subplot(2,2,2);
stem(n,h);
title('Impulse Response h(n)');
xlabel('discrete Time n');
ylabel('Amplitude');
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 5
disp('press "ENTER" for Response of the system');
pause
n=0:1:N-1;
subplot(2,2,3);
stem(n,y);
title('Response of discrete LTI system');
xlabel('discrete Time n');
ylabel('Amplitude');
6. EXPECTED RESULTS:
Example :
Let
Input sequence x(n) = [1, 2, 3, 4], and
Impulse response h(n) = [5, 6, 7, 8, 9], then
Expected response of the LTI system is y(n) = [5, 16, 34, 60, 70, 70, 59, 36]
7. CONCLUSION:
Program is executed successfully and results are obtained as per the
expected values.
8. PRECAUTIONS:
Dont open any other folders or files.
Dont delete any file or folder without informing the system administrator or lab
in-charge.
Shutdown the system before leaving the lab.

9. VIVA -VOCE QUESTIONS:
What is the need of convolution
Why DFT does not support Linear Convolution.
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 6
How to obtain the response of discrete LTI system from Linear
Convolution
In MATLAB which command is used to plot the discrete sequence
Write the logic in C, to compute the convolution
What are different steps required to execute the DSP program in CCS.
How to create project in CCS.
What are different files to be added for project, to execute the program
1. AIM:
Write a program in C and MATLAB to compute the response of a discrete LTI
system with input sequence x(n) and impulse response h(n) by using Circular
convolution. Verify the same on TMS320C6711 DSP kit, MATLAB.
2. TOOLS REQUIRED :
2.1 TMS 320C 6711 Kit,
2.2 Full version CCS s/w,
2.3 DSK 6711 s/w,
2.4 MATLAB s/w.
3. THEORY:
Convolution is a special operation, operated between two signals and which
includes the following operations.
Folding.
Shifting.
Multiplication.
Addition
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 7
CIRCULAR CONVOLUTION
EXPT. NO : 2
DATE :
Convolution sum is useful to obtain the response of discrete LTI system with
input x(n) and impulse response h(n).
x(n) y(n)
.



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

x(n) y(n)
(n).
3
h (n)
2
h (n)
1
h h(n)
To obtain the response, we have two types of convolutions.
Linear Convolution.
Circular Convolution.
Linear convoluted sequence y(n) between x(n) with duration N1and h(n) with
duration N2 is defined as


1 N
0 m
m) x(m)h(n y(n)
Where N = N1+N2 1 is the duration of convoluted sequence y(n).
DFT does not support linear convolution, because of x(n) and h(n) are of
different durations. Thats why we can go for circular convolution.
DFT supports only circular convolution, because of x(n) and h(n) are equal
durations. Circular convoluted sequence y(n) between x(n) and h(n) with equal
duration N is defined as


1 N
0 m
m) x(m)h(n y(n)
In this case if x(n) and h(n) are of different durations, then zero padding is
required to obtain the response of discrete LTI system.
4. COMPUTATION:
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 8
h(n)
h
1
(n) h
1
(n) h
1
(n)
Following steps are required to compute the response of discrete LTI system
with input x(n) and impulse response h(n)
Convert the input sequence x(n) duration N1 to N1+N2 1 by padding with
N2 1 number of zeros.
Convert the impulse response sequence h(n) duration N2 to N1+N2 1 by
padding with N1 1 number of zeros
Keep the input sequence x(m) as it is and fold the impulse response h(m).
Shift the folded version sequence, h(-m) by n units to get h(n-m).
Multiply the input sequence x(m) and h(n-m).
Finally compute the sum over the range 0 to N1+N2 2.
5. PROGRAM:
5.1 C PROGRAM:
#include<stdio.h>
int x[20],h[20],y[20],N1,N2,n,m;
void main()
{
printf("Enter the length of input sequence x(n)\t:N1=");
scanf("%d",&N1);
printf("Enter the length of impulse response h(n)\t:N2=");
scanf("%d",&N2);
printf("Enter %d samples for input sequence x(n):\n",N1);
for(n=0;n<N1;n++)
scanf("%d",&x[n]);
printf("Enter %d samples for impulse response h(n):\n",N2);
for(n=0;n<N2;n++)
scanf("%d",&h[n]);
for(n=N1;n<N1+N2-1;n++)
x[n]=0;
for(n=N2;n<N1+N2-1;n++)
h[n]=0;
printf("Input sequence after zero paddind \nx(n)=");
for(n=0;n<N1+N2-1;n++)
printf("\t%d",x[n]);
printf("\nImpulse Response after zero paddind \nh(n)=");
for(n=0;n<N1+N2-1;n++)
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 9
printf("\t%d",h[n]);
for(n=0;n<N1+N2-1;n++)
{
y[n]=0;
for(m=0;m<N1+N2-1;m++)
y[n]=y[n]+x[m]*h[n-m];
}
printf("\nResponse of LT1 system is\ny(n)=");
for(n=0;n<N1+N2-1;n++)
printf("\t%d",y[n]);
}
5.2 MATLAB PROGRAM:
x=input('Enter the input sequence x(n)=');
h=input('Enter the impulse response sequence h(n)=');
N1=length(x);
N2=length(h);
L=N1+N2-1;
n=0:1:L-1;
zpx=[x zeros(1,L-N1)];
disp('Input sequence after zero padding:: x(n):');
disp(zpx);
zph=[h zeros(1,L-N2)];
disp('Impulse Response after zero padding::y(n):');
disp(zph);
X=fft(zpx);
H=fft(zph);
y=ifft(X.*H);
disp('Response of discrete LTI System::y(n):');
disp(y);
disp('Press "ENTER" for zero padded x(n)');
pause
subplot(2,2,1);
stem(n,zpx);
title('Inpuit sequence after zero padding');
xlabel('Discrete Time');
ylabel('Amplitude');
disp('Press "ENTER" for zero padded h(n)');
pause
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 10
n=0:1:L-1;
subplot(2,2,2);
stem(n,zph);
title('Impulse response after zero padding');
xlabel('Discrete Time');
ylabel('Amplitude');
disp('Press "ENTER" for Responseof the system');
pause
n=0:1:L-1;
subplot(2,2,3);
stem(n,y);
title('Response of discrete LTI System');
xlabel('Discrete Time');
ylabel('Amplitude');
6. EXPECTED RESULTS:
Example :
Let
Input sequence x(n) = [1, 2, 3, 4], and
Impulse response h(n) = [5, 6, 7, 8, 9], then
Zero padded input sequence zpx(n) =[1, 2, 3, 4, 0, 0, 0, 0]
Zero padded impulse response zph(n) =[5, 6, 7, 8, 9, 0, 0, 0]
Expected response of the LTI system is y(n) = [5, 16, 34, 60, 70, 70, 59, 36]
7. CONCLUSION:
Program is executed successfully and results are obtained as per the
expected values.
8. PRECAUTIONS:
Dont open any other folders or files.
Dont delete any file or folder without informing the system administrator or lab
in-charge.
Shutdown the system before leaving the lab.

9. VIVA -VOCE QUESTIONS:
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 11
In what way Linear Convolution is different from Circular Convolution.
Why zero padding is required in circular convolution.
How to obtain the response of discrete LTI system from circular convolution
How to obtain the circular convolution through DFT & IDFT.
Why DFT supports only circular convolution.
1.AIM
Write a program in C and MATLAB to compute the Discrete Fourier Transform
of a given discrete sequence x(n). Verify the same on TMS320C6711 DSP kit,
MATLAB.
2. TOOLS REQUIRED :
2.1 TMS 320C 6711 Kit,
2.2 Full version CCS s/w,
2.3 DSK 6711 s/w,
2.4 MATLAB s/w.
3. THEORY:
Following are the different transforms used to obtain required frequency
domain representation of any given time domain representation.
Laplace Transform.
Fourier Transform.
Z Transform.
Discrete Fourier Transform.
Laplace transform is used for only continuous time signals and Z transform is
used for only discrete time signals. Fourier transform is used for both
continuous and discrete time signals.
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 12
DISCRETE FOURIER TRANSFORM
EXPT. NO : 3
DATE :
The DFT is used to convert N-point discrete time sequence x(n) to an N-point
frequency domain sequence X(k).

1 N
0 n
W
nk
N
x(n) X(k)
where k is ranging from 0 to N 1.
The IDFT is used to convert N-point frequency domain sequence X(k) to an N-
point time domain sequence x(n).

1 N
0 k
W
nk -
N
X(k)
1
x(n)
N
where n is ranging from 0 to N 1.
To compute DFT from above formulae is very difficult, if number of points(N)
increases, to over come this problem we can for Fast Fourier Transform(FFT).
The FFT is a method or algorithm is used to compute DFT with reduced
number of calculations(Complex additions & Complex multiplication).
4. PROGRAM:
4.1 C PROGRAM:
#include<stdio.h>
#include<math.h>
#define Pi 3.142857
int x[20],N,n,k;
float XReP[20],XImP[20],X[20],MSofX[20],PSofX[20];
void main()
{
printf("Enter the length of discrete sequence x(n):N=");
scanf("%d",&N);
printf("Enter the discrete sequence x(n):\n");
for(n=0;n<N;n++)
scanf("%d",&x[n]);
for(k=0;k<N;k++)
{
XReP[k]=0;
XImP[k]=0;
for(n=0;n<N;n++)
{
XReP[k]=XReP[k]+x[n]*cos(2*Pi*n*k/N);
XImP[k]=XImP[k]+x[n]*sin(2*Pi*n*k/N);
}
MSofX[k]=sqrt(XReP[k]*XReP[k]
+XImP[k]*XImP[k]);
XImP[k]=-XImP[k];
PSofX[k]=atan(XImP[k]/XReP[k]);
}
printf("\nDiscrete sequence x(n)=");
for(n=0;n<N;n++)
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 13
printf("\t%d",x[n]);
printf("\nDFT sequence X(K)=");
for(k=0;k<N;k++)
{
if(XImP[k]>0)
printf("\n%f-%fi",XReP[k],XImP[k]);
else
printf("\n%f+%fi",XReP[k],-XImP[k]);
}
printf("\nMagnitude Spectrum of X(K)\t=");
for(k=0;k<N;k++)
printf("\t %f",MSofX[k]);
printf("\nPhase Spectrum of X(K)\t=");
for(k=0;k<N;k++)
printf("\t %f ",PSofX[k]); }
4.2 MATLAB PROGRAM:
x=input('Enter the discrete sequence x(n)::');
N=length(x);
X=fft(x);
MSX=abs(X);
PSX=angle(X);
disp('Discrete time sequence x(n)::');
disp(x);
disp('DFT of x(n)= X(K)is');
disp(X);
disp('Magnitude Spectrum of X(K)is ');
disp(MSX);
disp('Phase Spectrum of X(K)is ');
disp(PSX);
disp('press "ENTER" for given sequence');
pause
n=0:1:N-1;
subplot(2,2,1);
stem(n,x);
title('Discrete Time Sequence');
xlabel('discrete Time n');
ylabel('Amplitude');
disp('For Magnitude Spectrum press "ENTER"');
pause
k=0:1:N-1;
subplot(2,2,2);
stem(k,MSX);
title('Magnitude Spectrum of X(K)');
xlabel('discrete Time k');
ylabel('Magnitude');
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 14
disp('For Phase Spectrum press "ENTER"');
pause
k=0:1:N-1;
subplot(2,2,3);
stem(k,PSX);
title('Phase Spetrum of X(K)');
xlabel('discrete Time k');
ylabel('Phase');
5. EXPECTED RESULTS:
Example :
Let
Discrete time sequence x(n) = [1, 2, 3, 4], then
DFT of x(n) X(k) = [10, -2+2 i, -2, -2 -2i]
Magnitude Spectrum of X(K)is X(k) = [10, 2.8284, 2,
2.8284]
Phase Spectrum of X(K)is in radians X(k) = [0, 2.3562, 3.1416, -2.3562]
6. CONCLUSION:
Program is executed successfully and results are obtained as per the
expected values.
7. PRECAUTIONS:
Dont open any other folders or files.
Dont delete any file or folder without informing the system administrator or lab
in-charge.
Shutdown the system before leaving the lab.

8. VIVA -VOCE QUESTIONS:
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 15
How to obtain Discrete Fourier Transform of a sequence x(n)
What is Fast Fourier Transform
What are different types of FFT algorithms
Explain clearly how computational efficiency increases through FFT
How to compute IDFT through FFT
How to obtain response of the system from FFT.
1. AIM
Write a program in C and MATLAB to generate two sinusoidal signals and its
sum. Verify the same on TMS320C6711 DSP kit, MATLAB.
2. TOOLS REQUIRED :
2.1 TMS 320C 6711 Kit,
2.2 Full version CCS s/w,
2.3 DSK 6711 s/w,
2.4 MATLAB s/w.
3. THEORY:
A signal can be defined as a physical quantity, which varies with respect to
one or more independent variables. Mathematically signal can be defined as a
function, which varies with respect to time and conveys some information.
Information may be temperature, Voltage, Current, Power etc. Based on
variation of amplitude of a signal, signals are classified into two categories.
Continuous Time Signals
Discrete Time Signals
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 16
SUM of SINUSOIDAL SIGNAL GENERATION
EXPT. NO : 4
DATE :
Continuous time signals are those for which the signal amplitude is
continuously varies with respect to continuous variation in time.
Example :
0 20 40 60 80 100
-1
0
1
ContinuousTimeSignal x(t)
ContinuousTime(t)
A
m
p
l
i
t
u
d
e
Discrete time signals are those for which the signal amplitude is discretely
varies with respect to discrete variation in time.
Example :
0 10 20 30 40 50 60 70 80 90 100
-1
-0.5
0
0.5
1
DiscreteTimeSignal x(n)
DiscreteTime(n)
A
m
p
l
i
t
u
d
e
4. PROCEDURE:
Choose the length (L) of required sine wave.
Select number of cycles (N1) of first sine wave x1(t)
x1(t) = Sin(2 n N1/L)
Select number of cycles (N2) of second sine wave x2(t)
x1(t) = Sin(2 n N1/L)
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 17
Finally add x1(t) and x2(t)
5. PROGRAM:
5.1 C PROGRAM:
#include<stdio.h>
#include<math.h>
#define pi 3.14159
int t,L,N1,N2;
float x[1000],x1[1000],x2[1000];
void main()
{
printf("Enter the Length of required SIN wave");
scanf("%d",&L);
printf("Enter Number of Cycles of First SIN wave");
scanf("%d",&N1);
printf("Enter Number of Cycles of Second SIN wave");
scanf("%d",&N2);
for(t=0;t<=L;t++)
{
x1[t]=sin(2*pi*t*N1/L);
x2[t]=sin(2*pi*t*N2/L);
x[t]=x1[t]+x2[t];
}
printf("First Sine Wave Amplitudes over the range 0 to %d\n",L);
for(t=0;t<=L;t++)
printf("x1[%d]=%f\n",t,x1[t]);
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 18
printf("Second Sine Wave Amplitudes over the range 0 to
%d\n",L);
for(t=0;t<=L;t++)
printf("x2[%d]=%f\n",t,x2[t]);
printf("SUM = x1(t)+x2(t) over the range 0 to %d\n",L);
for(t=0;t<=L;t++)
printf("x[%d]=%f\n",t,x[t]);
}
5.2 MATLAB PROGRAM:
L=input('Enter the length of sine wave:');
N1=input('Enter number of cycles of First Sine Wave:');
N2=input('Enter number of cycles of Second Sine Wave:');
n=0:1:L-1;
x1=sin(2*n*pi*N1/L);
x2=sin(2*n*pi*N2/L);
x=x1+x2;
disp('For First Sine Wave press ENTER');
pause;
subplot(3,1,1);
stem(n,x1);
title('First Signal');
xlabel('Discrete Time');
ylabel('Amplitude');
disp('For Second Sine Wave press ENTER');
pause;
subplot(3,1,2);
stem(n,x2);
title('Second Signal');
xlabel('Discrete Time');
ylabel('Amplitude');
disp('For the SUM of x1(t)and x2(t)press ENTER');
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 19
pause;
subplot(3,1,3);
stem(n,x);
title('SUM=x1+x2 Signal');
xlabel('Discrete Time');
ylabel('Amplitude');
6. EXPECTED RESULTS:
Example :
Let
First Sinusoidal Signal x1(t) = Sin(2 tN1/L), and
Second Sinusoidal Signal x2(t) = Sin(2 tN2/L),then
Sum of x1(t) and x2(t) is x(t) = x1(t) + x2(t);
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 20
0 10 20 30 40 50 60 70 80 90 100
-1
0
1
First Signal
DiscreteTime
A
m
p
l
i
t
u
d
e
0 10 20 30 40 50 60 70 80 90 100
-1
0
1
SecondSignal
DiscreteTime
A
m
p
l
i
t
u
d
e
0 10 20 30 40 50 60 70 80 90 100
-2
0
2
SUM=x1+x2Signal
DiscreteTime
A
m
p
l
i
t
u
d
e
7. CONCLUSION:
Program is executed successfully and results are obtained as per the
expected values.
8. PRECAUTIONS:
Dont open any other folders or files.
Dont delete any file or folder without informing the system administrator or lab
in-charge.
Shutdown the system before leaving the lab.

1. AIM:
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 21
CHARACTERISTICS OF ANALOG LPF/HPF
EXPT. NO : 5
DATE :
Write a program in C and MATLAB to obtain the frequency response of simple
analog RC low pass and high pass filters. Verify the same on TMS320C6711
DSP kit, MATLAB.
2. TOOLS REQUIRED :
TMS 320C 6711 Kit,
Full version CCS s/w,
DSK 6711 s/w,
MATLAB s/w.
3. THEORY:
Filter is a frequency selective device, which allows only specified band of
frequencies of a input signal and attenuate all other unwanted frequencies of
input signal. Based on the frequency response of the filter, filters are classified
into four types.
1. Low Pass Filter (LPF)
2. High Pass Filter (HPF)
3. Band Pass filter (BPF)
4. Band Stop Filter/Band Elimination Filter/Band Reject Filter
(BSF/BEF/BRF)
3.1 Low Pass Filter: Low pass filter allows only low frequencies of input
signal and attenuate all other high frequencies of input signal. A simple RC
low pass filter shown below
R
x(t) or X(s) I(s) C y(t) or Y(s)
Where
x(t) : Input Signal
y(t) : Output signal
X(s) : Input in s-domain
Y(s) : Output in s-domain
I(s) : current through the circuit
1/sC : Capacitive reactance
Loop equation
sC
1
R
X(s)
I(s)
+

Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 22


(RC Tan ) H(j
and
) RC ( 1
1
) H(j
C R j 1
1
) H(j
.
sRC 1
1
H(s)
.
1 RCs
1
X(s)
Y(s)
.
1 RCs
X(s)
Y(s)
sC
1
.
sC
1
R
X(s)
Y(s)
sC
1
. I(s) Y(s)
1
2


+

+

+

+

+

,
_

+


Characteristics of LPF:
H(j )1
Ideal characteristics
1
Practical characteristics
0 c
Where c is cut-off frequency
3.2 High Pass Filter: High pass filter allows only high frequencies of
input signal and attenuate all other low frequencies of input signal. A simple
RC high pass filter shown below
C
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 23
x(t) or X(s) I(s) R y(t) or Y(s)
Where
x(t) : Input Signal
y(t) : Output signal
X(s) : Input in s-domain
Y(s) : Output in s-domain
I(s) : current through the circuit
1/sC : Capacitive reactance
Loop equation
sC
1
R
X(s)
I(s)
+

RC) ( Tan ) H(j


and
) RC ( 1
RC
) H(j
C R j 1
RC j
) H(j
.
sRC 1
sRC
H(s)
.
1 RCs
sRC
X(s)
Y(s)
.
1 RCs
sRCX(s)
Y(s)
R .
sC
1
R
X(s)
Y(s)
R . I(s) Y(s)
1
2


+

+

+

+

+

+

Characteristics of HPF:
H(j )1
Ideal characteristics
1
Practical characteristics
0 c
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 24
3.3 Band Pass Filter: Band pass filter allows only a certain band of
frequencies and attenuate all other unwanted frequencies of input signal.
Characteristics of BPF:
H(j )1
Ideal characteristics
1
Practical characteristics
0 c1 c2
3.4 Band Stop Filter: Band stop filter allows entire band of frequencies of
input signal, except a certain band of input signal.
Characteristics of BSF:
H(j )1
Ideal characteristics
1
Practical characteristics
0 c1 c2
4. PROGRAM:
4.1 C PROGRAM:
#include<stdio.h>
#include<math.h>
int W,L;
float R,C,K,P,LpfH[1000],HpfH[1000];
void main()
{
printf("Enter the Resistor value of Filter in Kilo ohms:");
scanf("%f",&R);
printf("Enter the Capacitor value of Filter in micro Farads:");
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 25
scanf("%f",&C);
printf("Enter the Range of frequency response:");
scanf("%d",&L);
printf("Analog simple RC Filter\n");
printf("Resistance (R) = %f Kilo Ohms\n",R);
printf("Capacitor (C) = %f micro Farads\n",C);
R=1000*R;
C=C/1000000;
for(W=0;W<=L;W++)
{
K=W*R*C;
P=K*K;
LpfH[W]=1/sqrt(1+P);
HpfH[W]=K/sqrt(1+P);
}
printf("Magnitude spectrum values of LPF\n");
for(W=0;W<=L;W++)
printf("\nH(%d) = %f", W,LpfH[W]);
printf("Magnitude spectrum values of HPF\n");
for(W=0;W<=L;W++)
printf("\nH(%d) = %f", W,HpfH[W]);
}
4.2 MATLAB PROGRAM:
disp('Input data for Simple RC Analog LPF:');
R=input('Enter the Resistance value of LPF in Kilo Ohms:');
C=input('Enter the Capacitor value of LPF in micro Faradays:');
L=input('Enter the Frequency Range:');
R=1000*R;
C=C/1000000;
W=0:1:L;
k=W*R*C;
ks=k.*k;
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 26
S=sqrt(1+ks);
MSofLPF=S.^-1;
MSofHPF=k.*(S.^-1);
disp('Amplitude of Magnitude Spectrum of LPF');
disp(MSofLPF);
disp('Amplitude of Magnitude Spectrum of HPF');
disp(MSofHPF);
subplot(2,1,1);
plot(W,MSofLPF);
title('Response of LPF');
xlabel('Frequency');
ylabel('Amplitude');
subplot(2,1,2);
plot(W,MSofHPF);
title('Response of HPF');
xlabel('Frequency');
ylabel('Amplitude');
5. EXPECTED RESULTS:
Example :
Let
Resistor value R = 10K,
Capacitor value C = 10 F
Frequency range L = 100 rad/sec.
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 27
0 10 20 30 40 50 60 70 80 90 100
0
0.5
1
Responseof LPF
Frequency
A
m
p
l
i
t
u
d
e
0 10 20 30 40 50 60 70 80 90 100
0
0.5
1
Responseof HPF
Frequency
A
m
p
l
i
t
u
d
e
6. CONCLUSION:
Program is executed successfully and results are obtained as per the
expected values.
7. PRECAUTIONS:
Dont open any other folders or files.
Dont delete any file or folder without informing the system administrator or lab
in-charge.
Shutdown the system before leaving the lab.

8. VIVA -VOCE QUESTIONS:
Define filter
Explain different types of filters
Compare analog / digital filters
Explain the operation of RC low pass / high pass filter.
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 28
DESIGN OF IIR BUTTERWORTH LPF
EXPT. NO : 6
DATE :
1. AIM
Write a program in C and MATLAB to design IIR BUTTERWORTH low pass
filter for the given specifications pass band frequency, stop band frequency,
gain at pass band frequency and gain at stop band frequency. Verify the same
on TMS 320 C 6711 DSP kit, MATLAB.
2. TOOLS REQUIRED :
2.1 TMS 320C 6711 Kit,
2.2 Full version CCS s/w,
2.3 DSK 6711 s/w,
2.4 MATLAB s/w.
3. THEORY:
The filters designed by considering all the infinite samples of impulse
response are called IIR filters. It is a discrete time system that is designed to
pass the spectral contents of the input signal in a specified band of
frequencies. There are so many approximation solutions to design digital
filters, among them popular approximations
1. BUTTERWORTH approximation
2. CHEBYSHEV approximation
Here. First we have to design analog filters, then by using transformation
techniques we can obtain digital filter transfer function. There are two types of
transformation techniques.
1. Impulse Invariant Transformation
2. Bilinear Transformation
4. DESIGN PROCEDURE:
Following steps were required to design a digital CHEBYSHEV LPF
1. Take the specifications of desired Low Pass Filter
P= Pass band frequency corresponding to the analog filter frequency P
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 29
S= Stop band frequency corresponding to the analog filter frequency S
AP = Gain at Pass band frequency P
AS = Gain at Stop band frequency S
2. Choose either Impulse Invariant or Bilinear Transformation(IIT/BT) and
calculate the frequency ratio

,
_

,
_

Tan
2

Tan

BLT

IIT
P
S
P
S
P
S
P
S
3. Decide the order (N) of the filter (Choose greatest & nearest integer)

,
_

,
_

P
S
2
P
2
S

log
1
A
1
1
A
1
log
2
1
N
4. Calculate the analog cutoff frequency ( C)
5. Determine the analog filter Transfer function
Ha(s)

,
_

,
_

+ +

,
_

,
_

+ +

2N
1) (2k
2sin b Where
s b s

Ha(s) Odd is N If
s b s

Ha(s) Even is N If
k
2
1 - N
1 k
2
C C k
2
2
C
C
C
2
N
1 k
2
C C k
2
2
C
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 30
d perio sampling is T Where
1
A
1
2

Tan
T
2
BLT
1
A
1
T

IIT
2N
1
2
P
P
C
2N
1
2
P
P
C

,
_

,
_

,
_


6. Determine the Digital filter transfer function H(z) from analog filter transfer
function Ha(s), may be from impulse invariant or bilinear transformation by
using the following formulae.

,
_

1
1
1 aT
z 1
z 1
T
2
s BLT
z e 1
1
a s
1
IIT

7. Finally realize the digital system by a suitable structure
(a) Direct Form I Realization.
(b) Direct Form I Realization (Canonic Form Realization).
(c) Parallel Form Realization.
(d) Cascade Form Realization
5. PROGRAM:
5.1 C PROGRAM:
#include<stdio.h>
#include<math.h>
#define pi 3.14
int n,N,i,k;
float A,Ap,As,Wp,Ws,W21,N1,Wc,b[10],bk;
void main()
{
printf("Enter Pass band frequency of LPF in rad/sec :");
scanf("%f",&Wp);
printf("Enter Stop band frequency of LPF in rad/sec:");
scanf("%f",&Ws);
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 31
printf("Enter the gain at Pass band frequency %f rad/sec :",Wp);
scanf("%f",&Ap);
printf("Enter the gain at Stop band frequency %f rad/sec:",Ws);
scanf("%f",&As);
printf("\nSelect the required transformation\n");
printf("1. Impulse Invariant Transformation\n");
printf("2. Bilinear Transformation\n");
printf("\nEnter 1 or 2: ");
scanf("%d",&i);
switch(i)
{
case 1 :
printf("\nYou are selected Impulse Invariant
method");
W21=Ws/Wp;
A=(1/(As*As)-1)/(1/(Ap*Ap)-1);
N1=log(A)/(2.0*log(W21));
N=N1+1.0;
Wc=Wp/pow((1/(Ap*Ap)-1),1.0/(2.0*N));
break;
case 2 :
printf("\nYou are selected Bilinear Transformation
");
W21=tan(Ws/2)/tan(Wp/2);
A=(1/(As*As)-1)/(1/(Ap*Ap)-1);
N1=log(A)/(2.0*log(W21));
N=N1+1.0;
Wc=2*tan(Wp/2)/pow((1/(Ap*Ap)-1),1.0/(2.0*N));
break;
default:
printf("Sorry, Your selection is wrong");
}
printf("\nInput Data for the BUTTERWORTH LPF\n");
printf("Pass Band Frequency\t\tWp = %f rad/sec.",Wp);
printf("\nStop Band Frequency\t\tWs = %f rad/sec.",Ws);
printf("\nGain at Pass Band Frequency\tAp = %f",Ap);
printf("\nGain at Stop Band Frequency\tAs = %f",As);
printf("\n\nRequired Results of BUTTERWORTH LPF");
printf("\nFrequency ratio\t\t\tW21\t=%f",W21);
printf("\nOrder of the Filter\t\tN\t=%d",N);
printf("\nAnalog cutoff frequency\t Wc\t=%f rad/sec.",Wc);
if(N%2==0)
{
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 32
printf("\nOrder of the BUTTERWORTH LPF is Even");
printf("\nTransfer function of BUTTERWORTH Filter is");
printf("\nHa(s)=PI(Wc*Wc/(s*s+bk*Wc*s+Wc*Wc))");
printf("\nWhere bk=2*sin((2k-1)pi/2N), k=1,2,...N/2\n");
for(k=1;k<=N/2;k++)
b[k]=2*sin((2*k-1)*pi/(2*N));
for(k=1;k<=N/2;k++)
printf("\nb%d=%f",k,b[k]);
}
if(N%2==1)
{
printf("\nOrder of the BUTTERWORTH LPF is Odd");
printf("\nTransfer function of BUTTERWORTH Filter is");
printf("\nHa(s)=[Wc/(s+Wc)]
PI[Wc*Wc/(s*s+bk*Wc*s+Wc*Wc)]");
printf("\nWhere bk=2*sin((2k-1)pi/2N), k=1,2,...(N-1)/2\n");
for(k=1;k<=(N-1)/2;k++)
b[k]=2*sin((2*k-1)*pi/(2*N));
for(k=1;k<=(N-1)/2;k++)
printf("\nb%d=%f",k,b[k]);
}
}
5.2 MATLAB PROGRAM:
Wp=input('Enter the PASS band frequency of LPF in rad/sec:');
Ws=input('Enter the STOP band frequency of LPF in rad/sec:');
Ap=input('Enter the GAIN at pass band frequency:');
As=input('Enter the GAIN at stop band frequency:');
Apdb=20*log10(Ap);
Asdb=20*log10(As);
[N,Wc]=buttord(Wp,Ws,Apdb,Asdb);
[num,den]=butter(N,Wc,'low');
disp('Order of the Filter = ');
disp(N);
disp('Analog Cutoff frequency of the filter = ');
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 33
disp(Wc);
disp('Numerator coefficients of H(z)');
disp(num);
disp('Denomminator coefficients of H(z)');
disp(den);
freqz(num,den);
6. EXPECTED RESULTS:
Example :
Let
Pass band frequency ( P) = 0.6 rad/sec
Stop band frequency ( S) = 0.9 rad/sec
Gain at Pass band frequency (AP) = 0.8
Gain at Stop band frequency (AS) = 0.2, then
IIT Frequency ratio

,
_

P
S

= 1.5
Order of the filter (N) = 5
Analog filter cutoff frequency ( C) = 0.636 rad/sec
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 34
Coefficients (bk) = (b1, b2) = 0.618, 1.617
Analog filter Transfer function
Ha(s) =
,
_

+ +

,
_

+ +

,
_

+ 404 . 0 03 . 1
404 . 0
404 . 0 393 . 0
404 . 0
636 . 0
636 . 0
2 2
s s s s s
BLT Frequency ratio

,
_

P
S

= 1.562
Order of the filter (N) = 5
Analog filter cutoff frequency ( C) = 0.655 rad/sec
Coefficients (bk) = (b1, b2) = 0.618, 1.617
Analog filter Transfer function
Ha(s) =
,
_

+ +

,
_

+ +

,
_

+ 429 . 0 06 . 1
429 . 0
429 . 0 405 . 0
429 . 0
655 . 0
655 . 0
2 2
s s s s s
7. CONCLUSION:
Program is executed successfully and results are obtained as per the
expected values.
8. PRECAUTIONS:
Dont open any other folders or files.
Dont delete any file or folder without informing the system administrator or lab
in-charge.
Shutdown the system before leaving the lab.

9. VIVA -VOCE QUESTIONS:
Compare IIR / FIR filters
Compare BUTTERWORTH / CHEBYSHEV filter.
What are conditions for an analog filter to be stable and causal.
What are conditions for a digital filter to be stable and causal.
What is frequency warping?
1. AIM
Write a program in C and MATLAB to design IIR CHEBYSHEV low pass filter
for the given specifications pass band frequency, stop band frequency, gain at
pass band frequency and gain at stop band frequency. Verify the same on
TMS 320 C 6711 DSP kit, MATLAB.
2. TOOLS REQUIRED :
TMS 320C 6711 Kit,
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 35
DESIGN OF IIR CHEBYSHEV LPF
EXPT. NO : 7
DATE :
Full version CCS s/w,
DSK 6711 s/w,
MATLAB s/w.
3. THEORY:
The filters designed by considering all the infinite samples of impulse
response are called IIR filters. It is a discrete time system that is designed to
pass the spectral contents of the input signal in a specified band of
frequencies. There are so many approximation solutions to design digital
filters, among them popular approximations
3. BUTTERWORTH approximation
4. CHEBYSHEV approximation
Here. First we have to design analog filters, then by using transformation
techniques we can obtain digital filter transfer function. There are two types of
transformation techniques.
1. Impulse Invariant Transformation
2. Bilinear Transformation
4. DESIGN PROCEDURE:
Following steps were required to design a digital CHEBYSHEV LPF
1. Take the specifications of desired Low Pass Filter
P= Pass band frequency corresponding to the analog filter frequency P
S= Stop band frequency corresponding to the analog filter frequency S
AP = Gain at Pass band frequency P
AS = Gain at Stop band frequency S
2. Choose either Impulse Invariant or Bilinear Transformation(IIT/BT) and calculate
the frequency ratio

,
_

,
_

Tan
2

Tan

BLT

IIT
P
S
P
S
P
S
P
S
3. Decide the order (N) of the filter (Choose greatest & nearest integer)

,
_

,
_

P
S 1 -
2
P
2
S 1 -

Cosh
1
A
1
1
A
1
Cosh
N
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 36
4. Calculate the analog cutoff frequency ( C)
5. Determine the analog filter Transfer function Ha(s)

,
_


1
1
1
]
1

,
_

+ +

,
_

+ +

,
_

,
_

,
_

+ +

,
_

,
_

+ +

1
A
1

1
1

1
1

1
2
1
Y
Y c
2N
1) (2k
Cos Y c
2N
1) (2k
Sin 2Y b Where
c s b s
B
c s
B
Ha(s) Odd is N If
c s b s
B
Ha(s) Even is N If
2
P
N
1
2
N
1
2
N
N 0
2 2
N k
N k
2
1 - N
1 k
2
C k C k
2
2
C k
C 0
C 0
2
N
1 k
2
C k C k
2
2
C k
( )
Odd is N If 1, Ha(0)
Even is N If ,
1
1
Ha(0)
Take .....), B B (B B get To
2
2 1 0 k


6. Determine the Digital filter transfer function H(z) from analog filter transfer
function Ha(s), may be from impulse invariant or bilinear transformation by using
the following formulae.
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 37
period sampling is T Where
1
A
1
2

Tan
T
2
BLT
1
A
1
T

IIT
2N
1
2
P
P
C
2N
1
2
P
P
C

,
_

,
_

,
_

,
_

1
1
1 aT
z 1
z 1
T
2
s BLT
z e 1
1
a s
1
IIT

7. Finally realize the digital filter by a suitable structure
(e) Direct Form I Realization.
(f) Direct Form I Realization (Canonic Form Realization).
(g) Parallel Form Realization.
(h) Cascade Form Realization
5. C PROGRAM:
#include<stdio.h>
#include<math.h>
#define pi 3.14
int n,N,i,k;
float A,Ap,As,Wp,Ws,W21,N1,Wc,b[10],bk,a,Y,YN,c[10],ck,c0;
void main()
{
printf("Enter Pass band frequency of LPF in rad/sec :");
scanf("%f",&Wp);
printf("Enter Stop band frequency of LPF in rad/sec:");
scanf("%f",&Ws);
printf("Enter the gain at Pass band frequency %0.2f rad/sec :",Wp);
scanf("%f",&Ap);
printf("Enter the gain at Stop band frequency %0.2f rad/sec:",Ws);
scanf("%f",&As);
printf("\nSelect the required transfermation\n");
printf("1. Impulse Invariant Transfermation\n");
printf("2. Bilinear Transfermation\n");
printf("\nEnter 1 or 2: ");
scanf("%d",&i);
switch(i)
{
case 1 :
printf("\nYou are selected Impulse Invariant method");
W21=Ws/Wp;
A=sqrt((1/(As*As)-1)/(1/(Ap*Ap)-1));
N1=log(A+sqrt(A*A-1))/log(W21+sqrt(W21*W21-1));
N=N1+1.0;
Wc=Wp/pow((1/(Ap*Ap)-1),1/(2*N));
break;
case 2 :
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 38
printf("\nYou are selected Bilinear Transformation ");
W21=tan(Ws/2)/tan(Wp/2);
A=sqrt((1/(As*As)-1)/(1/(Ap*Ap)-1));
N1=log(A+sqrt(A*A-1))/log(W21+sqrt(W21*W21-1));
N=N1+1.0;
Wc=2*tan(Wp/2)/pow((1/(Ap*Ap)-1),1/(2*N));
break;
default:
printf("Sorry, Your selection is wrong");
}
printf("\nInput Data for the CHEBYSHEV LPF\n");
printf("Pass Band Frequency\t\tWp = %0.3f rad/sec.",Wp);
printf("\nStop Band Frequency\t\tWs = %0.3f rad/sec.",Ws);
printf("\nGain at Pass Band Frequency\tAp = %0.3f",Ap);
printf("\nGain at Stop Band Frequency\tAs = %0.3f",As);
printf("\n\nRequired Results of CHEBYSHEV LPF");
printf("\nFrequency ratio\t\t\tW21\t=%0.3f",W21);
printf("\nOrder of the Filter\t\tN\t=%d",N);
printf("\nAnalog cutoff frequency\t Wc\t=%0.3f rad/sec.",Wc);
a=sqrt(1/(Ap*Ap)-1);
Y=sqrt((1/(a*a))+1)+(1/a);
YN=(pow(Y,1/N)-pow(Y,-1/N));
c0=YN;
printf("\nYN=%f",YN);
if(N%2==0)
{
printf("\nOrder of the CHEBYSHEV LPF is Even");
printf("\nTransfer function of CHEBYSHEV Filter is");
printf("\nHa(s)=PI(Bk*Wc*Wc/(s*s+bk*Wc*s+ck*Wc*Wc))");
printf("\nWhere bk=2*YN*sin((2k-1)pi/2N), k=1,2,...N/2\n");
printf("\nWhere ck=YN*YN+Cos2((2k-1)pi/2N), k=1,2,...N/2\n");
printf("\nWhere c0=YN\n");
printf("\nWhere YN=\n");
for(k=1;k<=N/2;k++)
{
c[k]=YN*YN+pow((cos((2*k-1)*pi/(2*N))),2);
b[k]=2*YN*sin((2*k-1)*pi/(2*N));
}
for(k=1;k<=N/2;k++)
{
printf("\nb%d=%f",k,b[k]);
printf("\nc%d=%f",k,c[k]);
}
}
if(N%2==1)
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 39
{
printf("\nOrder of the CHEBYSHEV LPF is Odd");
printf("\nTransfer function of CHEBYSHEV LPF Filter is");
printf("\nHa(s)=[Wc/(s+Wc)] PI[Wc*Wc/
(s*s+bk*Wc*s+Wc*Wc)]");
printf("\nWhere bk=2*sin((2k-1)pi/2N), k=1,2,...(N-1)/2\n");
for(k=1;k<=(N-1)/2;k++)
b[k]=2*sin((2*k-1)*pi/(2*N));
for(k=1;k<=(N-1)/2;k++)
printf("\nb%d=%f",k,b[k]);
}
}
6. EXPECTED RESULTS:
Example :
Let
Pass band frequency ( P) = 0.6 rad/sec
Stop band frequency ( S) = 0.9 rad/sec
Gain at Pass band frequency (AP) = 0.8
Gain at Stop band frequency (AS) = 0.2, then
IIT Frequency ratio

,
_

P
S

= 1.5
Order of the filter (N) = 3
Analog filter cutoff frequency ( C) = 0.6rad/sec
BLT Frequency ratio

,
_

P
S

= 1.562
Order of the filter (N) = 3
Analog filter cutoff frequency ( C) = 0.619 rad/sec
7. CONCLUSION:
Program is executed successfully and results are obtained as per the
expected values.
8. PRECAUTIONS:
Dont open any other folders or files.
Dont delete any file or folder without informing the system administrator or lab
in-charge.
Shutdown the system before leaving the lab.

Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 40
1. AIM:
Write a program in C and MATLAB to design FIR Low pass filter for a given
cutoff frequency and number of samples. Verify the same on TMS320C6711
DSP kit, MATLAB.
2. TOOLS REQUIRED :
TMS 320C 6711 Kit,
Full version CCS s/w,
DSK 6711 s/w,
MATLAB s/w.
3. THEORY:
The filters designed by using finite number of samples of impulse response
are called IIR filters. Low pass filter allows only low frequency signals and
attenuate all other high frequency signals. Magnitude response of FIR low
pass filter as shown
Hd(e
j

)
1 Ideal
Practical
- - C 0 C
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 41
DESIGN OF FIR LPF USING WINDOWS
EXPT. NO : 8
DATE :
For a distortion less filter, we have to choose constant magnitude and linear
phase over required range.
Hd(e
j


) = e
-j

; - C C.
= 0 ; - - C & C
Where = (N 1)/2 and N is Number of samples of desired filter
In general, desired filter impulse response contains infinite number of
samples. From infinite number we have to choose finite number of samples by
using windowing techniques. Different windowing techniques are
Rectangular Window:
w(n) = 1; 0 n N 1.
Hanning Window:
w(n) =
,
_

1 N
2n
Cos 0.5 0.5
; 0 n N 1.
Hamming Window:
w(n) =
,
_

1 N
2n
Cos 0.46 0.54
; 0 n N 1.
Blackman Window: It is defined as
w(n) =
,
_

+
,
_

1 N
4n
Cos 0.08
1 N
2n
Cos 0.5 0.42
; 0 n N 1.
Triangular Window: It is defined as
w(n) =
1 - N
2
1 - N
- n 2
- 1
; 0 n N 1.
Characteristics of FIR Filters:
Only N samples of impulse response are considered.
The impulse response can be directly converted to digital filter transfer
function.
The digital filter can be directly designed to achieve the desired
specifications.
These are linear phase filters.
4. DESIGN PROCEDURE:
Following steps were required to design FIR LPF
1. Take the specifications of desired Low Pass Filter
N = Number of samples of desired Low pass filter
C= cutoff frequency of desired Low pass filter
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 42
2. Choose frequency response of the desired Low pass filter
Hd(e
j


) = e
-j

; - C C.
= 0 ; - - C & C
3. By using inverse Fourier Transform, obtain the desired filter impulse response
hd(n) from desired frequency response Hd( )
n ,

n ,
) - (n
)) - (n
c
Sin(
c

d e
2
1

d ) Hd(
2
1
hd(n)
j -

4. Convert infinite number of samples of hd(n) into finite number of samples by


using window w(n)
h(n) = hd(n) . w(n)
5. Determine the digital filter transfer function H(z) by using z transform

1 N
0 n
n
z h(n) H(z)
6. Finally realize the linear phase digital low pass filter
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 43
5. C PROGRAM:
#include<stdio.h>
#include<math.h>
#define pi 3.14
int N,a,n,i;
float Wc,hd[20],W[20],h[20];
void main()
{
printf("DESIGN OF LPF USING WINDOW TECHNIQUES\n");
printf("\nEnter Required number of Samples(ODD) of LPF:");
scanf("%d",&N);
printf("\nEnter the cutoff frequency in rad/sec:");
scanf("%f",&Wc);
a=(N-1)/2;
for(n=0;n<N;n++)
{
if(n==a)
hd[n]=Wc/pi;
else
hd[n]=sin(Wc*(n-a))/(pi*(n-a));
}
printf("\nSelect the WINDOWING Technique");
printf("1. Rectangular Window\n");
printf("2. Hanning Window\n");
printf("3. Hamming Window\n");
printf("4. Blackman Window\n");
printf("5. Triangular Window\n");
printf("\nEnter 1 or 2 or 3 or 4 or 5: ");
scanf("%d",&i);
switch(i)
{
case 1 :
printf("\nYou are selected Rectangular Window");
for(n=0;n<N;n++)
W[n]=1;
break;
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 44
case 2 :
printf("\nYou are selected Hanning Window");
for(n=0;n<N;n++)
W[n]=0.5-0.5*cos((2*n*pi)/(N-1));
break;
case 3 :
printf("\nYou are selected Hamming Window");
for(n=0;n<N;n++)
W[n]=0.54-0.46*cos((2*n*pi)/(N-1));
break;
case 4 :
printf("\nYou are selected Blackman Window");
for(n=0;n<N;n++)
W[n]=0.42-0.5*cos((2*n*pi)/(N-1))+0.08*cos((4*n*pi)/(N-1));
break;
case 5 :
printf("\nYou are selected Triangular Window");
for(n=0;n<N;n++)
W[n]=1.0-(2.0*abs(n-(N-1)/2.0)/(N-1));
break;
default:
printf("Sorry, Your selection is wrong");
}
for(n=0;n<N;n++)
h[n]=hd[n]*W[n];
printf("\nNumber of samples of LPF :N = %d",N);
printf("\nCutoff frequency of LPF :Wc = %0.2f rad/sec",Wc);
printf("\nConstant :a = %d",a);
printf("\nImpulse Response of Desired Filter\n");
for(n=0;n<N;n++)
printf("\nhd[%d] = %0.4f",n,hd[n]);
printf("\nSamples of Window\n");
for(n=0;n<N;n++)
printf("\nW[%d] = %0.4f",n,W[n]);
printf("\nImpulse Response of FIR Digital LPF\n");
for(n=0;n<N;n++)
printf("\nh[%d] = %0.4f",n,h[n]);
printf("\nH(z)=%0.3f",h[0]);
for(n=1;n<N;n++)
printf("+%0.3fzpow-%d",h[n],n);
}
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 45

6. EXPECTED RESULTS:
Example :
Let Number of samples of LPF (N) = 5
Cutoff frequency (wc)= 2 rad/sec, then
Digital FIR low pass filter transfer function for various windows
(a) Rectangular Window
H(z) = - 0.1205 + 0.2896 z
1
+ 0.6369 z
2
+ 0.2896 z
3
0.1205 z
4

(b) Hanning Window
H(z) = 0.1447 z
1
+ 0.6369 z
2
+ 0.1447 z
3

(c) Hamming Window
H(z) = - 0.0096 + 0.1563 z
1
+ 0.6369 z
2
+ 0.1563 z
3
0.0096 z
4

(d) Blackmann Window
H(z) = 0.0983 z
1
+ 0.6369 z
2
+ 0.983 z
3

(e) Triangular Window
H(z) = 0.1448 z
1
+ 0.6369 z
2
+ 0.1448 z
3

7. CONCLUSION:
Program is executed successfully and results are obtained as per the
expected values.
8. PRECAUTIONS:
Dont open any other folders or files.
Dont delete any file or folder without informing the system administrator or lab
in-charge.
Shutdown the system before leaving the lab.

9. VIVA -VOCE QUESTIONS:
What are advantages of IIR Filter over FIR Filter
Explain GIBBS Phenomenon
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 46
What is the need of Window technique
Which are raised cosine windows
How to design FIR Filters
What are characteristics of LPF

1. AIM:
Write a program in C and MATLAB to design FIR High pass filter for a given
cutoff frequency and number of samples. Verify the same on TMS320C6711
DSP kit, MATLAB.
2. TOOLS REQUIRED :
2.1 TMS 320C 6711 Kit,
2.2 Full version CCS s/w,
2.3 DSK 6711 s/w,
2.4 MATLAB s/w.
3. THEORY:
The filters designed by using finite number of samples of impulse response
are called IIR filters. High pass filter allows only high frequency signals and
attenuate all other low frequency signals. Magnitude response of FIR high
pass filter as shown
Hd(e
j

)
1 Ideal
Practical
- - C 0 C
For a distortion less filter, we have to choose constant magnitude and linear
phase over required range.
Hd(e
j


) = e
-j

; - - C & C .
= 0 ; - C C
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 47
DESIGN OF FIR HPF USING WINDOWS
EXPT. NO : 9
DATE :
Where = (N 1)/2 and N is Number of samples of desired filter
In general, desired filter impulse response contains infinite number of
samples. From infinite number we have to choose finite number of samples by
using windowing techniques. Different windowing techniques are
Rectangular Window:
w(n) = 1; 0 n N 1.
Hanning Window:
w(n) =
,
_

1 N
2n
Cos 0.5 0.5
; 0 n N 1.
Hamming Window:
w(n) =
,
_

1 N
2n
Cos 0.46 0.54
; 0 n N 1.
Blackman Window: It is defined as
w(n) =
,
_

+
,
_

1 N
4n
Cos 0.08
1 N
2n
Cos 0.5 0.42
; 0 n N 1.
Triangular Window: It is defined as
w(n) =
1 - N
2
1 - N
- n 2
- 1
; 0 n N 1.
Characteristics of FIR Filters:
Only N samples of impulse response are considered.
The impulse response can be directly converted to digital filter transfer
function.
The digital filter can be directly designed to achieve the desired
specifications.
These are linear phase filters.
4. DESIGN PROCEDURE:
Following steps were required to design FIR HPF
1. Take the specifications of desired High Pass Filter
N = Number of samples of desired High pass filter
C= cutoff frequency of desired High pass filter
2. Choose frequency response of the desired High pass filter
Hd(e
j


) = e
-j

; - - C & C .
= 0 ; - C C
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 48
3. By using inverse Fourier Transform, obtain the desired filter impulse response
hd(n) from desired frequency response Hd( )
n ,

1
n ,
) - (n
)) - (n
c
Sin( - )) - (n Sin(

d e
-

d e
2
1

d ) Hd(
2
1
hd(n)
C
j -
C
j -

,
_

4. Convert infinite number of samples of hd(n) into finite number of samples by


using window w(n)
h(n) = hd(n) . w(n)
5. Determine the digital filter transfer function H(z) by using z transform

1 N
0 n
n
z h(n) H(z)
6. Finally realize the linear phase digital low pass filter
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 49
5. C PROGRAM:
#include<stdio.h>
#include<math.h>
#define pi 3.14
int N,a,n,i;
float Wc,hd[20],W[20],h[20];
void main()
{
printf("DESIGN OF HPF USING WINDOW TECHNIQUES\n");
printf("\nEnter Required number of Samples(ODD) of HPF:");
scanf("%d",&N);
printf("\nEnter the cutoff frequency in rad/sec:");
scanf("%f",&Wc);
a=(N-1)/2;
for(n=0;n<N;n++)
{
if(n==a)
hd[n]=1-Wc/pi;
else
hd[n]=(sin(pi*(n-a))-sin(Wc*(n-a)))/(pi*(n-a));
}
printf("\nSelect the WINDOWING Technique");
printf("1. Rectangular Window\n");
printf("2. Hanning Window\n");
printf("3. Hamming Window\n");
printf("4. Blackman Window\n");
printf("5. Triangular Window\n");
printf("\nEnter 1 or 2 or 3 or 4 or 5: ");
scanf("%d",&i);
switch(i)
{
case 1 :
printf("\nYou are selected Rectangular Window");
for(n=0;n<N;n++)
W[n]=1;
break;
case 2 :
printf("\nYou are selected Hanning Window");
for(n=0;n<N;n++)
W[n]=0.5-0.5*cos((2*n*pi)/(N-1));
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 50
break;
case 3 :
printf("\nYou are selected Hamming Window");
for(n=0;n<N;n++)
W[n]=0.54-0.46*cos((2*n*pi)/(N-1));
break;
case 4 :
printf("\nYou are selected Blackman Window");
for(n=0;n<N;n++)
W[n]=0.42-0.5*cos((2*n*pi)/(N-1))+0.08*cos((4*n*pi)/(N-1));
break;
case 5 :
printf("\nYou are selected Triangular Window");
for(n=0;n<N;n++)
W[n]=1.0-(2.0*abs(n-(N-1)/2.0)/(N-1));
break;
default:
printf("Sorry, Your selection is wrong");
}
for(n=0;n<N;n++)
h[n]=hd[n]*W[n];
printf("\nNumber of samples of HPF :N = %d",N);
printf("\nCutoff frequency of HPF :Wc = %0.2f rad/sec",Wc);
printf("\nConstant :a = %d",a);
printf("\nImpulse Response of Desired Filter\n");
for(n=0;n<N;n++)
printf("\nhd[%d] = %0.4f",n,hd[n]);
printf("\nSamples of Window\n");
for(n=0;n<N;n++)
printf("\nW[%d] = %0.4f",n,W[n]);
printf("\nImpulse Response of FIR HPF\n");
for(n=0;n<N;n++)
printf("\nh[%d] = %0.4f",n,h[n]);
printf("\nH(z)=%0.3f",h[0]);
for(n=1;n<N;n++)
printf("+%0.3fzpow-%d",h[n],n);
}
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 51
6. EXPECTED RESULTS:
Example :
Let Number of samples of LPF (N) = 5
Cutoff frequency (wc)= 2 rad/sec, then
Digital FIR high pass filter transfer function for various windows
(a) Rectangular Window
H(z) = 0.12 - 0.2891 z
1
+ 0.3631 z
2
- 0.2891 z
3
+ 0.12 z
4

(b) Hanning Window
H(z) = -0.1444 z
1
+ 0.3631 z
2
- 0.1444 z
3

(c) Hamming Window
H(z) = 0.0096 - 0.1560 z
1
+ 0.3631 z
2
- 0.1560 z
3
+0.0096 z
4

(d) Blackmann Window
H(z) = -0.0982 z
1
+ 0.3631 z
2
- 0.982 z
3

(e) Triangular Window
H(z) = -0.1445 z
1
+ 0.3631 z
2
- 0.1445 z
3

7. CONCLUSION:
Program is executed successfully and results are obtained as per the
expected values.
8. PRECAUTIONS:
Dont open any other folders or files.
Dont delete any file or folder without informing the system administrator or lab
in-charge.
Shutdown the system before leaving the lab.

9. VIVA -VOCE QUESTIONS:
What are advantages of IIR Filter over FIR Filter
Explain GIBBS Phenomenon
What is the need of Window technique
Which are raised cosine windows
How to design FIR Filters
What are characteristics of HPF

Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 52
1. AIM :
Write a program in C and MATLAB to compute power spectral density of given
sequence x(n). Verify the same on TMS320C6711 DSP kit.
2. COMPONENTS & TOOLS REQUIRED :
2.1 TMS 320C 6711 Kit,
2.2 Full version CCS s/w,
2.3 DSK 6711 s/w,
2.4 MATLAB s/w.
3. THEORY:
Spectrum is a Latin word for image. Auto correlation function(ACF) is a
measure of similarity between a signal and time delayed version of the same signal.
Cross correlation function(CCF) is a measure of similarity between a signal and time
delayed version of the different signal. Frequency domain representation of a ACF of
non-periodic signal is known as Energy Spectral Density(ESD). Frequency domain
representation of a ACF of periodic signal is known as Power Spectral Density(PSD).
For a non-periodic signals ESD & ACF forms Fourier transformable pairs. For a
periodic signals PSD & ACF forms Fourier transformable pairs.
4. COMPUTATIONAL ALGORITHM:
1. Compute ACF of a given sequence x(n)
2. Compute PSD through ACF.
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 53
POWER SPECTRAL DENSITY
EXPT. NO : 10
DATE :
5. PROGRAM:
#include<stdio.h>
#include<math.h>
#define pi 3.14
int x[20],ACF[20],N,n,m,w;
float PSD[200];
void main()
{
printf("Enter the length of discrete sequence x(n)\t:N=");
scanf("%d",&N);
printf("Enter %d samples for discrete sequence x(n):\n",N);
for(n=0;n<N;n++)
scanf("%d",&x[n]);
for(n=0;n<N;n++)
{
ACF[n]=0;
for(m=0;m<N;m++)
ACF[n]=ACF[n]+x[m]*x[m-n];
}
for(w=0;w<N;w++)
{
PSD[w]=0;
for(n=1;n<N;n++)
PSD[w]=PSD[w]+2.0*ACF[n]*cos(w*n);
PSD[w]=ACF[0]+PSD[w];
}
printf("Given discrete sequence \nx(n)=");
for(n=0;n<N;n++)
printf("\t%d",x[n]);
printf("\nACF of given discrete sequence x(n) is \nACF[n]=");
for(n=-(N-1);n<N;n++)
printf("\t%d",ACF[abs(n)]);
printf(", where -%d<=n<=%d",(N-1),(N-1));
printf("\nPSD of Given discrete sequence x(n)\n PSD(w)=");
for(w=-(N-1);w<N;w++)
printf("\t%0.2f",PSD[abs(w)]);
printf(", where -%d<=w<=%d",(N-1),(N-1));
}
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 54
6. EXPECTED RESULTS:
Example :
Let
Discrete sequence x(n) = [1, 2, 3, 4], then
ACF of x(n) ACF(n) = [4, 11, 20, 30, 20, 11, 4], and
PSD of x(n) PSD(w) = [4.24, 6.66, 34.54, 100, 34.54, 6.66, 4.24], and
7. CONCLUSION:
Program is executed successfully and results are obtained as per the
expected values.
8. PRECAUTIONS:
Dont open any other folders or files.
Dont delete any file or folder without informing the system administrator or lab
in-charge.
Shutdown the system before leaving the lab.

9. VIVA -VOCE QUESTIONS:
Define spectrum
How to compute magnitude and phase spectrum
Compare ESD & PSD
In what way ESD and ACF are related
In what way PSD and ACF are related
What are properties of ACF
Compare convolution and correlation
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 55
Lakireddy Balireddy College of Engineering, Mylavaram 521 230. Page No. 56

Das könnte Ihnen auch gefallen