Sie sind auf Seite 1von 52

ELEN 5346/4304 DSP and Filter Design Fall 2008

1
Lecture 11: LTI FIR filter design
Instructor:
Dr. Gleb V.
Tcheslavski
Contact:
gleb@ee.lamar.edu
Office Hours: Room
2030
Class web site:
http://ee.lamar.edu/gleb/
dsp/index.htm
ELEN 5346/4304 DSP and Filter Design Fall 2008
2
Preliminary considerations
1
0
( )
M
k
k
k
H z h z

=
=

FIR filter:
unit-pulse response transfer function
(11.2.1)
Here M-1 is the filter order.
M is the number of filters coefficients. Assuming that M is odd:
1
1
0
0
0
0
( ) ; 1
M
k
k
M
k
k
k
k
b z
H z h z a
a

=
=
= =

BTW, using our


rational notation:
(11.2.2)
1 2 ( 2) ( 1)
0 1 2 2 1
3
1 1 1
1
2
2 2 2
1
1
0
2
2
( ) ...
M M
M M
M
M M M
M
k k
M k k
M
k
k
H z h h z h z h z h z
z h h z h z

+
=
=
= + + + + +
(
(
= + +
(
(


(11.2.3)
ELEN 5346/4304 DSP and Filter Design Fall 2008
3
Preliminary considerations
3 3
1
1 1
2 2
2
2 2
1 1
0 0
2
3
1
1 1
2
2
2 2
1 1
0
2
( )
M M
M
M M
k
k
M k M k
k k
M
M
M M
k
k
M k M k
k
H z z h h z h z
z h h z h z

(



(


= =

(



(


=
(
(
= + +
(
(

(
| |
(
= + +
|
( |
\ .
(

For an FIR filter to have a linear phase:


*
1 k M k
h 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)!
ELEN 5346/4304 DSP and Filter Design Fall 2008
4
Preliminary considerations
Since the filter is stable:
3
1
1 1
2
2
2 2
1
3
1
2
2
1
0
0
2
2
( )
1
2 cos
2
( )
k k
M
M
M M
j k
j j
j
M
M
j
M k k
k
j h j h
M k
k
k
j
c
H e
M
e
e h h
h h
e e e e
e
k h
R
e
e e
e
e
e
e

(



(
Z Z

=
=

=
(
| |
(
(
| |
(
+ + |
( |
\ .

(
+ + Z
|
(
(

\ .
(
=

Here is a real function of frequency. ( )


j
c
R e
e
(11.4.1)
( ) ( )
1
2
M
j
j j
c
H e e R e
e
e e

=
As a result of symmetry:
(11.4.2)
ELEN 5346/4304 DSP and Filter Design Fall 2008
5
Preliminary considerations
Therefore:
( )
( )
( )
1
0
2
1
0
2
j
c
j
j
c
M
if R e
H e
M
if R e
e
e
e
e
e t

>

Z =

<

Generalized linear phase


We can use to design ANY amplitude of frequency response: LPF,
HPF, BPF,
( )
j
c
R e
e
When changes sign, the phase undergoes an abrupt change of 180
0

( )
j
c
R e
e
In M is even:
2
2
0
1
( ) 2 cos
2
M
j
c k k
k
M
R e h k h
e
e

=
| |
(
= +Z
|
(

\ .

(11.5.1)
(11.5.2)
ELEN 5346/4304 DSP and Filter Design Fall 2008
6
Preliminary considerations
*
1 k M k
h h

=
3
2
0
1
( ) 2 sin ;
2
M
j
s k k
k
M
R e h k h M is odd
e
e

=
| |
(
= +Z
|
(

\ .

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
2
2
0
1
( ) 2 sin ;
2
M
j
s k k
k
M
R e h k h M is even
e
e

=
| |
(
= +Z
|
(

\ .

(11.6.1)
(11.6.2)
(11.6.3)
( ) ( )
1
2
M
j
j j
s
H e e jR e
e
e e
(

(

=
Therefore:
(11.6.4)
BTW:
( )
( ) ( )
H j differentiator
H j sign Hilbert transformer
O = O
O = O
(11.6.5)
(11.6.6)
ELEN 5346/4304 DSP and Filter Design Fall 2008
7
Preliminary considerations
Thus:
( )
( )
( )
1
0
2 2
3 1
0
2 2
j
s
j
j
s
M
if R e
H e
M
if R e
e
e
e
t
e
t
e

>

Z =

<

Generalized linear phase


(11.7.1)
Summarizing, a unit-pulse response of a GLP FIR filter must satisfy:
*
1 k M k
h h

=
(11.7.2)
1
0
( )
M
k
k
k
H z h z

=
=

(11.7.3)
( )
( )
( )
1
2
, , , ,...
,
j
M
j
c
j
j
s
R e LPF HPF BPF BSF
H e e
jR e differentiators Hilbert transformers
e
e
e
e
(

(11.7.4)
We only need to specify (M-1)/2 (odd M) or M/2 unique coefficients (even M).
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 M
k M k m
k k m
M
M m
m
m
M
H z h z h z m M k h z
z h z z H z



= = =


=

= = = = =
= =

(11.8.1)
0
j
has a zero at z z re
u
= =
*
0
1 1
j
has a zero at z e
z r
u
= =
-1 -0.5 0 0.5 1
-1
-0.5
0
0.5
1
4
Real Part
I
m
a
g
i
n
a
r
y

P
a
r
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]);
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 h
n
,
odd M
(number of
coefficients)
even order.
Type II:
symmetric h
n
,
even M
Type III:
antisymmetric
h
n
, odd M
Type IV:
antisymmetric
h
n
, even M
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 3
0 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 0
1
0
( ) 0
z
h h H h z h
=
= +
2. For M = 4, antisymmetrical pulse response ( Type IV FIR):
{ }
1 2 3 1 2 3
0 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 0
1
0
( ) 0
z
h H h h z h
=
= +
3. For M = 5, antisymmetrical pulse response ( Type III FIR):
{ }
1 2 3 4 1 2 3 4
0 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 2
1
0 ( ) 0
z
h h h h h H z h
=
= + + = =
{ }
1
0 1 2 1 0 2
0 0 ( )
z
h h h H z h h h
=
= + = = +
(11.10.1)
(11.10.2)
(11.10.3)
T
h
i
s

i
s

w
h
e
r
e

s
t
r
u
c
t
u
r
a
l

z
e
r
o
s

c
o
m
e

f
r
o
m


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 t - specs will be violated!
Type III FIR HPF would have a zero at t - 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!
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 n
DTFT
n
H e h e
e e
=

(11.12.1)
Filter coefficients could be found as:
( )
,
1
2
j j n
d n d
h H e e d
t
e e
t
e
t

=
}
Example: Ideal LPF
( ) ( )
,
2 sin
1
2
s
2
i
1
n
2
c
c c
c
j n j n
c j n
L
c
P
c
F
c
n
j n
e e
h e
n
n
d
j n
e
e e
e
e
e
e
t t t
e
e
t e

= = = =
}
(11.12.2)
(11.12.3)
Not causal, infinite length!
We need to preserve the main features while making the filter causal.
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:
( )
,
U
j j n
t t n
n L
H e h e
e 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.
ELEN 5346/4304 DSP and Filter Design Fall 2008
14
1. Least-square error minimization
In particular:
( ) ( )
2
1
min
2
j j
R t d
H e H e d
t
e e
t
e
t

u =
}
1
2 2 2
, , , ,
2
1
, ,
U L
t n d n d R t n d n n d n
n L n n U n
h h h h h h

= = = +

=
u = = + +

Apparently, to minimize u
R
(LS error), we select h
t,n
= h
d,n
for n = LU.
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 eL radians.
(11.14.1)
(11.14.2)
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
,
1
sin
2
1
2
c
c
LP FIR n
c
M
n
h
M
n
e
e
t
e
| |
(

|
(

\ .
=

(

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 (t rad/sample)
P
h
a
s
e

(
d
e
g
r
e
e
s
)
0 0.2 0.4 0.6 0.8 1
-100
-50
0
Normalized Frequency (t rad/sample)
M
a
g
n
i
t
u
d
e

(
d
B
)
Non-causal Causal
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 n
h h w =
( ) ( ) ( )
( )
1
2
j j j
t d
H e H e W e d
t
e e
t

t

=
}
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
e/t

|H
t
(e)|
|W(e)|
|H
d
(e)|
(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
:
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 (4t/M) PSL (dB) TB (2t/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:
ELEN 5346/4304 DSP and Filter Design Fall 2008
18
2. Windowing effects: window types
1, 0,1,... 1
R
n
W n M = =
Rectangular:
Hanning:
Hamming:
2
1 2 2
1 cos sin , 0,1,... 1
2 1 1
N
n
n n
W n M
M M
t t | |
( (
= ~ =
|
( (


\ .
2
0.54 0.46cos , 0,1,... 1
1
M
n
n
W n M
M
t
(
= =
(


2 4
0.42 0.5cos 0.08cos , 0,1,... 1
1 1
B
n
n n
W n M
M M
t t
( (
= + =
( (


Blackman:
(11.18.1)
(11.18.2)
(11.18.3)
(11.18.4)
ELEN 5346/4304 DSP and Filter Design Fall 2008
19
2. Windowing effects: window types
( )
2
0
0
2
1 1
1
, 0,1,... 1
K
n
n
I
M
W n M
I
|
|
| |
(
|

(
|

\ .
= =
Kaiser window:
(11.19.1)
( )
2
0
1
2
( ) 1
!
m
m
x
I x
m

=
(
= + (
(

Where: (11.19.2)
Normally, 15-20 terms in the summation are sufficient.
Note: if | = 0, W
n
K
= W
n
R
.
Adjustable windows:
ELEN 5346/4304 DSP and Filter Design Fall 2008
20
2. Windowing effects: window types
| TB (2t/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
ELEN 5346/4304 DSP and Filter Design Fall 2008
21
2. Windowing: experimental design
For the given transition band:
2
s p
f
e e
t

=
Stop-band attenuation:
20lg
s
A o =
Order estimate:
7.95
1
14.36
A
M
f

~ +

Adjustable parameter:
0.4
0.1102 ( 8.7) 50
0.5842 ( 21) 0.07886 ( 21) 21 50
0 21
A A dB
A A A
A
|
>

~ + < <

<

(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 o
s
, o
p
.
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 min
p s
A dB SB attenuation e t e t = = =
The transition band:
0.5 0.3
0.1
2 2
s p
f
e e
t t
t t


= = =
7.95 40 7.95
1 1 23.32
14.36 14.36 0.1
A
M
f

~ + = + ~

Order:
0.4
0.5842 ( 21) 0.07886 ( 21) 3.4 A A | ~ + ~ Parameter:
We select M = 24, | = 4. The filter is given by (11.15.1) with the cutoff frequency:
0.4
2
p s
c
e e
e t
+
= =
The resulting filter is a type II FIR which is ok for LPF.
,
sin
;
c
t n n
n
h w L n L
n
e
t
= s s
The transfer function:
ELEN 5346/4304 DSP and Filter Design Fall 2008
23
3. Frequency sampling
The desired frequency response
( )
1
,
0
M
j j n
d d n
DTFT
n
H e h e
e e

=
=

can be specified by its frequency samples at equally spaced (discrete) frequencies:
( )
2
k
k
M
t
e o = +
Where
(11.23.1)
(11.23.2)
1
0,1,... ,
2
2
0,1,... ,
2
M
M odd
k
M
M even

o = 0:
0
0.5
no offset
offset by M
o
t

(11.23.3)
(11.23.4)
o = 0.5:
ELEN 5346/4304 DSP and Filter Design Fall 2008
24
3. Frequency sampling
The sampled frequency response will be:
( )
2
1
( )
, ,
0
, 0,1,... 1
k
M
j k n
j
M
d k d d n
n
H H e h e k M
t
o
e
o
e e

+
+
=
=
= = =

Evaluating IDFT:
2
1
( )
,
0
1
, 0,1,... 1
M
j k n
M
n d k
k
h H e n M
M
t
o
o

+
+
=
= =

Therefore, we can compute the filter coefficients from the specified M


frequency samples.
(11.24.1)
(11.24.2)
Since h
n
is real:
*
k M k
H H
o o +
=
Since h
n
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)
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:
( )
( )
( )
1
2
1
1
2 2
1
,
, V
M
j
j
r n M n
j
M
j
j
r n M n
H e e symmetric h h types
H e
H e e antisymmetric h h types
e
e
e
t
e
e


| |
+
|
\ .

= I, II

= III, I

2 ; 0,1,... 1
k
k
k M
M
o
e t
+
= =
Sampled at the frequencies
the response becomes:
| |
( )
2 1
2 2
2
M
j k
M
k r
H H k e
M
t t
| o
o
t
o
( | |
+
| (
\ .
+
| |
= +
|
\ .
(11.25.1)
(11.25.2)
(11.25.3)
ELEN 5346/4304 DSP and Filter Design Fall 2008
26
3. Frequency sampling
Here:
0
n
n
symmetric h
antisymmetric h
|

=

1

For simplicity, we specify the following set of real frequency samples:


( ) | |
2
1 ; 0,1,... 1
k
k r
G H k k M
M
o
t
o
+
| |
+ =
|
\ .
Therefore:
( )
2 1
2 2
M
j k
M j k
k k
H G e e
t t
| o
t
o o
( | |
+
| (
\ .
+ +
=
0 0
; 4 ...
1 2
different cases o |

= =

1

(11.26.1)
(11.26.2)
(11.26.3)
ELEN 5346/4304 DSP and Filter Design Fall 2008
27
3. Frequency sampling
Case 1:
0
0 : 2
n
k
symmetric h
no offset k M
|
o e t
=
= =
2 1
2
2
2
M
M k
j k
j k j
j k j k M
M M
k
k
M
k k
j
k
G e e G H G e e e e
t
t
t t
t t
| |

|
\ .
= = =
2 2 2 2
1 1 1
0 0 0 1
2 ( ) 2
( )
0
1 1
2 1 2 1
2
0
1
1 1 1
1
1
k k k
M M U M
j kn j j kn j j kn j j kn
M M M M M M M
k k k k
k k k k U
k M k
U U
j j kn j j M k n
M M M M
k M k
k k
U
j k n j k n
M
n
M
k k
k
H e G e e G e e G e e
M M M
G G e e G e e
M
G G e G e
M
h
t t t t t t t
t t t t
t t

= = = = +

= =
| |
+ +
|
\ .
=
(
= = = +
(

(
= + +
(

= + +

{ }
2 2
0
1
1
2
1
1 2 1
2 cos ; 0,1,...
2
1
1
;
U
k
k
U
j j n j j n
k
G G
e
k n n M
M M
e e e
t t t t
t
| |
|
=
=
\ .
(

| |
= + + =
`

(
= = =
(
( |
\ .

(11.27.1)
(11.27.2)
ELEN 5346/4304 DSP and Filter Design Fall 2008
28
3. Frequency sampling
( )
2
1
k
k r
G H k
M
t
| |
=
|
\ .
Since h
n
is real:
*
k M k
H H

=
| |
| |
2 1 2 1
*
2 2
2 2
M M
j k j M k
M M
r r
H k e H M k e
M M
t t
t t


| | | |
=
| |
\ . \ .
Since H
r
is real:
| |
| |
| | | |
( )
( ) | |
( )
( )
2 1 2 1
2 2
2 2
1
2 2
2 2
2 2 2
2 2
1 1
M M
j k j M k
M M
r r
M
j j
j M
r r r
k k
j M k j k j
r r
H k e H M k e
M M
H k H M k e e H M k e
M M M
H k H M k e e e
M M
t t
t t
t
t t t
t t
t t t
t t



| | | |
=
| |
\ . \ .
| | | | | |
= =
| | |
\ . \ . \ .
| | | |
=
| |
\ . \ .
(11.28.1)
(11.28.2)
(11.28.3)
(11.28.4)
ELEN 5346/4304 DSP and Filter Design Fall 2008
29
3. Frequency sampling
Therefore:
k M k
G G

= (11.29.1)
The number of coefficients (frequency samples) to be specified:
1
;
2
1;
2
M
odd M
U
M
even M

- forced zero at z = -1
(11.29.2)
( ) { }

0
j
n
H e DFT h
e
= ,
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.
ELEN 5346/4304 DSP and Filter Design Fall 2008
30
3. Frequency sampling
Case 2:
0
1 2 : 2 ( 0.5)
n
k
symmetric h
ffset k M
|
o e t
=
= o = +
( )
0.5
2 1
1
2
k
k r
G H k
M
t
+
| |
(
= +
|
(

\ .
0.5
0
2 2 1 1
2sin ; 0,1,... 1
2 2
U
n k
k
h G k n n M
M M
t
+
=
(

| || |
= + + =
`
( | |
\ .\ .
)

1
;
2
1;
2
M
odd M
U
M
even M

(11.30.1)
(11.30.2)
(11.30.3)
The desired frequency samples:
ELEN 5346/4304 DSP and Filter Design Fall 2008
31
3. Frequency sampling
Case 3:
1
0 : 2
n
k
antisymmetric h
no ffset k M
|
o e t
=
= o =
( )
0.5
2
1
k
k r
k
G H
M
t
+
| |
=
|
\ .
( )
( ) 2 2
1
2
1
1 2 1
1 2 sin ;
2
M
n
n M k
k
h G G k n M is even
M M
t

+
=
(

| |
= +
` (
|
\ .
)

(11.31.1)
(11.31.2)
The desired frequency samples:
( ) 1 2
1
2 2 1
sin ;
2
M
n k
k
k
h G n M is odd
M M
t

=
(

| |
= +
` (
|
\ .
)

(11.31.3)
ELEN 5346/4304 DSP and Filter Design Fall 2008
32
3. Frequency sampling
0.5
0
2 2 1 1
cos ; 0,1,... 1
2 2
U
n k
k
h G k n n M
M M
t
+
=
(

| || |
= + + =
`
( | |
\ .\ .
)

Case 4:
| |
1
0.5 : 2 0.5
n
k
antisymmetric h
ffset k M
|
o e t
=
= o = +
( )
| |
0.5
2 0.5
1
k
k r
k
G H
M
t
+
| | +
=
|
\ .
(11.32.1)
The desired frequency samples:
3
;
2
1;
2
M
odd M
U
M
even M

(11.32.2)
(11.32.3)
ELEN 5346/4304 DSP and Filter Design Fall 2008
33
3. Frequency sampling
0 0.1 0.2 0.3 0.4 0.5
0
0.2
0.4
0.6
0.8
1
1.2
fractional frequency
|
H
(
e
)
|


actual
specified
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.5
0
0.2
0.4
0.6
0.8
1
1.2
fractional frequency
|
H
(
e
)
|


actual
specified
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.
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, dB
T1 0.3789795 if o = 0
0.3570496 if o = 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 o 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.
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 ;
;
j
p r p
j
s r s
H e PB
H e SB
e
e
o o
o o
s s +
s s
Considering four FIR types:
Type 1: symmetric pulse response, odd M.
1 n M n
h h

=
The real-valued frequency response:
( )
1 3
2
0
2
0
1
2
1 1
2 co
2
s
2
c s o
M
j
r
M
k
M
n
k n
H e a k
M M
h h n k n
e
e e

= =


| |
= + = =
`
|
\ .
=
)

1
2
1
2
, 0
1
2 , 1, 2,...
2
M
k
M
k
h k
a
M
h k

=


=

(11.35.1)
(11.35.2)
(11.35.3)
(11.35.4)
ELEN 5346/4304 DSP and Filter Design Fall 2008
36
4. Optimal equiripple design
Type 2: symmetric pulse response, even M.
1 n M n
h h

=
The real-valued frequency response:
( )
2
2 2
0 1
1 2 1
2 cos cos
2 2 2
M M
j
r n k
n k
M M
H e h n k n b k
e
e e

= =

| | | |
= = = =
`
| |
\ . ) \ .

2
1
2 , 1, 2,...
2
k M
k
M
b h k

= =
(11.36.1)
(11.36.2)
(11.36.3)
( )
1
2
0
cos cos
2
M
j
r k
k
H e b k
e
e
e

=
=

0 1
1
1
2 2
0.5
2 ; 1, 2,... 2
2
2
k k k
M M
b b
M
b b b k
b b

=
= =
=
Or:
Where:
(11.36.4)
(11.36.5)
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 1
2 sin sin
2 2
M M
j
r n k
n k
M M
H e h n k n c k
e
e e

= =

| |
= = = =
`
|
\ . )

1
2
1
2 , 1, 2,...
2
k M
k
M
c h k

= =
(11.37.1)
(11.37.2)
(11.37.3)
( )
3
2
0
sin cos
M
j
r k
k
H e c k
e
e e

=
=

( )
3 1
2 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

+
=
= s s
+ =
Or:
Where:
(11.37.4)
(11.37.5)
1 n M n
h h

=
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
1
2 sin sin
2 2
M M
j
r n k
n k
M M
H e h n k n d k
e
e e

= =

| |
= = = =
`
|
\ . )

2
2 , 1, 2,...
2
k M
k
M
d h k

= =
(11.38.1)
(11.38.2)
(11.38.3)
( )
2
2
0
sin cos
2
M
j
r k
k
H e d k
e
e
e

=
=

( )
3
2 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

=
= s s
=
Or:
Where:
(11.38.4)
(11.38.5)
1 n M n
h h

=
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 j
r
H e Q e P e
e e e
=
Where:
Filter type Q(e
je
) P(e
je
)
1: M odd 1
2: M even
3: M odd
4: M even
1 n M n
h h

=
1 n M n
h h

=
1 n M n
h h

=
1 n M n
h h

=
cos
2
e
sin
2
e
sine
( ) 1 2
0
cos
M
k
k
a k e

( ) 2 2
0
cos
M
k
k
b k e

( ) 3 2
0
cos
M
k
k
c k e

( ) 2 2
0
cos
M
k
k
d k e

(11.39.1)
( )
0
cos
L
j
k
k
P e k
e
o e
=
=

(11.39.2)
ELEN 5346/4304 DSP and Filter Design Fall 2008
40
4. Optimal equiripple design
The desired frequency response:
( )
1
0
j
dr
in PB
H e
in SB
e

We can compute and compare it to . Adjusting P(e) and


selecting filter type, we can obtain the desired frequency characteristic.
( )
j
dr
H e
e
( )
j
r
H e
e
We introduce the weighting function on the approximation error:
( )
1
j
s p
in SB
W e
in PB
e
o o

If o
s
< o
p
bigger error in the passband is allowed.
(11.40.1)
(11.40.2)
ELEN 5346/4304 DSP and Filter Design Fall 2008
41
4. Optimal equiripple design
The weighted approximation error:
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )
( ) ( )
( )
( )
( ) ( ) ( ) ( )

j j j j j j j
dr r dr
j
dr
j j j
j
j
j j j
dr
W e H e H e W e H e Q e P e
H e
W e Q e P e
E e
W e H e P e
Q e
e e e e e e e
e
e e e
e
e
e e e
( (
= =

(
( =
(

(

(11.41.1)
Where the modified weighting function and the modified desired frequency
response are:
( ) ( ) ( )

j j j
W e W e Q e
e e e
=
( )
( )
( )

j
dr
j
dr
j
H e
H e
Q e
e
e
e
=
(11.41.2)
(11.41.3)
ELEN 5346/4304 DSP and Filter Design Fall 2008
42
4. Optimal equiripple design
For the given error function E(e
je
), the Chebyshev (mini-max)
approximation problem is to determine the filter parameters o
k
that
minimize the maximum absolute error over the frequency bands of interest:
{ }
( )
{ }
( ) ( )
0

min max min max cos
k k
L
j j j
dr k
over over S S
k
E e W e H e k
e e e
o o e e
o e
e e
=
(
(
(
=
(
(


(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 - e
p
and e
s
- t (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.
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
je
) exhibit at least L + 2 extremal frequencies in S. That is, there must
exist at least L + 2 frequencies {e
i
}, such that:
( )
0
cos
L
j
k
k
P e k
e
o e
=
=

( )

j
dr
H e
e
1 2 2
...
L
e e e
+
< < <
( ) ( )
max , 1, 2,..., 2
i
j j
S
E e E e i L
e e
ee
= = +
( ) ( )
1 i i
j j
E e E e
e e
+
=
I.e., error alternates in sign between two successive extremal frequencies.
(11.43.1)
(11.43.2)
(11.43.3)
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 H
dr

and the weighting function W are piecewise constants:
( )
( ) ( ) ( )
{ }
( )
0
j j
r
j j j
dr r
dE e dH e
d
W e H e H e
d d d
e e
e e e
e e e
(
= = =

Consequently, the frequencies {e
i
} that correspond to the peaks of the error
function E(e
je
) also correspond to the peaks of H
r
(e
je
), i.e., where the
frequency response meets the specified error tolerance. Since H
r
(e
je
) is a
polynomial of degree L:
( ) ( ) ( )
0 0 0 0
cos cos cos
L L k L
n k
j
r k k nk k
k k n k
H e k
e
o e o | e o e
= = = =
= = =

(11.44.1)
(11.44.2)
H
r
(e
je
) has at most L-1 local minima and maxima and, therefore, at most L+1
extremal frequencies (bandages) since we add e = 0 and e = t. Furthermore, the
band-edge frequencies e
p
and e
s
are also extrema of the error function.
Therefore, E(e
je
) has at most L+3 extremal frequencies.
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
je
). 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 e
n
:
( ) ( ) ( )
( )

1 ; 0,1,... 1
n n n
n
j j j
dr
W e H e P e n L
e e e
o
(
= = +

Here o represents the maximum value of the error function E(e
je
).
alternations
( )
( )
( )
( )
1

0,1,... 1

n n
n
n
j j
dr
j
P e H e n L
W e
e e
e
o
+ = ; = +
( )
( )
( )
0
1

cos 0,1,... 1

n
n
n
L
j
k n dr
j
k
k H e n L
W e
e
e
o
o e
=

+ = ; = +

or alternatively:
(11.45.1)
(11.45.2)
(11.45.3)
ELEN 5346/4304 DSP and Filter Design Fall 2008
46
4. Optimal equiripple design: Example
We can consider the {o
k
} and o as the unknown (to be determined)
design parameters for the given extremal frequencies. Therefore:
( )
( )
( )
( )
( )
( )
( )
0 0
1 1
1 1
0
0 0 0
1
1 1 1
1
1 1 1

1 cos cos 2 cos 1

1 cos cos 2 cos 1

1 cos cos 2 cos 1
L
L L
j j
dr
j j
dr
L
L
j j
dr L L L
L W e H e
L W e H e
H e L W e
e e
e e
e e
o
e e e
o
e e e
o
e e e
o
+
+ +
+
+ + +
( ( (
( ( (
( ( (

( ( = (
( ( (
( ( (

( ( (

(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 {o
k
} and o;
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
je
) s o - convergence.
ELEN 5346/4304 DSP and Filter Design Fall 2008
47
4. Optimal equiripple design
Alternatively, we can compute o analytically [Rabiner 75]:
( ) ( ) ( )
( ) ( ) ( )
0 1 1
0 1 1
0 1 1
1
0 1 1

...
( 1)
...

L
L
j j j
dr dr L dr
L
L
j j j
H e H e H e
W e W e W e
e e e
e e e

o

+
+
+
+
+
+ + +
=

+ +
where:
1
0
1
cos cos
L
k
n
k n
n k

e e
+
=
=
=

[
(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 o. Thus:
( )
0
, cos
L
j k
k
k
P e x x
e
o e
=
= =

(11.47.3)
ELEN 5346/4304 DSP and Filter Design Fall 2008
48
4. Optimal equiripple design
Since we know that the polynomial at the points x
n
= cos e
n
has the values:
( ) ( )
( )
( 1)

, 0,1,... 1

n n
n
n
j j
dr
j
P e H e n L
W e
e e
e
o
= = +
the Lagrange interpolation formula can be used, which leads to
( )
( )
( )
( )
0
0
k
L
j
k k
j
k
L
k k
k
P e x x
P e
x x
e
e
|
|
=
=
(

=
(

Here:
cos
cos
k k
x
x
e
e
=
=
0
1
L
k
n
k n
n k
x x
|
=
=
=

[
(11.48.1)
(11.48.2)
(11.48.3)
(11.48.4)
(11.48.5)
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 j
dr
E e W e H e P e
e e e e
(
=

on a dense set of frequency points. Usually, 16M frequency points are sufficient.
If the error exceeds the estimated tolerance o, 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 o. 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 2
s p
s p
M
o o
e e t

= +

(11.49.1)
(11.49.2)
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 e
s
and e
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 2t/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.
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 method
fir2 FIR filter design via the frequency sampling method
firpm Parks-McClellan optimal equiripple FIR design
firpmord - Parks-McClellan optimal equiripple FIR order estimator
ELEN 5346/4304 DSP and Filter Design Fall 2008
52
Appendix: the ideal transfer functions
LPF:
( )
,
sin
,
c
LP n
n
h n
n
e
t
= < <
HPF:
( ) ,
1 , 0
sin
, 0
c
HP n
c
n
h
n
n
n
e t
e
t
=

=

>

( ) ( )
2 1
,
sin sin
, 0
c c
BP n
n n
h n
n n
e e
t t
= >
( )
( ) ( )
2 1
,
1 2
1 , 0
sin sin
, 0
c c
BS n
c c
n
h
n n
n
n n
e e
t
e e
t t

=

>

BPF:
BSF:
(11.52.1)
(11.52.2)
(11.52.3)
(11.52.4)

Das könnte Ihnen auch gefallen