You are on page 1of 36

Analog Lowpass Filter Analog Lowpass Filter

Specifications Specifications
• Typical magnitude response H a ( jΩ) of an • In the passband, defined by 0 ≤ Ω ≤ Ω p , we
analog lowpass filter may be given as require
indicated below 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 ≤ Ω < ∞
i.e., H a ( jΩ) approximates zero within an
1 2 error of δ s
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Analog Lowpass Filter Analog Lowpass Filter


Specifications Specifications
• Ω p - passband edge frequency • Magnitude specifications may alternately be
• Ω s - stopband edge frequency given in a normalized form as indicated
• δ p - peak ripple value in the passband below
• δ s - peak ripple value in the stopband
• Peak passband ripple
α p = − 20 log10 (1 − δ p ) dB
• Minimum stopband attenuation
α s = − 20 log10 (δ s ) dB
3 4
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Analog Lowpass Filter


Analog Lowpass Filter Design
Specifications
• Two additional parameters are defined -
• Here, the maximum value of the magnitude
in the passband assumed to be unity Ωp
(1) Transition ratio k =
Ωs
• 1 / 1 + ε 2 - Maximum passband deviation,
given by the minimum value of the For a lowpass filter k < 1
magnitude in the passband
ε
(2) Discrimination parameter k1 =
A2 − 1
• 1 - Maximum stopband magnitude Usually k1 << 1
A
5 6
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

1
Butterworth Approximation
Butterworth Approximation
• The magnitude-square response of an N-th
order analog lowpass Butterworth filter
is given by • Gain in dB is G (Ω) = 10 log10 H a ( jΩ) 2
1
H a ( jΩ ) =
2
1 + (Ω / Ω c ) 2 N • As G (0) = 0 and
• First 2 N − 1 derivatives of H a ( jΩ) at Ω = 0
2
G (Ωc ) = 10 log10 (0.5) = −3.0103 ≅ −3 dB
are equal to zero Ω c is called the 3-dB cutoff frequency
• The Butterworth lowpass filter thus is said
to have a maximally-flat magnitude at Ω = 0
7 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 Filter
Butterworth lowpass filter are Ωc and N
1
N=2 • These are determined from the specified
N=4
0.8 N = 10 bandedges Ω p and Ω s , and minimum
Magnitude

0.6 passband magnitude 1 / 1 + ε 2, and


0.4
maximum stopband ripple 1 / A
0.2
0
0 1 2 3

9 10
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Butterworth Approximation Butterworth Approximation


• Since order N must be an integer, value
• Ωc and N are thus determined from
2
obtained is rounded up to the next highest
H a ( jΩ p ) = 1 = 1 integer
1 + (Ω p / Ω c ) 2 N 1 + ε 2
• This value of N is used next to determine Ωc
H a ( jΩ s ) =
2 1 = 1 by satisfying either the stopband edge or the
1 + ( Ω s / Ω c ) 2 N A2
passband edge specification exactly
• Solving the above we get • If the stopband edge specification is
log [( A2 − 1) / ε 2 ] log10 (1 / k1 ) satisfied, then the passband edge
N = 1 ⋅ 10 = specification is exceeded providing a safety
2 log10 (Ω s / Ω p ) log10 (1 / k )
margin
11 12
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

2
Butterworth Approximation Butterworth Approximation
• Example - Determine the lowest order of a
• Transfer function of an analog Butterworth Butterworth lowpass filter with a 1-dB cutoff
frequency at 1 kHz and a minimum attenuation of 40
lowpass filter is given by dB at 5 kHz
ΩcN ΩcN
H a ( s) = C = N = • Now
DN ( s ) s + ∑lN=−01d s l ∏lN=1 ( s − pl )
l 10 log10 ⎛⎜ 1 2 ⎞⎟ = −1
⎝1 + ε ⎠
where which yields ε 2 = 0.25895
pl = Ωc e j[π ( N + 2l−1) / 2 N ] , 1 ≤ l ≤ N and
• Denominator DN (s ) is known as the 10 log10 ⎛⎜ 12 ⎞⎟ = − 40
Butterworth polynomial of order N ⎝A ⎠
which yields A2 = 10,000
13 14
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Butterworth Approximation Chebyshev Approximation


• The magnitude-square response of an N-th
• Therefore 1= A2 − 1 = 196.51334
k1 ε order analog lowpass Type 1 Chebyshev filter
is given by
and 1 = Ωs = 5 1
H a ( s) =
2
k Ωp
1 + ε TN (Ω / Ω p )
2 2

• Hence where TN (Ω) is the Chebyshev polynomial


log (1 / k1 ) of order N:
N = 10 = 3.2811
log10 (1 / k ) ⎧ cos( N cos −1 Ω), Ω ≤1
TN (Ω) = ⎨ −1
• We choose N = 4 ⎩cosh( N cosh Ω), Ω >1
15 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,
• Typical magnitude response plots of the then
analog lowpass Type 1 Chebyshev filter are 1
H a ( jΩ s ) = = 12
2
shown below 1 + ε TN (Ω s / Ω p ) A
2 2
Type 1 Chebyshev Filter

1
N=2
N=3
• Solving the above we get
cosh −1 ( A2 − 1 / ε ) cosh −1 (1 / k1 )
0.8 N=8
Magnitude

0.6 N= =
0.4 cosh −1 (Ω s / Ω p ) cosh −1 (1 / k )
0.2
• Order N is chosen as the nearest integer
0
0 1

2 3
greater than or equal to the above value
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 • Typical magnitude response plots of the
order analog lowpass Type 2 Chebyshev analog lowpass Type 2 Chebyshev filter are
(also called inverse Chebyshev) filter is shown below
given by Type 2 Chebyshev Filter

1 N=3
H a ( jΩ ) =
2 1 N=5

⎡T (Ω / Ω p ) ⎤
2 0.8 N=7

Magnitude
1+ ε 2 ⎢ N s ⎥
0.6

⎣ TN (Ω s / Ω) ⎦ 0.4
0.2
where TN (Ω) is the Chebyshev polynomial 0
0 1 2 3
of order N Ω
19 20
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Chebyshev Approximation Elliptic Approximation


