You are on page 1of 3

DSP Lab Manual - Ashwini Bhat , Dept of EC, PES, Bangalore.

EXPERIMENT No. 11 : Design and implementation of IIR filter to meet given specifications.
Aim: To design and implement an IIR filter for given specifications using Bilinear
transformation.
Theory:Bilinear transformation is an efficient transformation technique using which we can
design any filter(LP, HP ,BP, BS). In this experiment we are designing the Butterworth or
Chebyshev Low pass filter using bilinear transformation (for theory verification) given the pass
band (fp in radians) and Stop band edge (fs in radians) frequencies, Pass band ripple' ap' and
stopband attenuation 'as'. Since the frequencies are in hertz we need to calculate wp=2pifp/Fs
and ws=2pifs/Fs. To compute the order of the LPF use appropriate formula for Butterworth and
Chebyshev filter design. Also find cut off frequency wc. Find the filter coefficients. After
calculating the coefficients of the required IIR filter and we can plot the response of the required
Low pass filter.
Algorithm:
1. Input filter specs - fs,fp,as,ap,Fs.
2. Calculate wp and ws.
3. Calculate the order of the filter using
For Butterworth N=log(sqrt((10^(0.1*as)-1)/(10^(0.1*ap)-1)))/log(ws/wp);
For Chebyshev N=acosh(sqrt((10^(0.1*as)-1)/(10^(0.1*ap)-1)))/acosh(ws/wp);
4. Find wc=wp/((10^(0.1*ap)-1)^(1/(2*N)));
5. Obtain filter coefficients.
6. Plot mag and phase response.
1) Low passs Butterworth filter design.
clc;
fp=input('Enter the pass band frequency in Hz: ');
fs=input('Enter the stop band frequency in Hz: ');
ap=input('Enter the pass band attenuation in db: ');
as=input('Enter the stop band attenuation in db: ');
Fs=input('Enter the sampling frequency: ');
wp=(2*%pi*fp)/Fs;
ws=(2*%pi*fs)/Fs;
//To find the order of the butterworth filter
N=log(sqrt((10^(0.1*as)-1)/(10^(0.1*ap)-1)))/log(ws/wp);
N=ceil(N);
disp(N,'Order of the filter N= ');
wc=wp/((10^(0.1*ap)-1)^(1/(2*N)));
fc=wc/(2*%pi);
hz=iir(N,'lp','butt',[fc 0],[0 0]);
q=poly(0,'q'); //to express the result in terms of the delay operator q=z^-1
1

DSP Lab Manual - Ashwini Bhat , Dept of EC, PES, Bangalore.

hzd=horner(hz,(1/q));
// Plot the (freq. / magnitude and phase response)
[frq, freqres] = repfreq(hz,0:0.01:0.5);
[magnitude, phase] = dbphi(freqres);
subplot(3,1,1);
plot(frq*Fs,magnitude);
xtitle('Obtained Frequency Response (Magnitude in db)');
subplot(3,1,2);
plot(frq*Fs,phase);
xtitle('Obtained Frequency Response (Phase in degree)');
subplot(3,1,3);
[hzm,fr]=frmag(hz,1000);
plot(fr*Fs',hzm');
xtitle('Magnitude response');
disp(hz,'hz= ');
disp(hzd,'hzd= ');
2) Low passs Chebyshev filter design.
clc;
fp=input('Enter the pass band frequency in Hz: ');
fs=input('Enter the stop band frequency in Hz: ');
ap=input('Enter the pass band attenuation in db: ');
as=input('Enter the stop band attenuation in db: ');
Fs=input('Enter the sampling frequency: ');
wp=(2*%pi*fp)/Fs;
ws=(2*%pi*fs)/Fs;
//To find the order of the Chebyshev filter
N=acosh(sqrt((10^(0.1*as)-1)/(10^(0.1*ap)-1)))/acosh(ws/wp);
N=ceil(N);
disp(N,'Order of the filter N= ');
wc=wp/((10^(0.1*ap)-1)^(1/(2*N)));
fc=wc/(2*%pi);
hz=iir(N,'lp','cheb1',[fc 0],[.05 0]);
q=poly(0,'q'); //to express the result in terms of the delay operator q=z^-1
hzd=horner(hz,(1/q));
// Plot the (freq. / magnitude and phase response)
[frq, freqres] = repfreq(hz, 0:0.001:0.5);
[magnitude, phase] = dbphi(freqres);
subplot(3,1,1);
plot2d(frq*Fs,magnitude);
xtitle('Obtained Frequency Response (Magnitude in db)');
subplot(3,1,2);
2

DSP Lab Manual - Ashwini Bhat , Dept of EC, PES, Bangalore.

plot2d(frq*Fs,phase);
xtitle('Obtained Frequency Response (Phase in degree)');
subplot(3,1,3);
[hzm,fr]=frmag(hz,1000);
plot2d(fr*Fs',hzm');
xtitle('Magnitude response');
disp(hz,'hz= ');
disp(hzd,'hzd= ');

You might also like