Analog Lowpass Filter Specifications

advertisement
Analog Lowpass Filter
Specifications
Analog Lowpass Filter
Specifications
• Typical magnitude response H a ( jΩ) of an
analog lowpass filter may be given as
indicated below
1
• In the passband, defined by 0 ≤ Ω ≤ Ω p , we
require
1 − δ p ≤ H a ( jΩ ) ≤ 1 + δ p , Ω ≤ Ω p
i.e., H a ( jΩ) approximates unity within an
error of ± δ p
• In the stopband, defined by Ω s ≤ Ω < ∞ , we
require
H a ( jΩ ) ≤ δ s , Ω s ≤ Ω < ∞
2
i.e., H a ( jΩ) approximates zero within an
error of δ s
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Analog Lowpass Filter
Specifications
•
•
•
•
•
Analog Lowpass Filter
Specifications
Ω p - passband edge frequency
Ω s - stopband edge frequency
δ p - peak ripple value in the passband
δ s - peak ripple value in the stopband
Peak passband ripple
α p = − 20 log10 (1 − δ p ) dB
• Magnitude specifications may alternately be
given in a normalized form as indicated
below
• Minimum stopband attenuation
α s = − 20 log10 (δ s ) dB
3
4
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Analog Lowpass Filter
Specifications
Analog Lowpass Filter Design
• Two additional parameters are defined -
• Here, the maximum value of the magnitude
in the passband assumed to be unity
•
(1) Transition ratio k =
1 / 1 + ε 2 - Maximum passband deviation,
given by the minimum value of the
magnitude in the passband
For a lowpass filter k < 1
(2) Discrimination parameter k1 =
Usually k1 << 1
• 1 - Maximum stopband magnitude
A
5
Ωp
Ωs
ε
A2 − 1
6
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
1
Butterworth Approximation
7
• The magnitude-square response of an N-th
order analog lowpass Butterworth filter
is given by
1
2
H a ( jΩ ) =
1 + (Ω / Ω c ) 2 N
2
• First 2 N − 1 derivatives of H a ( jΩ) at Ω = 0
are equal to zero
• The Butterworth lowpass filter thus is said
to have a maximally-flat magnitude at Ω = 0
Butterworth Approximation
• Gain in dB is G (Ω) = 10 log10 H a ( jΩ) 2
• As G (0) = 0 and
G (Ωc ) = 10 log10 (0.5) = −3.0103 ≅ −3 dB
Ω c is called the 3-dB cutoff frequency
8
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Butterworth Approximation
Butterworth Approximation
• Typical magnitude responses with Ωc = 1
• Two parameters completely characterizing a
Butterworth lowpass filter are Ωc and N
• These are determined from the specified
bandedges Ω p and Ω s , and minimum
passband magnitude 1 / 1 + ε 2, and
maximum stopband ripple 1 / A
Butterworth Filter
N=2
N=4
N = 10
Magnitude
1
0.8
0.6
0.4
0.2
0
0
1
2
3
Ω
9
10
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Butterworth Approximation
Butterworth Approximation
• Ωc and N are thus determined from
2
1
= 1
H a ( jΩ p ) =
1 + (Ω p / Ω c ) 2 N 1 + ε 2
2
1
= 1
H a ( jΩ s ) =
1 + ( Ω s / Ω c ) 2 N A2
• Solving the above we get
log [( A2 − 1) / ε 2 ] log10 (1 / k1 )
N = 1 ⋅ 10
=
2 log10 (Ω s / Ω p )
log10 (1 / k )
11
12
Copyright © 2005, S. K. Mitra
• Since order N must be an integer, value
obtained is rounded up to the next highest
integer
• This value of N is used next to determine Ωc
by satisfying either the stopband edge or the
passband edge specification exactly
• If the stopband edge specification is
satisfied, then the passband edge
specification is exceeded providing a safety
margin
Copyright © 2005, S. K. Mitra
2
Butterworth Approximation
• Transfer function of an analog Butterworth
lowpass filter is given by
ΩcN
ΩcN
H a ( s) = C = N
=
DN ( s ) s + ∑lN=−01d s l ∏lN=1 ( s − pl )
l
Butterworth Approximation
• Example - Determine the lowest order of a
Butterworth lowpass filter with a 1-dB cutoff
frequency at 1 kHz and a minimum attenuation of 40
dB at 5 kHz
• Now
10 log10 ⎛⎜ 1 2 ⎞⎟ = −1
⎝1 + ε ⎠
which yields ε 2 = 0.25895
and
10 log10 ⎛⎜ 12 ⎞⎟ = − 40
⎝A ⎠
which yields A2 = 10,000
where
pl = Ωc e j[π ( N + 2l−1) / 2 N ] , 1 ≤ l ≤ N
• Denominator DN (s ) is known as the
Butterworth polynomial of order N
13
14
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Chebyshev Approximation
Butterworth Approximation
A2 − 1 = 196.51334
1=
k1
• Therefore
ε
1 = Ωs = 5
k Ωp
and
• The magnitude-square response of an N-th
order analog lowpass Type 1 Chebyshev filter
is given by
1
2
H a ( s) =
2 2
1 + ε TN (Ω / Ω p )
• Hence
where TN (Ω) is the Chebyshev polynomial
of order N:
log (1 / k1 )
N = 10
= 3.2811
log10 (1 / k )
⎧ cos( N cos −1 Ω),
TN (Ω) = ⎨
−1
⎩cosh( N cosh Ω),
• We choose N = 4
15
Ω ≤1
Ω >1
16
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Chebyshev Approximation
Chebyshev Approximation
• If at Ω = Ω s the magnitude is equal to 1/A,
then
2
1
= 12
H a ( jΩ s ) =
2 2
1 + ε TN (Ω s / Ω p ) A
• Typical magnitude response plots of the
analog lowpass Type 1 Chebyshev filter are
shown below
Type 1 Chebyshev Filter
Magnitude
• Solving the above we get
cosh −1 ( A2 − 1 / ε ) cosh −1 (1 / k1 )
=
N=
cosh −1 (Ω s / Ω p )
cosh −1 (1 / k )
• Order N is chosen as the nearest integer
greater than or equal to the above value
N=2
N=3
N=8
1
0.8
0.6
0.4
0.2
0
0
1
2
3
Ω
17
18
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
3
Chebyshev Approximation
Chebyshev Approximation
• The magnitude-square response of an N-th
order analog lowpass Type 2 Chebyshev
(also called inverse Chebyshev) filter is
given by
1
2
H a ( jΩ ) =
2
⎡T (Ω / Ω p ) ⎤
1+ ε 2 ⎢ N s
⎥
⎣ TN (Ω s / Ω) ⎦
• Typical magnitude response plots of the
analog lowpass Type 2 Chebyshev filter are
shown below
Type 2 Chebyshev Filter
Magnitude
0.6
0.4
0.2
where TN (Ω) is the Chebyshev polynomial
of order N
19
N=3
N=5
N=7
1
0.8
0
0
1
2
20
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Elliptic Approximation
Chebyshev Approximation
• The square-magnitude response of an
elliptic lowpass filter is given by
1
2
H a ( jΩ ) =
2 2
1 + ε RN ( Ω / Ω p )
where RN (Ω) is a rational function of order
N satisfying RN (1 / Ω) = 1 / RN (Ω) , with the
roots of its numerator lying in the interval
0 < Ω < 1 and the roots of its denominator
lying in the interval 1 < Ω < ∞
• The order N of the Type 2 Chebyshev filter
is determined from given ε , Ω s , and A
using
cosh −1 ( A2 − 1 / ε ) cosh −1 (1 / k1 )
=
N=
cosh −1 (Ω s / Ω p )
cosh −1 (1 / k )
• Example - Determine the lowest order of a
Chebyshev lowpass filter with a 1-dB cutoff
frequency at 1 kHz and a minimum attenuation of
40 dB at 5 kHz -
N=
21
3
Ω
cosh −1 (1 / k1 )
= 2.6059
cosh −1 (1 / k )
22
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Elliptic Approximation
Elliptic Approximation
• For given Ω p , Ω s , ε , and A, the filter order
can be estimated using
2 log10 (4 / k1 )
N≅
log10 (1 / ρ )
• Example - Determine the lowest order of a elliptic
lowpass filter with a 1-dB cutoff frequency at 1
kHz and a minimum attenuation of 40 dB at 5 kHz
Note: k = 0.2 and 1 / k1 = 196.5134
• Substituting these values we get
ρ0 = 0.00255135,
k '= 0.979796,
where k ' = 1 − k 2
ρ0 = 1 − k '
2(1 + k ')
ρ = ρ0 + 2( ρ0 )5 + 15( ρ0 )9 + 150( ρ0 )13
23
ρ = 0.0025513525
• and hence N = 2.23308
• Choose N = 3
24
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
4
Analog Lowpass Filter Design
Elliptic Approximation
• Example - Design an elliptic lowpass filter
of lowest order with a 1-dB cutoff
frequency at 1 kHz and a minimum
attenuation of 40 dB at 5 kHz
• Code fragments used
• Typical magnitude response plots with Ω p = 1
are shown below
Elliptic Filter
N=3
N=4
Magnitude
1
[N, Wn] = ellipord(Wp, Ws, Rp, Rs, ‘s’);
0.8
0.6
0.2
0
[b, a] = ellip(N, Rp, Rs, Wn, ‘s’);
Wp = 2*pi*1000;
Ws = 2*pi*5000;
Rp = 1;
Rs = 40;
with
0.4
0
1
2
3
Ω
25
26
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Design of Analog Highpass,
Highpass,
Bandpass and Bandstop Filters
Analog Lowpass Filter Design
• Gain plot
Lowpass Elliptic Filter
Gain, dB
0
-20
-40
-60
0
2000
4000
Frequency, Hz
6000
27
28
• Steps involved in the design process:
Step 1 - Develop of specifications of a
prototype analog lowpass filter H LP (s)
from specifications of desired analog filter
HD (s ) using a frequency transformation
Step 2 - Design the prototype analog
lowpass filter
Step 3 - Determine the transfer function HD (s )
of desired analog filter by applying the
inverse frequency transformation to H LP (s)
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Design of Analog Highpass,
Highpass,
Bandpass and Bandstop Filters
Analog Highpass Filter Design
• Spectral Transformation:
• Let s denote the Laplace transform variable
of prototype analog lowpass filter H LP (s)
and ŝ denote the Laplace transform
variable of desired analog filter HD (sˆ)
• The mapping from s-domain to ŝ -domain is
given by the invertible transformation
s = F (sˆ)
H
(
s
)
=
H LP ( s ) s = F ( sˆ)
ˆ
• Then
D
H LP ( s ) = HD ( sˆ) sˆ = F −1 ( s )
29
Ω p Ω̂ p
sˆ
where Ω p is the passband edge frequency of
H LP ( s) and Ω̂ p is the passband edge
frequency of H HP ( sˆ)
• On the imaginary axis the transformation is
ˆp
Ω pΩ
Ω=−
ˆ
Ω
s=
30
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
5
Analog Highpass Filter Design
Analog Highpass Filter Design
Ω=−
ˆp
Ω pΩ
ˆ
Ω
Ω
Ω p Ωs
Stopband − Ω s − Ω p
Stopband
Ω
0
Passband
Stopband
Passband
ˆ p −Ω
ˆs
−Ω
0
Passband
Ω̂ s
Lowpass
Ω̂ Highpass
Ω̂ p
31
• Example - Design an analog Butterworth
highpass filter with the specifications:
Fˆ p = 4 kHz, Fˆs = 1 kHz, α p = 0.1 dB,
α s = 40 dB
• Choose Ω p = 1
• Then
2πFˆ p Fˆ p 4000
=
=
=4
Ωs =
2πFˆs Fˆs 1000
• Analog lowpass filter specifications: Ω p = 1,
Ω s = 4 , α p = 0.1 dB, α s = 40 dB
32
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Analog Bandpass Filter
Design
Analog Highpass Filter Design
• Code fragments used
[N, Wn] = buttord(1, 4, 0.1, 40, ‘s’);
[B, A] = butter(N, Wn, ‘s’);
[num, den] = lp2hp(B, A, 2*pi*4000);
• Spectral Transformation
ˆ o2
sˆ 2 + Ω
s = Ωp
ˆ p2 − Ω
ˆ p1 )
sˆ(Ω
• Gain plots
-20
-20
-40
-60
33
-80
0
where Ω p is the passband edge frequency
ˆ p1 and Ω
ˆ p 2 are the lower
of H LP (s ), and Ω
and upper passband edge frequencies of
desired bandpass filter H BP (sˆ)
Highpass Filter
0
Gain, dB
Gain, dB
Prototype Lowpass Filter
0
-40
-60
2
4
6
Ω
8
10
-80
0
2
4
6
8
10
Frequency, kHz
Copyright © 2005, S. K. Mitra
34
Copyright © 2005, S. K. Mitra
Analog Bandpass Filter
Design
• On the imaginary axis the transformation is
ˆ 2 −Ω
ˆ2
Ω
Ω = −Ω p o
ˆ Bw
Ω
ˆ p2 − Ω
ˆ p1 is the width of
where Bw = Ω
passband and Ω̂ o is the passband center
frequency of the bandpass filter
• Passband edge frequency ± Ω p is mapped
ˆ p1 and ± Ω
ˆ p 2, lower and upper
into m Ω
passband edge frequencies
35
Analog Bandpass Filter
Design
Ω = −Ω p
ˆ o2 − Ω
ˆ2
Ω
ˆ Bw
Ω
Ω p Ωs
Stopband − Ω s − Ω p
Stopband
Ω
0
Passband
Stopband
Passband
Stopband
Passband
Stopband
ˆ ↓ −Ω
ˆ s1 0 Ω
ˆ s1 ↓ Ω̂ o ↓ Ω
ˆ s2
ˆ s2 ↓ − Ω
−Ω
ˆ p2 o− Ω
ˆ p1
−Ω
ˆ p1
Ω
ˆ p2
Ω
Lowpass
Ω̂ Bandpass
36
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
6
Analog Bandpass Filter
Design
Analog Bandpass Filter
Design
• Stopband edge frequency ± Ω s is mapped
ˆ s 2 , lower and upper
ˆ s1 and ± Ω
into m Ω
stopband edge frequencies
• Also,
ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s2
Ω
ˆ p1Ω
ˆ p2 > Ω
ˆ s1Ω
ˆ s2
• Case 1: Ω
ˆ
ˆ
ˆ
ˆ s 2 we can either
To make Ω p1Ω p 2 = Ω s1Ω
increase any one of the stopband edges or
decrease any one of the passband edges as
shown below
• If bandedge frequencies do not satisfy the
above condition, then one of the frequencies
needs to be changed to a new value so that
the condition is satisfied
37
←
Passband
←
Stopband →
ˆ s1
Ω
→ Stopband
ˆ p1
Ω
ˆ p2
Ω
ˆ s2
Ω
Ω̂
38
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Analog Bandpass Filter
Design
Analog Bandpass Filter
Design
ˆ s1Ω
ˆ s2 / Ω
ˆ p2
ˆ p1 to Ω
(1) Decrease Ω
larger passband and shorter
leftmost transition band
ˆ p1Ω
ˆ p2 / Ω
ˆ s2
ˆ s1 to Ω
(2) Increase Ω
ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s2
• Note: The condition Ω
ˆ p2
can also be satisfied by decreasing Ω
which is not acceptable as the passband is
reduced from the desired value
• Alternately, the condition can be satisfied
ˆ s 2 which is not acceptable
by increasing Ω
as the upper stop band is reduced from the
desired value
No change in passband and shorter
leftmost transition band
39
40
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Analog Bandpass Filter
Design
Analog Bandpass Filter
Design
ˆ p1Ω
ˆ p2 < Ω
ˆ s1Ω
ˆ s2
• Case 2: Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s 2 we can either
To make Ω
decrease any one of the stopband edges or
increase any one of the passband edges as
shown below
→ Passband
→
←
←
Stopband
ˆ s1
Ω
ˆ p1
Ω
ˆ p 2 to Ω
ˆ s1Ω
ˆ s2 / Ω
ˆ p1
(1) Increase Ω
larger passband and shorter
rightmost transition band
ˆ p1Ω
ˆ p2 / Ω
ˆ s1
ˆ s 2 to Ω
(2) Decrease Ω
No change in passband and shorter
rightmost transition band
ˆ p2
Ω
ˆ s2
Ω
Stopband
Ω̂
41
42
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
7
Analog Bandpass Filter
Design
Analog Bandpass Filter
Design
• Example - Design an analog elliptic
bandpass filter with the specifications:
Fˆ p1 = 4 kHz, Fˆ p 2 = 7 kHz, Fˆs1 = 3 kHz
ˆ
Fs 2 = 8 kHz, α p = 1 dB, α s = 22 dB
ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s2
• Note: The condition Ω
ˆ p1
can also be satisfied by increasing Ω
which is not acceptable as the passband is
reduced from the desired value
• Alternately, the condition can be satisfied
ˆ s1 which is not acceptable
by decreasing Ω
as the lower stopband is reduced from the
desired value
43
• Now Fˆ p1Fˆ p 2 = 28 × 106 and Fˆs1Fˆs 2 = 24 × 106
• Since Fˆ p1Fˆ p 2 > Fˆs1Fˆs 2 we choose
Fˆ p1 = Fˆs1Fˆs 2 / Fˆ p 2 = 3.571428 kHz
44
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Analog Bandpass Filter
Design
Analog Bandpass Filter
Design
• Code fragments used
[N, Wn] = ellipord(1, 1.4, 1, 22, ‘s’);
[B, A] = ellip(N, 1, 22, Wn, ‘s’);
[num, den]
= lp2bp(B, A, 2*pi*4.8989795, 2*pi*25/7);
• We choose Ω p = 1
• Hence
24 − 9
Ωs =
= 1.4
(25 / 7) × 3
• Gain plot
Prototype Lowpass Filter
• Analog lowpass filter specifications: Ω p = 1,
Ω s = 1.4 , α p = 1 dB, α s = 22 dB
45
0
Gain, dB
Gain, dB
46
Copyright © 2005, S. K. Mitra
-20
-40
-60
0
-20
-40
2
4
Ω
6
8
-60
0
5
10
15
Frequency,
kHz © 2005, S. K. Mitra
Copyright
Analog Bandstop Filter Design
Analog Bandstop Filter Design
• On the imaginary axis the transformation is
ˆB
Ω
Ω = Ωs 2 w 2
ˆ o −Ω
ˆ
Ω
ˆ
ˆ
where Bw = Ω s 2 − Ω s1 is the width of
stopband and Ω̂o is the stopband center
frequency of the bandstop filter
• Stopband edge frequency ± Ω s is mapped
ˆ s1and ± Ω
ˆ s 2 , lower and upper
into m Ω
stopband edge frequencies
• Spectral Transformation
ˆ s2 − Ω
ˆ s1 )
sˆ(Ω
s = Ωs
2
ˆ 2o
sˆ + Ω
where Ω s is the stopband edge frequency
ˆ s1 and Ω
ˆ s 2 are the lower
of H LP ( s ) , and Ω
and upper stopband edge frequencies of the
desired bandstop filter H BS ( sˆ)
47
Bandpass Filter
0
48
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
8
Analog Bandstop Filter Design
Analog Bandstop Filter Design
• Passband edge frequency ± Ω p is mapped
ˆ p1 and ± Ω
ˆ p 2 , lower and upper
into m Ω
passband edge frequencies
• Also,
Ω p Ωs
Stopband − Ω s − Ω p
Stopband
Ω
0
Passband
Passband
Stopband
Passband
Stopband
Passband
ˆ o ↓ −Ω
ˆ p1 ↓ Ω̂ o ↓ Ω
ˆ p10 Ω
ˆ p2
ˆ p2 ↓ − Ω
−Ω
ˆ s2
ˆ s1
ˆ s1
ˆ s2
−Ω
Ω
−Ω
Ω
ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s2
Ω
• If bandedge frequencies do not satisfy the
above condition, then one of the frequencies
needs to be changed to a new value so that
the condition is satisfied
Lowpass
Ω̂ Bandpass
49
50
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Analog Bandstop Filter Design
Analog Bandstop Filter Design
ˆ p1Ω
ˆ p2 > Ω
ˆ s1Ω
ˆ s2
• Case 1: Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s 2 we can either
• To make Ω
increase any one of the stopband edges or
decrease any one of the passband edges as
shown below
Passband
Passband
Stopband
51
ˆ p 2 to Ω
ˆ s1Ω
ˆ s2 / Ω
ˆ p2
(1) Decrease Ω
larger high-frequency passband
and shorter rightmost transition band
ˆ p1Ω
ˆ p2 / Ω
ˆ s2
ˆ s 2 to Ω
(2) Increase Ω
No change in passbands and
shorter rightmost transition band
ˆ p1
Ω
ˆ s1
Ω
ˆ s2
Ω
ˆ p2
Ω
Ω̂
52
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Analog Bandstop Filter Design
Analog Bandstop Filter Design
ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s2
• Note: The condition Ω
can also be satisfied by decreasing
ˆ p1
which is not acceptable as the low- Ω
frequency passband is reduced from the
desired value
• Alternately, the condition can be satisfied
ˆ s1 which is not acceptable
by increasing Ω
as the stopband is reduced from the desired
value
ˆ p1Ω
ˆ p2 < Ω
ˆ s1Ω
ˆ s2
• Case 1: Ω
ˆ
ˆ
ˆ
ˆ s 2 we can either
• To make Ω p1Ω p 2 = Ω s1Ω
decrease any one of the stopband edges or
increase any one of the passband edges as
shown below
53
Passband
54
Copyright © 2005, S. K. Mitra
Passband
Stopband
ˆ p1
Ω
ˆ s1
Ω
ˆ s2
Ω
ˆ p2
Ω
Ω̂
Copyright © 2005, S. K. Mitra
9
Analog Bandstop Filter Design
Analog Bandstop Filter Design
ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s2
• Note: The condition Ω
ˆ p2
can also be satisfied by increasing Ω
which is not acceptable as the highfrequency passband is decreased from the
desired value
• Alternately, the condition can be satisfied
ˆ s 2 which is not acceptable
by decreasing Ω
as the stopband is decreased
ˆ p1 to Ω
ˆ s1Ω
ˆ s2 / Ω
ˆ p1
(1) Increase Ω
larger passband and shorter
leftmost transition band
ˆ s1 to Ω
ˆ p1Ω
ˆ p2 / Ω
ˆ s1
(2) Decrease Ω
No change in passbands and
shorter leftmost transition band
55
56
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
10
Digital Filter Design
Digital Filter Specifications
• Usually, either the magnitude and/or the
phase (delay) response is specified for the
design of digital filter for most applications
• In some situations, the unit sample response
or the step response may be specified
• In most practical applications, the problem
of interest is the development of a realizable
approximation to a given magnitude
response specification
• Objective - Determination of a realizable
transfer function G(z) approximating a
given frequency response specification is an
important step in the development of a
digital filter
• If an IIR filter is desired, G(z) should be a
stable real rational function
• Digital filter design is the process of
deriving the transfer function G(z)
1
Copyright © 2005, S. K. Mitra
2
Digital Filter Specifications
Digital Filter Specifications
• We discuss in this course only the
magnitude approximation problem
• There are four basic types of ideal filters
with magnitude responses as shown below
HLP(e j )
HHP (e j )
1
1
– c 0
– c
c
– c2 – c1
c
1
–1
3
0
HBS (e j )
HBP (e j )
c1
c2
– c2 – c1
c1
Copyright © 2005, S. K. Mitra
c2
Copyright © 2005, S. K. Mitra
4
• As the impulse response corresponding to
each of these ideal filters is noncausal and
of infinite length, these filters are not
realizable
• In practice, the magnitude response
specifications of a digital filter in the
passband and in the stopband are given with
some acceptable tolerances
• In addition, a transition band is specified
between the passband and stopband
Copyright © 2005, S. K. Mitra
Digital Filter Specifications
Digital Filter Specifications
jω
• As indicated in the figure, in the passband,
defined by 0 ≤ ω ≤ ω p , we require that
G (e jω ) ≅ 1 with an error ± δ p, i.e.,
• For example, the magnitude response G (e )
of a digital lowpass filter may be given as
indicated below
1 − δ p ≤ G ( e jω ) ≤ 1 + δ p ,
ω ≤ ωp
• In the stopband, defined by ωs ≤ ω ≤ π, we
require that G (e jω ) ≅ 0 with an error δ s ,
i.e.,
G ( e jω ) ≤ δ s , ω s ≤ ω ≤ π
5
Copyright © 2005, S. K. Mitra
6
Copyright © 2005, S. K. Mitra
1
Digital Filter Specifications
7
• ω p - passband edge frequency
• ωs - stopband edge frequency
• δ p - peak ripple value in the passband
• δ s - peak ripple value in the stopband
• Since G (e jω ) is a periodic function of ω,
and G (e jω ) of a real-coefficient digital
filter is an even function of ω
• As a result, filter specifications are given
only for the frequency range 0 ≤ ω ≤ π
Copyright © 2005, S. K. Mitra
Digital Filter Specifications
• Specifications are often given in terms of
jω
loss function A (ω) = − 20 log10 G (e ) in
dB
• Peak passband ripple
α p = − 20 log10 (1 − δ p ) dB
• Minimum stopband attenuation
α s = − 20 log10 (δ s ) dB
8
Copyright © 2005, S. K. Mitra
Digital Filter Specifications
Digital Filter Specifications
• Magnitude specifications may alternately be
given in a normalized form as indicated
below
• Here, the maximum value of the magnitude
in the passband is assumed to be unity
• 1 / 1 + ε 2 - Maximum passband deviation,
given by the minimum value of the
magnitude in the passband
• 1 - Maximum stopband magnitude
A
9
Copyright © 2005, S. K. Mitra
Digital Filter Specifications
• For the normalized specification, maximum
value of the gain function or the minimum
value of the loss function is 0 dB
• Maximum passband attenuation α max = 20 log10 1 + ε 2 dB
• For δ p << 1, it can be shown that
α max ≅ − 20 log10 (1 − 2 δ p ) dB
(
11
)
Copyright © 2005, S. K. Mitra
10
Copyright © 2005, S. K. Mitra
Digital Filter Specifications
• In practice, passband edge frequency Fp
and stopband edge frequency Fs are
specified in Hz
• For digital filter design, normalized
bandedge frequencies need to be computed
from specifications in Hz using
Ω p 2π Fp
ωp =
=
= 2π FpT
FT
FT
Ω 2π Fs
ωs = s =
= 2π Fs T
FT
FT
12
Copyright © 2005, S. K. Mitra
2
Digital Filter Specifications
• Example - Let Fp = 7 kHz, Fs = 3 kHz, and
FT = 25 kHz
• Then
2π(7 × 103 )
ωp =
= 0.56π
25 × 103
ωs =
2π(3 × 103 )
= 0.24π
25 × 103
13
Copyright © 2005, S. K. Mitra
Selection of Filter Type
• The transfer function H(z) meeting the
frequency response specifications should be
a causal transfer function
• For IIR digital filter design, the IIR transfer
function is a real rational function of z −1:
p0 + p1z −1 + p2 z − 2 + L + pM z − M
, M≤N
d 0 + d1z −1 + d 2 z − 2 + L + d N z − N
• H(z) must be a stable transfer function and
must be of lowest order N for reduced
14 computational complexity
H ( z) =
Copyright © 2005, S. K. Mitra
Selection of Filter Type
Selection of Filter Type
• For FIR digital filter design, the FIR
transfer function is a polynomial in z −1
with real coefficients:
• Advantages in using an FIR filter (1) Can be designed with exact linear phase,
(2) Filter structure always stable with
quantized coefficients
• Disadvantages in using an FIR filter - Order
of an FIR filter, in most cases, is
considerably higher than the order of an
equivalent IIR filter meeting the same
specifications, and FIR filter has thus higher
computational complexity
N
H ( z ) = ∑ h[n] z −n
n =0
• For reduced computational complexity,
degree N of H(z) must be as small as
possible
• If a linear phase is desired, the filter
coefficients must satisfy the constraint:
h[n] = ± h[ N − n]
15
Copyright © 2005, S. K. Mitra
16
Digital Filter Design:
Basic Approaches
Digital Filter Design:
Basic Approaches
• Most common approach to IIR filter design (1) Convert the digital filter specifications
into an analog prototype lowpass filter
specifications
• (2) Determine the analog lowpass filter
transfer function H a (s )
• (3) Transform H a (s ) into the desired digital
transfer function G ( z )
17
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
18
• This approach has been widely used for the
following reasons:
(1) Analog approximation techniques are
highly advanced
(2) They usually yield closed-form
solutions
(3) Extensive tables are available for
analog filter design
(4) Many applications require digital
simulation of analog systems
Copyright © 2005, S. K. Mitra
3
Digital Filter Design:
Basic Approaches
Digital Filter Design:
Basic Approaches
• An analog transfer function to be denoted as
P ( s)
H a ( s) = a
Da ( s )
• Basic idea behind the conversion of H a (s )
into G ( z ) is to apply a mapping from the
s-domain to the z-domain so that essential
properties of the analog frequency response
are preserved
• Thus mapping function should be such that
– Imaginary ( jΩ ) axis in the s-plane be
where the subscript “a” specifically
indicates the analog domain
• A digital transfer function derived from H a ( s )
shall be denoted as
P( z )
G( z) =
D( z )
19
Copyright © 2005, S. K. Mitra
20
Digital Filter Design:
Basic Approaches
Copyright © 2005, S. K. Mitra
• Three commonly used approaches to FIR
filter design (1) Windowed Fourier series approach
(2) Frequency sampling approach
(3) Computer-based optimization methods
22
IIR Digital Filter Design: Bilinear
Transformation Method
• Digital filter design consists of 3 steps:
(1) Develop the specifications of Ha ( s ) by
applying the inverse bilinear transformation
to specifications of G(z)
(2) Design Ha (s )
(3) Determine G(z) by applying bilinear
transformation to Ha ( s )
• As a result, the parameter T has no effect on
G(z) and T = 2 is chosen for convenience
• Above transformation maps a single point
in the s-plane to a unique point in the
z-plane and vice-versa
• Relation between G(z) and Ha ( s ) is then
given by
G ( z ) = Ha ( s ) 2 ⎛⎜ 1− z −1 ⎞⎟
s=
T ⎜ 1+ z −1 ⎟
⎝
⎠
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Bilinear Transformation
• Bilinear transformation −1 ⎞
⎛
s = 2 ⎜⎜ 1 − z −1 ⎟⎟
T ⎝1 + z ⎠
23
Copyright © 2005, S. K. Mitra
Digital Filter Design:
Basic Approaches
• FIR filter design is based on a direct
approximation of the specified magnitude
response, with the often added requirement
that the phase be linear
• The design of an FIR filter of order N may
be accomplished by finding either the
length-(N+1) impulse response samples {h[n]}
or the (N+1) samples of its frequency
response H (e jω )
21
mapped onto the unit circle of the z-plane
– A stable analog transfer function be mapped
into a stable digital transfer function
24
Copyright © 2005, S. K. Mitra
4
Bilinear Transformation
Bilinear Transformation
• Inverse bilinear transformation for T = 2 is
z = 1+ s
1− s
• Mapping of s-plane into the z-plane
• For s = σo + jΩo
2
2
(1 + σo ) + jΩo
2 (1 + σo ) + Ω o
z=
⇒z =
(1 − σo ) − jΩo
(1 − σo ) 2 + Ωo2
σo = 0 → z = 1
• Thus,
σo < 0 → z < 1
σo > 0 → z > 1
25
Copyright © 2005, S. K. Mitra
26
Bilinear Transformation
Bilinear Transformation
jω
• For z = e with T = 2 we have
− jω e − jω / 2 (e jω / 2 − e − jω / 2 )
jΩ = 1 − e − jω = − jω / 2 jω / 2 − jω / 2
1+ e
e
(e
+e
)
j 2 sin(ω / 2)
=
= j tan(ω / 2)
2 cos(ω / 2)
or Ω = tan(ω / 2)
27
Copyright © 2005, S. K. Mitra
• Mapping is highly nonlinear
• Complete negative imaginary axis in the splane from Ω = −∞ to Ω = 0 is mapped into
the lower half of the unit circle in the z-plane
from z = −1 to z = 1
• Complete positive imaginary axis in the splane from Ω = 0 to Ω = ∞ is mapped into the
upper half of the unit circle in the z-plane
from z = 1 to z = −1
28
Ω
29
Ω = tan(ω/2)
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Bilinear Transformation
Bilinear Transformation
• Nonlinear mapping introduces a distortion
in the frequency axis called frequency
warping
• Effect of warping shown below
Copyright © 2005, S. K. Mitra
• Steps in the design of a digital filter (1) Prewarp (ω p , ωs ) to find their analog
equivalents (Ω p , Ω s )
(2) Design the analog filter H a (s )
(3) Design the digital filter G(z) by applying
bilinear transformation to H a (s )
• Transformation can be used only to design
digital filters with prescribed magnitude
response with piecewise constant values
• Transformation does not preserve phase
response of analog filter
30
Copyright © 2005, S. K. Mitra
5
IIR Digital Filter Design Using
Bilinear Transformation
IIR Digital Filter Design Using
Bilinear Transformation
• Example - Consider
Ωc
s + Ωc
• Applying bilinear transformation to the above
we get the transfer function of a first-order
digital lowpass Butterworth filter
• Rearranging terms we get
H a ( s) =
1+ z −1
where
α=
Ωc (1 + z −1 )
=
(1 − z −1 ) + Ωc (1 + z −1 )
31
Copyright © 2005, S. K. Mitra
32
Copyright © 2005, S. K. Mitra
IIR Digital Filter Design Using
Bilinear Transformation
IIR Digital Filter Design Using
Bilinear Transformation
• Example - Consider the second-order analog
notch transfer function
s 2 + Ωo2
H a ( s) = 2
s + B s + Ωo2
for which H a ( jΩo ) = 0
33
H a ( j 0) = H a ( j∞) = 1
• Ωo is called the notch frequency
• If H a ( jΩ 2 ) = H a ( jΩ1 ) = 1 / 2 then
B = Ω 2 − Ω1 is the 3-dB notch bandwidth
Copyright © 2005, S. K. Mitra
• Then
=
35
1+α
1 − 2β z + z
⋅
2 1 − 2 β (1 + α ) z −1 + α z −2
1 + Ωo2 − B 1 − tan( Bw / 2)
=
1 + Ωo2 + B 1 + tan( Bw / 2)
1 − Ωo2
β=
= cos ωo
Copyright © 2005, S. K. Mitra
1 + Ωo2
34
IIR Digital Filter Design Using
Bilinear Transformation
• Thus
0.954965 − 1.1226287 z −1 + 0.954965 z − 2
1 − 1.1226287 z −1 + 0.90993 z − 2
• The gain and phase responses are shown below
G( z) =
2
0
-10
-20
-30
β = 0.587785
Copyright © 2005, S. K. Mitra
−1
where α =
Gain, dB
α = 0.90993
G ( z ) = H a ( s ) s =1− z
1+ z −1
2
2
(1 + Ωo ) − 2(1 − Ωo ) z −1 + (1 + Ωo2 ) z −2
(1 + Ωo2 + B) − 2(1 − Ωo2 ) z −1 + (1 + Ωo2 − B ) z −2
−1
−2
=
IIR Digital Filter Design Using
Bilinear Transformation
• Example - Design a 2nd-order digital notch
filter operating at a sampling rate of 400 Hz
with a notch frequency at 60 Hz, 3-dB notch
bandwidth of 6 Hz
• Thus ωo = 2π(60 / 400) = 0.3π
Bw = 2π(6 / 400) = 0.03π
• From the above values we get
1 − Ωc 1 − tan(ωc / 2)
=
1 + Ωc 1 + tan(ωc / 2)
Phase, radians
G ( z ) = H a ( s ) s =1− z −1
−1
G ( z ) = 1 − α ⋅ 1 + z −1
2 1−α z
36
-40
0
50
100
150
Frequency, Hz
200
1
0
-1
-2
0
50
100
150
Frequency, Hz
200
Copyright © 2005, S. K. Mitra
6
IIR Lowpass Digital Filter Design
Using Bilinear Transformation
IIR Lowpass Digital Filter Design
Using Bilinear Transformation
• Example - Design a lowpass Butterworth
digital filter with ω p = 0.25π, ωs = 0.55π ,
α p ≤ 0.5 dB, and α s ≥ 15 dB
• Thus
A2 = 31.622777
ε 2 = 0.1220185
• Prewarping we get
Ω p = tan(ω p / 2) = tan(0.25π / 2) = 0.4142136
Ω s = tan(ωs / 2) = tan(0.55π / 2) = 1.1708496
• The inverse transition ratio is
1 Ωs
=
= 2.8266809
k Ωp
• The inverse discrimination ratio is
• If G (e j 0 ) = 1 this implies
20 log10 G (e j 0.25π ) ≥ − 0.5
20 log10 G (e j 0.55π ) ≤ −15
37
Copyright © 2005, S. K. Mitra
38
N=
• 3rd-order lowpass Butterworth transfer
function for Ωc = 1 is
1
Han ( s ) =
( s + 1)( s 2 + s + 1)
• We choose N = 3
• To determine Ωc we use
2
1
1
=
2N
1 + (Ω p / Ω c )
1 + ε2
39
Copyright © 2005, S. K. Mitra
• Denormalizing to get Ω c = 0.588148 we
arrive at
s
⎞
Ha ( s ) = Han ⎛⎜
⎟
⎝ 0.588148 ⎠
40
Copyright © 2005, S. K. Mitra
IIR Lowpass Digital Filter Design
Using Bilinear Transformation
Design of IIR Highpass,
Highpass, Bandpass,
Bandpass,
and Bandstop Digital Filters
• Applying bilinear transformation to H a (s )
we get the desired digital transfer function
G ( z ) = H a ( s ) s =1− z
• First Approach (1) Prewarp digital frequency specifications
of desired digital filter GD (z ) to arrive at
frequency specifications of analog filter H D (s )
of same type
(2) Convert frequency specifications of H D (s )
into that of prototype analog lowpass filter
H LP (s )
−1
1+ z −1
1
0
-10
Gain, dB
Magnitude
• Magnitude and gain responses of G(z) shown
below:
0.8
0.6
0.4
41
0
-20
-30
0.2
0
0.2
0.4
0.6
ω/π
0.8
1
-40
0
0.2
0.4
0.6
Copyright © 2005, S. K. Mitra
• We then get
Ω c = 1.419915 (Ω p ) = 0.588148
log10 (1 / k1 )
= 2.6586997
log10 (1 / k )
H a ( jΩ p ) =
A2 − 1
= 15.841979
ε
IIR Lowpass Digital Filter Design
Using Bilinear Transformation
IIR Lowpass Digital Filter Design
Using Bilinear Transformation
• Thus
1
=
k1
0.8
1
Copyright
© 2005, S. K. Mitra
ω/π
42
(3) Design analog lowpass filter H LP (s )
Copyright © 2005, S. K. Mitra
7
Design of IIR Highpass,
Highpass, Bandpass,
Bandpass,
and Bandstop Digital Filters
Design of IIR Highpass,
Highpass, Bandpass,
Bandpass,
and Bandstop Digital Filters
(4) Convert H LP (s ) into H D (s ) using
inverse frequency transformation used in
Step 2
(5) Design desired digital filter GD (z ) by
applying bilinear transformation to H D (s )
43
Copyright © 2005, S. K. Mitra
• Second Approach (1) Prewarp digital frequency specifications
of desired digital filter GD (z ) to arrive at
frequency specifications of analog filter H D (s )
of same type
(2) Convert frequency specifications of H D (s )
into that of prototype analog lowpass filter
H LP (s )
44
IIR Highpass Digital Filter Design
Design of IIR Highpass,
Highpass, Bandpass,
Bandpass,
and Bandstop Digital Filters
• Design of a Type 1 Chebyshev IIR digital
highpass filter
• Specifications: Fp = 700 Hz, Fs = 500 Hz,
α p = 1 dB, α s = 32 dB, FT = 2 kHz
• Normalized angular bandedge frequencies
(3) Design analog lowpass filter H LP (s )
(4) Convert H LP (s ) into an IIR digital
transfer function GLP (z ) using bilinear
transformation
(5) Transform GLP (z ) into the desired
digital transfer function GD (z )
• We illustrate the first approach
45
Copyright © 2005, S. K. Mitra
46
Copyright © 2005, S. K. Mitra
IIR Highpass Digital Filter Design
• Prewarping these frequencies we get
ˆ p = tan(ω p / 2) = 1.9626105
Ω
ˆ s = tan(ωs / 2) = 1.0
Ω
• MATLAB code fragments used for the design
[N, Wn] = cheb1ord(1, 1.9626105, 1, 32, ’s’)
[B, A] = cheby1(N, 1, Wn, ’s’);
[BT, AT] = lp2hp(B, A, 1.9626105);
[num, den] = bilinear(BT, AT, 0.5);
• For the prototype analog lowpass filter choose
Ωp =1
ˆ
Ω Ω
• Using Ω = − p p we get Ω s = 1.962105
ˆ
Ω
• Analog lowpass filter specifications: Ω p = 1,
0
Gain, dB
-10
Ω s = 1.926105 , α p = 1dB, α s = 32 dB
Copyright © 2005, S. K. Mitra
2π Fp
2π × 700
=
= 0.7 π
FT
2000
2π Fs 2π × 500
ωs =
=
= 0.5π
FT
2000
ωp =
IIR Highpass Digital Filter Design
47
Copyright © 2005, S. K. Mitra
-20
-30
-40
48
-50
0
0.2
0.4
0.6
ω/π
0.8
1
Copyright © 2005, S. K. Mitra
8
IIR Bandpass Digital Filter Design
IIR Bandpass Digital Filter Design
• Design of a Butterworth IIR digital bandpass
filter
• Specifications: ω p1 = 0.45π , ω p 2 = 0.65π ,
ωs1 = 0.3π, ωs 2 = 0.75π, α p = 1 dB, α s = 40 dB
• Prewarping we get
ˆ p1 = tan(ω p1 / 2) = 0.8540807
Ω
ˆ p 2 = tan(ω p 2 / 2) = 1.6318517
Ω
ˆ p2 − Ω
ˆ p1 = 0.777771
• Width of passband Bw = Ω
ˆ o2 = Ω
ˆ p1Ω
ˆ p 2 = 1.393733
Ω
ˆ s1Ω
ˆ s 2 = 1.23010325 ≠ Ω
ˆ o2
Ω
ˆ s1and
ˆ
• We therefore modify Ω s1 so that Ω
ˆ
exhibit
geometric
symmetry
with
Ωs2
ˆ o2
respect to Ω
ˆ s1 = 0.5773031
• We set Ω
• For the prototype analog lowpass filter we
choose Ω p = 1
ˆ s1 = tan(ωs1 / 2) = 0.5095254
Ω
ˆ
Ω s 2 = tan(ωs 2 / 2) = 2.41421356
49
Copyright © 2005, S. K. Mitra
50
IIR Bandpass Digital Filter Design
IIR Bandpass Digital Filter Design
• MATLAB code fragments used for the design
ˆ2 ˆ2
• Using Ω = −Ω p Ω o − Ω we get
ˆ Bw
Ω
Ωs =
[N, Wn] = buttord(1, 2.3617627, 1, 40, ’s’)
[B, A] = butter(N, Wn, ’s’);
[BT, AT] = lp2bp(B, A, 1.1805647, 0.777771);
[num, den] = bilinear(BT, AT, 0.5);
1.393733 − 0.3332788
= 2.3617627
0.5773031× 0.777771
• Specifications of prototype analog
Butterworth lowpass filter:
Ω p = 1 , Ω s = 2.3617627 , α p = 1 dB,
α s = 40 dB
51
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
0
Gain, dB
-10
-20
-30
-40
-50
52
0
0.2
0.4
0.6
0.8
1
ω/π
Copyright © 2005, S. K. Mitra
IIR Bandstop Digital Filter Design
IIR Bandstop Digital Filter Design
• Design of an elliptic IIR digital bandstop filter
• Specifications: ωs1 = 0.45π , ωs 2 = 0.65π ,
ω p1 = 0.3π, ω p 2 = 0.75π , α p = 1 dB, α s = 40 dB
• Prewarping we get
ˆ s 2 = 1.6318517,
ˆ s1 = 0.8540806, Ω
Ω
ˆ p 2 = 2.4142136
ˆ p1 = 0.5095254, Ω
Ω
ˆ s2 − Ω
ˆ s1 = 0.777771
• Width of stopband Bw = Ω
ˆ p1and Ω
ˆ p2
ˆ p1so that Ω
• We therefore modify Ω
exhibit geometric symmetry with respect to
ˆ o2
Ω
53
ˆ o2 = Ω
ˆ s 2Ω
ˆ s1 = 1.393733
Ω
ˆ
ˆ
ˆ o2
Ω p 2Ω p1 = 1.230103 ≠ Ω
Copyright © 2005, S. K. Mitra
ˆ p1 = 0.577303
• We set Ω
• For the prototype analog lowpass filter we
choose Ω s = 1
ˆB
Ω
• Using Ω = Ω s 2 w 2 we get
ˆ o −Ω
ˆ
Ω
0.5095254 × 0.777771
Ωp =
= 0.4234126
1.393733 − 0.3332787
54
Copyright © 2005, S. K. Mitra
9
IIR Bandstop Digital Filter Design
• MATLAB code fragments used for the design
[N, Wn] = ellipord(0.4234126, 1, 1, 40, ’s’);
[B, A] = ellip(N, 1, 40, Wn, ’s’);
[BT, AT] = lp2bs(B, A, 1.1805647, 0.777771);
[num, den] = bilinear(BT, AT, 0.5);
0
Gain, dB
-10
-20
-30
-40
-50
0
55
0.2
0.4
0.6
0.8
1
ω/π
Copyright © 2005, S. K. Mitra
10
Least Integral-Squared Error
Design of FIR Filters
Least Integral-Squared Error
Design of FIR Filters
• Let H d (e jω ) denote the desired frequency
response
• Since H d (e jω ) is a periodic function of ω
with a period 2π, it can be expressed as a
Fourier series
• In general, H d (e jω ) is piecewise constant
with sharp transitions between bands
• In which case, {hd [n]} is of infinite length
and noncausal
• Objective - Find a finite-duration {ht [n]}
of length 2M+1 whose DTFT H t (e jω )
approximates the desired DTFT H d (e jω ) in
some sense
∞
H d (e jω ) = ∑ hd [n]e − jωn
n = −∞
where
hd [n] =
1
π
1
jω jωn
∫ H d (e )e dω, − ∞ ≤ n ≤ ∞
2π − π
2
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Least Integral-Squared Error
Design of FIR Filters
Least Integral-Squared Error
Design of FIR Filters
• Using Parseval’s relation we can write
• Commonly used approximation criterion Minimize the integral-squared error
1 π
jω
jω 2
Φ=
∫ H t (e ) − H d (e ) dω
2π − π
where
2
n = −∞
M
2
− M −1
∞
n = −∞
n = M +1
= ∑ ht [n] − hd [ n] + ∑ hd2 [n] + ∑ hd2 [n]
n=− M
M
H t (e jω ) = ∑ ht [n]e − jωn
n=− M
3
∞
Φ = ∑ ht [n] − hd [n]
4
• It follows from the above that Φ is
minimum when ht [n] = hd [n] for − M ≤ n ≤ M
• ⇒ Best finite-length approximation to ideal
infinite-length impulse response in the
mean-square sense is obtained by truncation
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Impulse Responses of Ideal
Filters
Least Integral-Squared Error
Design of FIR Filters
• Ideal lowpass filter HLP(e j )
• A causal FIR filter with an impulse response
h[n] can be derived from ht [n] by delaying:
h[n] = ht [n − M ]
• The causal FIR filter h[n] has the same
magnitude response as ht [n] and its phase
response has a linear phase shift of ωM
radians with respect to that of ht [n]
hLP [n] =
1
– c 0
HHP (e j )
1
6
Copyright © 2005, S. K. Mitra
c
• Ideal highpass filter -
– c
5
sin ωc n
πn , − ∞ ≤ n ≤ ∞
0
c
⎧ 1 − ωc ,
n=0
π
⎪
hHP [n] = ⎨
sin(ω n)
⎪− πnc , n ≠ 0
⎩
Copyright © 2005, S. K. Mitra
1
Impulse Responses of Ideal
Filters
Impulse Responses of Ideal
Filters
• Ideal bandstop filter -
• Ideal bandpass filter -
HBS (e j )
HBP (e j )
1
–1
– c2 – c1
– c2 – c1
c1
c2
c2
⎧ 1 − (ωc 2 − ωc1 ) ,
n=0
π
⎪
hBS [n] = ⎨
sin(ω n) sin(ωc 2n)
⎪ πnc1 −
πn , n ≠ 0
⎩
⎧sin(ωc 2 n) − sin(ωc1n) , n ≠ 0
πn
⎪ πn
hBP [n] = ⎨
ωc 2 ωc1
⎪
n=0
π − π ,
⎩
7
c1
8
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Impulse Responses of Ideal
Filters
Impulse Responses of Ideal
Filters
• Ideal multiband filter HML (e
j
A5
A1
A4
A2
A3
0
• Ideal discrete-time Hilbert transformer -
H ML (e jω ) = Ak ,
)
1
2
3
4
⎧ j, − π < ω < 0
H HT (e jω ) = ⎨
⎩− j , 0 < ω < π
ωk −1 ≤ ω ≤ ωk ,
k = 1, 2,K, L
for n even
⎧ 0,
hHT [n] = ⎨
⎩2/π n, for n odd
sin(ω n)
hML [n] = ∑ ( Al − Al +1) ⋅ πnL
L
l =1
9
10
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Impulse Responses of Ideal
Filters
Gibbs Phenomenon
• Gibbs phenomenon - Oscillatory behavior in
the magnitude responses of causal FIR filters
obtained by truncating the impulse response
coefficients of ideal filters
• Ideal discrete-time differentiator H DIF (e jω ) = jω,
0≤ ω ≤π
1.5
11
Magnitude
n=0
⎧⎪ 0,
hDIF [ n] = ⎨cos π n
⎪⎩ n , n ≠ 0
12
Copyright © 2005, S. K. Mitra
N = 20
N = 60
1
0.5
0
0
0.2
0.4
0.6
0.8
1
ω/π
Copyright © 2005, S. K. Mitra
2
Gibbs Phenomenon
13
• As can be seen, as the length of the lowpass
filter is increased, the number of ripples in
both passband and stopband increases, with
a corresponding decrease in the ripple
widths
• Height of the largest ripples remain the
same independent of length
• Similar oscillatory behavior observed in the
magnitude responses of the truncated
versions of other types of ideal filters
Gibbs Phenomenon
• Gibbs phenomenon can be explained by
treating the truncation operation as an
windowing operation:
ht [n] = hd [n] ⋅ w[ n]
• In the frequency domain
H t ( e jω ) =
14
1
2π
π
jϕ
j ( ω− ϕ)
) dϕ
∫ H d (e ) Ψ ( e
−π
• where H t (e jω ) and Ψ (e jω ) are the DTFTs
of ht [n] and w[n] , respectively
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Gibbs Phenomenon
Gibbs Phenomenon
• Thus H t (e jω ) is obtained by a periodic
continuous convolution of H d (e jω ) with
Ψ (e jω )
15
• If Ψ (e jω ) is a very narrow pulse centered at
ω = 0 (ideally a delta function) compared to
variations in H d (e jω ), then H t (e jω ) will
approximate H d (e jω ) very closely
• Length 2M+1 of w[n] should be very large
• On the other hand, length 2M+1 of ht [n]
should be as small as possible to reduce
computational complexity
16
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
Gibbs Phenomenon
Gibbs Phenomenon
• A rectangular window is used to achieve
simple truncation:
⎧1, 0 ≤ n ≤ M
wR [n] = ⎨
⎩0, otherwise
• Presence of oscillatory behavior in H t (e jω )
is basically due to:
– 1) hd [n] is infinitely long and not absolutely
• Oscillatory behavior can be explained by
jω
examining the DTFT ΨR (e ) of wR [n] :
Rectangular window
30
Amplitude
20
jω
18
Copyright © 2005, S. K. Mitra
side lobe
M=4
0
-10
-1
summable, and hence filter is unstable
– 2) Rectangular window has an abrupt transition
to zero
17
main lobe
M = 10
10
-0.5
0
ω/π
0.5
1
• ΨR (e ) has a main lobe centered at ω = 0
• Other ripples are called sidelobes
Copyright © 2005, S. K. Mitra
3
Gibbs Phenomenon
19
• Main lobe of ΨR (e jω ) characterized by its
width 4π /( 2 M + 1) defined by first zero
crossings on both sides of ω = 0
• As M increases, width of main lobe
decreases as desired
• Area under each lobe remains constant
while width of each lobe decreases with an
increase in M
• Ripples in H t (e jω ) around the point of
discontinuity occur more closely but with
no decrease in amplitude as M increases
Copyright © 2005, S. K. Mitra
Gibbs Phenomenon
• Rectangular window has an abrupt transition
to zero outside the range − M ≤ n ≤ M , which
results in Gibbs phenomenon in H t (e jω )
• Gibbs phenomenon can be reduced either:
(1) Using a window that tapers smoothly to
zero at each end, or
(2) Providing a smooth transition from
passband to stopband in the magnitude
specifications
20
Copyright © 2005, S. K. Mitra
4
Fixed Window Functions
Fixed Window Functions
1
Copyright © 2005, S. K. Mitra
• Plots of magnitudes of the DTFTs of these
windows for M = 25 are shown below:
-20
-40
-40
-60
-100
0.2
0.4
0.6
0.8
-100
1
0
0.2
0.4
0.6
ω/π
ω/π
Hamming window
Blackman window
0
-20
-40
-40
Gain, dB
0
-20
-60
-100
2
-60
-80
0
-80
0.8
1
-60
-80
0
0.2
0.4
0.6
0.8
1
-100
0
0.2
ω/π
0.4
0.6
0.8
1
ω/π
Copyright © 2005, S. K. Mitra
Fixed Window Functions
• Magnitude spectrum of each window
characterized by a main lobe centered at
ω = 0 followed by a series of sidelobes with
decreasing amplitudes
• Parameters predicting the performance of a
window in filter design are:
• Main lobe width
• Relative sidelobe level
Copyright © 2005, S. K. Mitra
0
-20
-80
Fixed Window Functions
3
Hann window
0
Gain, dB
Gain, dB
Rectangular window
Gain, dB
• Using a tapered window causes the height
of the sidelobes to diminish, with a
corresponding increase in the main lobe
width resulting in a wider transition at the
discontinuity
• Hann:
w[n] = 0.5 + 0.5 cos( 2π n ), − M ≤ n ≤ M
2M + 1
• Hamming:
w[n] = 0.54 + 0.46 cos( 2π n ), − M ≤ n ≤ M
2M + 1
• Blackman:
w[n] = 0.42 + 0.5 cos( 2π n ) + 0.08 cos( 4π n )
2M + 1
2M + 1
• Main lobe width ∆ ML - given by the
distance between zero crossings on both
sides of main lobe
• Relative sidelobe level Asl - given by the
difference in dB between amplitudes of
largest sidelobe and main lobe
4
Fixed Window Functions
Copyright © 2005, S. K. Mitra
Fixed Window Functions
• Distance between the locations of the
maximum passband deviation and minimum
stopband value ≅ ∆ ML
• Observe H t (e j (ωc + ∆ω) ) + H t (e j (ωc − ∆ω) ) ≅ 1
• Thus,
H t (e jωc ) ≅ 0.5
• Passband and stopband ripples are the same
5
Copyright © 2005, S. K. Mitra
• Width of transition band
∆ω = ω s − ω p < ∆ ML
6
Copyright © 2005, S. K. Mitra
1
Fixed Window Functions
Fixed Window Functions
• To ensure a fast transition from passband to
stopband, window should have a very small
main lobe width
• To reduce the passband and stopband ripple
δ, the area under the sidelobes should be
very small
• Unfortunately, these two requirements are
contradictory
• In the case of rectangular, Hann, Hamming,
and Blackman windows, the value of ripple
does not depend on filter length or cutoff
frequency ωc , and is essentially constant
• In addition,
∆ω ≈ c
M
where c is a constant for most practical
purposes
7
Copyright © 2005, S. K. Mitra
8
Fixed Window Functions
Fixed Window Functions
• Rectangular window - ∆ ML = 4π /(2M + 1)
Asl = 13.3 dB, α s = 20.9 dB, ∆ω = 0.92π / M
• Hann window - ∆ ML = 8π /(2M + 1)
Asl = 31.5 dB, α s = 43.9 dB, ∆ω = 3.11π / M
• Hamming window - ∆ ML = 8π /(2M + 1)
Asl = 42.7 dB, α s = 54.5 dB, ∆ω = 3.32π / M
• Blackman window - ∆ ML = 12π /( 2M + 1)
Asl = 58.1 dB, α s = 75.3 dB, ∆ω = 5.56π / M
9
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
• Filter Design Steps (1) Set
ωc = (ω p + ωs ) / 2
(2) Choose window based on specified α s
(3) Estimate M using
∆ω ≈ c
M
10
Copyright © 2005, S. K. Mitra
FIR Filter Design Example
FIR Filter Design Example
• Lowpass filter of length 51 and ωc = π / 2
Lowpass Filter Designed Using Hamming window
0
Gain, dB
Gain, dB
Lowpass Filter Designed Using Hann window
0
-50
• An increase in the main lobe width is
associated with an increase in the width of
the transition band
• A decrease in the sidelobe amplitude results
in an increase in the stopband attenuation
-50
-100
-100
0
0.2
0.4
0.6
0.8
0
1
0.2
0.4
0.6
0.8
1
ω/π
ω/π
Gain, dB
Lowpass Filter Designed Using Blackman window
0
-50
-100
11
0
0.2
0.4
0.6
ω/π
0.8
1
Copyright © 2005, S. K. Mitra
12
Copyright © 2005, S. K. Mitra
2
Adjustable Window Functions
Adjustable Window Functions
• Dolph-Chebyshev window can be designed
with any specified relative sidelobe level
while the main lobe width adjusted by
choosing length appropriately
• Filter order is estimated using
2.056α s − 16.4
N=
2.85( ∆ω)
• Dolph-Chebyshev Window M
w[n] = 1 [1γ + 2 ∑ Tk (β cos k ) cos 2nkπ ],
2M + 1
2M + 1
2M + 1
k =1
−M ≤n≤M
amplitude of sidelobe
where
γ=
main lobe amplitude
β = cosh( 1 cosh −1 1γ )
2M
and
⎧ cos(l cos −1 x ),
x ≤1
Tl ( x) = ⎨
−1
⎩cosh(l cosh x), x > 1
13
Copyright © 2005, S. K. Mitra
14
Properties of Dolph-Chebyshev window:
• All sidelobes are of equal height
• Stopband approximation error of filters
designed have essentially equiripple
behavior
• For a given window length, it has the
smallest main lobe width compared to other
windows resulting in filters with the
smallest transition band
• Gain response of a Dolph-Chebyshev
window of length 51 and relative sidelobe
level of 50 dB is shown below
Dolph-Chebyshev Window
Gain, dB
0
-20
-40
-60
0.2
0.4
0.6
0.8
Copyright © 2005, S. K. Mitra
Adjustable Window Functions
Adjustable Window Functions
-80
0
where ∆ω is the normalized transition
bandwidth, e.g, for a lowpass filter
∆ω = ωs − ω p
1
ω/π
15
Copyright © 2005, S. K. Mitra
16
Adjustable Window Functions
Adjustable Window Functions
• β controls the minimum stopband
attenuation of the windowed filter response
• β is estimated using
• Kaiser Window -
I 0{β 1 − (n / M ) }
, −M ≤n≤M
I 0 (β)
where β is an adjustable parameter and I 0 (u )
is the modified zeroth-order Bessel function
of the first kind:
∞ (u / 2) r
I 0 (u ) = 1 + ∑ [
]2
r!
r =1
• Note I 0 (u ) > 0 for u > 0
20 (u / 2) r
• In practice I 0 (u ) ≅ 1 + ∑ [
]2
r!
r =1
17
w[n] =
2
Copyright © 2005, S. K. Mitra
Copyright © 2005, S. K. Mitra
0.1102( α s −8.7 ),
⎧⎪
β= ⎨0.5842( α s − 21)0.4 + 0.07886( α s − 21),
0,
⎪⎩
• Filter order is estimated using
N=
for α s > 50
for 21 ≤ α s ≤ 50
for α s < 21
αs − 8
2.285(∆ω)
where ∆ω is the normalized transition
bandwidth
18
Copyright © 2005, S. K. Mitra
3
FIR Filter Design Example
FIR Filter Design Example
sin(0.4π n)
• Hence ht [ n] =
⋅ w[n], − 12 ≤ n ≤ 12
πn
where w[n] is the n-th coefficient of a
length-25 Kaiser window with β = 3.3953
-20
Gain, dB
0
-20
-40
-80
0
20
Impulse Responses of FIR Filters
with a Smooth Transition
0.2
0.4
0.6
0.8
1
-80
0
0.2
0.4
0.6
0.8
1
ω/π
Copyright © 2005, S. K. Mitra
Impulse Responses of FIR Filters
with a Smooth Transition
• First-order spline passband-to-stopband
transition
• Pth-order spline passband-to-stopband
transition
ωc = (ω p + ωs ) / 2
ωc / π,
⎧
⎪
hLP [n] = ⎨⎛ 2 sin( ∆ω n / 2 P) ⎞ P sin(ωc n)
⎪⎩⎜⎝ ∆ω n / 2 P ⎟⎠ ⋅ π n
∆ω = ωs − ω p
ωc / π,
⎧⎪
hLP [n] = ⎨ 2 sin(∆ω n / 2) sin(ωc n)
⋅ πn
⎪⎩
∆ω n
-40
-60
ω/π
Copyright © 2005, S. K. Mitra
21
0
-60
• Choose N = 24 implying M =12
19
Lowpass filter designed with Kaiser window
Kaiser Window
Gain, dB
• Specifications: ω p = 0.3π , ωs = 0.5π ,
α s = 40 dB
• Thus ωc = (ω p + ωs ) / 2 = 0.4π
δ s = 10−α s / 20 = 0.01
β = 0.5842(19)0.4 + 0.07886 ×19 = 3.3953
32
N=
= 22.2886
2.285(0.2π)
n=0
n=0
n >0
n >0
Copyright © 2005, S. K. Mitra
22
Copyright © 2005, S. K. Mitra
Lowpass FIR Filter Design
Example
• Example
Magnitude
1
P = 1, N = 40
P = 2, N = 60
0.8
0.6
0.4
0.2
0
0
0.2
0.4
0.6
0.8
1
ω/π
23
Copyright © 2005, S. K. Mitra
4
[dsp TIPS&TRICKS]
Greg Berchin
Precise Filter Design
Y
ou have just been assigned
to a new project at work,
in which the objective is
to replace an existing analog system with a functionally equivalent digital system. Your
job is to design a digital filter that
matches the magnitude and phase
response of the existing system’s analog
filter over a broad frequency range. You
are running out of ideas. The bilinear
transform and impulse invariance
methods provide poor matches to the
analog filter response, particularly at
high frequencies. Fast convolution
requires more computational resources
than you have and creates more
input/output latency than you can tolerate. What will you do?
In this article, we describe an obscure
but simple and powerful method for
designing a digital filter that approximates an arbitrary magnitude and phase
response. If applied to the problem
above, it can create a filter roughly comparable in computational burden and
latency to that created by the bilinear
transform method, with fidelity
approaching that of fast convolution. In
addition, the method described here can
also be applied to a wide variety of other
system identification tasks.
The filter design method we present
is called frequency-domain least-squares
(FDLS) [1]–[3]. The FDLS algorithm
produces a transfer function that approximates an arbitrary frequency response.
The input to the algorithm is a set of
magnitude and phase values at a large
number (typically thousands) of arbitrary
frequencies between 0 Hz and half the
sampling rate. The algorithm’s output is
a set of transfer function coefficients.
The FDLS algorithm is quite flexible in
that it can create transfer functions con-
taining poles and zeros (infinite response
filters), only zeros (finite response filters), or only poles (autoregressive networks). The algorithm uses nothing
more esoteric than basic linear algebra.
Before we can see how the technique
works, we need to review some basic linear algebra and matrix concepts.
BACKGROUND
First let us recall that, in order to
uniquely solve a system of equations, we
need as many equations as unknowns.
For example, the single equation with
one unknown 5x = 7 has the unique
solution x = 7/5. But the single equation with two unknowns 5x + 2y = 7
has multiple solutions x = (7 − 2y )/5
that depend on the unspecified y-value. If
another equation, −6x + 4y = 9, is
added to the equation above, there are
unique solutions for both x and y that
can be found algebraically or by matrix
inversion (denoted in the following by a
“−1” superscript):
5 2
−6 4
x
7
=
y
9
x
5
=
y
−6
1
= 38
16
7
8
= −1 7
9
1 − 16
7
5
9
32 9
− 16
.
21
45
+
16
32
2
4
Let us consider what happens if we
add another equation, x + y = 5, to the
pair that we already have above (we will
see later why we might want to do this).
There are no values of x and y that satisfy all three equations simultaneously. To
address this case, matrix algebra provides
the “pseudoinverse,” which determines
the values of x and y that come, in the
IEEE SIGNAL PROCESSING MAGAZINE [137] JANUARY 2007
least-squares sense, as close as possible
to satisfying all three equations. The
solution is then given by


 
5 2 7
x
 −6 4 