• The order N of the Type 2 Chebyshev filter • The square-magnitude response of an
is determined from given ε , Ω s , and A elliptic lowpass filter is given by
using 1
H a ( jΩ ) =
2
cosh −1 ( A2 − 1 / ε ) cosh −1 (1 / k1 ) 1 + ε RN ( Ω / Ω p )
2 2
N= =
cosh −1 (Ω s / Ω p ) cosh −1 (1 / k )
where RN (Ω) is a rational function of order
• Example - Determine the lowest order of a N satisfying RN (1 / Ω) = 1 / RN (Ω) , with the
Chebyshev lowpass filter with a 1-dB cutoff
frequency at 1 kHz and a minimum attenuation of roots of its numerator lying in the interval
40 dB at 5 kHz - 0 < Ω < 1 and the roots of its denominator
cosh −1 (1 / k1 ) lying in the interval 1 < Ω < ∞
N= = 2.6059
21 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 • Example - Determine the lowest order of a elliptic
can be estimated using lowpass filter with a 1-dB cutoff frequency at 1
2 log10 (4 / k1 ) kHz and a minimum attenuation of 40 dB at 5 kHz
N≅
log10 (1 / ρ ) Note: k = 0.2 and 1 / k1 = 196.5134
where k ' = 1 − k 2 • Substituting these values we get
ρ0 = 0.00255135,
ρ0 = 1 − k '
k '= 0.979796,
2(1 + k ') ρ = 0.0025513525
ρ = ρ0 + 2( ρ0 )5 + 15( ρ0 )9 + 150( ρ0 )13 • and hence N = 2.23308
• Choose N = 3
23 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
• Typical magnitude response plots with Ω p = 1 frequency at 1 kHz and a minimum
are shown below attenuation of 40 dB at 5 kHz
Elliptic Filter

N=3
• Code fragments used
1 N=4 [N, Wn] = ellipord(Wp, Ws, Rp, Rs, ‘s’);
0.8
Magnitude

0.6 [b, a] = ellip(N, Rp, Rs, Wn, ‘s’);


0.4 with Wp = 2*pi*1000;
0.2
Ws = 2*pi*5000;
0
0 1 2 3 Rp = 1;

25 26 Rs = 40;
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Design of Analog Highpass,


Highpass,
Analog Lowpass Filter Design Bandpass and Bandstop Filters
• Steps involved in the design process:
• Gain plot Step 1 - Develop of specifications of a
Lowpass Elliptic Filter prototype analog lowpass filter H LP (s)
0
from specifications of desired analog filter
HD (s ) using a frequency transformation
Gain, dB

-20
Step 2 - Design the prototype analog
-40
lowpass filter
-60 Step 3 - Determine the transfer function HD (s )
0 2000 4000 6000
Frequency, Hz of desired analog filter by applying the
inverse frequency transformation to H LP (s)
27 28
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Design of Analog Highpass,


Highpass,
Analog Highpass Filter Design
Bandpass and Bandstop Filters
• Let s denote the Laplace transform variable • Spectral Transformation:
of prototype analog lowpass filter H LP (s) Ω p Ω̂ p
and ŝ denote the Laplace transform s=

variable of desired analog filter HD (sˆ)
where Ω p is the passband edge frequency of
• The mapping from s-domain to ŝ -domain is H LP ( s) and Ω̂ p is the passband edge
given by the invertible transformation
frequency of H HP ( sˆ)
s = F (sˆ)
• On the imaginary axis the transformation is
• Then H D ( s
ˆ ) = H LP ( s ) s = F ( sˆ)
Ω pΩ ˆp
H LP ( s ) = HD ( sˆ) sˆ = F −1 ( s ) Ω=−

ˆ
29 30
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

5
Analog Highpass Filter Design
Analog Highpass Filter Design
• Example - Design an analog Butterworth
Ω pΩ ˆp highpass filter with the specifications:
Ω=− Fˆ p = 4 kHz, Fˆs = 1 kHz, α p = 0.1 dB,
Ωˆ
α s = 40 dB

Stopband − Ω s − Ω p Ω p Ωs Stopband • Choose Ω p = 1
0
Ω Lowpass
Passband • Then 2πFˆ p Fˆ p 4000
Ωs = = = =4
Passband Stopband Passband 2πFˆs Fˆs 1000
−Ω
ˆ p −Ω
ˆs 0 Ω̂ s Ω̂ p
Ω̂ Highpass • Analog lowpass filter specifications: Ω p = 1,
31 32
Ω s = 4 , α p = 0.1 dB, α s = 40 dB
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Analog Highpass Filter Design Analog Bandpass Filter


• Code fragments used Design
[N, Wn] = buttord(1, 4, 0.1, 40, ‘s’); • Spectral Transformation
[B, A] = butter(N, Wn, ‘s’); sˆ 2 + Ω
ˆ o2
[num, den] = lp2hp(B, A, 2*pi*4000); s = Ωp
sˆ(Ω
ˆ p2 − Ω ˆ p1 )
• Gain plots
Prototype Lowpass Filter Highpass Filter where Ω p is the passband edge frequency
0 0
of H LP (s ), and Ω
ˆ p1 and Ω
ˆ p 2 are the lower
-20 -20
and upper passband edge frequencies of
Gain, dB

Gain, dB

-40 -40
desired bandpass filter H BP (sˆ)
-60 -60

-80 -80
0 2 4 6 8 10 0 2 4 6 8 10
33 Ω Frequency, kHz 34
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Analog Bandpass Filter Analog Bandpass Filter


Design Design
• On the imaginary axis the transformation is

ˆ o2 − Ω
ˆ2
Ωˆ 2 −Ω
ˆ2 Ω = −Ω p
Ω = −Ω p o Ω ˆ Bw

ˆ Bw
Stopband − Ω s − Ω p Ω p Ωs
where Bw = Ω ˆ p2 − Ω
ˆ p1 is the width of Stopband
Ω Lowpass
0
passband and Ω̂ o is the passband center Passband

frequency of the bandpass filter


Stopband Passband Stopband Passband Stopband
• Passband edge frequency ± Ω p is mapped ˆ s2 ↓ − Ω
−Ω ˆ ↓ −Ω ˆ s1 ↓ Ω̂ o ↓ Ω
ˆ s1 0 Ω ˆ s2
Ω̂ Bandpass
ˆ p2 o− Ω
into m Ω
ˆ p1 and ± Ωˆ p 2, lower and upper −Ω ˆ p1 Ω
ˆ p1 Ω
ˆ p2

passband edge frequencies


35 36
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

6
Analog Bandpass Filter Analog Bandpass Filter
Design Design
• Stopband edge frequency ± Ω s is mapped • Case 1: Ωˆ p1Ω
ˆ p2 > Ω
ˆ s1Ω
ˆ s2
ˆ s1 and ± Ω
into m Ω ˆ s 2 , lower and upper
To make Ω p1Ω p 2 = Ω s1Ω
ˆ ˆ ˆ ˆ s 2 we can either
stopband edge frequencies
increase any one of the stopband edges or
• Also, decrease any one of the passband edges as
Ωˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω ˆ s1Ω
ˆ s2 shown below
• If bandedge frequencies do not satisfy the ← Passband ←
above condition, then one of the frequencies
needs to be changed to a new value so that Stopband → → Stopband
Ω̂
the condition is satisfied Ω
ˆ s1 Ω
ˆ p1 Ω
ˆ p2 Ω
ˆ s2
37 38
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Analog Bandpass Filter Analog Bandpass Filter


Design Design
(1) Decrease Ω ˆ p1 to Ωˆ s1Ω
ˆ s2 / Ωˆ p2 • Note: The condition Ω ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s2
larger passband and shorter can also be satisfied by decreasing Ω ˆ p2
leftmost transition band which is not acceptable as the passband is
(2) Increase Ωˆ s1 to Ωˆ p1Ωˆ p2 / Ωˆ s2 reduced from the desired value
No change in passband and shorter • Alternately, the condition can be satisfied
leftmost transition band by increasing Ω ˆ s 2 which is not acceptable
as the upper stop band is reduced from the
desired value
39 40
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Analog Bandpass Filter


Analog Bandpass Filter
Design
Design
• Case 2: Ωˆ p1Ω
ˆ p2 < Ω
ˆ s1Ωˆ s2
To make Ω ˆ p1Ω
ˆ p2 = Ωˆ s1Ωˆ s 2 we can either
decrease any one of the stopband edges or (1) Increase Ω ˆ p 2 to Ωˆ s1Ω
ˆ s2 / Ω
ˆ p1
increase any one of the passband edges as larger passband and shorter
shown below rightmost transition band
→ Passband (2) Decrease Ω ˆ s 2 to Ω
ˆ p1Ωˆ p2 / Ω
ˆ s1

No change in passband and shorter

Stopband ← Stopband
Ω̂
rightmost transition band

ˆ s1 Ω
ˆ p1 Ω
ˆ p2 Ω
ˆ s2
41 42
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

7
Analog Bandpass Filter Analog Bandpass Filter
Design Design
• Example - Design an analog elliptic
• Note: The condition Ω ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s2 bandpass filter with the specifications:
can also be satisfied by increasing Ω ˆ p1 Fˆ p1 = 4 kHz, Fˆ p 2 = 7 kHz, Fˆs1 = 3 kHz
which is not acceptable as the passband is Fs 2 = 8 kHz, α p = 1 dB, α s = 22 dB
ˆ
reduced from the desired value
• Alternately, the condition can be satisfied • Now Fˆ p1Fˆ p 2 = 28 × 106 and Fˆs1Fˆs 2 = 24 × 106
by decreasing Ω ˆ s1 which is not acceptable
• Since Fˆ p1Fˆ p 2 > Fˆs1Fˆs 2 we choose
as the lower stopband is reduced from the
desired value Fˆ p1 = Fˆs1Fˆs 2 / Fˆ p 2 = 3.571428 kHz
43 44
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Analog Bandpass Filter


Analog Bandpass Filter Design
Design • Code fragments used
[N, Wn] = ellipord(1, 1.4, 1, 22, ‘s’);
• We choose Ω p = 1 [B, A] = ellip(N, 1, 22, Wn, ‘s’);
• Hence [num, den]
24 − 9 = lp2bp(B, A, 2*pi*4.8989795, 2*pi*25/7);
Ωs = = 1.4 • Gain plot
(25 / 7) × 3 Prototype Lowpass Filter Bandpass Filter

• Analog lowpass filter specifications: Ω p = 1,


0
0

Ω s = 1.4 , α p = 1 dB, α s = 22 dB
Gain, dB

Gain, dB
-20
-20

-40 -40

-60 -60
45 46 0 2 4 6 8 0 5 10 15
Copyright © 2005, S. K. Mitra Ω Frequency, kHz © 2005, S. K. Mitra
Copyright

Analog Bandstop Filter Design Analog Bandstop Filter Design


• On the imaginary axis the transformation is
• Spectral Transformation ΩˆB
ˆ s2 − Ω
sˆ(Ω ˆ s1 ) Ω = Ωs 2 w 2
s = Ωs Ω
ˆ o −Ω ˆ
sˆ + Ω
2 ˆ 2o where Bw = Ω s 2 − Ω s1 is the width of
ˆ ˆ
where Ω s is the stopband edge frequency stopband and Ω̂o is the stopband center
of H LP ( s ) , and Ω
ˆ s1 and Ω
ˆ s 2 are the lower frequency of the bandstop filter
and upper stopband edge frequencies of the • Stopband edge frequency ± Ω s is mapped
desired bandstop filter H BS ( sˆ) into m Ωˆ s1and ± Ω
ˆ s 2 , lower and upper
stopband edge frequencies
47 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 • Also,
into m Ω
ˆ p1 and ± Ω
ˆ p 2 , lower and upper Ω
ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s2
passband edge frequencies • If bandedge frequencies do not satisfy the
Stopband − Ω s − Ω p Ω p Ωs Stopband above condition, then one of the frequencies
Ω Lowpass
0
Passband
needs to be changed to a new value so that
the condition is satisfied
Passband Stopband Passband Stopband Passband
Ω̂ Bandpass
ˆ p2 ↓ − Ω
−Ω ˆ o ↓ −Ω ˆ p10 Ω
ˆ p1 ↓ Ω̂ o ↓ Ω ˆ p2
−Ω
ˆ s2 −Ω
ˆ s1 Ωˆ s1 Ω
ˆ s2

49 50
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Analog Bandstop Filter Design Analog Bandstop Filter Design


• Case 1: Ωˆ p1Ω
ˆ p2 > Ω
ˆ s1Ωˆ s2
• To make Ω ˆ p1Ω
ˆ p2 = Ωˆ s1Ωˆ s 2 we can either
increase any one of the stopband edges or (1) Decrease Ω ˆ p 2 to Ωˆ s1Ωˆ s2 / Ω
ˆ p2
decrease any one of the passband edges as larger high-frequency passband
shown below and shorter rightmost transition band
(2) Increase Ωˆ s 2 to Ω ˆ p1Ωˆ p2 / Ωˆ s2

Passband
No change in passbands and
Passband
shorter rightmost transition band
Stopband
Ω̂
51 Ω
ˆ p1 Ω
ˆ s1 Ω
ˆ s2 Ω
ˆ p2 52
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Analog Bandstop Filter Design Analog Bandstop Filter Design


• Note: The condition Ω ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ωˆ s1Ω
ˆ s2 • Case 1: Ωˆ p1Ω
ˆ p2 < Ω
ˆ s1Ω
ˆ s2
can also be satisfied by decreasing • To make Ω p1Ω p 2 = Ω s1Ω
ˆ ˆ ˆ ˆ s 2 we can either
which is not acceptable as the low- Ω ˆ p1
decrease any one of the stopband edges or
frequency passband is reduced from the increase any one of the passband edges as
desired value shown below
• Alternately, the condition can be satisfied
by increasing Ω ˆ s1 which is not acceptable
Passband Passband
as the stopband is reduced from the desired
value Stopband
Ω̂
53 54 Ω
ˆ p1 Ω
ˆ s1 Ω
ˆ s2 Ω
ˆ p2
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

9
Analog Bandstop Filter Design Analog Bandstop Filter Design
• Note: The condition Ω ˆ o2 = Ω
ˆ p1Ω
ˆ p2 = Ω
ˆ s1Ω
ˆ s2
(1) Increase Ωˆ p1 to Ω
ˆ s1Ω
ˆ s2 / Ω
ˆ p1 can also be satisfied by increasing Ω ˆ p2
larger passband and shorter which is not acceptable as the high-
leftmost transition band frequency passband is decreased from the
desired value
(2) Decrease Ωˆ s1 to Ω
ˆ p1Ω
ˆ p2 / Ωˆ s1
• Alternately, the condition can be satisfied
No change in passbands and by decreasing Ω ˆ s 2 which is not acceptable
shorter leftmost transition band as the stopband is decreased
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
• Objective - Determination of a realizable
phase (delay) response is specified for the
transfer function G(z) approximating a
design of digital filter for most applications
given frequency response specification is an
important step in the development of a • In some situations, the unit sample response
digital filter or the step response may be specified
• If an IIR filter is desired, G(z) should be a • In most practical applications, the problem
stable real rational function of interest is the development of a realizable
approximation to a given magnitude
• Digital filter design is the process of
response specification
deriving the transfer function G(z)
1 2
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Digital Filter Specifications Digital Filter Specifications


• We discuss in this course only the • As the impulse response corresponding to
magnitude approximation problem each of these ideal filters is noncausal and
• There are four basic types of ideal filters of infinite length, these filters are not
with magnitude responses as shown below realizable
HLP(e j ) HHP (e j )
• In practice, the magnitude response
1 1
specifications of a digital filter in the
– c 0 c – c 0 c
passband and in the stopband are given with
HBP (e j ) HBS (e j ) some acceptable tolerances
–1 1 • In addition, a transition band is specified
between the passband and stopband
3 – c2 – c1 c1 c2 – c2 – c1 c1 c2 4
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Digital Filter Specifications Digital Filter Specifications


jω • As indicated in the figure, in the passband,
• For example, the magnitude response G (e )
of a digital lowpass filter may be given as defined by 0 ≤ ω ≤ ω p , we require that
indicated below G (e jω ) ≅ 1 with an error ± δ p, i.e.,
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 6
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

1
Digital Filter Specifications
Digital Filter Specifications
• ω p - passband edge frequency
• ωs - stopband edge frequency • Specifications are often given in terms of

• δ p - peak ripple value in the passband loss function A (ω) = − 20 log10 G (e ) in
• δ s - peak ripple value in the stopband dB
• Since G (e jω ) is a periodic function of ω, • Peak passband ripple
and G (e jω ) of a real-coefficient digital α p = − 20 log10 (1 − δ p ) dB
filter is an even function of ω • Minimum stopband attenuation
• As a result, filter specifications are given α s = − 20 log10 (δ s ) dB
only for the frequency range 0 ≤ ω ≤ π
7 8
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Digital Filter Specifications Digital Filter Specifications


• Magnitude specifications may alternately be
• Here, the maximum value of the magnitude
given in a normalized form as indicated
in the passband is assumed to be unity
below

• 1 / 1 + ε 2 - Maximum passband deviation,


given by the minimum value of the
magnitude in the passband

• 1 - Maximum stopband magnitude


A
9 10
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Digital Filter Specifications


Digital Filter Specifications • In practice, passband edge frequency Fp
and stopband edge frequency Fs are
• For the normalized specification, maximum specified in Hz
value of the gain function or the minimum • For digital filter design, normalized
value of the loss function is 0 dB bandedge frequencies need to be computed
• Maximum passband attenuation - from specifications in Hz using
( )
α max = 20 log10 1 + ε 2 dB
ωp =
Ω p 2π Fp
= = 2π FpT
• For δ p << 1, it can be shown that FT FT
α max ≅ − 20 log10 (1 − 2 δ p ) dB Ω 2π Fs
ωs = s = = 2π Fs T
FT FT
11 12
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

2
Selection of Filter Type
Digital Filter Specifications • The transfer function H(z) meeting the
frequency response specifications should be
• Example - Let Fp = 7 kHz, Fs = 3 kHz, and a causal transfer function
FT = 25 kHz • For IIR digital filter design, the IIR transfer
• Then function is a real rational function of z −1:
2π(7 × 103 ) p0 + p1z −1 + p2 z − 2 + L + pM z − M
ωp = = 0.56π H ( z) = , M≤N
25 × 103 d 0 + d1z −1 + d 2 z − 2 + L + d N z − N
2π(3 × 103 )
ωs = = 0.24π • H(z) must be a stable transfer function and
25 × 103 must be of lowest order N for reduced
13 14 computational complexity
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Selection of Filter Type Selection of Filter Type


• For FIR digital filter design, the FIR • Advantages in using an FIR filter -
transfer function is a polynomial in z −1
with real coefficients: (1) Can be designed with exact linear phase,
N (2) Filter structure always stable with
H ( z ) = ∑ h[n] z −n quantized coefficients
n =0
• Disadvantages in using an FIR filter - Order
• For reduced computational complexity,
of an FIR filter, in most cases, is
degree N of H(z) must be as small as
possible considerably higher than the order of an
equivalent IIR filter meeting the same
• If a linear phase is desired, the filter
coefficients must satisfy the constraint: specifications, and FIR filter has thus higher
computational complexity
15 h[n] = ± h[ N − n] 16
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Digital Filter Design:


Digital Filter Design:
Basic Approaches
Basic Approaches • This approach has been widely used for the
• Most common approach to IIR filter design - following reasons:
(1) Convert the digital filter specifications (1) Analog approximation techniques are
into an analog prototype lowpass filter highly advanced
specifications (2) They usually yield closed-form
• (2) Determine the analog lowpass filter solutions
transfer function H a (s ) (3) Extensive tables are available for
analog filter design
• (3) Transform H a (s ) into the desired digital
(4) Many applications require digital
transfer function G ( z )
simulation of analog systems
17 18
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

3
Digital Filter Design: Digital Filter Design:
Basic Approaches Basic Approaches
• An analog transfer function to be denoted as • Basic idea behind the conversion of H a (s )
into G ( z ) is to apply a mapping from the
P ( s)
H a ( s) = a s-domain to the z-domain so that essential
Da ( s ) properties of the analog frequency response
where the subscript “a” specifically are preserved
indicates the analog domain • Thus mapping function should be such that
• A digital transfer function derived from H a ( s ) – Imaginary ( jΩ ) axis in the s-plane be
shall be denoted as mapped onto the unit circle of the z-plane
P( z )
G( z) = – A stable analog transfer function be mapped
D( z ) into a stable digital transfer function
19 20
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Digital Filter Design:


Digital Filter Design:
Basic Approaches
• FIR filter design is based on a direct
Basic Approaches
approximation of the specified magnitude • Three commonly used approaches to FIR
response, with the often added requirement filter design -
that the phase be linear
(1) Windowed Fourier series approach
• The design of an FIR filter of order N may
be accomplished by finding either the (2) Frequency sampling approach
length-(N+1) impulse response samples {h[n]} (3) Computer-based optimization methods
or the (N+1) samples of its frequency
response H (e jω )
21 22
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

IIR Digital Filter Design: Bilinear


Bilinear Transformation
Transformation Method
• Bilinear transformation - • Digital filter design consists of 3 steps:
⎛ −1 ⎞ (1) Develop the specifications of Ha ( s ) by
s = 2 ⎜⎜ 1 − z −1 ⎟⎟ applying the inverse bilinear transformation
T ⎝1 + z ⎠
to specifications of G(z)
• Above transformation maps a single point
in the s-plane to a unique point in the (2) Design Ha (s )
z-plane and vice-versa (3) Determine G(z) by applying bilinear
• Relation between G(z) and Ha ( s ) is then transformation to Ha ( s )
given by • As a result, the parameter T has no effect on
G ( z ) = Ha ( s ) 2 ⎛⎜ 1− z −1 ⎞⎟ G(z) and T = 2 is chosen for convenience
s=
T ⎜ 1+ z −1 ⎟
23 ⎝ ⎠ 24
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

4
Bilinear Transformation
• Inverse bilinear transformation for T = 2 is Bilinear Transformation
z = 1+ s
1− s • Mapping of s-plane into the z-plane

• For s = σo + jΩo
(1 + σo ) + jΩo 2 (1 + σo ) + Ω o
2 2
z= ⇒z =
(1 − σo ) − jΩo (1 − σo ) 2 + Ωo2
• Thus, σo = 0 → z = 1
σo < 0 → z < 1
σo > 0 → z > 1
25 26
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Bilinear Transformation Bilinear Transformation



• For z = e with T = 2 we have • Mapping is highly nonlinear
− jω e − jω / 2 (e jω / 2 − e − jω / 2 )
jΩ = 1 − e − jω = − jω / 2 jω / 2 − jω / 2 • Complete negative imaginary axis in the s-
1+ e e (e +e ) plane from Ω = −∞ to Ω = 0 is mapped into
j 2 sin(ω / 2)
= = j tan(ω / 2) the lower half of the unit circle in the z-plane
or Ω = tan(ω / 2) 2 cos(ω / 2) from z = −1 to z = 1
• Complete positive imaginary axis in the s-
plane from Ω = 0 to Ω = ∞ is mapped into the
upper half of the unit circle in the z-plane
from z = 1 to z = −1
27 28
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Bilinear Transformation Bilinear Transformation


• Nonlinear mapping introduces a distortion • Steps in the design of a digital filter -
in the frequency axis called frequency (1) Prewarp (ω p , ωs ) to find their analog
warping equivalents (Ω p , Ω s )
• Effect of warping shown below (2) Design the analog filter H a (s )
Ω Ω = tan(ω/2) (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
29 30
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

5
IIR Digital Filter Design Using
Bilinear Transformation IIR Digital Filter Design Using
• Example - Consider Bilinear Transformation
Ωc • Rearranging terms we get
H a ( s) =
s + Ωc −1
G ( z ) = 1 − α ⋅ 1 + z −1
• Applying bilinear transformation to the above 2 1−α z
we get the transfer function of a first-order where
digital lowpass Butterworth filter
1 − Ωc 1 − tan(ωc / 2)
α= =
Ωc (1 + z −1 ) 1 + Ωc 1 + tan(ωc / 2)
G ( z ) = H a ( s ) s =1− z −1 =
1+ z −1
(1 − z −1 ) + Ωc (1 + z −1 )
31 32
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

IIR Digital Filter Design Using IIR Digital Filter Design Using
Bilinear Transformation Bilinear Transformation
• Example - Consider the second-order analog • Then G ( z ) = H a ( s ) s =1− z −1

notch transfer function 1+ z −1

s 2 + Ωo2 (1 + Ωo ) − 2(1 − Ωo ) z −1 + (1 + Ωo2 ) z −2


2 2
H a ( s) = 2 =
s + B s + Ωo2 (1 + Ωo2 + B) − 2(1 − Ωo2 ) z −1 + (1 + Ωo2 − B ) z −2
−1 −2
for which H a ( jΩo ) = 0 1+α 1 − 2β z + z
= ⋅
2 1 − 2 β (1 + α ) z −1 + α z −2
H a ( j 0) = H a ( j∞) = 1
• Ωo is called the notch frequency 1 + Ωo2 − B 1 − tan( Bw / 2)
where α = =
• If H a ( jΩ 2 ) = H a ( jΩ1 ) = 1 / 2 then 1 + Ωo2 + B 1 + tan( Bw / 2)
B = Ω 2 − Ω1 is the 3-dB notch bandwidth 1 − Ωo2
33 34 β= = cos ωo
Copyright © 2005, S. K. Mitra 1 + Ωo2 Copyright © 2005, S. K. Mitra

IIR Digital Filter Design Using IIR Digital Filter Design Using
Bilinear Transformation Bilinear Transformation
• Example - Design a 2nd-order digital notch • Thus
filter operating at a sampling rate of 400 Hz 0.954965 − 1.1226287 z −1 + 0.954965 z − 2
with a notch frequency at 60 Hz, 3-dB notch G( z) =
bandwidth of 6 Hz 1 − 1.1226287 z −1 + 0.90993 z − 2
• The gain and phase responses are shown below
• Thus ωo = 2π(60 / 400) = 0.3π 2

Bw = 2π(6 / 400) = 0.03π 0


1
Phase, radians

-10
Gain, dB

• From the above values we get 0


-20
α = 0.90993 -30 -1

β = 0.587785 -40
0 50 100 150 200
-2
0 50 100 150 200
35 36 Frequency, Hz Frequency, Hz
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

6
IIR Lowpass Digital Filter Design IIR Lowpass Digital Filter Design
Using Bilinear Transformation Using Bilinear Transformation
• Example - Design a lowpass Butterworth • Prewarping we get
digital filter with ω p = 0.25π, ωs = 0.55π , Ω p = tan(ω p / 2) = tan(0.25π / 2) = 0.4142136
α p ≤ 0.5 dB, and α s ≥ 15 dB Ω s = tan(ωs / 2) = tan(0.55π / 2) = 1.1708496
• Thus • The inverse transition ratio is
ε 2 = 0.1220185 A2 = 31.622777 1 Ωs
= = 2.8266809
• If G (e j 0 ) = 1 this implies k Ωp
20 log10 G (e j 0.25π ) ≥ − 0.5 • The inverse discrimination ratio is

20 log10 G (e j 0.55π ) ≤ −15 1 A2 − 1


= = 15.841979
k1 ε
37 38
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

IIR Lowpass Digital Filter Design IIR Lowpass Digital Filter Design
Using Bilinear Transformation Using Bilinear Transformation
• We then get
log10 (1 / k1 ) Ω c = 1.419915 (Ω p ) = 0.588148
• Thus N= = 2.6586997
log10 (1 / k )
• 3rd-order lowpass Butterworth transfer
• We choose N = 3 function for Ωc = 1 is
• To determine Ωc we use Han ( s ) =
1
( s + 1)( s 2 + s + 1)
2 1 1
H a ( jΩ p ) = = • Denormalizing to get Ω c = 0.588148 we
1 + (Ω p / Ω c ) 2N
1 + ε2
arrive at
Ha ( s ) = Han ⎛⎜ ⎞
s

39 40 ⎝ 0.588148 ⎠
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

IIR Lowpass Digital Filter Design Design of IIR Highpass,


Highpass, Bandpass,
Bandpass,
Using Bilinear Transformation and Bandstop Digital Filters
• Applying bilinear transformation to H a (s ) • First Approach -
we get the desired digital transfer function
(1) Prewarp digital frequency specifications
G ( z ) = H a ( s ) s =1− z −1

1+ z −1 of desired digital filter GD (z ) to arrive at


• Magnitude and gain responses of G(z) shown frequency specifications of analog filter H D (s )
below: of same type
1 0

0.8 -10
(2) Convert frequency specifications of H D (s )
into that of prototype analog lowpass filter
Magnitude

Gain, dB

0.6
-20
0.4 H LP (s )
-30
0.2

0 -40
(3) Design analog lowpass filter H LP (s )
41 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 42
ω/π ω/π
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

7
Design of IIR Highpass,
Highpass, Bandpass,
Bandpass, Design of IIR Highpass,
Highpass, Bandpass,
Bandpass,
and Bandstop Digital Filters and Bandstop Digital Filters
(4) Convert H LP (s ) into H D (s ) using • Second Approach -
inverse frequency transformation used in (1) Prewarp digital frequency specifications
Step 2 of desired digital filter GD (z ) to arrive at
(5) Design desired digital filter GD (z ) by frequency specifications of analog filter H D (s )
applying bilinear transformation to H D (s ) of same type
(2) Convert frequency specifications of H D (s )
into that of prototype analog lowpass filter
H LP (s )
43 44
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Design of IIR Highpass,


Highpass, Bandpass,
Bandpass, IIR Highpass Digital Filter Design
and Bandstop Digital Filters • Design of a Type 1 Chebyshev IIR digital
highpass filter
(3) Design analog lowpass filter H LP (s ) • Specifications: Fp = 700 Hz, Fs = 500 Hz,
(4) Convert H LP (s ) into an IIR digital α p = 1 dB, α s = 32 dB, FT = 2 kHz
transfer function GLP (z ) using bilinear
• Normalized angular bandedge frequencies
transformation
2π Fp2π × 700
(5) Transform GLP (z ) into the desired ωp = = = 0.7 π
digital transfer function GD (z ) FT 2000
• We illustrate the first approach 2π Fs 2π × 500
ωs = = = 0.5π
FT 2000
45 46
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

IIR Highpass Digital Filter Design IIR Highpass Digital Filter Design
• Prewarping these frequencies we get • MATLAB code fragments used for the design

ˆ p = tan(ω p / 2) = 1.9626105
[N, Wn] = cheb1ord(1, 1.9626105, 1, 32, ’s’)
Ωˆ s = tan(ωs / 2) = 1.0 [B, A] = cheby1(N, 1, Wn, ’s’);
• For the prototype analog lowpass filter choose [BT, AT] = lp2hp(B, A, 1.9626105);
Ωp =1 [num, den] = bilinear(BT, AT, 0.5);
Ω Ω ˆ
• Using Ω = − p p we get Ω s = 1.962105 0

Ωˆ -10

• Analog lowpass filter specifications: Ω p = 1,


Gain, dB

-20
-30
Ω s = 1.926105 , α p = 1dB, α s = 32 dB -40

-50
0 0.2 0.4 0.6 0.8 1
47 48 ω/π
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

8
IIR Bandpass Digital Filter Design IIR Bandpass Digital Filter Design
• Design of a Butterworth IIR digital bandpass • Width of passband Bw = Ω ˆ p2 − Ωˆ p1 = 0.777771
filter
Ωˆ o2 = Ωˆ p1Ωˆ p 2 = 1.393733
• Specifications: ω p1 = 0.45π , ω p 2 = 0.65π ,
Ωˆ s1Ωˆ s 2 = 1.23010325 ≠ Ω ˆ o2
ωs1 = 0.3π, ωs 2 = 0.75π, α p = 1 dB, α s = 40 dB
• We therefore modify Ω s1 so that Ω
ˆ ˆ s1and
• Prewarping we get Ωs2
ˆ exhibit geometric symmetry with
Ωˆ p1 = tan(ω p1 / 2) = 0.8540807 respect to Ω ˆ o2

ˆ p 2 = tan(ω p 2 / 2) = 1.6318517 • We set Ω ˆ s1 = 0.5773031

ˆ s1 = tan(ωs1 / 2) = 0.5095254 • For the prototype analog lowpass filter we
choose Ω p = 1
Ω s 2 = tan(ωs 2 / 2) = 2.41421356
ˆ
49 50
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

IIR Bandpass Digital Filter Design IIR Bandpass Digital Filter Design
• MATLAB code fragments used for the design
• Using Ω = −Ω p Ω o − Ω we get
ˆ2 ˆ2
Ωˆ Bw [N, Wn] = buttord(1, 2.3617627, 1, 40, ’s’)
[B, A] = butter(N, Wn, ’s’);
1.393733 − 0.3332788 [BT, AT] = lp2bp(B, A, 1.1805647, 0.777771);
Ωs = = 2.3617627
0.5773031× 0.777771 [num, den] = bilinear(BT, AT, 0.5);
• Specifications of prototype analog 0

Butterworth lowpass filter: -10


Gain, dB

Ω p = 1 , Ω s = 2.3617627 , α p = 1 dB,
-20
-30

α s = 40 dB -40
-50
0 0.2 0.4 0.6 0.8 1
51 52 ω/π
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

IIR Bandstop Digital Filter Design IIR Bandstop Digital Filter Design
• Design of an elliptic IIR digital bandstop filter • We therefore modify Ωˆ p1so that Ω
ˆ p1and Ω
ˆ p2
• Specifications: ωs1 = 0.45π , ωs 2 = 0.65π , exhibit geometric symmetry with respect to
ω p1 = 0.3π, ω p 2 = 0.75π , α p = 1 dB, α s = 40 dB Ωˆ o2
• Prewarping we get • We set Ω ˆ p1 = 0.577303
Ωˆ s1 = 0.8540806, Ω ˆ s 2 = 1.6318517, • For the prototype analog lowpass filter we
ˆ p1 = 0.5095254, Ω
Ω ˆ p 2 = 2.4142136 choose Ω s = 1
ΩˆB
• Width of stopband Bw = Ω ˆ s2 − Ω
ˆ s1 = 0.777771 • Using Ω = Ω s 2 w 2 we get
Ωˆ o −Ω
ˆ

ˆ o2 = Ωˆ s 2Ω
ˆ s1 = 1.393733 0.5095254 × 0.777771
Ωp = = 0.4234126
Ω p 2Ω p1 = 1.230103 ≠ Ω
ˆ ˆ ˆ o2 1.393733 − 0.3332787
53 54
Copyright © 2005, S. K. Mitra 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
-10
Gain, dB

-20
-30
-40

-50
0 0.2 0.4 0.6 0.8 1
55 ω/π
Copyright © 2005, S. K. Mitra

10
Least Integral-Squared Error
Least Integral-Squared Error
Design of FIR Filters
• Let H d (e jω ) denote the desired frequency
Design of FIR Filters
response • In general, H d (e jω ) is piecewise constant
• Since H d (e jω ) is a periodic function of ω with sharp transitions between bands
with a period 2π, it can be expressed as a • In which case, {hd [n]} is of infinite length
Fourier series and noncausal

H d (e jω ) = ∑ hd [n]e − jωn • Objective - Find a finite-duration {ht [n]}
where n = −∞ of length 2M+1 whose DTFT H t (e jω )
1 π
jω jωn
approximates the desired DTFT H d (e jω ) in
hd [n] = ∫ H d (e )e dω, − ∞ ≤ n ≤ ∞ some sense
2π − π
1 2
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Least Integral-Squared Error


Least Integral-Squared Error
Design of FIR Filters
Design of FIR Filters • Using Parseval’s relation we can write

• Commonly used approximation criterion - Φ = ∑ ht [n] − hd [n]
2
Minimize the integral-squared error n = −∞
M − M −1 ∞
1 π jω jω 2 = ∑ ht [n] − hd [ n] + ∑ hd2 [n] + ∑ hd2 [n]
2
Φ= ∫ H t (e ) − H d (e ) dω n=− M n = −∞ n = M +1
2π − π
• It follows from the above that Φ is
where minimum when ht [n] = hd [n] for − M ≤ n ≤ M
M
H t (e jω ) = ∑ ht [n]e − jωn • ⇒ Best finite-length approximation to ideal
n=− M
infinite-length impulse response in the
3 4 mean-square sense is obtained by truncation
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Impulse Responses of Ideal


Least Integral-Squared Error
Filters
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: sin ωc n
hLP [n] = πn , − ∞ ≤ n ≤ ∞
1

h[n] = ht [n − M ] – c 0 c

• The causal FIR filter h[n] has the same • Ideal highpass filter -
magnitude response as ht [n] and its phase HHP (e j )
⎧ 1 − ωc , n=0
response has a linear phase shift of ωM ⎪ π
radians with respect to that of ht [n]
1
hHP [n] = ⎨
sin(ω n)
⎪− πnc , n ≠ 0
5 6
– c 0 c

Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

1
Impulse Responses of Ideal
Impulse Responses of Ideal
Filters
Filters
• Ideal bandstop filter -
• Ideal bandpass filter - HBS (e j )

HBP (e j )
1
–1

– c2 – c1 c1 c2
– c2 – c1 c1 c2

⎧sin(ωc 2 n) − sin(ωc1n) , n ≠ 0 ⎧ 1 − (ωc 2 − ωc1 ) , n=0


⎪ π
⎪ πn πn hBS [n] = ⎨
hBP [n] = ⎨ sin(ω n) sin(ωc 2n)
ωc 2 ωc1 ⎪ πnc1 −
⎪ πn , n ≠ 0
⎩ π − π , n=0 ⎩
7 8
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Impulse Responses of Ideal Impulse Responses of Ideal


Filters Filters
• Ideal multiband filter -
• Ideal discrete-time Hilbert transformer -
H ML (e jω ) = Ak ,
j
HML (e )

⎧ j, − π < ω < 0
H HT (e jω ) = ⎨
A5
A1
A4
ωk −1 ≤ ω ≤ ωk , ⎩− j , 0 < ω < π
A2
A3
0 1 2 3 4 k = 1, 2,K, L
⎧ 0, for n even
L sin(ω n) hHT [n] = ⎨
hML [n] = ∑ ( Al − Al +1) ⋅ πnL ⎩2/π n, for n odd
l =1
9 10
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Impulse Responses of Ideal Gibbs Phenomenon


Filters • Gibbs phenomenon - Oscillatory behavior in
• Ideal discrete-time differentiator - the magnitude responses of causal FIR filters
obtained by truncating the impulse response
H DIF (e jω ) = jω, 0≤ ω ≤π coefficients of ideal filters
1.5
N = 20

⎧⎪ 0, n=0 1
N = 60
Magnitude

hDIF [ n] = ⎨cos π n
⎪⎩ n , n ≠ 0 0.5

0
0 0.2 0.4 0.6 0.8 1
11 12 ω/π
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

2
Gibbs Phenomenon Gibbs Phenomenon
• As can be seen, as the length of the lowpass • Gibbs phenomenon can be explained by
filter is increased, the number of ripples in treating the truncation operation as an
both passband and stopband increases, with windowing operation:
a corresponding decrease in the ripple ht [n] = hd [n] ⋅ w[ n]
widths • In the frequency domain
• Height of the largest ripples remain the π
H t ( e jω ) = jϕ j ( ω− ϕ)
1
same independent of length 2π ∫ H d (e ) Ψ ( e ) dϕ
−π
• where H t (e jω ) and Ψ (e jω ) are the DTFTs
• Similar oscillatory behavior observed in the
magnitude responses of the truncated
of ht [n] and w[n] , respectively
13 versions of other types of ideal filters 14
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 • If Ψ (e jω ) is a very narrow pulse centered at
Ψ (e jω ) ω = 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
15 16
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Gibbs Phenomenon Gibbs Phenomenon


• A rectangular window is used to achieve • Oscillatory behavior can be explained by

simple truncation: examining the DTFT ΨR (e ) of wR [n] :
⎧1, 0 ≤ n ≤ M Rectangular window

wR [n] = ⎨
30

⎩0, otherwise 20
M = 10 main lobe
Amplitude

• Presence of oscillatory behavior in H t (e jω ) 10


M=4 side lobe
is basically due to: 0

– 1) hd [n] is infinitely long and not absolutely -10


-1 -0.5 0 0.5 1
summable, and hence filter is unstable ω/π

– 2) Rectangular window has an abrupt transition • ΨR (e ) has a main lobe centered at ω = 0
to zero • Other ripples are called sidelobes
17 18
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

