IIR Filter Using Butterworth Filter Approximation

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Ex.

No: 7 IIR Filter Using Butterworth Filter Approximation


Date:

Anna university Questions:


1. Write a Mat lab program to design an IIR filter (Butterworth 2 nd order LPF) to satisfy the
following specifications (Assume T= 0.1seconds Write a Mat lab program to design an IIR filter
(Butterworth 2 nd order LPF) to satisfy the following specifications (Assume T= 0.1seconds)
using BLT method.
0.6≤|H (ejω) |≤1, for 0≤ω≤0.35π
|H (ejω) |≤0.1, for 0.7≤ω≤π
2. Write a Mat lab program to design an IIR filter (Butterworth 2 nd order LPF) to satisfy the
following specifications (Assume T= 1 seconds) using Impulse invariance method.
0.707≤|H (ejω) |≤1, for 0≤ω≤0.3π
|H (ejω) |≤0.2, for 0.75≤ω≤π
3. Write a MATLAB Program to design a Butterworth Band pass filter with the pass band
frequency of 200Hz-300Hz and the stop band frequency of 50Hz-450Hz and sampling frequency
of 1kHz. Design the filter in analog domain and transfer the coefficients to z domain using
Tustin’s mapping. Plot the Frequency Response and location of poles.

Aim:
To write a MATLAB program for IIR filter using Butterworth approximation.

Pre-Lab Questions:

1. The tool used to represent the order of butterworth filter is


a)[n,Wn] = buttord(Wp,Ws,Rp,Rs) b)[n,Wn] = cheb1ord(Wp, Ws, Rp, Rs)
c) [n,Wn] = cheb2ord(Wp, Ws, Rp, Rs) d) [n,Wn] = ellipord(Wp, Ws, Rp, Rs)
2. The design function of butterworth filter is
a) [b,a] = butter (n,Wn,options) b)[b,a] = besself (n,Wn,options)
c) [b,a] = ellip (n,Rp,Rs,Wn,options) d) None
3. The command used to plot x-axis is
a)xlabel(‘n’) b) ylabel(‘n’) c) both a and b d)none
4. The command used to plot y-axis is
a) xlabel(‘n’) b) ylabel(‘n’) c) both a and b d) none
5. To label x-axis and y-axis what command is used to represent
a)plot(x,y) b) subplot(x,y,z) c) clc d) none

Algorithm:
1. Start the program.
2. Get pass band ripple and stop band ripple.
3. Get Pass band and stop band frequency.
4. Calculate the order of the filter.
5. Plot the band pass and band stop filter.

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

%LPF
[n,wn]=buttord(w1,w2,rp,rs,'s');
[b,a]=butter(n,wn,'low','s');
w=0:0.1:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
wn=angle(h);
subplot(4,2,1);
plot(om/pi,m);
title('Magnitude response of LPF');
xlabel('Normalized frequency');
ylabel('Gain in dB');
subplot(4,2,2);
plot(om/pi,wn);
title('Phase response of LPF');
xlabel('Normalized frequency');
ylabel('Phase in radians');

%HPF
[n,wn]=buttord(w1,w2,rp,rs,'s');
[b,a]=butter(n,wn,'high','s');
w=0:0.1:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
wn=angle(h);
subplot(4,2,3);
plot(om/pi,m);
title('Magnitude response of HPF');
xlabel('Normalized frequency');
ylabel('Gain in dB');
subplot(4,2,4);
plot(om/pi,wn);
title('Phase response of HPF');
xlabel('Normalized frequency');
ylabel('Phase in radians');
Theory:

The magnitude function of the Butterworth filter is given by


1
H (j )  1
N  1, 2,3.....
   2N 2

1    
   c  
Where N is the order of the filter and is the cutoff frequency. The magnitude response of
the Butterworth filter closely approximates the ideal response as the order N increases.
The phase response response becomes more non-linear as N increases.
The order of the filter

100.1 s  1
log 0.1 p
N 10 1
s
log
p
Where αs= stopband attenuation at stopband frequency Ωs
αp= passband attenuation at passband frequency Ωp