=  9  or
y
1 1
5

 
−1
5 2 T
5 2
x


≈  −6 4   −6 4 
y
1 1
1 1

T  
5 2
7
for THIS case:
×  −6 4   9 
p_inv(X) =
1 1
5
[inv(X'X)][X']
0.3716
≈
,
2.8491
where T denotes the matrix transpose. Of
course, the mathematical derivation of
the matrix inverse and pseudoinverse,
and the definition of least-squares, can
be found in any basic linear algebra text
[1]. And while our more mathematically
inclined readers will point out that there
are better ways than this to compute the
pseudoinverse, this method is adequate
for our example.
You may also remember that filter
specifications are commonly expressed in
terms of passband width and flatness,
transition band width, and stopband
attenuation. There may also be some general specifications about phase response
“DSP Tips and Tricks” introduces practical design and implementation signal processing algorithms that you
may wish to incorporate into your
designs. We encourage readers to
submit their contributions to
Associate Editors Rick Lyons
(r.lyons@ieee.org) or Britt Rorabaugh
(dspboss@aol.com).
1053-5888/07/$25.00©2007IEEE
[dsp TIPS&TRICKS]
continued
or time-domain performance, but the
exact magnitude and phase responses are
usually left to the designer’s discretion.
However, an important exception occurs
when a digital filter is to be used to emulate an analog filter. This is traditionally a
very difficult problem, because analog
systems are described by Laplace transforms using integration and differentiation, whereas digital systems are
described by z-transforms using delay.
Since the conversion between them is
nonlinear, the response of an analog system can only be approximated by a digital
system and vice-versa.
Let us assume that the transfer function of our digital filter (i.e., the mathematical description of the relationship
between the filter’s input and output) is
in a standard textbook form [2] given by
Y(z )
b0 + b1 z −1 + · · · + bN z −N
=
,
U(z )
1 + a1 z −1 + · · · + aD z −D
where U(z ) is the z-transform of the input
signal, Y(z ) is the z-transform of the output signal, and the a and b factors are realvalued coefficients. Furthermore, we
assume that the filter is causal, meaning
that its response to an input does not begin
until after the input is applied. Under these
assumptions, the time-domain difference
equation that implements our filter is
y(k) = − a1 y(k − 1) − · · · − aD y(k − D)
ues of which are not yet known. We also
know that the relationship between
input u and output y at any sample time
can be inferred from the frequency
response value A φ at frequency ω.
Combining these two ideas, we obtain
one equation in D + N + 1 unknowns
Let us conclude our background section with a comment on what a frequency response value means. In a simple
example, if the frequency response of a
system at a frequency ω1 is given in
magnitude/phase form as A1 φ1 , the
output amplitude will be A1 times the
input amplitude and the output phase
will be shifted an angle φ1 relative to the
input phase when a steady-state sine
wave of frequency ω1 is applied to the
system. For instance, if the input to the
system described above at time k is
u1 (k) = cos(kω1 ts ), where ts is the sampling period (equal to one over the sampling frequency), then the output will be
y1 (k) = A1 cos(kω1 ts + φ1 ) . The input
and output values at any sample time
can be determined in a similar manner.
For example, the input sample value N
samples
in
the
past
was
u1 (k − N) = cos ((k − N )ω1 ts ) and the
output sample value D samples in the
past was y1 (k − D) = A1 cos ((k − D)
ω1 ts + φ1 ). For our purposes, since k
represents the current sample time, its
value can conveniently be set to zero.
y1 (0) = [−y1 (−1) . . . − y1 (−D)
a 
1
 .. 
 . 
 
 aD 

u1 (0) . . . u1 (−N )] 
 b0  .
 
 . 
 .. 
bN
(Note that the current-sample index k
has been set to zero.) If we repeat using
A2 φ2 at a different frequency ω2 , we
obtain a second equation in D + N + 1
unknowns as shown in (a) at the bottom
of the page. And if we repeat at many
more different frequencies M than we
have unknowns D + N + 1, we know
from our review of linear algebra that the
pseudoinverse will compute values for
the set of coefficients a1 . . . aD and
b0 . . . bN that come as close as possible
to solving all of the equations, which is
exactly what we need to design our filter.
So now we can write (b), shown at the
bottom of the page. We can denote the
y1 (0) . . . yM (0) column vector above as
Y, the matrix as X, and the a1 . . . bN col-
FDLS FILTER APPROXIMATION
Based on our review of the pseudoinverse, transfer function, and frequency
response, we know that the output is a
combination of present and past input
and output values, each scaled by a set of
b or a coefficients (respectively), the val-
+ b0 u(k) + · · · + bN u(k − N ),
where the a and b coefficients are exactly
the same as in the transfer function
above, k is the time index, u(k) and y(k)
are the current values of the input and
output (respectively), u(k − N ) was the
input value N samples in the past, and
y(k − D) was the output value D samples
in the past. We can write the equation
above in matrix form as
y(k) = [−y(k − 1) . . . − y(k − D)
a 
1
 .. 
 . 
 
 aD 

u(k) . . . u(k − N )] 
 b0  .
 
 . 
 .. 
−y1 (−1) . . .
y1 (0)
=
y2 (0)
−y2 (−1) . . .
−y1 (−D)
−y2 (−D)
u1 (0) . . .
u2 (0) . . .
a 
1
 .. 
 . 
 

u1 (−N) 
 aD  .

u2 (−N) 
b
0
 
 . 
 .. 
(a)
bN



−y1 (−1) . . .
y1 (0)
 y2 (0)   −y2 (−1) . . .
 

 ..  = 
..
 .  
.
yM (0)
−yM (−1) . . .
−y1 (−D)
−y2 (−D)
..
.
u1 (0)
u2 (0)
..
.
−yM (−D)
uM (0) . . .
bN
IEEE SIGNAL PROCESSING MAGAZINE [138] JANUARY 2007
...
...
a 
1
  .. 
u1 (−N)  . 
 
u2 (−N) 
aD 



..
 b0  .

 
.
 . 
uM (−N)  .. 
bN
(b)
We can now summarize our filter
design trick as follows:
1) Select the numerator order N and
the denominator order D, where N
and D do not have to be equal and
either one (but not both) may be zero.
(We have found no “rule of thumb”
for defining N and D; they are best
determined experimentally.)
2) Define the M separate input um
cosine sequences, each of length
(N + 1).
3) Compute the M separate output ym
cosine sequences, each of length D
(based on Am φ m ).
4) Fill the X matrix with the input um
and output ym cosine sequences.
5) Fill the Y vector with the M output
cosine values, ym (0) = Am cos(φ m ).
6) Compute the pseudoinverse; the
resulting vector contains the filter
coefficients.
A numerical example is shown in
Figures 1 and 2, which illustrate the
magnitude and phase, respectively, of a
real-world example analog system (black)
and of the associated bilinear transform
(blue), impulse invariance (green), and
FDLS (red) approximations. The sampling rate is equal to 240 Hz and
D = N = 12. The red FDLS graphs are
almost completely obscured by the black
analog system graphs. In this example,
the FDLS errors are often three to four
orders of magnitude smaller than those
of the other methods. (In Figure 2, the
bilinear transform curve is obscured by
the FDLS and analog curves at low frequencies and by the impulse invariance
curve at high frequencies.)
In terms of the computational complexity of an FDIS-designed filter, the
number of feedback and feed-forward
coefficients is determined by the variables D and N, respectively. As such, an
FDIS-designed
filter
requires
(N + D + 1) multiplies and (N + D)
additions per filter output sample.
Magnitude (dB)
(X T X )−1 X T Y ≈ .
0
−10
−20
−30
−40
Black: Analog (Desired)
Blue: Bilinear Transform
Green: Impulse Invariance
Red: FDLS
−50
10−2
10−1
100
Frequency (Hz)
101
102
[FIG1] Magnitude responses of the filter designed using the bilinear transform, impulse
invariance, and FDLS methods.
150
Phase (degrees)
umn vector as . With these notations,
Y = X, and the pseudoinverse solves
for the vector that contains the
desired filter coefficients
100
50
0
−50
−100
−150
10−2
Black: Analog (Desired)
Blue: Bilinear Transform
Green: Impulse Invariance
Red: FDLS
10−1
100
Frequency (Hz)
101
102
[FIG2] Phase responses of the filter designed using the bilinear transform, impulse
invariance, and FDLS methods.
CONCLUSION
FDLS is a powerful method for designing digital filters. As is the case with all
approximation techniques, there are
circumstances in which the FDLS
method works well and others in which
it does not. The FDLS method does not
replace other filter design methods; it
provides one more method from which
to choose. FDLS is most useful in cases
where a specified frequency response
must be duplicated to within tight tolerances over a wide frequency range or
when the frequency response of an
existing system is known but the coefficients of the system’s transfer function are unknown. It is up to the
designer to determine whether to use
it in any given situation. Detailed
examples and a MATLAB code implementation of the FDLS algorithm are
available at http://apollo.ee.columbia.
edu/spm/?i=external/tipsandtricks.
IEEE SIGNAL PROCESSING MAGAZINE [139] JANUARY 2007
ACKNOWLEDGMENTS
My thanks to Jaime Andrés Aranguren
Cardona for providing the example
shown in Figures 1 and 2, originally
posted on the comp.dsp Newsgroup on
9 January 2005, which ultimately led to
this article.
AUTHOR
Greg Berchin (berchin@ieee.org) is a signal processing algorithm engineer who
provides contract engineering services
from Naperville, Illinois.
REFERENCES
[1] G. Strang, Linear Algebra and Its Applications,
2nd ed., Orlando, FL: Academic, pp. 103–152, 1980.
[2] R. Lyons, Understanding Digital Signal
Processing, 2nd ed., Upper Saddle River, NJ:
Prentice-Hall, pp. 232–240, 2004.
[3] G. Berchin, “A new algorithm for system identification from frequency response information,” master’s thesis, University of California-Davis, 1988 .
[4] G. Berchin and M.A. Soderstrand, “A transformdomain least-squares beamforming technique,” in
Proc. IEEE Oceans ‘90 Conf., Arlington, VA, Sept.
1990.
[SP]
FDLS Examples
by Greg Berchin and Richard Lyons [January 2007]
The following material provides additional examples of the FDLS algorithm described in the
January 2007 IEEE Signal Processing magazine DSP Tips & Tricks column article "Precise Filter
Design" by Greg Berchin.
Algebraic Example
Recall the FDLS matrix expression
⎡ a1 ⎤
⎢ ⎥
⎡ y1 (0) ⎤ ⎡ − y1 ( −1) K − y1 ( − D ) u1 (0) K u1 ( − N ) ⎤ ⎢ M ⎥
⎢ y (0) ⎥ ⎢ − y ( −1) K − y ( − D ) u (0) K u ( − N ) ⎥ ⎢a ⎥
2
2
2
2
⎥⎢ D ⎥ ,
⎢ 2 ⎥=⎢
⎥ ⎢ b0 ⎥
M
M
M
M
⎢ M ⎥ ⎢
⎥
⎢
⎥ ⎢
⎣ y M (0)⎦ ⎣ − y M ( −1) K − y M ( − D ) u M (0) K u M ( − N )⎦ ⎢ M ⎥
⎢ ⎥
⎣ bN ⎦
which we wrote as Y = XΘ.
Each individual element in the Y column vector is of the form Amcos(φm), and each
element in the X matrix is of the form A1cos(kω1ts + φ1) or cos(kω1ts). Because all of these
elements are of the form of a product (Amplitude)[cos(angle)], each element in Y and X is equal
to a constant.
Now if, say, D = 10 and N = 9, then:
y1(0) = A1cos(φ1)
is the first element of the Y column vector and
[–y1(–1) ... –y1(–10) u1(0) ... u1(–9)]
is the top row of the X matrix expression where
–y1(–1) = –A1cos[(–1)ω1ts + φ1] = –A1cos(–ω1ts + φ1)
–y1(–2) = –A1cos[(–2)ω1ts + φ1] = –A1cos(–2ω1ts + φ1)
...
–y1(–10) = –A1cos[(–10)ω1ts + φ1] = –A1cos(–10ω1ts + φ1)
and
u1(0) = cos[(0)ω1ts] = 1
u1(–1) = cos[(–1)ω1ts] = cos(–ω1ts)
u1(–2) = cos[(–2)ω1ts] = cos(–2ω1ts)
...
u1(–9) = cos[(–9)ω1ts] = cos(–9ω1ts).
IEEE Copyright © All Rights Reserved
Page 1 of 5
So the top row of the X matrix looks like:
[–A1cos(–ω1ts + φ1) –A1cos(–2ω1ts + φ1) ... –A1cos(–10ω1ts + φ1) 1 cos(–ω1ts)
cos(–2ω1ts) ... cos(–9ω1ts)].
The second row of the X matrix looks like:
[–A2cos(–ω2ts + φ2) –A2cos(–2ω2ts + φ2) ... –A2cos(–10ω2ts + φ2) 1 cos(–ω2ts)
cos(–2ω2ts) ... cos(–9ω2ts)].
And so on.
Numerical Example
Here’s an example of the above expressions using actual numbers. Suppose we
need to approximate the transfer function coefficients for the system whose frequency
magnitude and phase response is that shown in Figure E1. Assume that our discretesystem sample rate is 1000 Hz, thus ts = 10–3 seconds, and N = D = 2. Also assume
M = 8 and we have the eight A1 -to- A8 magnitude sample values and the eight φ1 -to- φ8
phase samples, shown as dots in Figure E1, available to us as input values to the FDLS
algorithm.
M=8
ωm = 2π . fm :
1.5
A5
Linear
1
Desired magnitude response
0.5
A1
(a)
A8
0
0
100
f1 = 0 Hz
200
300
Frequency
f7 = 106.3 Hz
400
500
ω1 = 2π(0.0)
ω2 = 2π(19.69)
ω3 = 2π(35.43)
ω4 = 2π(51.18)
ω5 = 2π(59.05)
ω6 = 2π(66.93)
ω7 = 2π(106.30)
ω8 = 2π(389.76)
f8 = 389.76 Hz
f4 = 51.18 Hz
(b)
Phase (radians)
4
φ5
2
φ1
Desired phase response
0
–2
φ8
0
100
200
300
Frequency
400
500
Fig E1
IEEE Copyright © All Rights Reserved
Page 2 of 5
In matrix form, the target analog system parameters are
┌
│0.0
│19.6850
│35.4331
fm = │51.1811
│59.0551
│66.9291
│106.299
│389.764
└
┐
┌
┐
│
│0.0
│
│
│0.1237 │
│
│0.2226 │
│ ωmts = │0.3216 │
│
│0.3711 │
│
│0.4205 │
│
│0.6679 │
│
│2.449 │
┘
└
┘
┌
┐
│0.2172 │
│0.2065 │
│0.1696 │
Am = │0.0164 │
│1.3959 │
│0.6734 │
│0.3490 │
│0.3095 │
└
┘
┌
│ 0.0
│–0.0156
│–0.0383
φm = │ 3.0125
│ 2.3087
│ 0.955
│ 0.0343
│ 0.0031
└
┐
│
│
│
│
│
│
│
│
┘
where the fm vector is in Hz, the ωmts vector is in radians, and 1 ≤ m ≤ 8. The first two
elements of the Y vector are:
y1(0) = A1cos(φ1) = 0.2172cos(0) = 0.2172.
y2(0) = A2cos(φ2) = 0.2065cos(–0.0156) = 0.2065.
The complete Y vector is:
Y =
┌
│A1cos(φ1)
│A2cos(φ2)
│A3cos(φ3)
│A4cos(φ4)
│A5cos(φ5)
│A6cos(φ6)
│A7cos(φ7)
│A8cos(φ8)
└
┐
┌
┐
│
│ 0.2172 │
│
│ 0.2065 │
│
│ 0.1695 │
│ = │–0.0162 │
│
│–0.9390 │
│
│ 0.6605 │
│
│ 0.3488 │
│
│ 0.3095 │
┘
└
┘
The two elements of the "y1" part of the first row of the X vector are:
–y1(–1) = –A1cos(–ω1ts + φ1) = –0.2172cos(–0 + 0) = –0.2172.
–y1(–2) = –A1cos(–2ω1ts + φ1) = –0.2172cos(–0 + 0) = –0.2172.
The two elements of the "y8" part of the eighth row of the X vector are:
–y8(–1) = –A8cos(–ω8ts + φ8) = –0.3095cos(–2.449 + 0.0031) = 0.2376.
–y8(–2) = –A8cos(–2ω8ts + φ8) = –0.3095cos(–4.898 + 0.0031) = –0.562.
IEEE Copyright © All Rights Reserved
Page 3 of 5
The three elements of the "u1" part of the first row of the X matrix are:
u1(0) = cos(0) = 1
u1(–1) = cos(–ω1ts) = cos(–0) = 1
u1(–2) = cos(–2ω1ts) = cos(–0) = 1.
The three elements of the "u8" part of the eighth row of the X matrix are:
u8(0) = cos(0) = 1
u8(–1) = cos(–ω8ts) = cos(–2.449) = –0.7696
u8(–2) = cos(–2ω8ts) = cos(–4.898) = 0.1845.
The complete X matrix is:
┌
│–A1cos(–1ω1ts+φ1)
│–A2cos(–1ω2ts+φ2)
│–A3cos(–1ω3ts+φ3)
X = │–A4cos(–1ω4ts+φ4)
│–A5cos(–1ω5ts+φ5)
│–A6cos(–1ω6ts+φ6)
│–A7cos(–1ω7ts+φ7)
│–A8cos(–1ω8ts+φ8)
└
┌
│–0.2172
│–0.2045
│–0.1639
= │ 0.0147
│ 0.5007
│–0.6564
│–0.2812
│ 0.2376
└
–0.2172
–0.994
–0.1502
0.0117
–0.0059
–0.5378
–0.0928
–0.0562
–A1cos(–2ω1ts+φ1)
–A2cos(–2ω2ts+φ2)
–A3cos(–2ω3ts+φ3)
–A4cos(–2ω4ts+φ4)
–A5cos(–2ω5ts+φ5)
–A6cos(–2ω6ts+φ6)
–A7cos(–2ω7ts+φ7)
–A8cos(–2ω8ts+φ8)
1.00
1.00
1.00
1.00
1.00
1.00
1.00
1.00
1.0000
0.9924
0.9753
0.9487
0.939
0.9129
0.7851
–0.7696
cos(0)
cos(0)
cos(0)
cos(0)
cos(0)
cos(0)
cos(0)
cos(0)
cos(–ω1ts)
cos(–ω2ts)
cos(–ω3ts)
cos(–ω4ts)
cos(–ω5ts)
cos(–ω6ts)
cos(–ω7ts)
cos(–ω8ts)
cos(–2ω1ts)
cos(–2ω2ts)
cos(–2ω3ts)
cos(–2ω4ts)
cos(–2ω5ts)
cos(–2ω6ts)
cos(–2ω7ts)
cos(–2ω8ts)
┐
│
│
│
│
│
│
│
│
┘
┐
1.0000 │
0.9696 │
0.9025 │
0.8002 │.
0.7370 │
0.6667 │
0.2328 │
0.1845 │
┘
Given the above Y vector and the X matrix, the FDLS algorithm computes the 2nd-order
(N = D = 2) transfer function coefficients vector θM=8 as
θM=8 =
┌
│–1.8439
│ 0.9842
│ 0.3033
│–0.5762
│ 0.3034
└
┐
│
│
│.
│
│
┘
IEEE Copyright © All Rights Reserved
Page 4 of 5
Treated as filter coefficients, we can write vector θM=8 as:
a0 = 1
a1 = –1.8439
a2 = 0.9842
b0 = 0.3033
b1 = –0.5762
b2 = 0.3034
implemented as the recursive filter network shown in Figure E2.
u(k)
y(k)
z –1
1.8439
z –1
0.3033
–0.5762
0.3034
–0.9842
Fig E2
(a)
Magnitude (dB)
The frequency-domain performance of the filter are the solid red curves shown in Figure E3.
There we see that the θM=8 coefficients provide an accurate approximation to the desired
frequency response in Figure E1.
0
–20
Desired magnitude response
Actual magnitude response
–40
0
100
200
300
Frequency
400
500
400
500
(b)
Phase (radians)
4
2
Desired phase response
Actual phase response
0
–2
0
100
200
300
Frequency
Fig E3
IEEE Copyright © All Rights Reserved
Page 5 of 5
Download