3
Gibbs Phenomenon Gibbs Phenomenon
• Main lobe of ΨR (e jω ) characterized by its • Rectangular window has an abrupt transition
width 4π /( 2 M + 1) defined by first zero to zero outside the range − M ≤ n ≤ M , which
crossings on both sides of ω = 0
results in Gibbs phenomenon in H t (e jω )
• As M increases, width of main lobe
decreases as desired • Gibbs phenomenon can be reduced either:
• Area under each lobe remains constant (1) Using a window that tapers smoothly to
while width of each lobe decreases with an zero at each end, or
increase in M (2) Providing a smooth transition from
• Ripples in H t (e jω ) around the point of passband to stopband in the magnitude
discontinuity occur more closely but with specifications
no decrease in amplitude as M increases
19 20
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

4
Fixed Window Functions Fixed Window Functions
• Using a tapered window causes the height • Plots of magnitudes of the DTFTs of these
of the sidelobes to diminish, with a windows for M = 25 are shown below:
Rectangular window Hann window
corresponding increase in the main lobe 0 0

width resulting in a wider transition at the -20 -20

discontinuity -40 -40

Gain, dB

Gain, dB
-60 -60
• Hann:
w[n] = 0.5 + 0.5 cos( 2π n ), − M ≤ n ≤ M
-80 -80

