Unit IV Fir Design Lecture Notes
Unit IV Fir Design Lecture Notes
Phase I Coverage:
http://www.udel.edu/idsardi/sinewave/sinewave.html
AVR 2
Group Delay:
−d ∠ H ( e jω )
τ g=delay=
dω
Derivation for Condition for Linear Phase Filter:
M −1 M −1
System Function, H ( z )= ∑ b k z−k = ∑ h (k )z −k
k=0 k=0
jω jω
z=ℜ =e ( assume r=1 )
M−1
Frequency Respons e , H ( e )= ∑ h ( n ) e
jω − jωn
, ( k is replaced by n just for convenience )
n=0
|x|= √ ( ℜ ( x ) ) + ( ℑ ( x ) )
2 2
H ( e )=|H ( e )|e
jω jω j ∠ H ( e jω )
Since we are interested only about the phase (or angle) of the Frequency
response, ∠ x=tan
−1
( )
ℑ(x)
ℜ(x)
( ℑ ( H (e ))
)
jω
∠ H ( e )=ta n
jω −1
ℜ ( H ( e jω ) ) Re(x) = a Im(x) = b
AVR 3
( )
M −1
− ∑ h ( n ) sin ( ωn )
∠ H ( e )=ta n
jω −1 n=0
M−1
∑ h ( k ) cos ( ωn )
n=0
tan−1 ¿
( )
M−1
∑ h ( n ) sin ( ωn )
∠ H ( e )=−ta n jω −1 n=0
M−1
∑ h ( n ) cos ( ωn )
n=0
( ) ( )
M −1 M −1
−1
∑ h ( n ) sin ( ωn )
−1
∑ h ( n ) sin ( ωn )
n=0 n=0
−ωτ =−ta n M −1
→ωτ =ta n M −1
∑ h ( n ) cos ( ωn ) ∑ h ( n ) cos ( ωn )
n=0 n=0
M −1 M −1
∑ h ( n ) sin ( ωn )
sin ( ωτ ) n=0
∑ h ( n ) sin ( ωn )
n=0
tan ( ωτ )= → =
M−1
cos ( ωτ ) M −1
∑ h ( n ) cos ( ωn ) ∑ h ( n ) cos ( ωn )
n=0 n=0
M −1 M−1
M −1
M
IF M is even, then τ = (¿ our problems , M isusually odd)
2
Usually M is chosen to be odd to avoid half-sample delay.
FIR Filter Design technique is to find the values of h(n) for n: 0 to M-1 (h(n) is called as Filter
coefficients). From this, H(z) can be found which can be implemented using any of the structures
(like Direct form…) .
Digital FIR Filter Design: Windowing Technique-Rectangular
FIR Filter Design:
We are going to design Digital FIR Filter using two techniques:
Window Method
Frequency Sampling Method
Magnitude: |e jθ|=1
It affects the amplitude of the input signal. |H ( e jω )|=1 for frequency ¿ be allowed .
Phase:
It causes the delay in the input signal.
∠ H e )=−ωτ =Linear Phase for frequency ¿ be allowed
( jω
Window Method:
{ {
− jω ( M −1) − jω ( M −1)
H d ( e )= 1 e ,0 ≤|ω|≤ ω c =
jω 2 2
1e ,−ω c ≤ ω ≤+ ωc
0 , otherwise 0 ,−π ≤ ω ←ωc ∧¿∧¿∧¿ ωc ≤ ω< π
π
1
2. Taking Inverse ℱ Transform , hd ( n ) = ∫ H ( e jω ) e jωn dω ,−∞≤ n ≤+ ∞
2 π −π d
ωc
1 ( M −1 )
h d ( n )= ∫ e− jωτ e jωn dω , since τ= 2
2 π −ω c
[ ] [ ]
ωc ωc j ωc ( n −τ ) − j ωc ( n−τ )
1 1 e jω ( n−τ ) 1 e −e
h d ( n )= ∫
2 π −ω
e
jω ( n−τ )
dω=
2 π j ( n−τ )
=
2π j ( n−τ )
c −ωc
h d ( n )=
2π [ j ( n−τ )
=
]
1 2 j sin ( ω c ( n−τ ) ) sin ( ωc ( n−τ ) )
π ( n−τ )
In the above equation, if n=τ , thenbecomesinfinite , which isimpossible ∈digital domain .
h ( x )x=τ =
N ' ( x)
' |
AVR 5
Hence we need to find h d ( n ), for n=τ using L' Hospital ' s Rule ,
h d ( n )at n=τ =
ωc cos ( ω c ( n−τ ) )
π |
n=τ
ωc
h d ( τ )=
π
{
sin ( ωc ( n−τ ) )
, n ≠ τ ∧¿−∞≤ n ≤+ ∞
h d ( n )= π ( n−τ )
ωc
, n=τ
π
In above equation, n varies from−∞ ¿+∞ .This results in IIR which has to be converted to FIR by
means of truncation (Windowing).
{
sin ( ω c ( n−τ ) ) ωc
h (n)= , n ≠ τ∧¿∧0 ≤ n≤ M −1∧¿ , n=τ
π ( n−τ ) π
0 , otherwise (n<0 , n> M −1)
n=0
+∞
H ( e jω )= ∑ h ( n ) e− jωn
n=−∞
{
+∞
hd ( n ) w ( n ) e− jωn where , w ( n ) = 1 , 0 ≤ n≤ M −1
H ( e jω )= ∑
n=−∞ 0 ,Otherwise
(Considering Rectangular Window)
M −1
¿ ∑ hd ( n ) w ( n ) e
− jωn
n=0
+∞
H ( e jω )= ∑ hd ( n ) w(n)e− jωn
n=−∞
π
1
Substituting, inverse Fourier transform for h d ( n )= ∫
2 π −π
H d ( e ) e dω
jθ jθn
+∞ π
1
¿ ∑ ∫
2 π −π
H d ( e ) e dω w( n)e
jθ jθn − jωn
n=−∞
{ }
π ∞
1
¿ ∫
2 π −π
∑ w ( n ) e− j (ω−θ) n H d ( e jθ ) dω
n=−∞
π
1
H ( e )=
jω
∫ H ( e jθ ) W ( e j (ω−θ )) dθ=H d ( e jθ)∗W ( e jθ )
2 π −π d
So Frequency response of designed FIR filter can be obtained using convolution of desired
frequency response and Window Frequency response.
(Actually H ( e jω )=H d ( e jω) should be equal, this is possible only ifW ( e jω )is a impulse function
of value:2 πδ ( ω ) )
AVR 6
Gibbs Phenomenon:
When using rectangular window, there is large oscillation
near the band edge of the filter (while observing the
frequency response of the desired filter). This is called Gibbs Phenomenon. This is due to
transition of rectangular window, which is not gradual (rather abrupt). So other windows are
proposed which has gradual transition.
Fig: 4.2 Gibb’s Phenomenon
( M2 πn−1 ), n=0 ¿ M −1
Hann Window: w ( n )=0.5−0.5 cos Hanning window is a wrong
name of Hann Window.
Hamming Window:w ( n )=0.54−0.46 cos (
M −1 )
2 πn
, n=0 ¿ M −1
{
2n M −1 2n M −1
w ( n )= M −1 , n=0 ¿ 2− , n= ¿ M −1 ¿
2 M −1 2
¿
2|n−τ| ( M −1 )
¿ 1− ,n=0 ¿ M −1∧τ=
M −1 2
w ( n )=0 , outside the limit :n< 0∧n> M −1.
Window function also follows symmetry property: w ( n )=w ( M −1−n )
Fig:4.3 Window shape. (Only for rectangular window, transitions are abrupt and hence Gibbs
Phenomenon)
In window method, main lobe transition width and side lobe height should be as small as
possible but they are inversely changing parameter.
Problem:
1. Using a Hamming Window technique, design a Low pass filter with pass band gain of unity,
cutoff frequency of 1000Hz and working at a sampling frequency of 5 KHz. The length of the
impulse response should be 7.
Solution:
2 π F c 2 π 1000
ω c =2 π f c = = =0.4 π (rad / s)∧M =7
Fs 5000
{
− jωτ
For alow pass filter , H d ( e )=
jω e ,−ω c ≤ ω ≤ +ω c
0 ,−π ≤ ω← ωc ∧ω c ≤ ω ≤ π ∧¿∧¿
M −1 7−1
where , τ = = =3
2 2
AVR 7
+∞
1
h d ( n )= ∫
2 π −∞
H d ( e jω ) e jωn dω
+ω c + ωc
1 1
¿ ∫
2 π −ω
e− jωτ e jωn dω= ∫ e jω(n− τ) dω
2 π −ω
c c
[ ] [ ]
ωc jω ( n −τ ) ωc j ω c ( n−τ ) − j ωc ( n−τ )
1 1 e 1 e −e
h d ( n )= ∫
2 π −ω
e
jω ( n−τ )
d ω=
2 π j ( n−τ )
=
2π j ( n−τ )
c −ω c
h d ( n )=
2π [ j ( n−τ )
= ]
1 2 j sin ( ω c ( n−τ ) ) sin ( ωc ( n−τ ) )
π ( n−τ )
,n≠τ
'
Using L Hospitals rule :h d ( n ) for ( n=τ )= [ ω c cos ( ωc ( n−τ ) )
π ] n=τ
=
ωC
π
Substituting, ω C =0.4 π , M =7 , τ=3 ,
{ {
sin ( 0.4 π ( n−3 ) )
, n≠ 3 sin ( 0.4 π ( n−3 ))
h d ( n )= π ( n−3 ) = , n ≠3
π ( n−3 )
0.4 π
, n=3 0.4 , n=3
π
Since M=7,
h d ( 0 )=h d ( 6 )=−0.0624
h d (1 ) =hd ( 5 ) =0.0935
h d ( 2 )=hd ( 4 ) =0.3027
h d (3 )=0.4
Window Function:
{
− jωτ
e ,−ω c ≤ ω ≤−ωC ∧+ω c 1 ≤ ω ≤+ω c2∧¿
Band Pass Filter: H d ( e ) =
jω
2 1
0 ,Otherwis e
2) Sampling the desired response (Frequency Sampling) can be done in two ways:
ωk=
2 πk
ωk =
2π k+
1
2
=
( )
2 π ( 2 k +1 ) π ( 2 k +1 )
=
M M 2M M
(Type 1 design) (Type 2 Design)
~
3) Inverse DFT of H ( k ) :(Type I Design)
M−1 j 2 πnk
1
h (n)=
M
∑~
H (k ) e M
, n=0,1, … , M −1
k=0
( )
M−1
1
remember , h ( n )= ∑ H ( k ) e
jω n
, for all n k
M k=0
~
For any filter, h(n) should be real. For h(n) to be real, H ( k ) should be in complex conjugate pairs,
then
~ ~ ~¿ M −1
H ( 0 ) isreal and H ( M −k ) = H ( k ) , k =1,2, … , for M odd
2
~ ~ ~¿ M ~ M
H ( 0 ) isreal∧ H ( M −k )= H ( k ) , k =1,2 ,… , −1∧ H
2 2
=0 for M even ( )
Filter Coefficients, h(n) can be given by:
{ }
j 2 πn j 2 πn 2 j 2 πn(M −2) j 2 πn ( M−1 )
1 ~ ~ ~ ~ ~
h (n)= H ( 0 )+ H ( 1 ) e M + H ( 2 ) e M + …+ H ( M −2 ) e M + H ( M −1 ) e M
M
j 2 πnk j 2 πn (M −k) j2 πnM j 2 πnk j 2 πnk − j 2 πn
If k =M −k , then ~
H ( k ) e N =~ H ( M −k ) e N =~ =~ =~
− j2 πn−
H ( M −k ) e M M
H ( M −k ) e M
H ( M −k ) e M
Since, e j 2 πn=cos 2 πn+ jsin 2 πn=1 , where n is aninteger
j 2 πn − j 2 πn
~
H ( 1 ) e M =~ H ( M −1 ) e M
j2 πn2 − j 2 πn 2
~ ~
H ( 2 ) e M = H ( M −2 ) e M
~ ~ ~ ~
Since H ( M −k ) = H ¿ ( k ) , then, H ( M −1 )= H ¿ ( 1 )∧for other terms also ,
{ }
j 2 πn j 2 πn 2 − j 2 πn 2 − j 2 πn
1 ~ ~ M ~ M ~¿ M ~¿
h (n)= H ( 0 )+ H ( 1 ) e + H ( 2) e + …+ H ( 2 ) e + H (1 ) e M
M
∵ ( a+ jb ) ( cosθ+ jsinθ )+ ( a− jb )( cosθ− jsinθ )=2∗Real Term of {( a+ jb ) ( cosθ+ jsinθ ) }
{ }
M −1
{ } for M odd
2 j 2 πn k
1 ~ ~
h (n)= H (0)+ ∑ 2 ℜ H ( k ) e M
M k=1
{ }}
M
−1
{
2 j 2 πnk
1 ~ ~
h ( n) = H ( 0) + ∑ 2 ℜ H ( k ) e M
for M even
M k=1
AVR 10
M +1 M −1
Thus filter coefficients can be found using
2
¿
2 ( )
+1 points rather using M points. This
~
simplification is done using Symmetry property of the h(n) and H ( k) .
4) Z-Transform to find the system Function:
M−1
H ( z )= ∑ h ( n ) z−n
n=0
Type 2 Design:
ωk=
2π k+( 12 ) = 2 π (2 k +1 ) = π (2 k + 1)
M 2M M
( )
π ( 2k +1)
~ j
2 ¿ Frequency Sampling : H ( k )=H d ( e ) =H d e
jω k M
~
3) Inverse DFT of H ( k ) :
M−1 j 2 πnk
1
h (n)=
M
∑~
H (k ) e M
, n=0,1, … , M −1
k=0
Condition for h(n) to be real is:
~
H ( M −k −1 )=~ H ¿ ( k ) , k =0,1 , … ,
M −1
2
−1∧~H
M −1
2
=0 for M odd ( )
~ ~¿ M
H ( M −k −1 )= H ( k ) , k =0,1 , … , −1 for M even
2
Filter coefficient , h ( n ) is given by :
M −3
{ } for M odd
2 jnπ ( 2 k+1 )
1 ~
h (n)=
M
∑ 2 ℜ H (k ) e M
k=0
M
−1
{ } for M even
2 jnπ ( 2 k+1 )
1
h (n)= ∑ 2 ℜ ~ H (k)e M
M k =0
4) Z-Transform to find the system Function:
M−1
H ( z )= ∑ h ( n ) z−n
n=0
x(n-(M-1))
h(M-1)
h(1) h(2)
h(0)
M −1
Fig: 1.7 FIR Direct Form implementation of y ( n )= ∑ x ( n−k ) h ( k )
k=0
AVR 11
FIR filter with Linear Phase property can be implemented with less hardware compared to Non
Linear phase FIR filter.
AVR 12
k=0 k=0
M −1
Y (z)
= ∑ h ( k ) z−k
H ( z )=
X ( z ) k=0
−1 −2 − ( M −2) − ( M −1 )
H ( z )=h ( 0 ) +h ( 1 ) z + h ( 2 ) z +…+h ( M −2 ) z +h ( M −1 ) z
For alinear phase filter , h ( n ) =±h ( M −1−n ) , n=0,1… M −1
i .e . h ( 0 )=± h ( M −1 ) ,h ( 1 )=±h ( M −2 ) , . .
−1 −2 − ( M −2) − ( M −1)
H ( z )=h ( 0 ) +h ( 1 ) z + h ( 2 ) z +… ± h (1 ) z ±h ( 0 ) z
H ( z )=h ( 0 ) { 1 ± z−( M −1) } +h ( 1 ) { z ± z−( M−2) }+… h
−1 M
2
−1 {.. ± .. } ( )
( Assume M even above )
H ( z )=z 2
h (0) z 2
±z 2 2
±z 2
[ ] for M even
−1
− ( M−1) 2 ( M−1−2 n) − ( M −1−2 n)
H ( z )=z 2
∑ h ( n) z 2
±z 2
n=0
Similarly for M odd,
{( }
M −3
[ ] for M odd
− ( M−1) ( M −1−2 n) −( M −1−2 n)
)
2
M −1
H ( z )=z 2
h + ∑ h ( n) z 2
±z 2
2 n=0
∑ h( n) [e ]
−1
− jω ( M −1 ) 2 ( M −1−2n ) ( M−1−2 n)
jω − jω
2 2 2
H ( ω ) =e +e
n=0 Basic Math:
M
∑ h( n) [e ]
−1
− jω ( M −1 ) 2 ( M −1−2n ) ( M−1−2 n)
jω − jω jθ
H ( ω ) =e 2 2
+e 2 e =cos θ+ jsinθ
n=0
M
−1
− jω ( M −1 ) 2
H ( ω ) =e 2
∑ 2 h ( n ) cosω ( M −1−2
2
n
) for M even
n=0
− jω ( M −1 )
H ( ω ) =e 2
Hr (ω )
Let, H r ( ω ) is real function of ω∧is given by :
M
−1
2
H r ( ω )= ∑ 2 h ( n ) cosω
n=0
( M −1−2
2
n
) for M even
M−3
2
Similarly , H r ( ω )=h ( M2−1 )+ ∑ 2 h ( n) cosω ( M −1−2
n=0 2
n
) for M odd
Phase:
θ ( ω )=−ω ( M2−1 )=−ωτ → Linear Phase
AVR 13
∑ h( n) [e ]
−1
− jω ( M −1 ) 2 ( M−1−2n ) ( M −1−2n )
jω − jω jθ
H ( ω ) =e 2 2
−e 2
e =cos θ+ jsinθ
n=0
j( )
π
M
− jω ( M −1 ) 2
−1
[ jω
( M−1−2n )
− jω
( M −1−2n )
]
j=cos () π
2
+ jsin ()
π
2
=e
2
H ( ω ) =e 2
∑ h( n) e 2
−e 2
M
−1
− jω ( M −1 )
()
π 2
∑ 2 h ( n ) sinω ( M −1−2 )
j
2 2 n
H ( ω ) =e e
n=0 2
j( + )
−ω ( M−1 ) π
2 2
Let , H ( ω ) =e H ( ω) r
M
−1
2
H r ( ω )= ∑ 2 h ( n ) sinω
n=0
( M −1−2
2
n
) for M even
M−3
2
Similarly , H r ( ω )=h ( M2−1 )+ ∑ 2 h ( n) sinω ( M −1−2
n=0 2
n
) for M odd
Phase:
−ω ( M −1 ) π
θ ( ω )= +
2 2
Note:
Y ( z ) M −1
= ∑ h (k ) z
−1 −k
Replace z by z ∈ H ( z ) =
X ( z ) k=0
M−1
H ( z−1 )= ∑ h ( k ) z+ k
k =0
− ( M −1)
Multiply by z on both sides ,
M−1
z − ( M−1)
H ( z ) = ∑ h ( k ) z −( M −1−k )
−1
k=0
Assume , n=M −1−k , then when k =0 , n=M −1
when k =M −1 , n=0
h ( k )=h ( M −1−n )=h ( n ) ( Sincelinear phase )
M−1
H ( z ) = ∑ h ( n ) z =H ( z )
− ( M−1) −1 −n
z
n=0
Anti-Symmetric FIR filter can’t be used to design Low Pass Filter whereas Symmetric FIR
filter can be used to design Low Pass Filter and also other filters.
AVR 15
Kaiser window
Kaiser window is an optimal window which have reduced main lobe transition and side lobe
width (in contrast to other windows discussed earlier).
{ {[ ( )] }
2 1
n−α 2
I o β 1−
w ( n )= α M −1
, 0 ≤ n≤
I o ( β) 2
0 , Otherwise
Where, I o ( x ) isthe modified Bessel function of the first kind of order zero .
[ ( )]
∞ k 2
1 x
I 0 ( x )=1+ ∑
k =1 k! 2
Design Specifications:
Design Procedure:
(1) Determine δ
δ=min ( δ p , δ s )
( )
'
100.05 A −1p
−0.05 A's
where , δ p= '
0.05 A p
∧δ s =10
10 +1
{
0 , for A s ≤21
α = 0.5842 ( A s −21 ) +0.07886 ( A s−21 ) , for 21< A s ≤50
0.4
{
0.9222 , for A s ≤ 21
D= A s −7.95
, for A s >21
14.36
(5) Calculate the filter order for the lowest odd value of M
AVR 16
{
− jωτ
For high pass filter: H d ( e
jω
) = e ,−π ≤ ω ≤−ωc ∧ωc ≤ ω ≤ π
0 , Otherwise
AVR 17
Additional Problem:
Window Method:
1. Design a digital filter with
3π
H d ( e ) =e
jω −j3ω
, 0≤|ω|≤
4
3π
≤|ω|≤ π¿0,
4
Use Blackman Window with N=7. Realize the resulting filter in direct form.
Solution:
{
−j3ω π
e , 0 ≤|ω|≤
H d ( e )= jω 2
π
0, ≤|ω|≤ π
2
Determine the filter coefficients h(n) for M =7, using Type1 Frequency Sampling Technique.
Solution:
Frequency Sampling
Inverse DFT
~
To find H ( k ) :
{ {
− j 6 πk
~ − j3ω
H ( k )= e , k =0,1,6 = e 7 , k =0,1,6
k
0 ,k =2,3,4,5 0 ,k =2,3,4,5
To find h(n):
~
h ( n ) =Inverse DFT of H ( k )
M−1 M −1 j 2 πk 6 j 2 πnk
1 1 1 ~
∑~ ∑~
n
h (n)=
M
jω n
H (k ) e =
M
k
H (k ) e M
= ∑ H (k )e
7 k=0
7
k=0 k=0
{ }
j 2 πn j 2 πn 6
1 ~ ~ ~
h (n)= H (0)+ H (1)e 7 + H (6) e 7
7
~ ~ ~ ~ ~ ~
Since H ( k ) = H ¿ ( M −k ) → H ( 1 )= H ¿ ( 6 ) → H ¿ ( 1 )= H ( 6 ) , M −k =k → 7−1=1→ 6=1
{ }
j 2 πn − j 2 πn
1
h (n)= 1+~
H (1)e 7
+~
H¿ (1) e 7
7
{ }
−j6 π j 2 πn + j6π − j 2 πn
1 7 7 7 7
h ( n ) = 1+e e +e e
7
1 {
h ( n ) = 1+ e
7
j(
2 π ( n−3)
7 )+ e− j( 2 π (n−3
7
)
)}= 1
7 {
1+2 cos ( 2 π ( n−3
7
)
)}
h ( n ) =0.1429+0.2857 cos ( 0.2857 π ( n−3 ) )
Design over here.