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 + 2l1) / 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 s denote the Laplace transform s=
s
variable of desired analog filter HD (s)
where p is the passband edge frequency of
The mapping from s-domain to s -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, Fs = 1 kHz, p = 0.1 dB,

s = 40 dB

Stopband s p p s Stopband Choose p = 1
0
Lowpass
Passband Then 2F p F p 4000
s = = = =4
Passband Stopband Passband 2Fs Fs 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, Fs1 = 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 Fs1Fs 2 = 24 106
by decreasing s1 which is not acceptable
Since F p1F p 2 > Fs1Fs 2 we choose
as the lower stopband is reduced from the
desired value F p1 = Fs1Fs 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
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

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) = , MN
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 + jo
(1 + o ) + jo 2 (1 + o ) + o
2 2
z= z =
(1 o ) jo (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


j
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 ( jo ) = 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 ( j1 ) = 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 jn Objective - Find a finite-duration {ht [n]}
where n = of length 2M+1 whose DTFT H t (e j )
1
j jn
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 Parsevals 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 jn 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
j
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 /
j
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 jc ) 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 nM 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 nM 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 systems 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 algorithms 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.002007IEEE


[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 designers 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(k1 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(k1 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 filters 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 102 101 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 ). 102 101 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 Andrs 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 systems transfer func- 2nd ed., Orlando, FL: Academic, pp. 103152, 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. 232240, 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-
ters 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(k1ts + 1) or cos(k1ts). 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(21ts + 1)
...
y1(10) = A1cos[(10)1ts + 1] = A1cos(101ts + 1)
and
u1(0) = cos[(0)1ts] = 1
u1(1) = cos[(1)1ts] = cos(1ts)
u1(2) = cos[(2)1ts] = cos(21ts)
...
u1(9) = cos[(9)1ts] = cos(91ts).

IEEE Copyright All Rights Reserved Page 1 of 5


So the top row of the X matrix looks like:
[A1cos(1ts + 1) A1cos(21ts + 1) ... A1cos(101ts + 1) 1 cos(1ts)
cos(21ts) ... cos(91ts)].
The second row of the X matrix looks like:
[A2cos(2ts + 2) A2cos(22ts + 2) ... A2cos(102ts + 2) 1 cos(2ts)
cos(22ts) ... cos(92ts)].
And so on.

Numerical Example
Heres 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 = 103 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(21ts + 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(28ts + 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(21ts) = 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(28ts) = cos(4.898) = 0.1845.

The complete X matrix is:



A1cos(11ts+1) A1cos(21ts+1) cos(0) cos(1ts) cos(21ts)
A2cos(12ts+2) A2cos(22ts+2) cos(0) cos(2ts) cos(22ts)
A3cos(13ts+3) A3cos(23ts+3) cos(0) cos(3ts) cos(23ts)
X = A4cos(14ts+4) A4cos(24ts+4) cos(0) cos(4ts) cos(24ts)
A5cos(15ts+5) A5cos(25ts+5) cos(0) cos(5ts) cos(25ts)
A6cos(16ts+6) A6cos(26ts+6) cos(0) cos(6ts) cos(26ts)
A7cos(17ts+7) A7cos(27ts+7) cos(0) cos(7ts) cos(27ts)
A8cos(18ts+8) A8cos(28ts+8) cos(0) cos(8ts) cos(28ts)


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