-100
2M + 1
-100
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
ω/π ω/π
Hamming window Blackman window
• Hamming:
w[n] = 0.54 + 0.46 cos( 2π n ), − M ≤ n ≤ M
0 0

-20 -20
2M + 1 -40 -40

Gain, dB
Gain, dB
• Blackman: -60 -60

w[n] = 0.42 + 0.5 cos( 2π n ) + 0.08 cos( 4π n )


-80 -80

1 2M + 1 2M + 1 2
-100
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 Copyright © 2005, S. K. Mitra

Fixed Window Functions Fixed Window Functions


• Magnitude spectrum of each window
• Main lobe width ∆ ML - given by the
characterized by a main lobe centered at
distance between zero crossings on both
ω = 0 followed by a series of sidelobes with
sides of main lobe
decreasing amplitudes
• Relative sidelobe level Asl - given by the
• Parameters predicting the performance of a
difference in dB between amplitudes of
window in filter design are:
largest sidelobe and main lobe
• Main lobe width
• Relative sidelobe level
3 4
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Fixed Window Functions 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


• Width of transition band
• Thus, H t (e jωc ) ≅ 0.5
∆ω = ω s − ω p < ∆ ML
• Passband and stopband ripples are the same
5 6
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

1
Fixed Window Functions Fixed Window Functions
• To ensure a fast transition from passband to • In the case of rectangular, Hann, Hamming,
stopband, window should have a very small and Blackman windows, the value of ripple
main lobe width does not depend on filter length or cutoff
• To reduce the passband and stopband ripple frequency ωc , and is essentially constant
δ, the area under the sidelobes should be • In addition,
very small ∆ω ≈ c
M
• Unfortunately, these two requirements are where c is a constant for most practical
contradictory purposes
7 8
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Fixed Window Functions Fixed Window Functions


