5 IIR Filter

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Rajgad Dnyanpeeth’s

SHRI CHATTRAPATI SHIVAJIRAJE COLLEGE OF ENGINNERING


S.No.237, Satara –Pune, NH -4, Dhangawadi, Tal: .Bhor, Dist.Pune (Mahararashtra)

Experiment No.: 05

Title of Experiment

IIR FILTER

Date of Performance:
Experiment No.: 05

IIR FILTER

AIM: To design IIR filter for first order analog Butterworth approximation

OBJECTIVES:
1. Display the order of filter.
2. Get frequency response of the filter.

EQUIPMENTS & SOFTWARE:


1. PC
2. MATLAB software.

THEORY:

IIR Filter can closely be obtained by beginning with an analog filter and then using a
mapping to transform the s-plane to z-plane. The design of an analog filter is
reduced to design of an analog filter and performing the conversion from H(s) to
H(z).

Design of Digital IIR Filters using MATLAB

A digital filter is an LTI system which modifies some characteristics of a digital


input signal to yield a digital output signal. The input signal characteristics that
are being modified mainly include amplitude-frequency characteristics and phase-
frequency characteristics. Based on the impulse response, digital filters can be
broadly classified into two types:
1. Finite Impulse Response (FIR) filters
2. Infinite Impulse Response (IIR) filters

IIR Filters:
IIR filters, as the name indicates, have an impulse response h[n] of infinite
duration. Thus the output response of a causal IIR filter for an input sequence a[n]
is given by

y (n)   h[k ]x[n  k ]
k 0
But in practice, it is not feasible to compute the output yn using Eq. (2.90)
since the impulse response hin) is of infinite duration. So, the output (n) of an IIR
filter is often expressed in a recursive form given by
M N
y[n]   bk x[n  k ]   a k y[n  k ]
k 0 k 1

where ak and bk by are the coefficients of the filter. The present output sample
y[n] depends on the past outputs as well as on the present and past input samples.
An IIR filter normally requires fewer coefficients than an FIR filter for the same
set of specifications. Hence, IIR filters are preferred over FIR when sharp cut-off
and high throughput are the important requirements. But IIR filters cannot always
guarantee both stability and a linear phase response which are the key features of
an FIR filter.
Note: Designing a digital IIR filter means obtaining the filter coefficients a k and
bk .
Based on the frequency response characteristics, digital IIR filters can mainly be
classified into Butterworth, Chebyshev (Type I and II) and Elliptical filters. Here,
we discuss the design of digital IIR Butterworth and Chebyshev (Type I and II)
filters using MATLAB functions.
Digital IIR Butterworth Filters
The Butterworth filters are characterised by the magnitude response which is flat
in both passband and stopband. They have a monotonically varying (with
frequency) magnitude response with no ripples in both passband and stopband.
The digital IIR Butterworth filters are implemented in MATLAB using two
functions butter and buttord. Here, we consider the design of Butterworth
lowpass, highpass, bandpass and bandstop filters.

The notations used in Figure are:


ωp= passband edge frequency (-3 dB cut-off frequency)
ωs= stopband edge frequency
As= minimum stopband attenuation required in dB (i.e. attenuation at ωs).
Δω= transition bandwidth
Figure Magnitude response of an arbitrary digital IIR lowpass Butterworth
filter. w = wp corresponds to -3 dB cut-off frequency.

Butterworth lowpass filter:

The design of digital IIR Butterworth lowpass filters using MATLAB functions
involves the following steps:
1. Provide the specifications of the filter to be designed.

wp = passband edge frequency in radians/sample (wp < radians/sample)


ws = stopband edge frequency in radians/sample (ws < radians/sample)
Rp = passband ripple or deviation in dB (attenuation at wp)
As = minimum stopband attenuation required in dB (attenuation at ws)

For a lowpass filter 0 < wp < ss < π.

2. [N, wn] = buttord (wp, ws, Rp, As) computes the filter order N and the cut-off
frequency wn (at -3 dB) from the given specifications. Before being used in the
buttord function, the frequencies wp and ws must be normalised from 0 to
1(where 1 corresponds to radians /sample).

3. [b, a] = butter (N, wn) or [b, a] = butter (N, wn, 'low') computes the filter
coefficients bk and ak in length N+1 vectors b and a, respectively. The cut-off
frequency wn must be 0.0< wn < 1.0, with 1.0 corresponding to π. The input
parameters N and wn are same as that obtained in Step 2.
The above steps design an IIR Butterworth lowpass filter that loses no more than
Rp dB in the passband and has at least As dB of attenuation in the stopband.

ALGORITHM:

1. Accept passband edge frequency.


2. Accept passband ripple.
3. Enter stopband edge frequency.
4. Enter stopband ripple.
5. Accept sampling frequency.
6. Display the order of the filter using function buttord.
7. Plot frequency response.

PROGRAM:
Butterworth LPF

% To design a Butterworth low pass filter for the given


specifications:
clear all;
alphap= input('Enter passband attenuation in dB = '); %
0.4
alphas= input('Enter Stopband attenuation in dB = '); %
30dB
fp= input('Enter Passband frequency in hz = '); % 400;
fs= input('Enter Stopband frequency in hz = '); %800;
F= input('Enter Sampling frequency in hz = '); %2000;
omp=2*fp/F;
oms=2*fs/F;
% To find cutoff frequency and order of the filter
[n,wn]=buttord(omp,oms,alphap,alphas);
Disp(‘Butterworth filter order is’);
n
Disp(‘Cutoff frequency is’);
wn
% system function of the filter
[b,a]= butter(n,wn);
w=0:01:pi;
[h,om]= freqz(b,a,w,'whole');
m=abs(h);
an=angle(h);
subplot(2,1,1);
plot(om/pi,20*log(m));grid; % om/pi–for normalized freq.
ylabel('Gain in dB');
xlabel("Normalised frequency")
subplot(2,1,2); plot(om/pi,an);grid;
ylabel('Phase in radians');
xlabel('Normalised frequency');

OUTPUT:

>> BLT
Enter passband attenuation in dB = 0.4
Enter Stopband attenuation in dB = 30
Enter Passband frequency in hz = 400
Enter Stopband frequency in hz = 800
Enter Sampling frequency in hz = 2000
n=
4
wn =
0.5821
CONCLUSIONS:

Thus we designed and implemented IIR filter are of recursive type and having
infinite impulse response.

Questions with ref. to University Practical/Oral/Theory


Examination point of view

Q1. What is bilinear transformation?


Q2. What are the properties of the bilinear transformation.
Q3. Give the bilinear transform equation between s-plane and z-plane.
Q4. Why impulse invariance method is not preferred in the design of IIR filter other than
low pass Filter?
Q5. What is mean by impulse invariance method of designing IIR filter?
Q6. What are the advantages and disadvantages of bilinear transformation?

You might also like