Beruflich Dokumente
Kultur Dokumente
Dr. Manjunatha. P
manjup.jnnce@gmail.com
Professor
Dept. of ECE
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 2 / 94
Unit 7 Syllabus
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 3 / 94
FIR Filter Design Introduction
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 4 / 94
FIR Filter Design Introduction
−π −ωc 0 ωc π ω
The impulse response is given by
Figure 1: Ideal low pass filter
Zωc ( ωc
1 π
n=0
h(n) = H(ω)e jωn dω = ωc sin(ωc n)
2π π ωc n
n 6= 0
−ωc
Paley-Wiener Theorem:
If h(n) has finite energy and h(n) = 0 for n < 0
then
Zπ
| ln |H(ω)||dω < ∞ Figure 2: Unit sample response
−π
H(ω) can be zero at some frequencies. but it cannot be zero over any finite of
frequencies, since the integral then becomes infinite.
H(ω) cannot be exactly zero over any band of frequencies. (Except in the trivial case where h[n]
= 0.) Furthermore, |H(ω)| cannot be flat (constant) over any finite band.
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 5 / 94
FIR Filter Design Introduction
N = k 2π
M
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 6 / 94
FIR Filter Design Introduction
Ideal filters are noncausal, hence physically unrealizable for real time signal processing
applications.
Causality implies that the frequency response characteristic H(ω) of the filter cannot be
zero, except at finite set of points in the frequency range. And also H(ω) cannot have an
infinitely sharp cutoff from passband to stopband, that is H(ω) cannot drop from unity to
zero abruptly.
It is not necessary to insist that the magnitude be constant in the entire passband of the
filter. A small amount of ripple in the passband is usually tolerable.
The filter response may not be zero in the stopband, it may have small nonzero value or
ripple.
The transition of the frequency response from passband to stopband defines transition
band.
The passband is usually called bandwidth of the filter.
The width of transition band is ωs − ωp where ωp defines passband edge frequency and ωs
defines stopband edge frequency.
The magnitude of passband ripple is varies between the limits 1 ± δ1 where δ1 is the ripple
in the passband
The ripple in the stopand of the filter is denoted as δ2
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 7 / 94
FIR Filter Design FIR Filter Design
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 8 / 94
FIR Filter Design FIR Filter Design
An FIR system does not have feedback. Hence y (n − k) term is absent in the system. FIR
output is expressed as
M
X
y (n) = bk x(n − k)
k=0
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 9 / 94
FIR Filter Design Symmetric and Antisymmetric FIR Filters
Linear phase is a property of a filter, where the phase response of the filter is a linear
function of frequency. The result is that all frequency components of the input signal are
shifted in time (usually delayed) by the same constant amount, which is referred to as the
phase delay. And consequently, there is no phase distortion due to the time delay of
frequencies relative to one another.
Linear-phase filters have a symmetric impulse response.
The FIR filter has linear phase if its unit sample response satisfies the following condition:
h(n) = h(M − 1 − n) n = 0, 1, 2, . . . , N − 1
M−1
X
H(z) = h(n)z −n
n=0
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 10 / 94
FIR Filter Design Symmetric and Antisymmetric FIR Filters
-2 -1 0 1 2 3 4
-2 -1 0 1 2 3 4
0 1 2 3 4 5 6 7 8 n 0 1 2 3 4 5 6 7 8 n
-2 -1 0 1 2 3 4
0 1 2 3 4 5 6 7 8 n 0 1 2 3 4 5 6 7 8 n
Center of Symmetry
Center of Symmetry
-2 -1 0 1 2 3 4
-2 -1 0 1 2 3 4
Symmetric impulse response with M=odd Then
h(n) = h(M − 1 − n) and (z = e jω )
(M−3)/2 0 1 2 3 4 5 6 7 8 n
M −1 M−1 X h i
H(z) = h z 2 + h(n) z −n + z −(M−1−n)
2 n=0 Center of Symmetry
-2 -1 0 1 2 3 4
-2 -1 0 1 2 3 4
M−1 M−1 M−1 M−1
e −jωn = e −jωn e jω( 2
)
e −jω( 2
)
= e jω( 2
−n)
.e −jω( 2
)
M−1
−jω M−1 jω −n −jω M−1 −n
e −jωn + e −jω(M−1−n) = e 2 e 2 +e 2 Center of Symmetry
−jω M−1 M −1
= e 2 2cosω −n
2
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 12 / 94
FIR Filter Design Symmetric and Antisymmetric FIR Filters
M−3
2
M − 1 −jω( M−1 ) X
H(e jω
) = h( )e 2 + h(n)[e −jωn + e −jω(M−1−n) ]
2 n=0
M−3
2
M −1 −jω M−1 X M −1
−jω M−1
= h e 2 + h(n)e −n2 2cosω
2 n=0
2
M−3
2
−jω M−1 M − 1 X M − 1
= e 2
h +2 h(n)cos ω −n
2 n=0
2
M−3
2
M −1 X M −1
|H(ω)| = h +2 h(n)cos ω −n
2 n=0
2
−ω M−1 for |H(ω)| > 0
2
∠H(ω) =
−ω M−1 + π for |H(ω)| < 0
2
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 13 / 94
FIR Filter Design Symmetric and Antisymmetric FIR Filters
-2 -1 0 1 2 3 4
-2 -1 0 1 2 3 4
H(ω) = |H(ω)|e j∠H(ω)
M −1
2 0 1 2 3 4 5
6 7 8 n 0 1 2 3 4 5 6 7 8 n
X M −1
|H(ω)| = 2 h(n)cos ω −n
n=0
2
Center of Symmetry Center of Symmetry
−ω M−1 for |H(ω)| > 0
Antisymmetry: h(n)=-h(M-1-n) Odd M Antisymmetry: h(n)=-h(M-1-n) Even M
2
∠H(ω) = h[n] h[n]
−ω M−1 + π for |H(ω)| < 0
2
-2 -1 0 1 2 3 4
-2 -1 0 1 2 3 4
0 1 2 3 4 5 6 7 8 n 0 1 2 3 4 5 6 7 8 n
Center of Symmetry
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter
CenterDesign
of Symmetry October 25, 2016 14 / 94
FIR Filter Design Design of linear-phase FIR filters using windows
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 15 / 94
FIR Filter Design
Design steps for Linear Phase FIR Filter (Fourier Series method)
1 Based on the desired frequency response specification Hd (e jω ) determine the
corresponding unit sample response hd (n).
∞
X
Hd (e jω ) = hd (n)e −jωn
n=0
2 Obtain the impulse response hd (n) for the desired frequency response Hd (ω) by evaluating
the inverse Fourier transform.
1
Z π
hd (n) = Hd (e jω )e jωn dω
2π −π
3 In general the sample response hd (n) is infinite in duration and must be truncated at
some point to get an FIR filter of length M. Truncation is achieved by multiplying hd (n)
by window function.
h(n) = hd (n)w (n)
where w (n) is window function
4 Obtain the H(z) for h(n) by taking z transform
5 Obtain the magnitude response |H(e jω )| and phase response θ(ω)|
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 16 / 94
FIR Filter Design
H d (ω ) H d (ω )
1 1
ω ω
0 ωp π 0 ωp π
Low pass Filter High pass Filter
H d (ω ) H d (ω )
1 1
ω π
ω
0 ω1 ω2 π 0 ω1 ω2 ω3 ω4
Band pass Filter Band stop pass Filter
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 18 / 94
FIR Filter Design Window Design Techniques
Rectangular window
wR (n)
attenuation.
The width of main lobe is 4π/N Figure 6: Rectangular window
1 for n = 0, 1, M − 1
ωR (n) =
0 otherwise
| sin( ωM
2
)|
|WR (ω)| =
| sin( ω2 )|
n
0 1 2 3 4 5 6 M-1
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 20 / 94
FIR Filter Design Window Design Techniques
Hanning window
wH (n)
n
0 1 2 3 4 5 6 M-1
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 21 / 94
FIR Filter Design Window Design Techniques
Hamming window
This is a modified version of the raised cosine window
2πn
w (n) = 0.54 − 0.46 cos
M −1
2π 2π
W (ω) ≈ 0.54WR (ω) + 0.23 WR (ω − ) + WR (ω + )
M M
8π
The width of main lobe is: M
wH (n)
n
0 1 2 3 4 5 6 M-1
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 22 / 94
FIR Filter Design Window Design Techniques
Blackman window
This is a 2nd -order raised cosine window.
2πn 4πn
w (n) = 0.42 − 0.5 cos + 0.08 cos
M −1 M −1
2π 2π
W (ω) ≈ 0.42WR (ω) + 0.25 WR (ω − M
) + WR (ω + M
)
+0.04 WR (ω − 4π ) + WR (ω + 4π
M M
)
n
0 1 2 3 4 5 6 M-1
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 23 / 94
FIR Filter Design Window Design Techniques
Kaiser window
This is one of the most useful and optimum windows.
r !
2
2n
I0 β 1− 1− M−1
w (n) =
I0 (β)
Where I0 (X ) is the modified zero-order Bessel function, and is a parameter that can be chosen
to yield various transition widths and stop band attenuation. This window can provide different
transition widths for the same N.
β = 0 → rectangularwindow
β = 5.44 → Hammingwindow
β = 8.5 → Blackmanwindow
wH (n)
n
0 1 2 3 4 5 6 M-1
Figure 16:
Dr. Manjunatha. P Kaiser windowUNIT - 7: FIR Filter DesignFigure 17: Kaiser
(JNNCE) window
October 25, 2016 24 / 94
FIR Filter Design Window Design Techniques
Gibbs Phenomenon
The magnitude of the frequency response H(ω) is as shown in Figure. Large oscillations
or ripples occur near the band edge of the filter. The oscillations increase in frequency as
M increases, but they do not dimmish in amplitude.
These large oscillations are due to the result of large sidelobes existing in the frequency
characteristic W (ω) of the rectangular window.
The truncation of the Fourier series is known to introduce ripples in the frequency
response characteristic H(ω) due to the nonuniform convergence of the Fourier series at a
discontinuity.
The oscillatory behavior near the band edge of the filter is called the Gibbs Phenomenon.
To alleviate the presence of large oscillations in both the passband and the stopband
window function is used that contains a taper and decays toward zero gradually .
Design a LPF using rectangular window for the desired frequency response of a low pass filter
given by ωc = π2 rad/sec, and take M=11. Find the values of h(n). Also plot the magnitude
response.
Solution:
H d (e jω )
1
e −jωτ − ωc ≤ ω ≤ ωc
jω
Hd (e ) = 0 − π ≤ ω ≤ −ωc
0 ωc ≤ ω ≤ π
ω
−π −
π
0 π π
M −1 2 2
τ = =5
2
−jωτ Figure 20: Frequency response of LPF
e − ωc ≤ ω ≤ ωc
Hd (e jω ) =
0 Otherwise
By taking inverse Fourier transform
" # ωc
Z π 1 e jω(n−τ )
1 hd (n) =
hd (n) = Hd (e jω )e jωn dω 2π j(n − τ )
2π −π −ωc
1
Z ωc 1 h i
= e −jωτ e jωn dω = e jωc (n−τ )
− e −jωc (n−τ )
2π −ωc 2jπ(n − τ )
" #
e jωc (n−τ ) − e −jωc (n−τ )
Z ωc
1 1
= e jω(n−τ ) dω =
2π −ωc π(n − τ ) 2j
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 27 / 94
FIR Filter Design Low Pass FIR Filter Design
M−3
2
M −1 X M −1
|H(e jω )| = h +2 h(n)cos ω −n
2 n=0
2
4
X
= h(5) + 2 h(n)cos ω(5 − n)
n=0
= h(5) + 2h(0)cos 5ω + 2h(1)cos 4ω + 2h(2)cos 3ω + 2h(3)cos 2ω + 2h(4)cos ω
= 0.5 + 0.127cos 5ω − 0.212cos 3ω + 0.636cos ω
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 29 / 94
FIR Filter Design Low Pass FIR Filter Design
|H(ejw)|dB
−20
0.2π 0.9535 -0.41
0.3π 1.0758 0.63 −30
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 30 / 94
FIR Filter Design Low Pass FIR Filter Design
M −1
τ = =3
2
Z π
1
hd (n) = Hd (e jω )e jωn dω
2π −π H d (e jω )
Z ωc 1
1
= e −jωτ e jωn dω
2π −ωc
ω
Z ωc
1 3π 3π
= e jω(n−τ ) dω −π − 0 π
2π −ωc 4 4
" # ωc
1 e jω(n−τ )
=
2π j(n − τ )
−ωc
sinωc (n − τ )
hd (n) =
" #
1 e jωc (n−τ ) − e −jωc (n−τ ) π(n − τ )
=
π(n − τ ) 2j
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 31 / 94
FIR Filter Design Low Pass FIR Filter Design
3π(0−3)
sin 4
hd (0) = = 0.075
π(0 − 3)
3π(1−3)
sin 4
hd (1) = = −0.159
π(1 − 3)
3π M−1
n 6= 3 ωc = τ = =3
4 2 3π(2−3)
sin 4
hd (2) = = 0.225
h
3π(n−3)
i π(2 − 3)
sin 4
hd (n) = 3π(3−3)
sin
π(n − 3) 4
hd (3) = = 0.75
π(3 − 3)
for n=3 hd (n) = 00 . Using L Hospital’s Rule
3π(4−3)
sin 4
hd (4) = = 0.225
sin
3π
(n − 3)
π(4 − 3)
4 3π/4
lim = = 0.75
3π(5−3)
n→3 π(n − 3) π sin 4
hd (5) = = −0.159
π(5 − 3)
3π(6−3)
sin 4
hd (6) = = 0.075
π(6 − 3)
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 32 / 94
FIR Filter Design Low Pass FIR Filter Design
2πn
w (n) = 0.54 − 0.46cos
M −1 To calculate the value of h(n)
0
ω(0) = 0.54 − 0.46cos = 0.08 h(n) = hd (n)w (n)
6
2π
ω(1) = 0.54 − 0.46cos = .31
6
h(0) = hd (0)w (0) = 0.075 × 0.08 = 0.006
4π
ω(2) = 0.54 − 0.46cos = .77 h(1) = hd (1)w (1) = −0.159 × 0.31 = −0.049
6
h(2) = hd (2)w (2) = 0.225 × 0.77 = 0.173
6π
ω(3) = 0.54 − 0.46cos =1 h(3) = hd (3)w (3) = 0.750 × 1 = 0.750
6
8π h(4) = hd (4)w (4) = 0.225 × 0.77 = 0.173
ω(4) = 0.54 − 0.46cos = 0.77 h(5) = hd (5)w (5) = −0.159 × 0.31 = −0.049
6
h(6) = hd (6)w (6) = 0.075 × 0.08 = 0.006
10π
ω(5) = 0.54 − 0.46cos = .31
6
12π
ω(6) = 0.54 − 0.46cos = .08
6
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 33 / 94
FIR Filter Design Low Pass FIR Filter Design
|H(ejw)|dB
−4
0.2π 0.9959 -0.0354
0.3π 1.9722 -0.2445 −6
Matlab code
clc; clear all; close all;
M= input(’enter the value of M:’);
omega= input(’enter the value of omega:’);
tau=(M-1)/2 ;
for n=0:M-1;
% c(n+1)=.5-.5*cos((2*pi*n)/(M-1));
c(n+1)=.54-.46*cos((2*pi*n)/(M-1));
if n==tau
h(n+1)=omega/pi;
else
h(n+1)=sin(omega*(n-tau))/(pi*(n-tau));
end
end
h
c
for n=1:M
y=h(n)*c(n)’
end
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 35 / 94
FIR Filter Design Low Pass FIR Filter Design
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 36 / 94
FIR Filter Design Low Pass FIR Filter Design
Determine the filter coefficients hd (n) for the desired frequency response of a low pass filter
given by
for − π4 ≤ ω ≤ π4
−2jω
e
Hd (e jω ) =
0 for π4 ≤ |ω| ≤ −π
If we define the new filter coefficients by hd (n) = hd (n)ω(n) where
1 for 0 ≤ n ≤ 4
ω(n) =
0 otherwise
Determine h(n) and also the frequency response H(e jω ) July-2013, July-2011
Solution:
π H d (e jω )
Z
1
hd (n) = Hd (e jω )e jωn dω 1
2π −π
1
Z π/4
= e −j2ω e jωn dω π ω
2π −π/4 −π − 0 π π
4 4
1
Z π/4
= e jω(n−2) dω
2π −π/4
" #π/4
1 e jω(n−2) 1 h π π
i
= hd (n) = e j 4 (n−2) − e −j 4 (n−2)
2π j(n − 2) 2jπ(n − 2)
−π/4 " π π #
1 e j 4 (n−2) − e −j 4 (n−2)
=
π(n − 2) 2j
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 37 / 94
FIR Filter Design Low Pass FIR Filter Design
π n hd (n) n hd (n)
sin 4
(n − 2) π/4
lim = = 0.25 0 0.159091 3 0.224989
n→2 π(n − 2) π 1 0.224989 4 0.159091
2 0.25
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 38 / 94
FIR Filter Design Low Pass FIR Filter Design
|H(ejw)|dB
−20
0.2π 0.7123 -2.9464
0.3π 0.4162 -7.6132 −30
Design the symmetric FIR lowpass filter whose desired frequency response is given as
e −jωτ
for |ω| ≤ ωc
Hd (ω) =
0 Otherwise
The length of the filter should be 7 and ωc = 1 radians/sample. Use rectangular window.
Solution:
Desired frequency response Hd (ω)
Length of the filter M=7 H d (e jω )
1
Cut-off frequency ωc = 1 radians/sample.
Unit sample response is defined as
Z π ω
1 −π π
hd (n) = Hd (e jω )e jωn dω −1 0 1
2π −π
Given Hd (ω) is Figure 24: Frequency response of
LPF
e −ωτ
for − 1 ≤ ω ≤ 1
Hd (ω) =
0 Otherwise
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 40 / 94
FIR Filter Design Low Pass FIR Filter Design
Thus hd (n) is
This is the unit sample response of required
(
sin(n−τ ) FIR filter. The filter is symmetric and satis-
for n 6= τ
hd (n) = π(n−τ ) fies h(n) = h(M − 1 − n)
1
π
for n = τ
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 41 / 94
FIR Filter Design Low Pass FIR Filter Design
2πn
ω(n) = 0.5(1 − cos )
M −1
2πn
ω(n) = 0.5(1 − cos )
6
To calculate the value of h(n)
ω(0) = 0.0
2π h(0) = hd (0)w (0) = 0.01497 × 0 = 0
ω(1) = 0.5(1 − cos ) = .25
6 h(1) = hd (1)w (1) = 0.014472 × 0.25 = 0.03618
4π
ω(2) = 0.5(1 − cos ) = .75 h(2) = hd (2)w (2) = 0.26785 × 0.75 = 0.20089
6
6π h(3) = hd (3)w (3) = 0.31831 × 1 = 0.31831
ω(3) = 0.5(1 − cos )=1 h(4) = hd (4)w (4) = 0.26785 × 0.75 = 0.20089
6
8π h(5) = hd (5)w (5) = 0.14472 × 0.25 = 0.03618
ω(4) = 0.5(1 − cos ) = .75
6 h(6) = hd (6)w (6) = 0.014497 × 0.0 = 0
10π
ω(5) = 0.5(1 − cos ) = .25
6
12π
ω(6) = 0.5(1 − cos )=0
6
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 42 / 94
FIR Filter Design Low Pass FIR Filter Design
Design a lowpass digital filter to be used in an A/D Hz D/A structure that will have a -3 dB
cut-off at 30 π rad/sec and an attenuation of 50 dB at 45 π rad/sec. The filter is required to
have linear phase and the system will use sampling rate of 100 samples/second.
Solution:
3 dB cut-off at 30 π rad/sec
ωc = 30πrad/sec
Sampling frequency FSF = 100 Hz
Stopband attenuation of 50 dB at 45 π rad/sec
As =50 dB for ωs = 45πrad/sec H d (e jω )
ω = FΩ 1
sf
ω1 =
Ω1
=
30π
= 0.3π rad/sample ω
Fsf 100 −π −0.3π 0 0.3π π
Ω2 45π
ω2 = = = 0.45π rad/sample Figure 25: Frequency response of LPF
Fsf 100
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 43 / 94
FIR Filter Design Low Pass FIR Filter Design
Type of window is
The stopband attenuation of 50 dB
e −jωτ
is provided by the Hamming window for − ωc ≤ ω ≤ ωc
Hd (ω) =
which of -53 dB. Hence Hamming win- 0 Otherwise
dow is selected for the given specifica-
tions. τ = (M − 1)/2 = 55 − 1/2 = 27
To determine the order of the filter ωc = 0.3π
The width of the main lobe in Ham-
1
Z ωc
ming window is 8πM hd (n) = e −jωτ e jωn dω
2π −ωc
2π 8π Z 0.3π
k = 1
M M = e jω(n−27) dω
2π −0.3π
8π " #0.3π
M= 1 e ω(n−27)
ω2 − ω1 =
2π j(n − 27)
The order of the filter M is: −0.3π
sin[ωc (n − 27)]
8π = for n 6= 27
M= = 53.33 π(n − 27)
0.45π − 0.3π
when n = 27
Assume linear phase FIR filter of odd
length Hence select next odd integer ωc
hd (n) = = 0.3
length of 55. π
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 44 / 94
FIR Filter Design Low Pass FIR Filter Design
n h(n) n h(n)
The selected window is Hamming M=27 0 0.0 28 0.2567
1 0.0 29 0.1495
2 -0.0012 30 0.0319
3 0.0 31 -0.0445
2πn 4 0.0 32 -0.0588
w (n) = 0.54 − 0.46cos 5 0.0021 33 - 0.0278
M −1 6 0.0023 34 0.012
πn
7 0.0 35 0.0308
= 0.54 − 0.46cos 8 -0.0036 36 0.0220
18 9 -0.0052 37 -0.0
10 -0.0021 38 -0.0157
The value of h(n) 11 0.0048 39 -0.0156
12 0.0098 40 -0.0043
13 0.0069 41 0.0069
h(n) = hd (n)w (n) 14 -0.0043 42 0.0098
15 -0.0156 43 0.0048
16 -0.0157 44 -0.0021
for M= 27 17 0.0 45 -0.0052
18 0.0220 46 -0.0036
19 -0.0308 47 0.0
sin[0.3π(n − 27)] h πn i
20 -0.0120 48 0.0023
h(n) = 0.54 − 0.46cos
π(n − 27) 18 21 -0.0278 49 0.0021
22 -0.0588 50 0.0
23 -0.0445 51 0.0
for n 6= 27 24 0.0319 52 -0.0012
25 0.1495 53 0.0
h πn i 26 0.2567 54 0.0
h(n) = 0.3 0.54 − 0.46cos 27 0.3
18
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 45 / 94
FIR Filter Design Low Pass FIR Filter Design
An analog signal contains frequencies upto 10 KHz. The signal is sampled at 50 KHz. Design
an FIR filter having linear phase characteristic and transition band of 5 KHz. The filter should
provide minimum 50 dB attenuation at the end of transition band.
Solution:
3 dB cut-off at 30 π rad/sec
Ωp = 2π × 10 × 103 rad/sec
Ωs = 2π × (10 + 5) × 103 rad/sec
Sampling frequency FSF = 100 Hz
Stopband attenuation of 50 dB at 45 π rad/sec
As =50 dB for ωs = 45πrad/sec H d (e jω )
1
ω = FΩ
sf
Ωp 2π × 10 × 103 ω
ωp = = = 0.4π −π −0.5π 0 0.5π π
Fsf 50 × 103
Ωs 2π × (10 + 5) × 103 Figure 26: Frequency response of LPF
ωs = = = 0.6π
Fsf 50 × 103
ωp = 0.4π rad/sample
ωs = 0.6π rad/sample
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 46 / 94
FIR Filter Design Low Pass FIR Filter Design
Type of window is
e −jωτ
The stopband attenuation of 50 dB for − ωc ≤ ω ≤ ωc
Hd (ω) =
is provided by the Hamming window 0 Otherwise
which of -53 dB. Hence Hamming win-
dow is selected for the given specifica- τ = (M − 1)/2 = 41 − 1/2 = 20
tions. ωc = ωp + ∆ω = 0.4π + 0.2π
2 2
To determine the order of the filter ωc = 0.5π
The width of the main lobe in Ham-
ming window is 8πM 1
Z ωc
hd (n) = e −jωτ e jωn dω
2π 8π 2π −ωc
k = Z 0.5π
M M 1
= e jω(n−20) dω
2π −0.5π
8π
M≥ " #0.5π
ωs − ωp 1 e ω(n−27)
=
2π j(n − 20)
The order of the filter M is: −0.5π
sin[ωc (n − 20)]
8π = for n 6= 20
M≥ ≥ 40 π(n − 20)
0.6π − 0.4π
when n = 20
Assume linear phase FIR filter of odd
length Hence select next odd integer ωc 0.5π
length of 41. hd (n) = = = 0.5
π π
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 47 / 94
FIR Filter Design Low Pass FIR Filter Design
n h(n) n h(n)
The selected window is Hamming M=41
0 0.0 21 0.3148
1 -0.00146 22 0.0
2πn
2 0.0 23 -0.1
w (n) = 0.54 − 0.46cos 3 -0.00247 24 0.0
M −1
4 0 25 0.055
2πn 5 -0.00451 26 0.0
= 0.54 − 0.46cos
40 6 0.0 27 -0.0337
7 0.0079 28 0.0
The value of h(n) 8 0.0 29 0.0213
9 -0.0136 30 0.0
h(n) = hd (n)w (n) 10 0.0 31 -0.0136
11 0.002135 32 0.0
for M= 41 n 6= 20 12 0.0 33 0.0079
13 -0.03375 34 0
14 0.0 35 -0.0045
sin[0.5π(n − 20)] 2πn
h(n) = 0.54 − 0.46cos 15 0.05504 36 0.0
π(n − 20) 20 16 0.0 37 0.0024
17 -0.1006 38 0.0
for n = 20 18 0.0 39 -0.0014
19 0.3148 40 0.0
2πn 20 0.5
h(n) = 0.5 0.54 − 0.46cos
20
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 48 / 94
FIR Filter Design Low Pass FIR Filter Design
Design an FIR filter (lowpass) using rectangular window with passband gain of 0 dB, cutoff
frequency of 200 Hz, sampling frequency of 1 kHz. Assume the length of the impulse response
as 7.
Solution:
Fc = 200 Hz, Fs = 1000 Hz,
fc = FFc 1000
200
= 0.2cycles/sample
s
ωc = 2π ∗ fc = 2π × 0.2 = 0.4πrad H d (e jω )
1
M=7
ω
e −jωτ π
Hd (ω) =
for − ωc ≤ ω ≤ ωc −π −0.4π 0 0.4π
0 Otherwise
Figure 27: Frequency response of LPF
τ = (M − 1)/2 = 7 − 1/2 = 3
ωc = 0.4π
when n 6= 3
1
Z ωc
hd (n) = e −jωτ e jωn dω
2π −ωc sin[0.4π(n − 3)]
0.4π
hd (n) =
π(n − 3)
Z
1
= e jω(n−3) dω
2π −0.4π
" #0.4π when n = 3
1 e ω(n−3)
= 0.4π
2π j(n − 3) hd (n) = = 0.4
−0.4π
π
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 49 / 94
FIR Filter Design Low Pass FIR Filter Design
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 50 / 94
FIR Filter Design Low Pass FIR Filter Design
Using rectangular window design a lowpass filter with passband gain of unity, cutoff frequency of
1000 Hz, sampling frequency of 5 kHz. The length of the impulse response should be 7.
DEC:2013,DEC:2012
Solution:
Fc = 1000 Hz, Fs = 5000 Hz,
fc = FFc 5000
1000
= 0.2cycles/sample
s
ωc = 2πfc = 2 × π × 0.2 = 0.4πrad
M=7
The filter specifications (ωc and M=7) are similar to the previous example. Hence same filter
coefficients are obtained.
h(0)=-0.062341, h(1)=0.093511, h(2)=0.302609
h(3)=0.4, h(4)=0.302609, h(5)=0.093511, h(6)=-0.062341
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 51 / 94
FIR Filter Design Low Pass FIR Filter Design
Design a normalized linear phase FIR low pass filter having phase delay of τ = 4 and at least 40
dB attenuation in the stopband. Also obtain the magnitude/frequency response of the filter.
M −1 ω
τ = −π −1 0 1 π
2
For τ = 4 M=9
Figure 28: Frequency response of
LPF
Desired unit sample response hd (n) is
1
Z ωc when n 6= 4
hd (n) = e −jωτ e jωn dω
2π −ωc
sin[(n − 4)]
1
Z1 hd (n) =
= e jω(n−4) dω π(n − 4)
2π −1
" #1 when n = 4
1 e ω(n−4)
=
2π j(n − 4) 1
Z 1 ω 1
−1
hd (n) = 1dω = =
2π −1 π π
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 52 / 94
FIR Filter Design Low Pass FIR Filter Design
for n = 0 to 8
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 53 / 94
FIR Filter Design Low Pass FIR Filter Design
|H(ejw)|dB
−20
0.2π 0.7123 -2.9464
0.3π 0.4162 -7.6132 −30
Design a HPF using Hamming window. Given that cutoff frequency the filter coefficients hd (n)
for the desired frequency response of a low pass filter given by ωc = 1rad/sec, and take M=7.
Also plot the magnitude response.
Solution: −jωτ
e − π ≤ ω ≤ −ωc
jω
Hd (e ) = e −jωτ ωc ≤ ω ≤ −π
0 − ωc ≤ ω ≤ ωc
M −1
τ = =3
2
e −jωτ
− π ≤ −ω ≤ ωc
Hd (e jω ) =
0 Otherwise
H d ( e jω )
1
1
Z π
hd (n) = Hd (e jω )e jωn dω
2π −π −ωc ωc π ω
−π 0
Z −ωc Z π
1 jω(n−τ ) jω(n−τ )
= [ e dω + e dω
2π −π ωc
" #−ωc " #π
1 e jω(n−τ ) 1 e jω(n−τ )
= +
2π j(n − τ ) 2π j(n − τ )
−π ωc
" #
1 e −jωc (n−τ ) − e −jπ(n−τ ) + e jπ(n−τ ) − e jωc (n−τ )
=
π(n − τ ) 2j
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 55 / 94
FIR Filter Design High Pass FIR Filter Design
" #
e jπ(n−τ ) − e −jπ(n−τ ) − e jωc (n−τ ) − e −jωc (n−τ )
1
hd (n) =
π(n − τ ) 2j
1
= [sinπ(n − τ ) − sinωc (n − τ ]
π(n − τ )
1
τ = 3 ωc = 1 hd (n) = π(n−3) [sinπ(n − 3) − sin(n − 3)]
when n = τ using L Hospital rule
1 sinπ(n − 3) sinωc (n − 3) 1 1
hd (n) = − = [π − ωc ] = [π − 1]
π (n − 3) (n − 3) π π
The given window function is Hamming window. In this case h(n) = hd (n)ω(n)) for 0 ≤ n ≤ 6
2πn
w (n) = 0.54 − 0.46cos
M −1
1 2πn
h(n) = [sinπ(n − 3) − sin(n − 3)] × 0.54 − 0.46cos
π(n − 3) M −1
n h(n) n h(n)
0 -0.00119 4 -0.00119
1 -0.00448 5 -0.00448
2 -0.2062 6 -0.2062
3 0.6816
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 56 / 94
FIR Filter Design High Pass FIR Filter Design
For M=7
2
X
|H(e jω )| = h (3) + 2 h(n)cosω(3 − n)
n=0
= h (3) + 2h(0)cos3ω + 2h(1)cos2ω + 2h(2)cosω
= 0.6816 − 0.000238cos3ω − 0.0896cos2ω − 0.4214cosω
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 57 / 94
FIR Filter Design Band Pass FIR Filter Design
Design the bandpass linear phase FIR filter having cut off frequencies of ωc1 = 1rad/sample and
ωc2 = 2rad/sample. Obtain the unit sample response through following window.
1 for 0 ≤ n ≤ 6
ω(n) =
0 Otherwise
Solution:
H d ( e jω )
1
e −jωτ ωc1 ≤ |ωc | ≤ ωc2
Hd (ω) =
0 Otherwise
−π −ωc 2 −ωc1 0 ωc 1 ωc 2 π ω
1
Z π
hd (n) = Hd (ω)e jωn dω
2π −π
"Z #
1 −ωc1 Z ωc2
−jωτ jωn −jωτ jωn
= e e dω + e e dω
2π −ωc2 ωc1
"Z #
1 −ωc1 Z ωc2
= e jω(n−τ ) + e jω(n−τ ) dω
2π −ωc2 ωc1
" #−ωc " #ωc
1 e jω(n−τ ) 1
e jω(n−τ ) 2
= +
2π (n − τ ) (n − τ )
−ωc2 ωc1
sinωc2 (n − τ ) − sinωc1 (n − τ )
= for n 6= τ
π(n − τ )
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 58 / 94
FIR Filter Design Band Pass FIR Filter Design
sinωc2 (n − τ ) − sinωc1 (n − τ )
hd (n) =
π(n − τ )
ωc2 − ωc1
= for n = τ
π
The linear phase FIR filter is normalized means its n h(n) n h(n)
cut-off frequency is of ωc = 1rad/sample 0 -0.044 4 0.0215
The length of the filter with given τ is related by 1 -0.165 5 0.265
2 0.215 6 -0.044
M −1 7−1 3 0.3183
τ = = =3
2 2
M−3
2
M −1 X M −1
H(ω) = h +2 h(n)cos ω −n
2 n=0
2
2
X
H(ω) = h(3) + 2 h(n)cos ω (n − 3)
n=0
Estimate the H(ω) by substituting the required values in the above equation.
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 60 / 94
FIR Filter Design Band Pass FIR Filter Design
Solution:
H d ( e jω )
1
e −jωτ ω
c1 ≤ |ωc | ≤ ωc2
Hd (ω) =
0 Otherwise
−π −ωc 2 −ωc1 0 ωc 1 ωc 2 π ω
1
Z π
hd (n) = Hd (ω)e jωn dω
2π −π
"Z #
1 −ωc1 Z ωc2
−jωτ jωn −jωτ jωn
= e e dω + e e dω
2π −ωc2 ωc1
"Z #
1 −ωc1 Z ωc2
= e jω(n−τ ) + e jω(n−τ ) dω
2π −ωc2 ωc1
" #−ωc " #ωc
1 e jω(n−τ ) 1
e jω(n−τ ) 2
= +
2π (n − τ ) (n − τ )
−ωc2 ωc1
sinωc2 (n − τ ) − sinωc1 (n − τ )
= for n 6= τ
π(n − τ )
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 61 / 94
FIR Filter Design Band Pass FIR Filter Design
sinωc2 (n − τ ) − sinωc1 (n − τ )
hd (n) =
π(n − τ )
ωc 2 − ωc 1
= for n = τ
π
( sinωc2 (n−τ )−sinωc1 (n−τ )
π(n−τ )
for n 6= τ
hd (n) = ωc2 −ωc1
π
for n = τ for
The length of the filter with given τ is related by
M −1 11 − 1
τ = = =5
2 2
π 3π
and ωc2 = 4
rad/sample ωc = 4
rad/sample
h i h i
3π(n−5) π(n−5)
sin 4
−sin 4
for n 6= 5
hd (n) = π(n−5)
3π − π
4 4
π
for n = 5 for
Design a BPF using Hanning window with M=7. Given that lower cutoff frequency
ωc1 = 2rad/sec and ωc2 = 3rad/sec.
Solution:
−jωτ
e for − ωc2 ≤ ω ≤ −ωc1
jω
Hd (e )= e −jωτ for ωc1 ≤ ω ≤ ωc2
0 for − ωc − ωc1 ω ≤ ωc1
M −1
τ = =3
2
1
Z π
−π −ωc 2 −ωc1 ωc 1 ωc 2 π ω
hd (n) = Hd (e jω )e jωn dω 0
2π −π
Z −ωc1 Z ωc2
1 jω(n−τ )
= [ e dω + e jω(n−τ ) dω
2π −ωc2 ωc1
" #−ωc1 " #ωc1
1 e jω(n−τ ) 1 e jω(n−τ )
= +
2π j(n − τ ) 2π j(n − τ )
−ωc2 ωc2
1
= [sinωc2 (n − τ ) − sinωc1 (n − τ ]
π(n − τ )
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 63 / 94
FIR Filter Design Band Pass FIR Filter Design
τ = M−12
= 7−1
2
=3
ωc1 = 2 rad/sec ωc2 = 3 rad/sec
for n 6= 3
1
hd (n) = [sin3(n − 3) − sin2(n − 3)]
π(n − 3)
n h(n) n h(n)
for n = τ 0 0 4 0
1 0.0189 5 0.0189
1 sinωc2 (n − τ ) sinωc1 (n − τ ) 2 -0.01834 6 -0.01834
hd (n) = lim − lim
π n→τ (n − τ ) n→τ (n − τ ) 3 0.3183
1 1
hd (n) = [ωc2 − ωc1 ] =
π π
The given window function is Hanning window
2πn
ω(n) = 0.5 − 0.5cos 0≤n ≤M −1
M −1
This is rectangular window of length M=11. In this case h(n) = hd (n)ω(n) = hd (n)
for 0 ≤ n ≤ 6
sin3(n − τ ) − sin2(n − τ ) 2πn
h(n) = 0.5 − 0.5cos
π(n − 3) M −1
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 64 / 94
FIR Filter Design Band Pass FIR Filter Design
M−1
X 6
X
H(z) = h(n)z −n = h(n)z −n
n=0 n=0
3
X
|H(e jω )| = h (3) + 2h (3 − n) cosωn
n=1
5
X
= h(3) + 2h (5 − n) cosωn
n=1
= h(3) + 2h(2)cosω + 2h(1)cos2ω + 2h(0)cos3ω
= 0.3183 − 0.3668cosω + 0.0378cos2ω
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 65 / 94
FIR Filter Design Bandstop FIR Filter Design
Design a bandstop filter to reject the frequencies from 2 to 3 rad/sec using rectangular window
with M=5. Find the frequency response.
Solution:
H d ( e jω )
−jωτ
e for − π ≤ ω ≤ −ωc2 1
−jωτ
jω e for − ωc1 ≤ ω ≤ ωc1
Hd (e ) =
e −jωτ for ωc2 ≤ ω ≤ π
0 for ωc1 ≤ |ω| ≤ ωc2 −ωc 2 −ωc1 ωc 1 ωc 2 ω
−π 0 π
1
Z π
hd (n) = Hd (e jω )e jωn dω
2π −π
Z −ωc2 Z ωc1 Z π
1 jω(n−τ )
= [ e dω + e jω(n−τ ) dω + e jω(n−τ ) dω
2π −π −ωc1 ωc2
" #−ωc2 " #ωc1 " #π
1 e jω(n−τ ) 1 e jω(n−τ ) 1 e jω(n−τ )
= + +
2π j(n − τ ) 2π j(n − τ ) 2π j(n − τ )
−π −ωc1 ωc2
1
= [sinωc1 (n − τ ) + sinπ(n − τ − sinωc2 (n − τ ]
π(n − τ )
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 66 / 94
FIR Filter Design Bandstop FIR Filter Design
1
hd (n) = [sin2(n − 2) + sinπ(n − 2) − sin3(n − 2)] for n 6= 2
π(n − 2)
for n = τ
1 sinωc1 (n − τ ) sinπ(n − τ ) sinωc2 (n − τ )
hd (n) = lim + lim − lim
π n→τ (n − τ ) n→τ (n − τ ) n→τ (n − τ )
1 1
hd (n) = [ωc1 + π − ωc2 ] = [π − 1]
π π
The given window function is Rectangular window
ω(n) = 1 0≤n ≤M −1
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 67 / 94
FIR Filter Design Bandstop FIR Filter Design
sin2(0 − 2) + sinπ(0 − 2) − sin3(0 − 2)
n = 0 h(0) = = −0.0759
π(0 − 2)
sin2(1 − 2) + sinπ(1 − 2) − sin3(1 − 2)
n = 1 h(1) = = 0.2445
π(1 − 2)
1
n = 2 h(2) = [π − 1] = 0.6817
π
sin2(3 − 2) + sinπ(3 − 2) − sin3(3 − 2)
n = 3 h(3) = = 0.2445
π(3 − 2)
sin2(4 − 2) + sinπ(4 − 2) − sin3(4 − 2)
n = 4 h(4) = = −0.0759
π(4 − 2)
M−1
X 4
X
H(z) = h(n)z −n = h(n)z −n
n=0 n=0
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 68 / 94
FIR Filter Design Bandstop FIR Filter Design
For M=5
2
X
|H(e jω )| = h (2) + 2h (2 − n) cosωn
n=1
3
X
|H(e jω )| = h (3) + 2h (3 − n) cosωn
n=1
= h(2) + 2h(1)cosω + 2h(0)cos2ω
= 0.6817 + 2(0.2445)cosω + 2h(−0.0759)cos2ω
= 0.6817 + 0.4890cosω − 0.1518cos2ω
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 69 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
∞
X 1 x k
I0 (x) = 1+
k=1
k! 2
0.25x 2 (0.25x 2 )2 (0.25x 2 )3
= 1+ + + +
(1!)2 (2!)2 (3!)2
α = 0 if A < 21
= 0.5842(A − 21)0.4 + 0.07886(A − 21) if 21 ≤ A ≤ 50 dB
= 0.1102(A − 8.7)) if A > 50 dB
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 70 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
H (ω ) δ1 Passband ripple
1 + δ1 δ 2 Stopband ripple
A P
1
1 − δ1 Ideal
LPF
A S
Gain
δ2
ωP ωC ωS ω
Passband Transition
Stopband
band
Figure 30: Frequency response of LPF
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 71 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
where ωc = 12 (ωp + ωs )
2 Chose δ such that the actual passband ripple, Ap is equal to or less than the specified
passband ripple Ãp , and the actual minimum stopband attenuation A is equal or greater
than the specified minimum stop attenuation Ãs
δ = min(δp , δs )
0.05Ãp
10 −1
where δp = and δs = 10−0.05Ãs
100.05Ãp +1
3 The actual stopband attenuation is
A = −20log10 δ
4 The parameter α is
0 for A ≤ 21
α= 0.5842(A − 21)0.4 + 0.07886(Aa − 21) for 21 < A ≤ 50
0.1102(A − 8.7) for A > 50
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 72 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
M−1
X
H(z) = h(n)z −n
n=0
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 73 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
Design a lowpass filter with a cutoff frequencies from wc = π4 ∆ω = 0.02π and a stopband
ripple δs = 0.01. Use Kaiser window
Solution:
1 for |ω| ≤ ωc
Hd (e jω ) =
0 for ωc ≤ |ω| ≤ π
A = −20log δs = −20log (0.01) = 40 dB
The inverse transform of the Hd (e jω ) is
1
Z π α = 0.5842(A − 21)0.4 + 0.07886(A − 21)
hd (n) = Hd (e jω )e jωn dω
2π −π = 0.5842(40 − 21)0.4 + 0.07886(40 − 21)
Z ωc
1 = 3.4
= e jωn dω
2π −ωc
ω
1 e jωn c
0.02π
= ∆f = = 0.01
2π jn −ωc 2π
1 h jωc n i
= e − e −jωc n A − 7.95
2jπn M≥ ≥ 223.189 ' 225
14.36∆f
1 e jωc n − e −jωc n
= 225 − 1
πn 2j τ = = 112
sinωc n 2
=
πn
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 74 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
" r #
2
2n
I0 α 1− M−1
wk (n) = 0≤n ≤M −1
I0 (α)
q
2n 2
I0 3.4 1 − 224
wk (n) = 0≤n ≤M −1
I0 (3.4)
q
2n 2
I0 3.4 1 − 224
1
h(n) = hd × wk (n) = [sinωc n] ×
πn I0 (3.4)
where
0 ∆ω 0.02π
ωc = ωc + = 0.25π + = 0.26π
2 2
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 75 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
Find an expression for the impulse response h(n) of a linear phase lowpass FIR filter using Kaiser
window to satisfy the following magnitude response specifications for the equivalent analog
filter.
Stopband attenuation: 40 dB
Passband ripple: 0.01 dB
Transition width: 1000 π rad/sec
Ideal cutoff frequency: 2400 π rad/sec
Sampling frequency: 10 KHz
Solution:
x(t ) x ( n) y ( n) y (t )
A/D Filter D/A
A = −20log δs = 40 dB
∆Ω 1000π
log δs = −2 ⇒ δs = 0.01 ∆ω = = = 0.1π rad
fs 10 × 103
20log (1 + δp ) = 0.01
0.1π
∆f = = 0.05
log (1 + δp ) = 0.0005 2π
δp = 0.00115 A − 7.95 58.8 − 7.95
M≥ ≥ = 70.82 ' 71
14.36∆f 14.36 × 0.05
δmin(δp , δs ) = 0.00115
71 − 1
A = −20log (0.00115) = 58.8 dB τ = = 35
2
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 76 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 77 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
Find an expression for the impulse response h(n) of a linear phase Design a lowpass FIR filter
satisfying the following specifications using Kaiser window
αp ≤ 0.1 dB αs ≥ 44 dB
ωp = 20 rad/sec ωs = 30 rad/sec ωsf = 100 rad/sec
Solution:
1 for |ω| ≤ ωc
Hd (e jω ) =
0 for ωc ≤ |ω| ≤ π
∆ω = ωs − ωp = 10rad/sec
The inverse transform of the Hd (e jω ) is 1
ωc = (ωp + ωs ) = 25rad/sec
Z π 2
1
hd (n) = Hd (e jω )e jωn dω 25 π
2π −π ωc (in discrete and radian) = (2π) = rad
Z ωc 100 2
1
= e jωn dω
2π −ωc δs = 10−0.05As = 10−0.05×44 = 6.3096 × 10−3
ω
1 e jωn c 100.05Ap − 1 100.05×0.1 − 1
= δp = 0.05A
= = 5.7563×10−3
2π jn −ωc 10 p +1 100.05×0.1 + 1
1 h jωc n
δ = min(δp , δs ) = 5.7563 × 10−3
i
= e − e −jωc n
2jπn
sinωc n A = −20log10 (δ) = 44.797dB
=
πn
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 78 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 79 / 94
FIR Filter Design FIR Filter Design Using Kaiser Window
Design a high pass digital satisfying the following specifications using Kaiser window
Passband cut-off frequency fp = 3200Hz Stopband cut-off frequency fs = 1600Hz
Passband ripple αp ≤ 0.1dB Stopband ripple αs ≥ 40dB
Sampling frequency F = 10000Hz
Solution:
0 for |ω| ≤ ωc
Hd (e jω ) =
1 for ωc ≤ |ω| ≤ π
∆ω = ωp − ωs = 3200π rad/sec
The inverse transform of the Hd (e jω ) is
1
ωc = (ωp + ωs ) = 4800π rad/sec
1
Z −ωc Z π 2
hd (n) = e jωn dω + e jωn dω
2π −π ωc 4800
ωc (discrete, radian) = (2π) = 0.48πrad
" −ωc π # 20000
e jωn e jωn
1
= +
2π jn −π jn ωc δs = 10−0.05As = 10−0.05×40 = 0.01
1 h i
= e −jωc n − e −jπn + e jπn − e jωc n
2jπn
sinπn − sinωc n 100.05Ap −1 100.05×0.1−1
= δp = = = 0.005756
πn 100.05A p +1 100.05×0.1+1
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 81 / 94
Design of FIR system Frequency Sampling for FIR Filters
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 82 / 94
Design of FIR system Frequency Sampling for FIR Filters
In this method a set of M equally spaced
samples in the interval (0, 2π)are taken in
the desired frequency response Hd (ω).
The continuous frequency ω is replaced by
2π
ω = ωk = k k = 0, 1, . . . M − 1
M
2π k 2π k
| H d (ω ) | ωk = =
M 17
K=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 83 / 94
Design of FIR system Frequency Sampling for FIR Filters
For the FIR filter to be realizable the coefficients h(n) must be real. This is possible if all
complex terms appear in complex conjugate pairs. Consider the term
H(M − k)e j2πn(M−k)/M
H(M − k) = H ∗ (k)
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 84 / 94
Design of FIR system Frequency Sampling for FIR Filters
P
!
1 X h i
h(n) = H(0) + 2 Re H(k)e j2πkn/M
M k=1
where P is M−1
2
if M is odd
P= M
2
− 1 if M is even
M−1
X
H(ω) = h(n)e −jωn
n=0
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 85 / 94
Design of FIR system Frequency Sampling for FIR Filters
Design a lowpass FIR filter using frequency sampling technique having cut-off frequency of π/2
rad/sample. The filter should have linear phase and length of 17.
Solution:
The Ideal LPF frequency response Hd (ω)
for the linear phase is
2π k 2π k
ωk = =
(
−jω M−1 | H d (ω ) |
Hd (ω) = e 2 0 ≤ ω ≤ π2 K=0 1 2 3 4 5 6 7 8
M
9
17
10 11 12 13 14 15 16 17
π
0 2
≤ω≤π
ω
e −j8ω 0 ≤ ω ≤ π2 8π π 30π
4π π 20π 3π 2π
Hd (ω) = π 17 2 17
0 2
≤ω≤π 17 17 2
θ (ω )
2πk 2πk
To sample put ω = M
= 17 ω
16π (k − 17)
θk = −
16π k 17
( 2πk θ k = −8ωk = −
e −j 17
8
0 ≤ 2πk ≤ π2 17
Hd (ω) = π
17
2πk
0 2
≤ 17
≤ π
The range of k is
2πk
17
= π2 k = 17 4
'4
2πk 17
= π k = ' 8
( 16πk
e −j 17 0 ≤ k ≤ 17 17 2
Hd (ω) = 17
4
0 4
≤ k ≤ 17
2
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 86 / 94
Design of FIR system Frequency Sampling for FIR Filters
The range of k is 0 ≤ k ≤ 17 8
!
4 1 X h
j2πkn/17
i
k is an integer. = 1+2 Re H(k)e
Hence the range is 0 ≤ k ≤ 4 17 k=1
Similarly 17
4
≤ k ≤ 17
2
= 4.25 ≤ k ≤ 8.5
The range 5 ≤ k ≤ 8 |H(k)| = 1 0≤k≤4
1 0≤k≤4
4
!
|H(k)| = 0 5≤k≤8 1 X h 16πk
i
1 13 ≤ k ≤ 16 h(n) = 1+2 Re e −j 17 e j2πkn/17
17 k=1
4
!
1 X h i
= 1+2 Re e j2πk(n−8)/17
17 k=1
4 !
1 X 2πk(n − 8)
= 1+2 cos
17 k=1
17
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 87 / 94
Design of FIR system Frequency Sampling for FIR Filters
Determine the impulse response h(n) of a filter having desired frequency response
(M−1)ω
(
−j
Hd (w ) = e 2 0 ≤ |ω| ≤ π2
π
0 2
≤ω≤π
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 88 / 94
Design of FIR system Frequency Sampling for FIR Filters
The value of h(n)is given by
The range of k is 0 ≤ k ≤ 74
M−1
2
k is an integer. 1 X h i
h(n) = H(0) + 2 Re H(k)e j2πkn/M
Hence the range is 0 ≤ k ≤ 1 M k=1
Similarly 74 ≤ k ≤ 72 = 1.75 ≤ k ≤ 3.5
The range 2 ≤ k ≤ 3 3
!
1 X h i
= 1+2 Re H(k)e j2πkn/7
1 0≤k≤1 7 k=1
|H(k)| = 0 2≤k≤3
1 k=6
|H(k)| = 1 0≤k≤1
1
!
n h(n) n h(n) 1 X h 6πk
i
h(n) = 1+2 Re e −j 7 e j2πkn/7
0 -0.1146 4 321 7 k=1
1 0.0793 5 0.0793 1
!
2 0.321 6 -0.1146 1 X h
j2πk(n−3)/7
i
= 1+2 Re e
3 0.4283 7 k=1
1 !
1 X 2πk(n − 3)
= 1+2 cos
7 k=1
7
Determine the filter coefficients h(n) obtained by frequency sampling Hd (w ) given by
(
e −j3ω 0 ≤ |ω| ≤ π
2
Hd (w ) = π ≤ ω ≤ π
0 2
Also obtain the frequency response H(w ). Take N=7. DEC 2011
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 89 / 94
Design of FIR system Frequency Sampling for FIR Filters
Solution:
2π k 2π k
ωk = =
1 0≤k≤3 | H d (ω ) | M 15
|H(k)| = 0 4 ≤ k ≤ 11 K=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 12 ≤ k ≤ 14
ω
4π 6π π π 18π 3π 28π
2π
15 15 2 15 2 15
14 θ (ω )
− 15 πk 0≤k≤7
θ(k) = ω
14π − 1415
πk = − 14
15
π(k − 15) 8 ≤ k ≤ 14
14π (k − 15)
θk = −
14π k 15
θ k = −7ωk = −
15
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 90 / 94
Design of FIR system Frequency Sampling for FIR Filters
7
! n h(n) n h(n)
1 X h
j2πkn/7
i
0 -0.05 8 0.3188
= 1+2 Re H(k)e
15 k=1
1 0.041 9 0.034
2 0.066 10 -0.108
3 -0.036 11 -0.036
|H(k)| = 1 0≤k≤3 4 -0.108 12 0.066
5 0.034 13 0.041
3
!
1 X h 17πk
i 6 0.3188 14 -0.05
h(n) = 1+2 Re e −j 15 e j2πkn/15 7 0.466
715 k=1
3
!
1 X h i
= 1+2 Re e j2πk(n−7)/15
15 k=1
3 !
1 X 2πk(n − 7)
= 1+2 cos
15 k=1
15
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 91 / 94
Design of FIR system Frequency Sampling for FIR Filters
Solution:
1 0≤k≤3
2π k 2π k
ωk = =
0.4 k = 4 | H d (ω ) |
M 15
|H(k)| = 0 5 ≤ k ≤ 10 K=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0.4 k = 11
0.4
0.4
1 12 ≤ k ≤ 14 ω
4π 6π π π 18π 3π 28π
2π
15 15 2 15 2 15
θ (ω )
14 ω
− 15 πk 0≤k≤7
θ(k) = 14
− 15 π(k − 15) 8 ≤ k ≤ 14 14π (k − 15)
θk = −
14π k 15
θ k = −7ωk = −
15
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 92 / 94
Design of FIR system Frequency Sampling for FIR Filters
7
!
1 X h i n h(n) n h(n)
j2πkn/7
= 1+2 Re H(k)e 0 -0.0143 8 0.313
15 k=1 1 -0.002 9 -0.0181
2 0.04 10 -0.091
|H(k)| = 1 0 ≤ k ≤ 3 3 0.0122 11 0.0122
|H(k)| = 0.4 k = 4&11 4 -0.091 12 0.04
5 -0.0181 13 -0.002
3
! 6 0.313 14 -0.0143
1 X h 17πk
i
7 0.520
h(n) = 1+2 Re e −j 15 e j2πkn/15
715 k=1
3
!
1 X h
j2πk(n−7)/15
i h
j2π4(n−7)/15
i
= 1+2 Re e + 2Re 0.4e
15 k=1
3 !
1 X 2πk(n − 7) 8π(n − 7)
= 1+2 cos + 0.8cos
15 k=1
15 15
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 93 / 94
References
Dr. Manjunatha. P (JNNCE) UNIT - 7: FIR Filter Design October 25, 2016 94 / 94