p
 c 1
0.1
(10 p
 1) 2 N

Procedure:

 Start the MATLAB software and create new M-file.


 Type the program in the file.
 Save & compile the program.
 Give the input data.
 Observe the output waveform.
 Thus the graph is to be plotted.
%BPF
wn=[w1 w2];
[b,a]=butter(n,wn,'bandpass','s');
w=0:0.1:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
wn=angle(h);
subplot(4,2,5);
plot(om/pi,m);
title('Magnitude response of BPF');
xlabel('Normalized frequency');
ylabel('Gain in dB');
subplot(4,2,6);
plot(om/pi,wn);
title('Phase response of BPF');
xlabel('Normalized frequency');
ylabel('Phase in radians');

%BSF
wn=[w1 w2];
[b,a]=butter(n,wn,'stop','s');
w=0:0.1:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));

wn=angle(h);
subplot(4,2,7);
plot(om/pi,m);
title('Magnitude response of BSF');
xlabel('Normalized frequency');
ylabel('Gain in dB');
subplot(4,2,8);
plot(om/pi,wn);
title('Phase response of BSF');
xlabel('Normalized frequency');
ylabel('Phase in radians');

Output:
Enter the pass band ripple10
Enter the stop band ripple30
Enter the pass band frequency [0.2 0.8]
Enter the stop band frequency [0.4 0.7]

Post-Lab Questions:

1. IIR filter designed on the basis of


a) analog filter b) FIR filter c) a and b d) none
2. IIR fiter requires
a) less hardware, slow computation b) less hardware, fast computation
c) more hardware, slow computation d) more hardware, fast computation
3. Wraping effect seen in
a) FIR filter b) IIR filter c) a and b d) all
4. The poles on the butter worth filter are
a) lie on the circle b)lie outside the circle c) lie on the origin d) none
5. The Butterworth filter transition band is
a) more b) less c) all the above d) none
Ex. No: 8 IIR filter using Chebyshev Filter Approximation
Date:

Anna university Questions:


1. Write a Mat lab program to design an IIR filter (Chebyshev3 rd order LPF) to satisfy the
following specifications (Assume T= 1seconds) using BLT method.
0.8≤|H (ejω) |≤1, for 0≤ω≤0.2π |H (ejω) |≤0.2, for 0.32≤ω≤π
2. Write a MATLAB Program to design a Chebyshev Lowpass filter with Passband frequency of
0-60Hz,Stopband frequency of 150-200Hz, Sampling frequency of1000Hz, Passband ripple at
3dB and Stopband attenuation at 60dB. Design the filter in analog domain and transfer the
coefficients to z domain using one to one mapping. Plot the Frequency Response
and location of poles.
3. Write a MATLAB Program to design a Chebyshev Band pass filter with Passband frequency
of 200-300Hz,Stopband frequency of 50-450Hz, Sampling frequency of 2000Hz, Passband
ripple at 3dB and Stopband attenuation at 60dB. Design the filter in analog domain and transfer
the coefficients to z domain using Tustin’s mapping. Plot the Frequency Response and location
of poles.

Aim:
To write a MATLAB program for IIR filter using Chebyshev approximation.

Pre-Lab Questions:

1. Poles of Chebyshev lie on ellipse


a)true b)false c) lie on circle d) none

2. The magnitude response of the chebyshev filter exhibits _____in passband and stop band.
a)ripple b)linear c)none d) nonlinear

3. Chebyshev filter poles are close to jΩ axis than those in butterworth filter
a)true b)false c)none d) lie on origin

4. IIR Filters are stable when


a)all poles are at origin b) all poles are at x-axis c) all poles are at y-axis
d)none

5. FIR filter designed using


a)Fourier transform b) Fourier series c) Laplace transform d) All the above

