2. Ideal Filters
One of the reasons why we design a filter is to remove disturbances
We discriminate between signal and noise in terms of the frequency
spectrum
2
)(ns
)(nv
)(nx )()( nsny Filter
SIGNAL
NOISE
F
)(FS
)(FV
0F0F 0F
F
)(FY
0F0F
3. Conditions for Non-Distortion
Problem: ideally we do not want the filter to distort the signal we want to
recover.
Consequence on the Frequency Response:
3
IDEAL
FILTER
)()( tstx )()( TtAsty Same shape as s(t),
just scaled and
delayed.
0 200 400 600 800 1000
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
0 200 400 600 800 1000
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
0 200 400 600 800 1000
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
0 200 400 600 800 1000
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
otherwise
passbandtheinisFifAe
FH
FTj
0
)(
2
F
F
|)(| FH
)(FH
constant
linear
4. Phase Distortion
Phase distortion results from a variable time delay (phase delay) for
different frequency components of a signal.
If the phase response of a filter is a linear function of frequency, then
the phase delay is constant for all frequencies and no phase distortion
occurs.
4
5. Real Time Implementation
For real time implementation we also want the filter to be causal, ie.
FACT (Bad News!): by the Paley-Wiener Theorem, if h(n) is causal and with
finite energy,
ie ( ) cannot be zero on an interval, therefore it cannot be ideal.
5
0for0)( nnh
h n( )
n
since
0
)()()(
k
knxkhny
onlyspast value
dH )(ln
)(H
dHH )(log)0log()(log
1 2 1
2
6. Practical Filter specifications
Filters
Frequency-selective Filter
Three Stages
Specifications
Approximation of the Specifications.
Realization
6
|)(| H
p
IDEAL
7. Practical Filter specifications
In practical design the following parameters would be specified:
The maximum ripple allowed in the pass-band:
The maximum ripple allowed in the stop-band:
The pass-band edge frequency:
The stop-band edge frequency:
The order of the FIR or IIR filter.
7
p
s
p
s
8. Selection of Digital Filters (FIR & IIR)
Finite Impulse Response (FIR) filter
always stable,
the phase can be made exactly linear,
we can approximate any filter we want.
Higher order w.r.t IIR filter (we need a lot of coefficients (N large) for good
performance)
Infinite Impulse Response (IIR) filter
very selective with a few coefficients
Always Nonlinear Phase.
8
9. Design of FIR Filters
Design means calculation (determination) of the coefficients of the
difference equation or the transfer function.
Methods of FIR Filter Design:
Window Method
Frequency sampling method.
9
M
k
knxkhny
0
)()()(
M
k
k
zkhzH
0
)()(
11. 11
Design of FIR Filters (Window Method)
Simplest way of designing FIR filters
Method is all discrete-time no continuous-time involved
Start with ideal frequency response
Choose ideal frequency response as desired response
Most ideal impulse responses are of infinite length
The easiest way to obtain a causal FIR filter from ideal is by evaluating the
IDTFT of
n
nj
d
j
d enheH
deeHnh njj
dd
2
1
j
d eH
12. 12
Design of FIR Filters (Window Method)
In general, the obtained impulse response is infinite in duration and
must be truncated at some point say at: = to give an FIR filter of
length M. Truncation of to a length M is equivalent to multiplying by a
rectangular window defined as:
Thus, the impulse response of the FIR filter becomes :
else
Mnnh
nh d
0
0
else
Mn
nwnwnhnh d
0
01
where
nhd
nhd
14. Effect of the Window Size
As the width of the window increases, its spectrum will be sharper and
the resulting convolution will be near ideal.
The rectangular window truncates the impulse response to be of
duration . But this truncation introduces ripples (oscillations) in the
resulting frequency response characteristics (results of convolution).
14
15. >> n=0:20;
>> omega=pi/4; % This is the cut-off frequency
>> h=(omega/pi)*sinc(omega*(n-10)/pi); % Note the 10 step shift
>> stem(n,h)
>> title('Sample-Shifted LP Impulse Response')
>> xlabel('n')
>> ylabel('h[n]')
>> fvtool(h,1)
0 2 4 6 8 10 12 14 16 18 20
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
Sample-Shifted LP Impulse Response
n
h[n]
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
0
0.2
0.4
0.6
0.8
1
1.2
1.4
Normalized Frequency ( rad/sample)
Magnitude
Magnitude Response
Note the linear phase properties of
the impulse response
Example: 21 Coefficient LP Filter with Ω0 = π/4
16. >> n=0:200; % This sets the order of the filter where length(n)=201
>> omega=pi/4;
>> h=(omega/pi)*sinc((n-100)*omega/pi); %Note the sample shift of 100 samples
>> fvtool(h,1)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
0
0.2
0.4
0.6
0.8
1
1.2
1.4
Normalized Frequency ( rad/sample)
Magnitude
Magnitude Response
Higher order = sharper
transition
Side-lobe “ripple” (Gibbs
phenomenon) due to
abrupt truncation of the
impulse response
Example: 201 Coefficient LP Filter with Ω0 = π/4
How to reduce the Gibbs phenomenon?
1) using a window that tapers smoothly
to zero at each end.
2) providing a smooth transition from
the passband to the stopband.
17. 17
Windowing in Frequency Domain
Windowed frequency response
The windowed version is smeared version of desired response
If w[n]=1 for all n, then W(ej) is pulse train with 2 period
deWeHeH jj
d
j
2
1
18. 18
Properties of Windows
Prefer windows that concentrate around DC in frequency
Less smearing, closer approximation
Prefer window that has minimal span in time
Less coefficient in designed filter, computationally efficient
So we want concentration in time and in frequency
Contradictory requirements
Example: Rectangular window
2/sin
2/1sin
1
1 2/
1
0
M
e
e
e
eeW Mj
j
MjM
n
njj
19. Window Parameters
Two important parameters:
Main lobe width.
Relative side lobe level.
The effect of window function on FIR filter
design
The window have a small main lobe width will
ensure a fast transition from the passband to
the stopband.
The area under the side lobes small will reduce
the ripple.
19
0 0.5 1 1.5 2 2.5 3
-120
-100
-80
-60
-40
-20
0
20
0 0.5 1 1.5 2 2.5 3
-120
-100
-80
-60
-40
-20
0
20
attenuation
transition
region
-100 -50 0 50 100
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
L L
)(nhw
n
with = +
20. 20
Rectangular Window
else0
Mn01
nw
Narrowest main lob
4/(M+1)
Sharpest transitions at discontinuities in
frequency
Large side lobs
-13 dB
Large oscillation around discontinuities
Simplest window possible
21. 21
Bartlett (Triangular) Window
else0
Mn2/MM/n22
2/Mn0M/n2
nw
Medium main lob
8/M
Side lobs
-25 dB
Hamming window performs better
Simple equation
23. 23
Hamming Window
Medium main lob
8/M
Side lobs
-41 dB
Simpler than Blackman
else0
Mn0
M
n2
cos46.054.0
nw
24. 24
Blackman Window
else0
Mn0
M
n4
cos08.0
M
n2
cos5.042.0
nw
Large main lob
12/M
Very good side lobs
-57 dB
Complex equation
25. Example of Design of an FIR filter using Windows
Specifications:
Pass Band = 0 - 4 kHz
Stop Band > 5kHz with attenuation of at least 40dB
Sampling Frequency = 20kHz
Step 1: translate specifications into digital frequency
Pass Band
Stop Band
Step 2: from pass band, determine ideal filter impulse
response
25
2 5 20 2 / / rad
0 2 4 20 2 5 / / rad
h n nd
c c
( )
sinc sinc
2n
5
2
5
40dB
F kHz54 10
2
2
5
10
26. Example of Design of an FIR filter using Windows
Step 3: from desired attenuation choose the window.
In this case we can choose the hamming window;
Step 4: from the transition region choose the length N of the impulse response.
Choose an odd number N such that:
So choose N = 81 which yields the shift L=40.
Finally the impulse response of the filter
26
8
10
N
h n
n
n
( )
. . cos , ,
2
5
054 046
2
80
0 80sinc
2(n -40)
5
if
0 otherwise
27. Example of Design of an FIR filter using Windows
The Frequency Response of the Filter:
27
H( )
H( )
dB
rad
28. Design Example: 201 Coefficient HP with Ω0 = 3π/4
>> n=0:200;
>> omega=3*pi/4;
>> h=sinc(n-100)-(omega/pi)*sinc(omega*(n-100)/pi); % Both terms shifted by 100
% samples
>> hw=h.*blackman(201)';
>> fvtool(hw,1)
28
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
-200
-150
-100
-50
0
50
Normalized Frequency ( rad/sample)
Magnitude(dB)
Magnitude Response (dB)
The Blackman tapering
window provides greater
suppression of stop-band
side-lobes
29. Kaiser Window (A Parametrized Window)
All the windows discussed so far can be
approximated by an equivalent Kaiser
window.
Parameterized equation forming a set of
windows
Parameter to change main-lob width,
and side-lob area trade-off.
I0(.) represents zero-th order modified Bessel
function of first kind.
represent the shape parameter coefficient.
29
else0
Mn0
I
2/M
2/Mn
1I
nw
0
2
0
30. Kaiser Window Filter Design Method
Parameterized equation forming a set of windows
Parameter to change main-lob width,
and side-lob area trade-off.
where
I0(.) represents zero-th order modified Bessel function of first kind.
30
else0
Mn0
I
2/M
2/Mn
1I
nw
0
2
0
2
0
cos
.
2
1
)( dexI x
o
1
2
2!
1
1)(
k
k
o
x
k
xI
31. Design guidelines using Kaiser windows
Assume a low pass filter.
Given that Kaiser windows have linear phase, we will only focus on the
function in the approximation filter
Normalize to unity for , where is the cutoff frequency of
the ideal low pass filter.
Specify in terms of
a passband frequency ,
a stop band frequency ,
a maximum passband distortion of ,
and a maximum stopband distortion of ,
The cutoff frequency of the ideal low pass filter is midway between and
and should be equal, because of the nature of windowing.
31
)( jw
eA)( jw
eH
)( jw
eH c 0 c
)( jw
eA
p
s
1
2
c p s
1 2
32. Design guidelines using Kaiser windows
Let
and
The shape parameter should be
The filter order M is determined approximately by
32
ps
21
10log20A
210
50212107886.0215842.0
507.81102.0
4.0
A
AAA
AA
285.2
8A
M
33. 33
Example: Kaiser Window Design of a Lowpass Filter
Example: Determine , , , when
Solution:
Cutoff frequency,
Since, , this means
Since, , and
Then the impulse response is given as
001.0,6.0,4.0 21 sp
5.0
2
ps
c
2.0ps
60log20 10 A 653.5)7.860(1102.0
3722.36
2.0285.2
860
M
else
Mn
I
n
I
n
nnh
0
0
653.5
5.18
5.18
1653.5
.
5.18
5.185.0sin
0
2
0
c M
60log20A 10
34. 34
General Frequency Selective Filters
A general multiband impulse response can be written as
Window methods can be applied to multiband filters
Example multiband frequency response
Special cases of
• Bandpass
• Highpass
• Bandstop
mbN
1k
k
1kkmb
2/Mn
2/Mnsin
GGnh
36. FIR Filter Design (Frequency Sampling Method)
In this approach we are given and need to find
This is an interpolation problem and the solution is given in the DFT
part of the course
It has similar problems to the windowing approach
36
1
0 1
2
.1
1
).(
1
)(
N
k k
N
j
N
ze
z
kH
N
zH
)(kH )(zH