Professional Documents
Culture Documents
Analog Low Pass Filter Design PDF
Analog Low Pass Filter Design PDF
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
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
9 10
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
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
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
-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
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
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
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
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
Ω 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
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
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
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
1
Digital Filter Specifications
Digital Filter Specifications
• ω p - passband edge frequency
• ωs - stopband edge frequency • Specifications are often given in terms of
jω
• δ 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
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
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
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
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
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
-10
Gain, dB
β = 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
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
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
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
-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
Ω 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
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
⎧ 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
⎧⎪ 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
wR [n] = ⎨
30
⎩0, otherwise 20
M = 10 main lobe
Amplitude
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
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
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
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
-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
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
-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
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
-20 -20
32
N= = 22.2886
Gain, dB
Gain, dB
2.285(0.2π)
-40 -40
-60 -60
19 20
Copyright © 2005, S. K. Mitra Copyright © 2005, S. K. Mitra
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]
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
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
Magnitude (dB)
−20
(X T X )−1 X T Y ≈ . −30
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
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
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
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:
┌ ┐ ┌ ┐
│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:
The two elements of the "y8" part of the eighth row of the X vector are:
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.
┌ ┐
│–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 │
└ ┘
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