• Rectangular window - ∆ ML = 4π /(2M + 1) • Filter Design Steps -
Asl = 13.3 dB, α s = 20.9 dB, ∆ω = 0.92π / M (1) Set
• Hann window - ∆ ML = 8π /(2M + 1) ωc = (ω p + ωs ) / 2
Asl = 31.5 dB, α s = 43.9 dB, ∆ω = 3.11π / M (2) Choose window based on specified α s
• Hamming window - ∆ ML = 8π /(2M + 1) (3) Estimate M using
Asl = 42.7 dB, α s = 54.5 dB, ∆ω = 3.32π / M
∆ω ≈ c
• Blackman window - ∆ ML = 12π /( 2M + 1) M
Asl = 58.1 dB, α s = 75.3 dB, ∆ω = 5.56π / M
9 10
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

FIR Filter Design Example


• Lowpass filter of length 51 and ωc = π / 2 FIR Filter Design Example
Lowpass Filter Designed Using Hann window Lowpass Filter Designed Using Hamming window
0 0

• An increase in the main lobe width is


Gain, dB
Gain, dB

-50 -50
associated with an increase in the width of
-100 -100 the transition band
0 0.2 0.4
ω/π
0.6 0.8 1 0 0.2 0.4
ω/π
0.6 0.8 1
• A decrease in the sidelobe amplitude results
Lowpass Filter Designed Using Blackman window
0
in an increase in the stopband attenuation
Gain, dB

