lecture 11 - fir filter design
TRANSCRIPT
![Page 1: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/1.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
1
Lecture 11: LTI FIR filter design
Instructor: Dr. Gleb V. Tcheslavski
Contact: [email protected]
Office Hours: Room 2030
Class web site: http://ee.lamar.edu/gleb/dsp/index.htm
![Page 2: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/2.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
2
Preliminary considerations
1
0
( )M
kk
k
H z h z
FIR filter:
unit-pulse responsetransfer function
(11.2.1)
Here M-1 is the filter order.M is the number of filter’s coefficients. Assuming that M is odd:
1
10
00 0
( ) ; 1
Mk
kMk k
kk
b zH z h z a
a
BTW, using our “rational notation”:
(11.2.2)
1 2 ( 2) ( 1)0 1 2 2 1
31 1 112
2 2 21
1022
( ) ... M MM M
MM M MMk k
M k kMk k
H z h h z h z h z h z
z h h z h z
(11.2.3)
![Page 3: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/3.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
3
Preliminary considerations
3 311 12 2
22 21 1
0 02
311 12
22 21 1
02
( )
M MMM M kk
M k M kk k
MMM M kk
M k M kk
H z z h h z h z
z h h z h z
For an FIR filter to have a linear phase:
*1k M kh h
That means an even symmetry of the coefficients.
(11.3.1)
(11.3.2)
Remember: FIR filters are always stable (no poles other than at the origin)!
![Page 4: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/4.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
4
Preliminary considerations
Since the filter is stable:3
11 1222 2
1
31 2
21
0
02
2
( )
12 cos2
( )
k k
MMM M j kj jj
MMj
M k k
kj h j hM k
k
k
jc
H e
Me
e h h
h h
e e e e
e
k h
R
Here is a real function of frequency.( )jcR e
(11.4.1)
1
2Mjj j
cH e e R e
As a result of symmetry:
(11.4.2)
![Page 5: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/5.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
5
Preliminary considerations
Therefore:
1 021 0
2
jc
j
jc
M if R eH e
M if R e
Generalized linear phase
We can use to design ANY amplitude of frequency response: LPF, HPF, BPF,…
jcR e
When changes sign, the phase undergoes an abrupt change of 1800 jcR e
In M is even: 22
0
1( ) 2 cos2
M
jc k k
k
MR e h k h
(11.5.1)
(11.5.2)
![Page 6: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/6.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
6
Preliminary considerations
*1k M kh h
32
0
1( ) 2 sin ;2
M
js k k
k
MR e h k h M is odd
An FIR filter will also have a linear phase in the case of odd symmetry of filter coefficients (antisymmetric impulse response), i.e.:
It can be shown that
22
0
1( ) 2 sin ;2
M
js k k
k
MR e h k h M is even
(11.6.1)
(11.6.2)
(11.6.3)
1
2Mj
j jsH e e jR e
Therefore:
(11.6.4)
BTW:
H j differentiator
H j sign Hilbert transformer
(11.6.5)
(11.6.6)
![Page 7: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/7.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
7
Preliminary considerations
Thus:
1 02 23 1 02 2
js
j
js
M if R eH e
M if R e
Generalized linear phase
(11.7.1)
Summarizing, a unit-pulse response of a GLP FIR filter must satisfy:*1k M kh h (11.7.2)
1
0
( )M
kk
k
H z h z
(11.7.3)
12
, , , ,...
,
jMj cj
js
R e LPF HPF BPF BSFH e e
jR e differentiators Hilbert transformers
(11.7.4)
We only need to specify (M-1)/2 (odd M) or M/2 unique coefficients (even M).
![Page 8: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/8.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
8
Preliminary considerations
Combining (11.7.2) and (11.7.3), we arrive at:
1
( 1
1 1* * ( 1)1
0 0 0
)1
( 1) * *
0
*
( 1
1
)M M M
k k m Mk M k m
k k m
MM m
mm
M
H z h z h z m M k h z
z h z z H z
(11.8.1)
0jhas a zero at z z re *
0
1 1 jhas a zero at z ez r
-1 -0.5 0 0.5 1
-1
-0.5
0
0.5
1
4
Real PartIm
agin
ary
Par
t
Example: if M = 5:1 2 3 4
0 1 2 3 4( )H z h h z h z h z h z
Has two pairs of reciprocal zeros.
firls(4,[0 0.25],[1 0]);
![Page 9: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/9.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
9
Preliminary considerations
There are four types of real GLP FIR filters:
indicate “structural zeros”
Type I: symmetric hn, odd M (number of coefficients) – even order.
Type II: symmetric hn, even M
Type III: antisymmetric hn, odd M
Type IV: antisymmetric hn, even M
![Page 10: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/10.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
10
Preliminary considerations
1. For M = 4, symmetrical pulse response ( Type II FIR):
1 2 3 1 2 30 1 2 3 0 1 1 0( )H z h h z h z h z even symmetry h h z h z h z
1 1 01 0( ) 0z
h hH hz h
2. For M = 4, antisymmetrical pulse response ( Type IV FIR):
1 2 3 1 2 30 1 2 3 0 1 1 0( )H z h h z h z h z odd symmetry h h z h z h z
1 1 01 0( ) 0z
hH h hz h
3. For M = 5, antisymmetrical pulse response ( Type III FIR):
1 2 3 4 1 2 3 40 1 2 3 4 0 1 2 1 0( )H z h h z h z h z h z odd symmetry h h z h z h z h z
0 1 2 1 0 210( ) 0
zh h h h hH z h
1 0 1 2 1 0 2 00( )z
h h hH z h h h
(11.10.1)
(11.10.2)
(11.10.3)
This
is w
here
stru
ctur
al z
eros
com
e fro
m…
![Page 11: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/11.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
11
Preliminary considerations
As a result of structural zeros…
Type II FIR HPF would have a zero at - specs will be violated!Type III FIR HPF would have a zero at - specs will be violated!Type IV FIR LPF would have a zero at 0 - specs will be violated!
If something like tis happens, increase or decrease the FIR order to change the type of your filter.
We need to be careful with selection of filter orders!
![Page 12: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/12.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
12
1. Least-square error minimization
The desired magnitude response (something we specify):
,j j n
d d nDTFTn
H e h e (11.12.1)
Filter coefficients could be found as:
,12
j j nd n dh H e e d
Example: Ideal LPF
,
2 sin12
s2
i1
n2
c c c
c
j n j ncj n
Lc
Pc
Fc
n
j ne eh enn
dj n
(11.12.2)
(11.12.3)
Not causal, infinite length!
We need to preserve the main features while making the filter causal.
![Page 13: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/13.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
13
1. Least-square error minimization
The filter specified by (11.12.3) has an infinite impulse response. Therefore, we need to truncate it at some point to make an FIR filter. As a criterion for such truncation, we need to minimize the approximation error (the difference between the desired and the truncated frequency responses).
The magnitude of the frequency response of the “truncated filter”:
,
Uj j n
t t nn L
H e h e
Where L and U are points at which the pulse response was truncated.
Therefore, the objective is to find a finite-duration impulse response sequence, whose DTFT would approximate the desired frequency response.
(11.13.1)
We need to minimize the least-square integral error of approximation.
![Page 14: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/14.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
14
1. Least-square error minimization
In particular:
21min2
j jR t dH e H e d
12 2 2
, , , ,
2
1, ,
U L
t n d n dR t n d n n d nn L n n Un
h h h h h h
Apparently, to minimize R (LS error), we select ht,n = hd,n for n = L…U. Moreover, GLP requires symmetry of filter coefficients, therefore L = -U.
The best finite length approximation of the ideal infinite length impulse response in the LS error sense is obtained by truncation.
To make the resulting FIR causal, we need to shift it by L radians.
(11.14.1)
(11.14.2)
![Page 15: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/15.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
15
1. Least-square error minimization
Relating the point of truncation to the FIR filter order: L = (M – 1)/2
,
1sin21
2
cc
LP FIR n
c
Mnh
Mn
Note: filter length M (number of filter coefficients) can be both even or odd.
(11.15.1)
-50 0 50-0.1
0
0.1
0.2
0.3
n
h n
0 20 40 60 80 100-0.1
0
0.1
0.2
0.3
n
h n
0 0.2 0.4 0.6 0.8 1-4000
-2000
0
Normalized Frequency ( rad/sample)
Pha
se (d
egre
es)
0 0.2 0.4 0.6 0.8 1-100
-50
0
Normalized Frequency ( rad/sample)
Mag
nitu
de (d
B)
Non-causal Causal
![Page 16: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/16.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
16
2. Windowing effects
We can view the truncation of the infinite impulse response of an ideal filter as windowing. In frequency domain, this operation is equivalent to convolution of a frequency response of the window function with the frequency response of an ideal filter.
, ,t n d n nh h w
( )12
j j jt dH e H e W e d
from the Modulation theorem:
-1 -0.5 0 0.5 1-0.2
0
0.2
0.4
0.6
0.8
1
1.2
/
|Ht()|
|W()||Hd()|
(11.16.1)
(11.16.2)
Gibbs phenomenon(comes from truncated
Fourier series)
Ripples of equal magnitude in PB and SB
Transition band – another window artifact
W R:
![Page 17: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/17.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
17
2. Windowing effects: window types
As discussed previously, different window functions can be used…
Window MLW (4/M) PSL (dB) TB (2/M) Max SB ripple (dB)
Rectangular 0.9 -13 0.9 -21
Hanning 2 -31 3.1 -44
Hamming 2 -41 3.3 -53
Blackman 3 -57 5.5 -74
Window properties Filter properties
Fixed windows:
![Page 18: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/18.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
18
2. Windowing effects: window types
1, 0,1,... 1RnW n M Rectangular:
Hanning:
Hamming:
21 2 21 cos sin , 0,1,... 12 1 1
Nn
n nW n MM M
20.54 0.46cos , 0,1,... 11
Mn
nW n MM
2 40.42 0.5cos 0.08cos , 0,1,... 11 1
Bn
n nW n MM M
Blackman:
(11.18.1)
(11.18.2)
(11.18.3)
(11.18.4)
![Page 19: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/19.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
19
2. Windowing effects: window types
2
0
0
21 11
, 0,1,... 1Kn
nIM
W n MI
Kaiser window:
(11.19.1)
2
01
2( ) 1
!
m
m
xI x
m
Where: (11.19.2)
Normally, 15-20 terms in the summation are sufficient.
Note: if = 0, WnK = Wn
R.
Adjustable windows:
![Page 20: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/20.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
20
2. Windowing effects: window types
TB (2/M) Max SB ripple (dB)2 1.5 -29
3 2.0 -37
4 2.6 -45
5 3.2 -54
7 4.5 -72
8 5.1 -81
Properties:
Kaiser window is the most frequently used for the FIR filter design.
Hanning
Hamming
Blackman
![Page 21: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/21.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
21
2. Windowing: experimental design
For the given transition band:
2s pf
Stop-band attenuation: 20lg sA
Order estimate:7.95 1
14.36AM
f
Adjustable parameter: 0.4
0.1102 ( 8.7) 50
0.5842 ( 21) 0.07886 ( 21) 21 500 21
A A dB
A A AA
(11.21.1)
(11.21.2)
(11.21.3)
(11.21.4)M controls transition band, changes ripples.
Note: in practice, ripples in SB and PB are approximately equal. If this does not hold, need to select minimum of s, p.
![Page 22: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/22.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
22
2. Windowing: experimental design
Example 11.1: design an FIR LPF using a Kaiser window for the following specs:
0.3 ; 0.5 ; 40 minp s A dB SB attenuation
The transition band:0.5 0.3 0.1
2 2s pf
7.95 40 7.951 1 23.3214.36 14.36 0.1AM
f
Order:
0.40.5842 ( 21) 0.07886 ( 21) 3.4A A Parameter:
We select M = 24, = 4. The filter is given by (11.15.1) with the cutoff frequency:
0.42
p sc
The resulting filter is a type II FIR which is ok for LPF.
,sin ;c
t n nn
h w L n Ln
The transfer function:
![Page 23: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/23.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
23
3. Frequency sampling
The desired frequency response
1
,0
Mj j n
d d nDTFT n
H e h e
can be specified by its frequency samples at equally spaced (discrete) frequencies:
2k k
M
Where
(11.23.1)
(11.23.2)
10,1,... ,220,1,... ,
2
M M oddk
M M even
= 0:
00.5
no offsetoffset by M
(11.23.3)
(11.23.4)
2/M
2/M/M
= 0.5:
![Page 24: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/24.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
24
3. Frequency sampling
The sampled frequency response will be:
21 ( )
, ,0
, 0,1,... 1k
M j k nj Md k d d n
n
H H e h e k M
Evaluating IDFT:
21 ( )
,0
1 , 0,1,... 1M j k n
Mn d k
k
h H e n MM
Therefore, we can compute the filter coefficients from the specified M frequency samples.
(11.24.1)
(11.24.2)
Since hn is real: *k M kH H
Since hn is symmetric, we only need to specify either (M+1)/2 (M is odd) or M/2 (M is even) frequency samples to determine the pulse response.
(11.24.3)
![Page 25: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/25.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
25
3. Frequency sampling
We can rewrite the FIR filter frequency response (11.7.4) as:
12
1
12 2
1
,
, V
Mjjr n M nj
Mjj
r n M n
H e e symmetric h h typesH e
H e e antisymmetric h h types
2 ; 0,1,... 1kk k MM
Sampled at the frequencies
the response becomes:
2 1
2 22 Mj kM
k rH H k eM
(11.25.1)
(11.25.2)
(11.25.3)
![Page 26: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/26.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
26
3. Frequency sampling
Here:0 n
n
symmetric hantisymmetric h
For simplicity, we specify the following set of real frequency samples:
21 ; 0,1,... 1kk rG H k k M
M
Therefore: 2 1
2 2Mj k
Mj kk kH G e e
0 0; 4 ...
1 2different cases
(11.26.1)
(11.26.2)
(11.26.3)
![Page 27: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/27.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
27
3. Frequency sampling
Case 1: 00 : 2
n
k
symmetric hno offset k M
2 1 2
2 2M M kj k j k jj k j kM M M
k
kM
kk
j
k G e e GH Ge e e e
2 2 2 21 1 1
0 0 0 1
2 ( ) 2 ( )
01 1
2 1 2 12
01
1 1 1
1
1
k k kM M U Mj kn j j kn j j kn j j knM M M M M M M
k k k kk k k k U
k M kU Uj j kn j j M k nM M M M
k M kk k
U j k n j k nM
n
Mk k
k
H e G e e G e e G e eM M M
G G e e G e eM
G G e G eM
h
22
0
1
1
2 1
1 2 12 cos ; 0,1,...2
1
1
;
U
kk
Uj j n j j n
k
G G
e
k n n MM M
e e e
(11.27.1)
(11.27.2)
![Page 28: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/28.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
28
3. Frequency sampling
21 kk rG H k
M
Since hn is real:
*k M kH H
2 1 2 1*2 22 2M Mj k j M k
M Mr rH k e H M k eM M
Since Hr is real:
2 1 2 12 2
2 212 2
2 2
2 2 2
2 21 1
M Mj k j M kM M
r r
Mj j j Mr r r
k kj M k j k jr r
H k e H M k eM M
H k H M k e e H M k eM M M
H k H M k e e eM M
(11.28.1)
(11.28.2)
(11.28.3)
(11.28.4)
![Page 29: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/29.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
29
3. Frequency sampling
Therefore: k M kG G (11.29.1)
The number of coefficients (frequency samples) to be specified:
1;2
1;2
M odd MU
M even M
- forced zero at z = -1(11.29.2)
ˆ 0jnH e DFT h
Since the unit-pulse response is already evaluated, we can estimate the corresponding frequency response as its zero-padded DFT:
and check whether the specifications are satisfied.
![Page 30: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/30.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
30
3. Frequency sampling
Case 2: 01 2 : 2 ( 0.5)
n
k
symmetric hffset k M
0.52 11
2k
k rG H kM
0.50
2 2 1 12sin ; 0,1,... 12 2
U
n kk
h G k n n MM M
1;2
1;2
M odd MU
M even M
(11.30.1)
(11.30.2)
(11.30.3)
The desired frequency samples:
![Page 31: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/31.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
31
3. Frequency sampling
Case 3: 10 : 2
n
k
antisymmetric hno ffset k M
0.521 k
k rkG H
M
2 2
12
1
1 2 11 2 sin ;2
Mn
n M kk
h G G k n M is evenM M
(11.31.1)
(11.31.2)
The desired frequency samples:
1 2
1
2 2 1sin ;2
M
n kk
kh G n M is oddM M
(11.31.3)
![Page 32: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/32.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
32
3. Frequency sampling
0.50
2 2 1 1cos ; 0,1,... 12 2
U
n kk
h G k n n MM M
Case 4:
1
0.5 : 2 0.5n
k
antisymmetric h
ffset k M
0.5
2 0.51 k
k r
kG H
M
(11.32.1)
The desired frequency samples:
3 ;2
1;2
M odd MU
M even M
(11.32.2)
(11.32.3)
![Page 33: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/33.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
33
3. Frequency sampling
0 0.1 0.2 0.3 0.4 0.50
0.2
0.4
0.6
0.8
1
1.2
fractional frequency
|H(
)|
actualspecified
We specify the desired response in the SB and the PB only…
The stopband attenuation in this case (only SB and PB samples are given) is approximately -20 dB.
0 0.1 0.2 0.3 0.4 0.50
0.2
0.4
0.6
0.8
1
1.2
fractional frequency
|H(
)|
actualspecified
Alternatively, we can add transition sample(s) and make the frequency response smoother.
The stopband attenuation would be: for one TB sample: approximately -40 dB.for two TB sample: approximately -60 dB.for three TB sample: approximately -80 dB.
![Page 34: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/34.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
34
3. Frequency sampling
The transition band sample(s) “optimized” experimentally are:
# of TB samples Sample(s) value(s) SB attenuation, dBT1 0.3789795 – if = 0
0.3570496 – if = 0.5~ 40
T2 [0.1065 0.5886] ~ 60
T3 [0.025779 0.251635 0.723071][0.030957 0.27557 0.744348]Note: only one of them is correct.
~ 80
T4 [0.006061 0.09324 0.4082 0.82097] ~ 100
Effects of adding TB sample(s) are increased SB attenuation and wider TB. These samples must be optimized for the situation.Selection of the offset can help too.Note: we can specify any desired frequency response at the samples but not in between! Ultimately, we can view all frequency samples as the TB samples, which leads to an optimal (equiripple) design.
![Page 35: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/35.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
35
4. Optimal equiripple design
We are interested in a LP filter satisfying the following requirements:
1 1 ;
;
jp r p
js r s
H e PB
H e SB
Considering four FIR types:Type 1: symmetric pulse response, odd M. 1n M nh h
The real-valued frequency response:
13
2
0
2
01
2
1 12 co2
s2
cs o
M
jr
M
kM
nknH e a kM Mh h n k n
1
2
12
, 0
12 , 1,2,...2
M
k
M k
h k
a Mh k
(11.35.1)
(11.35.2)
(11.35.3)
(11.35.4)
![Page 36: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/36.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
36
4. Optimal equiripple design
Type 2: symmetric pulse response, even M. 1n M nh h
The real-valued frequency response:
2
2 2
0 1
1 2 12 cos cos2 2 2
M M
jr n k
n k
M MH e h n k n b k
2
12 , 1,2,...2k M k
Mb h k
(11.36.1)
(11.36.2)
(11.36.3)
1
2
0
cos cos2
M
jr k
k
H e b k
0 1
1
12 2
0.5
2 ; 1,2,... 22
2
k k k
M M
b bMb b b k
b b
Or:
Where:
(11.36.4)
(11.36.5)
![Page 37: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/37.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
37
4. Optimal equiripple design
Type 3: antisymmetric pulse response, odd M.
The real-valued frequency response:
3 1
2 2
0 1
1 12 sin sin2 2
M M
jr n k
n k
M MH e h n k n c k
12
12 , 1,2,...2k M k
Mc h k
(11.37.1)
(11.37.2)
(11.37.3)
3
2
0
sin cos
M
jr k
k
H e c k
3 12 2
1 1
0 2 1
2 ; 2 5 2
0.5
M M
k k k
c c
c c c k M
c c c
Or:
Where:
(11.37.4)
(11.37.5)
1n M nh h
![Page 38: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/38.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
38
4. Optimal equiripple design
Type 4: antisymmetric pulse response, even M.
The real-valued frequency response:
2
2 2
0 1
12 sin sin2 2
M M
jr n k
n k
M MH e h n k n d k
2
2 , 1,2,...2k M k
Md h k
(11.38.1)
(11.38.2)
(11.38.3)
2
2
0
sin cos2
M
jr k
k
H e d k
32 2
1
0 1 1
2
2 ; 2 3 2
0.5
M M
k k k
d d
d d d k M
d d d
Or:
Where:
(11.38.4)
(11.38.5)
1n M nh h
![Page 39: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/39.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
39
4. Optimal equiripple design
Therefore, we can express the frequency response for all FIR types as:
j j jrH e Q e P e
Where:
Filter type Q(ej) P(ej)
1: M odd 1
2: M even
3: M odd
4: M even
1n M nh h
1n M nh h
1n M nh h
1n M nh h
cos2
sin2
sin
1 2
0
cosM
kk
a k
2 2
0
cosM
kk
b k
3 2
0
cosM
kk
c k
2 2
0
cosM
kk
d k
(11.39.1)
0
cosL
jk
k
P e k
(11.39.2)
![Page 40: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/40.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
40
4. Optimal equiripple design
The desired frequency response:
10
jdr
in PBH e
in SB
We can compute and compare it to . Adjusting P() and
selecting filter type, we can obtain the desired frequency characteristic.
jdrH e j
rH e
We introduce the weighting function on the approximation error:
1j
s p
in SBW e
in PB
If s < p – bigger error in the passband is allowed.
(11.40.1)
(11.40.2)
![Page 41: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/41.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
41
4. Optimal equiripple design
The weighted approximation error:
ˆ ˆ
j j j j j j jdr r dr
jdrj j j
j
j
j j jdr
W e H e H e W e H e Q e P e
H eW e Q e P e
E e
W e H e P eQ e
(11.41.1)
Where the modified weighting function and the modified desired frequency response are:
ˆ j j jW e W e Q e
ˆj
drjdr j
H eH e
Q e
(11.41.2)
(11.41.3)
![Page 42: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/42.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
42
4. Optimal equiripple design
For the given error function E(e j), the Chebyshev (mini-max) approximation problem is to determine the filter parameters k that minimize the maximum absolute error over the frequency bands of interest:
0
ˆ ˆmin max min max cosk k
Lj j j
dr kover overS S k
E e W e H e k
(11.42.1)
Usually, the frequency bands of interest are specified as:
S PB SB (11.42.2)
a disjoint union of the passband and the stopband: 0 - p and s - (for a LPF). That is we “ignore” the transition band. More precisely speaking, error over the TB will not be optimized.The solution of this problem can be found via the alternation theorem.
![Page 43: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/43.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
43
4. Optimal equiripple design
The alternation theorem
A necessary and sufficient conditions for to be
unique and best approximation to in S is that the error function
E(e j) exhibit at least L + 2 extremal frequencies in S. That is, there must
exist at least L + 2 frequencies {i}, such that:
0
cosL
jk
k
P e k
ˆ j
drH e
1 2 2... L
max , 1,2,..., 2ij j
SE e E e i L
1i ij jE e E e
I.e., error alternates in sign between two successive extremal frequencies.
(11.43.1)
(11.43.2)
(11.43.3)
![Page 44: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/44.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
44
4. Optimal equiripple design: Example
Example 11.2: design a LPF. Since both the desired frequency response Hdr and the weighting function W are piecewise constants:
0
j jrj j j
dr r
dE e dH ed W e H e H ed d d
Consequently, the frequencies {i} that correspond to the peaks of the error function E(e j) also correspond to the peaks of Hr(e j), i.e., where the frequency response meets the specified error tolerance. Since Hr(e j) is a polynomial of degree L:
0 0 0 0
cos cos cosL L k L
n kjr k k nk k
k k n k
H e k
(11.44.1)
(11.44.2)
Hr(e j) has at most L-1 local minima and maxima and, therefore, at most L+1 extremal frequencies (bandages) since we add = 0 and = . Furthermore, the band-edge frequencies p and s are also extrema of the error function. Therefore, E(e j) has at most L+3 extremal frequencies.
![Page 45: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/45.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
45
4. Optimal equiripple design: Example
However, from the alternation theorem, there are at least L+2 extremal frequencies in E(e j). Thus the error function for the LPF design will have either L+2 or L+3 (extra ripple filters) extremal frequencies.
At the specified extremal frequencies n:
ˆ ˆ 1 ; 0,1,... 1n n nnj j j
drW e H e P e n L
Here represents the maximum value of the error function E(e j).
alternations
1 ˆ 0,1,... 1ˆ
n n
n
nj j
drjP e H e n L
W e
0
1 ˆcos 0,1,... 1ˆn
n
nLj
k n drjk
k H e n LW e
or alternatively:
(11.45.1)
(11.45.2)
(11.45.3)
![Page 46: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/46.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
46
4. Optimal equiripple design: Example
We can consider the {k} and as the unknown (to be determined) design parameters for the given extremal frequencies. Therefore:
0 0
1 1
11
00 0 0
11 1 1
11 1 1
ˆ ˆ1 cos cos 2 cos 1
ˆ ˆ1 cos cos 2 cos 1
ˆˆ1 cos cos 2 cos 1
L
LL
j jdr
j jdr
LL jj
drL L L
L W e H e
L W e H e
H eL W e
(11.46.1)
Note: initially, both the design parameters and the extremal frequencies are unknown. The above system can be solved by the iterative algorithm (Remez exchange algorithm):1)Guess the set of L + 1 extremal frequencies;2)Solve for {k} and ;3)Determine the error function as in (11.39.1);4)Determine the new set of L + 1 extremal frequencies and go to 2)…Keep running until E(e j) - convergence.
![Page 47: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/47.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
47
4. Optimal equiripple design
Alternatively, we can compute analytically [Rabiner ‘75]:
0 1 1
0 1 1
0 1 11
0 1 1
ˆ ˆ ˆ...
( 1)...ˆ ˆˆ
L
L
j j jdr dr L dr
LL
j j j
H e H e H e
W e W eW e
where:1
0
1cos cos
L
kn k nn k
(11.47.1)
(11.47.2)
Therefore, the initial guess of the L + 2 extremal frequencies allows us to compute the maximum value of the error . Thus:
0
, cosL
j kk
k
P e x x
(11.47.3)
![Page 48: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/48.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
48
4. Optimal equiripple design
Since we know that the polynomial at the points xn = cos n has the values:
( 1)ˆ , 0,1,... 1ˆ
n n
n
nj j
dr jP e H e n L
W e
the Lagrange interpolation formula can be used, which leads to
0
0
k
Lj
k kj k
L
k kk
P e x xP e
x x
Here: coscosk k
xx
0
1L
kn k nn kx x
(11.48.1)
(11.48.2)
(11.48.3)
(11.48.4)
(11.48.5)
![Page 49: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/49.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
49
4. Optimal equiripple design
Having the solution for P, we can compute the error function:
ˆ ˆj j j jdrE e W e H e P e
on a dense set of frequency points. Usually, 16M frequency points are sufficient. If the error exceeds the estimated tolerance , we select a new set of frequencies corresponding to the L+2 largest peaks of error function and the procedure starts from (11.45.1). New set of critical frequencies will lead to increased . As a result, the algorithm produces the optimal solution with equal ripples in the PB and the SB for the given M.
The order of the filter can be estimated as:
20lg 13ˆ 1
14.6 2s p
s p
M
(11.49.1)
(11.49.2)
![Page 50: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/50.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
50
Summary
Historically, the window-based algorithm was the first proposed method for FIR design. Its major disadvantage is the lack of precise control of the critical frequencies, such as s and p. These values, in general, depend on the type of the window and the filter length M.
The frequency sampling method is attractive since it specifies an arbitrary frequency response at the uniformly spaced frequencies and the transition band is a multiple of 2/M. However, no control for the response in between the samples.
The Chebyshev approximation method provides a total control of the filter specifications and may lead to an equiripple design. This way, the approximation error is spread evenly across the PB and SB, which leads to an optimal filter. This method is usually preferred.
![Page 51: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/51.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
51
Remarks and conclusions
Since orders of FIR filters can be quite high, these filters can introduce a considerable group delay, which is approximately M/2.
The following Matlab functions are handy for FIR design:fir1 – FIR filter design using the windowing methodfir2 – FIR filter design via the frequency sampling methodfirpm – Parks-McClellan optimal equiripple FIR designfirpmord - Parks-McClellan optimal equiripple FIR order estimator
![Page 52: Lecture 11 - FIR Filter Design](https://reader033.vdocuments.site/reader033/viewer/2022051101/577cc9d81a28aba711a4c7e7/html5/thumbnails/52.jpg)
ELEN 5346/4304 DSP and Filter Design Fall 2008
52
Appendix: the ideal transfer functions
LPF:
,
sin,c
LP n
nh n
n
HPF: ,
1 , 0
sin, 0
c
HP n c
nh n
nn
2 1,
sin sin, 0c c
BP n
n nh n
n n
2 1
,1 2
1 , 0
sin sin, 0
c c
BS nc c
nh
n nn
n n
BPF:
BSF:
(11.52.1)
(11.52.2)
(11.52.3)
(11.52.4)