Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
5
Experiment No. 5
FIR and IIR Filters Design
In this experiment, you will study the different methods of designing the Finite Impulse
Response (FIR), and Infinite Impulse Response (IIR) Filters.
Introduction:
Filters are a basic component of all signal processing and telecommunication system. A filter
is a device or process that removes some unwanted components or features from a signal.
Filtering is a class of signal processing used to complete or partial suppression of some
aspects of the signal. Most often, this means to remove some frequencies and not others in
order to suppress the interfacing signals and reduce the background noise.
Types of Filters:
In signal processing, the filters can be of four types, i.e. Lowpass Filters, Highpass Filter,
Bandpass Filters, and Bandstop Filters.
Lowpass Filters: An ideal Lowpass filter is the one that allows to pass all frequency
components of a signal below a designated cutoff frequency c, and rejects to pass all
frequency components of a signal above c.
Its frequency response satisfies:
1,
H LP (e j )
0,
0 c
Highpass Filters: An ideal Highpass filter is the one that allows to pass all frequency
components of a signal above a designated cutoff frequency c, and rejects to pass all
frequency components of a signal below c.
Its frequency response satisfies:
0,
H HP (e j )
1,
15
0 c
1,
H BP (e j )
0,
L H
Otherwise
Bandstop Filters: An ideal Bandstop filter is the one that rejects to pass all frequency
components of a signal within a certain range, and allows to pass all frequency components
of a signal outside of that range.
Its frequency response satisfies:
0,
H BS (e j )
1,
L H
Otherwise
y (n) bk x(n k )
k 0
Where "y(n)" is the filter output at discrete time instrances "n", "bk" is the k-th feedforward
tap, or the filter coefficient, and "x(n k)" is the filter input delayed by "k" samples. The ""
denotes summation from k = 0 to k = M -1, where "M" is the number of the feedforward
taps in the FIR filter. Note that the FIR filter output depends only on the previous "M"
inputs. This feature is why the impulse response for a FIR fitler is finite.
15
FIR filters have some drawbacks however. The most important is that they can be
computationally expensive to implement. Another is that they have a long transient response.
It is commonly thought that IIR fitlers must be used when computational power is at the
premium. This is certainly true is some case. However, in many cases, the use of multistage
or multirate techniques can yield FIR implementations that can compete (and even surpass)
IIR implementations while retaining the nice charachteristics of FIR filters such as linearphase, stability, and robutness to quantization effects. However, these efficient multistage or
multirate designs tend to have very large transient responses, so depending on the
requirements of the filter, IIR design may still be the way to go.
15
N = 512;
O = 64;
%Define the order of the filter
fc = input('Enter the cutoff frequency');
fs = input('Enter the sampling frequency');
Wc=2*fc/fs;
%Normalizing the frequencies
b=fir1(O,Wc,'low');
%Calculation of filter coefficients
freqz(b,1,N,fs);
%Plotting the filter response
TITLE('Magnitude and Phase Response of FIR Lowpass Filter');
The Output is:
Enter the cutoff frequency1200
Enter the sampling frequency3000
Magnitude and Phase Response of FIR Lowpass Filter
Magnitude (dB)
50
0
-50
-100
-150
500
1000
1500
1000
1500
Frequency (Hz)
Phase (degrees)
-2000
-4000
-6000
500
Frequency (Hz)
15
N = 512;
O = 64;
%Define the order of the filter
fc = input('Enter the cutoff frequency');
fs = input('Enter the sampling frequency');
Wc=2*fc/fs;
%Normalizing the frequencies
b=fir1(O,Wc,'high');
%Calculation of filter coefficients
freqz(b,1,N,fs);
%Plotting the filter response
TITLE('Magnitude and Phase Response of FIR Highpass Filter');
The Output is:
Enter the cutoff frequency1000
Enter the sampling frequency3000
Magnitude and Phase Response of FIR Highpass Filter
Magnitude (dB)
50
0
-50
-100
-150
500
1000
1500
1000
1500
Frequency (Hz)
Phase (degrees)
1000
0
-1000
-2000
-3000
500
Frequency (Hz)
11
N = 512;
O = 64;
Magnitude (dB)
50
0
-50
-100
-150
100
200
300
400
Frequency (Hz)
500
600
700
100
200
300
400
Frequency (Hz)
500
600
700
Phase (degrees)
1000
0
-1000
-2000
-3000
15
N = 512;
O = 64;
Magnitude (dB)
50
-50
-100
500
1000
1500
1000
1500
Frequency (Hz)
Phase (degrees)
-2000
-4000
-6000
500
Frequency (Hz)
15
M 1
k 1
k 0
y (n) ak y (n k ) bk x(n k )
Where "ak" is the k-th feedback tap. The left "" denoted the summation from k =1 to k =N-1,
"N" is the number of the feedback taps in the IIR filter. The right "" denotes the summation
from k = 0 to k = M 1, where "M" is the number of feedforward taps.
15
N = 512;
n = 6;
Magnitude (dB)
-100
-200
-300
500
1000
1500
1000
1500
Frequency (Hz)
Phase (degrees)
-200
-400
-600
500
Frequency (Hz)
15
Magnitude (dB)
-100
-200
-300
500
1000
1500
1000
1500
Frequency (Hz)
Phase (degrees)
-200
-400
-600
500
Frequency (Hz)
56
N = 512;
n = 6;
R = 20;
Magnitude (dB)
-20
-40
-60
500
1000
1500
1000
1500
Frequency (Hz)
Phase (degrees)
100
0
-100
-200
-300
500
Frequency (Hz)
55
5.2.
5.3.
55