-50

-100

0 0.2 0.4 0.6 0.8 1


11 ω/π 12
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

2
Adjustable Window Functions Adjustable Window Functions
• Dolph-Chebyshev Window - • Dolph-Chebyshev window can be designed
w[n] = 1 [1γ + 2 ∑ Tk (β cos k ) cos 2nkπ ],
M with any specified relative sidelobe level
2M + 1 k =1 2M + 1 2M + 1 while the main lobe width adjusted by
−M ≤n≤M choosing length appropriately
where amplitude of sidelobe
γ= • Filter order is estimated using
main lobe amplitude 2.056α s − 16.4
β = cosh( 1 cosh −1 1γ ) N=
2M 2.85( ∆ω)
and
⎧ cos(l cos −1 x ), x ≤1 where ∆ω is the normalized transition
Tl ( x) = ⎨ −1 bandwidth, e.g, for a lowpass filter
⎩cosh(l cosh x), x > 1 ∆ω = ωs − ω p
13 14
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Adjustable Window Functions Adjustable Window Functions


• Gain response of a Dolph-Chebyshev Properties of Dolph-Chebyshev window:
window of length 51 and relative sidelobe • All sidelobes are of equal height
level of 50 dB is shown below • Stopband approximation error of filters
Dolph-Chebyshev Window designed have essentially equiripple
0 behavior
-20
• For a given window length, it has the
Gain, dB

-40
smallest main lobe width compared to other
-60 windows resulting in filters with the
-80
0 0.2 0.4 0.6 0.8 1
smallest transition band
ω/π
15 16
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Adjustable Window Functions Adjustable Window Functions


• Kaiser Window - • β controls the minimum stopband
attenuation of the windowed filter response
I 0{β 1 − (n / M ) } 2
w[n] = , −M ≤n≤M • β is estimated using
I 0 (β)
⎧⎪ 0.1102( α s −8.7 ), for α s > 50
where β is an adjustable parameter and I 0 (u )
β= ⎨0.5842( α s − 21)0.4 + 0.07886( α s − 21), for 21 ≤ α s ≤ 50
is the modified zeroth-order Bessel function
⎪⎩ 0, for α s < 21
of the first kind: ∞ (u / 2) r
I 0 (u ) = 1 + ∑ [ ]2 • Filter order is estimated using
αs − 8
r =1 r! N=
• Note I 0 (u ) > 0 for u > 0 2.285(∆ω)
20 (u / 2) r where ∆ω is the normalized transition
• In practice I 0 (u ) ≅ 1 + ∑ [ ]2 bandwidth
17 r =1 r! 18
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

3
FIR Filter Design Example FIR Filter Design Example
• Specifications: ω p = 0.3π , ωs = 0.5π , sin(0.4π n)
• Hence ht [ n] = πn ⋅ w[n], − 12 ≤ n ≤ 12
α s = 40 dB
where w[n] is the n-th coefficient of a
• Thus ωc = (ω p + ωs ) / 2 = 0.4π
length-25 Kaiser window with β = 3.3953
δ s = 10−α s / 20 = 0.01 Kaiser Window Lowpass filter designed with Kaiser window

β = 0.5842(19)0.4 + 0.07886 ×19 = 3.3953 0 0

-20 -20
32
N= = 22.2886

Gain, dB
Gain, dB
2.285(0.2π)
-40 -40