Algorithm:
1. Start the program.
2. Get pass band ripple and stop band ripple.
3. Get Pass band and stop band frequency.
4. Calculate the order of the filter.
5. Plot the band pass and band stop filter.
Program:
%LPF
clc;
clear all;
close all;
format long rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
wp=input('enter the pass band frequency');
ws=input('enter the stop band frequency');
fs=input('enter the sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
wn=[w1,w2];
[n,wn]=cheb1ord(w1,w2,rp,rs);
[b,a]=cheby1(n,rp,wn,'low');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(4,2,1);
plot(om/pi,m);
ylabel('gain in db--->');
xlabel('freq');
title('magnitude response');
subplot(4,2,2);
plot(om/pi,an);
ylabel('gain in db--->');
xlabel('angle');
title('phase response');

%HPF
[n,wn]=cheb1ord(w1,w2,rp,rs);
[b,a]=cheby1(n,rp,wn,'high');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(4,2,3);
plot(om/pi,m);
ylabel('gain in db--->');
xlabel('freq');
title('magnitude response');
subplot(4,2,4);
plot(om/pi,an);
ylabel('gain in db--->');
xlabel('angle'); title('phase response');
Theory:
The transfer function of Chebyshev filter is given by
1
H (j ) 
    2
1

1  j C   
N 
   p  

Where ε is a parameter of the filter related to the ripple in the passband and CN(x) is the
Nth order Chebyshev polynomial defined as
C N (x)  cos(Ncos 1x) for x  1
C N (x)  cosh(Ncos  h x) for x  1
The order N of Chebyshev filter is given by,

100.1 s  1
cosh 1 0.1
N 10 p  1

cosh 1 s
p

p
Where  s is stop band attenuation at stop band frequency  s and is pass band

p
attenuation at pass band frequency . The major and minor axes of the ellipse are given
by

Where     1  
1 2

0.1
And   10 1
p

Procedure:

 Start the MATLAB software and create new M-file.


 Type the program in the file.
 Save & compile the program.
 Give the input data.
 Observe the output waveform.
 Thus the graph is to be plotted.
%BPF
[n,wn]=cheb1ord(w1,w2,rp,rs);
wn=[w1,w2];
[b,a]=cheby1(n,rp,wn,'bandpass');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(4,2,5);
plot(om/pi,m);
ylabel('gain in db--->');
xlabel('freq');
title('magnitude response');
subplot(4,2,6);
plot(om/pi,an);
ylabel('gain in db--->');
xlabel('angle');
title('phase response');

%BSF
[n,wn]=cheb1ord(w1,w2,rp,rs);
wn=[w1,w2];
[b,a]=cheby1(n,rp,wn,'stop');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(4,2,7);
plot(om/pi,m);
ylabel('gain in db--->');
xlabel('freq');
title('magnitude response');
subplot(4,2,8);
plot(om/pi,an);
ylabel('gain in db--->');
xlabel('angle');
title('phase response');
Output:
Enter the pass band ripple 0.4
Enter the stop band ripple 50
Enter the pass band frequency 1200
Enter the stop band frequency 2200
Enter the sampling frequency 6000

Post-Lab Questions:

1. The tool used to represent the order of Chebyshev filter is


a)[n,Wn] = buttord(Wp,Ws,Rp,Rs) b) [n,Wn] = cheb1ord(Wp, Ws, Rp, Rs)
c) [n,Wn] = cheb2ord(Wp, Ws, Rp, Rs) d) Both b and c

2. The design function of Chebyshev filter is


a) [b,a] = butter (n,Wn,options)
b) [b,a] = cheby1(n,Rp,Wn,options) and [b,a] = cheby2(n,Rs,Wn,options)
c)[b,a] = ellip (n,Rp,Rs,Wn,options) d)None of the above

3. What is the value of chebyshev polynomial degree 0?


a)1 b) 0 c)-1 d) 2

4. Which command is used to add title to current axes?


a) title(‘name’) b) subplot (x,y,z) c) clear all d) y axis

5. What is the number of minima present in the pass band of magnitude frequency response
of chebyshev-I filter of order 4?
a)1 b) 2 c)3 d) 4

You might also like