-60 -60

• Choose N = 24 implying M =12 -80


0 0.2 0.4 0.6 0.8 1
-80
0 0.2 0.4 0.6 0.8 1
ω/π ω/π

19 20
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Impulse Responses of FIR Filters


with a Smooth Transition 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 / π, n=0
∆ω = ωs − ω p ⎪
hLP [n] = ⎨⎛ 2 sin( ∆ω n / 2 P) ⎞ P sin(ωc n)
⎪⎩⎜⎝ ∆ω n / 2 P ⎟⎠ ⋅ π n n >0
⎧⎪ ωc / π, n=0
hLP [n] = ⎨ 2 sin(∆ω n / 2) sin(ωc n)
⎪⎩ ⋅ πn n >0
∆ω n
21 22
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra

Lowpass FIR Filter Design


Example
• Example

1 P = 1, N = 40
P = 2, N = 60
0.8
Magnitude

0.6
0.4
0.2

0
0 0.2 0.4 0.6 0.8 1
ω/π

23
Copyright © 2005, S. K. Mitra

4
Greg Berchin
[dsp TIPS&TRICKS]

Precise Filter Design

Y
ou have just been assigned taining poles and zeros (infinite response least-squares sense, as close as possible
to a new project at work, filters), only zeros (finite response fil- to satisfying all three equations. The
in which the objective is ters), or only poles (autoregressive net- solution is then given by
to replace an existing ana- works). The algorithm uses nothing    
5 2   7
log system with a func- more esoteric than basic linear algebra.  −6 4  x
=  9  or
tionally equivalent digital system. Your Before we can see how the technique y
1 1 5
job is to design a digital filter that works, we need to review some basic lin-
matches the magnitude and phase ear algebra and matrix concepts.
   −1
response of the existing system’s analog   5 2 T 5 2
x  
filter over a broad frequency range. You BACKGROUND ≈  −6 4   −6 4 
are running out of ideas. The bilinear First let us recall that, in order to y
1 1 1 1
transform and impulse invariance uniquely solve a system of equations, we  T  
methods provide poor matches to the need as many equations as unknowns. 5 2 7
×  −6 4   9  for THIS case:
analog filter response, particularly at For example, the single equation with p_inv(X) =
high frequencies. Fast convolution one unknown 5x = 7 has the unique 1 1 5
  [inv(X'X)][X']
requires more computational resources solution x = 7/5. But the single equa- 0.3716
≈ ,
than you have and creates more tion with two unknowns 5x + 2y = 7 2.8491
input/output latency than you can toler- has multiple solutions x = (7 − 2y )/5
ate. What will you do? that depend on the unspecified y-value. If where T denotes the matrix transpose. Of
In this article, we describe an obscure another equation, −6x + 4y = 9, is course, the mathematical derivation of
but simple and powerful method for added to the equation above, there are the matrix inverse and pseudoinverse,
designing a digital filter that approxi- unique solutions for both x and y that and the definition of least-squares, can
mates an arbitrary magnitude and phase can be found algebraically or by matrix be found in any basic linear algebra text
response. If applied to the problem inversion (denoted in the following by a [1]. And while our more mathematically
above, it can create a filter roughly com- “−1” superscript): inclined readers will point out that there
parable in computational burden and are better ways than this to compute the
    
latency to that created by the bilinear 5 2 x 7 pseudoinverse, this method is adequate
=
transform method, with fidelity −6 4 y 9 for our example.
approaching that of fast convolution. In    −1   You may also remember that filter
x 5 2 7
addition, the method described here can = specifications are commonly expressed in
y −6 4 9
also be applied to a wide variety of other  1 1   terms of passband width and flatness,
− 16 7
system identification tasks. = 38 5 transition band width, and stopband
 32  9
The filter design method we present  16 7 9  attenuation. There may also be some gen-
8 − 16
is called frequency-domain least-squares =   . eral specifications about phase response
21 45
(FDLS) [1]–[3]. The FDLS algorithm 16 + 32
produces a transfer function that approx-
“DSP Tips and Tricks” introduces prac-
imates an arbitrary frequency response. Let us consider what happens if we
tical design and implementation sig-
The input to the algorithm is a set of add another equation, x + y = 5, to the
nal processing algorithms that you
magnitude and phase values at a large pair that we already have above (we will
may wish to incorporate into your
number (typically thousands) of arbitrary see later why we might want to do this). designs. We encourage readers to
frequencies between 0 Hz and half the There are no values of x and y that satis- submit their contributions to
sampling rate. The algorithm’s output is fy all three equations simultaneously. To Associate Editors Rick Lyons
a set of transfer function coefficients. address this case, matrix algebra provides (r.lyons@ieee.org) or Britt Rorabaugh
The FDLS algorithm is quite flexible in the “pseudoinverse,” which determines (dspboss@aol.com).
that it can create transfer functions con- the values of x and y that come, in the

IEEE SIGNAL PROCESSING MAGAZINE [137] JANUARY 2007 1053-5888/07/$25.00©2007IEEE


[dsp TIPS&TRICKS] continued

or time-domain performance, but the Let us conclude our background sec- ues of which are not yet known. We also
exact magnitude and phase responses are tion with a comment on what a frequen- know that the relationship between
usually left to the designer’s discretion. cy response value means. In a simple input u and output y at any sample time
However, an important exception occurs example, if the frequency response of a can be inferred from the frequency
when a digital filter is to be used to emu- system at a frequency ω1 is given in response value A φ at frequency ω.
late an analog filter. This is traditionally a magnitude/phase form as A1  φ1 , the Combining these two ideas, we obtain
very difficult problem, because analog output amplitude will be A1 times the one equation in D + N + 1 unknowns
systems are described by Laplace trans- input amplitude and the output phase
forms using integration and differentia- will be shifted an angle φ1 relative to the y1 (0) = [−y1 (−1) . . . − y1 (−D)
tion, whereas digital systems are input phase when a steady-state sine a 
1
described by z-transforms using delay. wave of frequency ω1 is applied to the  .. 
Since the conversion between them is system. For instance, if the input to the  . 
 
 aD 
nonlinear, the response of an analog sys- system described above at time k is u1 (0) . . . u1 (−N )]  
 b0  .
tem can only be approximated by a digital u1 (k) = cos(kω1 ts ), where ts is the sam-  
 . 
system and vice-versa. pling period (equal to one over the sam-  .. 
Let us assume that the transfer func- pling frequency), then the output will be bN
tion of our digital filter (i.e., the mathe- y1 (k) = A1 cos(kω1 ts + φ1 ) . The input
matical description of the relationship and output values at any sample time (Note that the current-sample index k
between the filter’s input and output) is can be determined in a similar manner. has been set to zero.) If we repeat using
in a standard textbook form [2] given by For example, the input sample value N A2  φ2 at a different frequency ω2 , we
samples in the past was obtain a second equation in D + N + 1
Y(z ) b0 + b1 z −1 + · · · + bN z −N u1 (k − N) = cos ((k − N )ω1 ts ) and the unknowns as shown in (a) at the bottom
= ,
U(z ) 1 + a1 z −1 + · · · + aD z −D output sample value D samples in the of the page. And if we repeat at many
past was y1 (k − D) = A1 cos ((k − D) more different frequencies M than we
where U(z ) is the z-transform of the input ω1 ts + φ1 ). For our purposes, since k have unknowns D + N + 1, we know
signal, Y(z ) is the z-transform of the out- represents the current sample time, its from our review of linear algebra that the
put signal, and the a and b factors are real- value can conveniently be set to zero. pseudoinverse will compute values for
valued coefficients. Furthermore, we the set of coefficients a1 . . . aD and
assume that the filter is causal, meaning FDLS FILTER APPROXIMATION b0 . . . bN that come as close as possible
that its response to an input does not begin Based on our review of the pseudoin- to solving all of the equations, which is
until after the input is applied. Under these verse, transfer function, and frequency exactly what we need to design our filter.
assumptions, the time-domain difference response, we know that the output is a So now we can write (b), shown at the
equation that implements our filter is combination of present and past input bottom of the page. We can denote the
and output values, each scaled by a set of y1 (0) . . . yM (0) column vector above as
y(k) = − a1 y(k − 1) − · · · − aD y(k − D) b or a coefficients (respectively), the val- Y, the matrix as X, and the a1 . . . bN col-
+ b0 u(k) + · · · + bN u(k − N ),
a 
where the a and b coefficients are exactly 1
 .. 
the same as in the transfer function  . 
    
above, k is the time index, u(k) and y(k) y1 (0) −y1 (−1) . . . −y1 (−D) u1 (0) . . . u1 (−N)  
 aD  .
= (a)
are the current values of the input and y2 (0) −y2 (−1) . . . −y2 (−D) u2 (0) . . . u2 (−N)  b
  0

output (respectively), u(k − N ) was the  . 
 .. 
input value N samples in the past, and
bN
y(k − D) was the output value D samples
in the past. We can write the equation
above in matrix form as
a 
1
     .. 
y(k) = [−y(k − 1) . . . − y(k − D) y1 (0) −y1 (−1) . . . −y1 (−D) u1 (0) ... u1 (−N)  . 
a   y2 (0)   −y2 (−1) . . . −y2 (−D) u2 (0) ... u2 (−N)   
    aD 
1
 ..  =  .. .. .. ..  
 b0  .
 ..   .   . . . .   
 .   . 
  yM (0) −yM (−1) . . . −yM (−D) uM (0) . . . uM (−N)  .. 
 aD 
u(k) . . . u(k − N )]  
 b0  .
  bN
 .  (b)
 .. 
bN

IEEE SIGNAL PROCESSING MAGAZINE [138] JANUARY 2007


umn vector as . With these notations,
Y = X, and the pseudoinverse solves
0
for the vector  that contains the
−10
desired filter coefficients

Magnitude (dB)
−20

(X T X )−1 X T Y ≈ . −30

−40 Black: Analog (Desired)


We can now summarize our filter Blue: Bilinear Transform
−50 Green: Impulse Invariance
design trick as follows: Red: FDLS
1) Select the numerator order N and 10−2 10−1 100 101 102
the denominator order D, where N Frequency (Hz)
and D do not have to be equal and
either one (but not both) may be zero. [FIG1] Magnitude responses of the filter designed using the bilinear transform, impulse
(We have found no “rule of thumb” invariance, and FDLS methods.
for defining N and D; they are best
determined experimentally.)
2) Define the M separate input um
cosine sequences, each of length
(N + 1). 150
100
Phase (degrees)

3) Compute the M separate output ym


cosine sequences, each of length D 50
(based on Am  φ m ). 0
4) Fill the X matrix with the input um −50 Black: Analog (Desired)
−100 Blue: Bilinear Transform
and output ym cosine sequences. Green: Impulse Invariance
5) Fill the Y vector with the M output −150 Red: FDLS
cosine values, ym (0) = Am cos(φ m ). 10−2 10−1 100 101 102
6) Compute the pseudoinverse; the Frequency (Hz)
resulting vector  contains the filter
coefficients. [FIG2] Phase responses of the filter designed using the bilinear transform, impulse
A numerical example is shown in invariance, and FDLS methods.
Figures 1 and 2, which illustrate the
magnitude and phase, respectively, of a
real-world example analog system (black) CONCLUSION ACKNOWLEDGMENTS
and of the associated bilinear transform FDLS is a powerful method for design- My thanks to Jaime Andrés Aranguren
(blue), impulse invariance (green), and ing digital filters. As is the case with all Cardona for providing the example
FDLS (red) approximations. The sam- approximation techniques, there are shown in Figures 1 and 2, originally
pling rate is equal to 240 Hz and circumstances in which the FDLS posted on the comp.dsp Newsgroup on
D = N = 12. The red FDLS graphs are method works well and others in which 9 January 2005, which ultimately led to
almost completely obscured by the black it does not. The FDLS method does not this article.
analog system graphs. In this example, replace other filter design methods; it
the FDLS errors are often three to four provides one more method from which AUTHOR
orders of magnitude smaller than those to choose. FDLS is most useful in cases Greg Berchin (berchin@ieee.org) is a sig-
of the other methods. (In Figure 2, the where a specified frequency response nal processing algorithm engineer who
bilinear transform curve is obscured by must be duplicated to within tight tol- provides contract engineering services
the FDLS and analog curves at low fre- erances over a wide frequency range or from Naperville, Illinois.
quencies and by the impulse invariance when the frequency response of an
curve at high frequencies.) existing system is known but the coef- REFERENCES
[1] G. Strang, Linear Algebra and Its Applications,
In terms of the computational com- ficients of the system’s transfer func- 2nd ed., Orlando, FL: Academic, pp. 103–152, 1980.
plexity of an FDIS-designed filter, the tion are unknown. It is up to the [2] R. Lyons, Understanding Digital Signal
Processing, 2nd ed., Upper Saddle River, NJ:
number of feedback and feed-forward designer to determine whether to use Prentice-Hall, pp. 232–240, 2004.
coefficients is determined by the vari- it in any given situation. Detailed [3] G. Berchin, “A new algorithm for system identifi-
ables D and N, respectively. As such, an examples and a MATLAB code imple- cation from frequency response information,” mas-
ter’s thesis, University of California-Davis, 1988 .
FDIS-designed filter requires mentation of the FDLS algorithm are [4] G. Berchin and M.A. Soderstrand, “A transform-
(N + D + 1) multiplies and (N + D) available at http://apollo.ee.columbia. domain least-squares beamforming technique,” in
Proc. IEEE Oceans ‘90 Conf., Arlington, VA, Sept.
additions per filter output sample. edu/spm/?i=external/tipsandtricks. 1990. [SP]

IEEE SIGNAL PROCESSING MAGAZINE [139] JANUARY 2007


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 2 ⎥⎢ D ⎥ ,
⎢ M ⎥ ⎢ M M M M ⎥ ⎢ b0 ⎥
⎢ ⎥ ⎢ ⎥
⎣ 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 discrete-
system 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
ω1 = 2π(0.0)
1 ω2 = 2π(19.69)
Linear

Desired magnitude response ω3 = 2π(35.43)


ω4 = 2π(51.18)
0.5
A1 ω5 = 2π(59.05)
(a) ω6 = 2π(66.93)
A8 ω7 = 2π(106.30)
0
0 100 200 300 400 500 ω8 = 2π(389.76)
Frequency
f1 = 0 Hz f7 = 106.3 Hz f8 = 389.76 Hz

f4 = 51.18 Hz

4
φ5
Phase (radians)

2
φ1 Desired phase response
(b)
0
φ8

–2
0 100 200 300 400 500
Frequency

Fig E1

IEEE Copyright © All Rights Reserved Page 2 of 5


In matrix form, the target analog system parameters are
┌ ┐ ┌ ┐ ┌ ┐ ┌ ┐
│0.0 │ │0.0 │ │0.2172 │ │ 0.0 │
│19.6850 │ │0.1237 │ │0.2065 │ │–0.0156 │
│35.4331 │ │0.2226 │ │0.1696 │ │–0.0383 │
fm = │51.1811 │ ωmts = │0.3216 │ Am = │0.0164 │ φm = │ 3.0125 │
│59.0551 │ │0.3711 │ │1.3959 │ │ 2.3087 │
│66.9291 │ │0.4205 │ │0.6734 │ │ 0.955 │
│106.299 │ │0.6679 │ │0.3490 │ │ 0.0343 │
│389.764 │ │2.449 │ │0.3095 │ │ 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:

┌ ┐ ┌ ┐
│A1cos(φ1) │ │ 0.2172 │
│A2cos(φ2) │ │ 0.2065 │
│A3cos(φ3) │ │ 0.1695 │
Y = │A4cos(φ4) │ = │–0.0162 │
│A5cos(φ5) │ │–0.9390 │
│A6cos(φ6) │ │ 0.6605 │
│A7cos(φ7) │ │ 0.3488 │
│A8cos(φ8) │ │ 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) –A1cos(–2ω1ts+φ1) cos(0) cos(–ω1ts) cos(–2ω1ts) │
│–A2cos(–1ω2ts+φ2) –A2cos(–2ω2ts+φ2) cos(0) cos(–ω2ts) cos(–2ω2ts) │
│–A3cos(–1ω3ts+φ3) –A3cos(–2ω3ts+φ3) cos(0) cos(–ω3ts) cos(–2ω3ts) │
X = │–A4cos(–1ω4ts+φ4) –A4cos(–2ω4ts+φ4) cos(0) cos(–ω4ts) cos(–2ω4ts) │
│–A5cos(–1ω5ts+φ5) –A5cos(–2ω5ts+φ5) cos(0) cos(–ω5ts) cos(–2ω5ts) │
│–A6cos(–1ω6ts+φ6) –A6cos(–2ω6ts+φ6) cos(0) cos(–ω6ts) cos(–2ω6ts) │
│–A7cos(–1ω7ts+φ7) –A7cos(–2ω7ts+φ7) cos(0) cos(–ω7ts) cos(–2ω7ts) │
│–A8cos(–1ω8ts+φ8) –A8cos(–2ω8ts+φ8) cos(0) cos(–ω8ts) cos(–2ω8ts) │
└ ┘

┌ ┐
│–0.2172 –0.2172 1.00 1.0000 1.0000 │
│–0.2045 –0.994 1.00 0.9924 0.9696 │
│–0.1639 –0.1502 1.00 0.9753 0.9025 │
= │ 0.0147 0.0117 1.00 0.9487 0.8002 │.
│ 0.5007 –0.0059 1.00 0.939 0.7370 │
│–0.6564 –0.5378 1.00 0.9129 0.6667 │
│–0.2812 –0.0928 1.00 0.7851 0.2328 │
│ 0.2376 –0.0562 1.00 –0.7696 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
┌ ┐
│–1.8439 │
│ 0.9842 │
θM=8 = │ 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 0.3033

1.8439 –0.5762
z –1

–0.9842 0.3034

Fig E2
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
Magnitude (dB)

(a) –20
Desired magnitude response
Actual magnitude response
–40
0 100 200 300 400 500
Frequency

4
Phase (radians)

2
Desired phase response
(b)
Actual phase response
0

–2
0 100 200 300 400 500
Frequency

Fig E3

IEEE Copyright © All Rights Reserved Page 5 of 5

You might also like