Vous êtes sur la page 1sur 26

Design of IIR filters

Giuseppe Scarpa
ENS 2013

Contents
1 Introduction 2

2 CT lowpass 3
2.1 The Butterworth approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 The Chebyshev approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 The inverse Chebyshev or Chebyshev II approximation . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 The elliptic or Cauer approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3 CT to DT 11
3.1 Impulse-invariance transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Bilinear transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4 Lowpass examples 19

5 Frequency transformations 21
5.1 Continuous-time frequency transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.2 Discrete-time frequency transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

6 M ATLAB examples 24

1
1 Introduction to the IIR filter design problem
Key observation: A practically realizable IIR (in particular a causal one) cannot have a linear phase response

The approximation concerns magnitude AND phase response

The direct optimization according to any given criterion becomes a very complex task

The canonical design paradigm for IIR moves the problem to the continuous-time domain.

General design paradigm for IIR


The reference general paradigm for IIR filter design lies on the following steps:
CT specifications: the conversion of the (given) IIR specifications in continuous-time (CT) specifications
CT filter design: continuous-time filter design
CT/DT transformation: transformation of the CT filter in a DT filter

In addition, for selective filters like BP, HP, SB it is custom to design a lowpass in the CT domain and the apply a
frequency band transformation.

The frequency band transformation can be carried both in the CT and the DT domains, resulting in two possible
approaches:

CT specifications: specification in the CT domain for the equivalent lowpass


Lowpass CT filter design: design of the equivalent LP filter
CT band shift: frequency band transformation in the CT domain
CT/DT transformation: CT to DT filter transformation
DT band shift: frequency band transformation in the DT domain

where only one band shift step has to be chosen.

FIR vs IIR
Advantages of FIR:
possibility to have exact linear phase
always stable with finite-duration transients
design methods generally linear in filter parameters
flexibility in the choice of the frequency response

Advantages of IIR:

much smaller filter order for fixed specifications


typically much smaller delay introduced
noniterative design methods no need for computer-aided techniques

2
2 Design of continuous-time lowpass filter
Magnitude-squared response
Let us start analysing some properties of the magnitude-squared response of a real-coefficients CT system. We can
write:
|Hc (j)|2 = Hc (j)Hc (j) = Hc (j)Hc (j) = Hc (s)Hc (s)|s=j
Therefore:

(s sk ) is a factor of Hc (s) (s sk ) is a factor of Hc (s)




(s sk )(s sk ) = (s2k s2 ) s=j = (s2k + 2 ) is a factor of |Hc (j)|2

Hence we can always write

(2 + 12 )(2 + 22 ) (2 + M
2
)
|Hc (j)|2 = G2 2 2 2 2 2 2
( + s1 )( + s2 ) ( + sN )

For real system zeros and poles are either real o pairs of complex conjugate ones:
real (2 + s2k ) R+
complex conjugate s1 = rej , s2 = rej :

(2 + s21 )(2 + s22 ) = (2 r2 )2 R+

In conclusion |Hc (j)|2 is:


real and non negative

rational function in 2
differentiable
For these reasons it is typically preferred to |Hc (j)| for the design of continuous-time filters.
Observe, also, that due to the causality and stability requirements the phase response cannot be assigned indepen-
dently.
In continuous-time lowpass filter design, the magnitude-squared function is usually put in the following form:
(
2 1 V 2 () << 1, < c
|Hc (j)| = ,
2
1 + V () V 2 () >> 1, > c

Different choices of V () lead to different design techniques.


Observe:
once determined |Hc (j)|2 , a proper spectral factorization is needed to get a causal and stable solution.

zeros and poles of Hc (s)H(s) are symmetrically located wrt both the real and the imaginary axes (quadrantal
symmetry)
hence, causal and stable systems are obtained by picking poles from the left-half plane
if zeros are taken from the left-half plane as well, than minimum phase is also achieved

3
Analog specification

|H(j)|2
Specifications Transition band
Relative Analog
Passband
0 1 Ideal Response
Ap
1
1+2
As Passband Stopband ripple
ripple

1 Stopband
A2

p c s
Passband edge Stopband edge
Cutoff-freq.

2.1 The Butterworth approximation


The Butterworth family of lowpass filter is defined by the following formula
1
|HB (j)|2 , , N = 1, 2, . . .
1 + (/c )2N

Properties:

|HB (j0)|2 = 1
|HB (j)|2 = 0
|HB (jc )|2 = 1/2 (c is the 3dB cutoff frequency for all N )

Maximally flat
Asymptotic rolloff 6N dB/oct.

Ideal LP (N = )
1 |HB (j)|2

1/2
N

Pole locations
The solution of the equation 1 + (s/jc )2N = 0 yields the 2N poles:
(
k = c cos k
sk = k + jk , where
k = c sin k

with
2k 1
k , + , k = 1, 2, . . . , 2N
2 2N

4
/N I{s} I{s}
s1 s12 s1 s10
N =6 N =5
s2 s11
s2 s9

s3 s10

c s3 s8

s4 s9 R{s} R{s}

s4 s7
s5 s8

s6 s7 s5 s6

poles never occur on the imaginary axis

poles occur on the real axis only for odd values of N


stability is obtained by selecting the N poles lying on the left-half plane (gray)

Nc
HB (s) =
(s s1 )(s s2 ) (s sN )

Design procedure
Let p , s , Ap and As be the specifications. We want to find the filter parameters c and N .
To satisfy the specification we need:
(
1 1
1+(p /c )2N
1+2 (p /c )2N 2
1 1
1+(s /c )2N
A2 (s /c )2N A2 1

p A2 1
N
= s N
c A 2 1 p N

Solving wrt N :
ln s 1p 2 10As /10 1
N , where , , , A 1= p
ln p  10Ap /10 1

In particular we can choose the smallest N larger than ln / ln :


 
ln
N=
ln

Once computed N , c can be anywhere in the interval:

p (10Ap /10 1)1/2N c s (10As /10 1)1/2N

Observe:
the left limit satisfy exactly the specifications at p
the right limit satisfy exactly the specifications at s

if we want smaller ripple in the bandpass, than we take the right limit

5
M ATLAB functions for analog Butterworth lowpass
The SP toolbox provides the following functions:
[N,Omegac] = buttord(Omegap,Omegas,Ap,As,s)
[C,D] = butter(N,Omegac,s)
where C and D are the numerator and denominator polynomials of the system function.
Example: design of a Butterworth lowpass filter [buttex.m]
Specifications:
Fp = 40Hz, Fs = 50Hz, Ap = 1dB, As = 30dB

Op = 2*pi*40; Os = 2*pi*50; Ap = 1; As = 30;


[N,Oc] = buttord(Op,Os,Ap,As,s); N
N =

19
Fc = Oc/(2*pi)
Fc =
41.6902

[C, D] = butter(N,Oc,s);
% Plots...
% ...

2.2 The Chebyshev approximation


Differently from FIR filters, in the IIR case there are closed formulas for filter design, avoiding the use of iterative
algorithms for searching the optimal solution.
Start with the Chebyshev I:
1
|HC (j)|2 =
1+ 2 TN2 (/c )
2
The approximation error, for  << 1, is:

2 1
EC (/c ) = 1 2 TN2 (/c ), || c
1 + 2 TN2 (/c )

A Chebyshev polynomial TN (x) is defined for any value of x, and not just on the interval [1, 1]
However the formula used for TN (x) in the passband

TN (x) = cos(N cos1 x), |x| 1

is not valid for |x| > 1


It can be proved that
TN (x) = cosh(N cosh1 x), |x| > 1

M ATLAB generation of Chebyshev polynomials:

6
|x| 1: T = cos(N*acos(x))
|x| > 1: T = cosh(N*acosh(x))

|HC (j)| N =4
N =6
1 N =7

1
1+2

Properties of the lowpass Chebyshev I filter


1
|| c |HC (j)|2 equiripple between 1 and 1+2

|| > c |HC (j)|2 0 (monotonically)


Asymptotic roll-off 20N dB/decade = 6N dB/octave
(
1, N odd 1
|HC (j0)|2 = , |HC (jc )|2 = 1+2
1/(1 + 2 ), N even

Pole locations
The solution of the equation 1 + 2 TN2 (s/jc ) = 0 yields the 2N poles:
(
k = [c sinh()] cos k
sk = k + jk , where
k = [c cosh()]] sin k

with
2k 1
k , + , k = 1, 2, . . . , 2N
2 2N
and
1 1
, sinh1
N 
It can be shown that the poles lie on an elliptic curve elongated in direction of the vertical axis
By selecting the poles lying on the left-half plane ({sk }, k = 1, 2. . . . , N ) we get a stable and causal system with
system function: (
N
Y
G 1/ 1 + 2 , N even
HC (s) = QN , G= (sk )
k=1 (s sk ) k=1
1, N odd
with G selected to satisfy the normalization condition on HC (j0).

7
Design procedure
Given p , s , Ap and As find c and N .
To satisfy the specification we need:
( 1 1
2 ( / )
1+2 TN
1+2 c = p
1
p c
1 1

2 ( / )
1+2 TN s p
A2 TN (s /p )  A2 1

Outside the passband (|| > p = c ) we have:


  1p
cosh N cosh1 (s /p ) A2 1

Solving wrt N :  
p
ln
1 + 21
cosh
N = 
cosh1 ln + 2 1
where and are the same parameters involved in the Butterworth design procedure.

s 1p 2 10As /10 1
, , , A 1= p
p  10Ap /10 1

M ATLAB functions for analog Chebyshev I lowpass


The SP toolbox provides the following functions:
[N,Omegac] = cheb1ord(Omegap,Omegas,Ap,As,s)
[C,D] = cheby1(N,Ap,Omegac,s)

where C and D are the numerator and denominator polynomials of the system function.
Example: design of a Chebyshev I lowpass filter [cheb1ex.m]
Specifications:
Fp = 40Hz, Fs = 50Hz, Ap = 1dB, As = 30dB

Op = 2*pi*40; Os = 2*pi*50; Ap = 1; As = 30;


[N,Oc] = cheb1ord(Op,Os,Ap,As,s); N
N =
7
Fc = Oc/(2*pi)
Fc =

40
[C, D] = cheby1(N,Ap,Oc,s);
% Plots...
% ...

8
2.3 The inverse Chebyshev or Chebyshev II approximation
To convert a Chebyshev I to a Chebyshev II we need two steps:
c / /c
Complement to 1 of |HC (j)|2

|HC (j)|2 |HC (j)|2 |HIC (j)|2

1 1 1
1
A2 1 A2 1 1+2
A2 A2

1
2 2 A2
1+2 1+2

1 /c 1 /c 1 /c

Therefore:
1 2 TN2 (c /)
|HIC (j)|2 , 1 =
1 + 2 TN2 (c /) 1 + 2 TN2 (c /)
Observe the maximally flat behaviour in the passband.

Zeros and poles


Zeros: (
1 k = jc / cos uk
TN (jc /s) = cos[N cos (jc /s)] = 0
uk = 2k1
N 2 , k = 1, . . . , 2N

Poles:
2c
TN (jc /s) = j/ sk =
k + jk
where k and k are the same coefficients defined for the Chebyshev I , that is:

k = [c sinh()] cos k


= [ cosh()]] sin
k c k
k , 2 + 2k1
, k = 1, 2, . . . , 2N

2N
1 1 1
, N sinh 

Observe that the poles do not lie on any geometric curve, while the zeros are located on the imaginary axis.

Design by M ATLAB
The design procedure is similar to that of Chebyshev I, except that the roles of passband and stopband are inter-
changed, that is:

c is anchored to s
N is determined to satisfy the specifications in the passband
The M ATLAB SP Toolbox provides the necessary functions:

[N,Ws] = cheb2ord(Omegap,Omegas,Ap,As,s)
[C,D] = cheby2(N,As,Ws,s)

9
where C and D are the numerator and denominator polynomials of the system function. Ws is the exact stopband edge
frequency.
Example: design of a Chebyshev II lowpass filter [cheb2ex.m]
Specifications:
Fp = 40Hz, Fs = 50Hz, Ap = 1dB, As = 30dB

Op = 2*pi*40; Os = 2*pi*50; Ap = 1; As = 30;


[N,Ws] = cheb2ord(Op,Os,Ap,As,s); N
N =
7

Fs = Ws/(2*pi)
Fs =
49.8720
[C, D] = cheby2(N,As,Ws,s);
% Plots...
% ...

2.4 The elliptic or Cauer approximation


Equiripple behaviour in passband or stopband provides a performance gain
(smaller N for fixed specifications)

We can expect additional gain with equiripple in both bands, which is obtained by [no proof]:
1
|HE (j)|2 , 2 (/ )
1 + 2 RN c

due to Cauer, and also referred to as elliptic filter, where the Chebyshev polynomial has been replaced by
2
2 1
2
23 2 22N 1 2
121 2 123 2
1 2 2, N even
RN () , 2N 1
2 2 2 2 2 2
2 2 2 2 2 4 2 2 2N2 2 , N odd

1 1
2 4 2N1

Design by M ATLAB
We skip heavy analytical aspects concerning the design of Cauer filters, focusing on the M ATLAB based design.
As usual one function computes the filter parameters, the other singles out the system function:
[N,Oc] = ellipord(Omegap,Omegas,Ap,As,s)
[C,D] = ellip(N,Ap,As,Oc,s)

where C and D are the numerator and denominator polynomials of the system function. Oc is the passband edge
frequency p .
Example: design of a Cauer lowpass filter [cauerex.m]
Specifications:
Fp = 40Hz, Fs = 50Hz, Ap = 1dB, As = 30dB

10
Op = 2*pi*40; Os = 2*pi*50; Ap = 1; As = 30;
[N,Oc] = ellipord(Op,Os,Ap,As,s); N
N =
5
[C, D] = ellip(N,Ap,As,Oc,s);
% Plots...
% ...

Comparison

Butterworth filters are optimal in the maximally flat sense


Elliptic filters are optimal in the minimax sense (minimum ripples and steepest transition)
Chebyshev I and II are in the middle

About the group delay


The phase has not been taken in consideration in the design.
If the (linearity of the) phase response is of critical importance than the Butterworth and the Chebyshev II filters
are the most suited solutions.

3 Transformation of continuous-time filters to discrete-time IIR filters


Our attention we be focused on two (among several ones) solutions:
Impulse-invariance: for didactic purpose

Bilinear transform: because is the state-of-the-art

A mapping function s = f (z) from s-plane to z-plane should satisfy the three following conditions, in order to
ensure the practical realizability:

A rational Hc (s) should be mapped to a rational H(z);

Imaginary axis to the unit circle:

{s = j, < < } {z = ej , < }

left-half s-plane mapped into the interior of the unit circle of the z-plane

3.1 Impulse-invariance transformation


Given by the sampling the continuous-time impulse response:

h[n] , Td hc (nTd ) (Td , design sampling period)

Said impulse-invariance because it preserves the shape of hc (t)

Spectral domain:

11
The time-domain sampling corresponds to replication in the spectral domain (with possibility of aliasing!):

X  
2
H(ej ) = Hc j +j k
Td Td
k=

Mapping for the impulse-invariance transformation


For simplicity rely on a proper (M < N ) rational system function Hc (s). We can then consider a partial fraction
expansion:
N
X N
X
Ak
Hc (s) = hc (t) = Ak esk t u(t)
s sk
k=1 k=1

N
X
h[n] = Td hc (nTd ) = Td Ak (esk Td )n u[n]
k=1


X X
X N N
X Td Ak
H(z) = h[n]z n = Td Ak (esk Td )n z n =
n=0 n=0 k=1
1 esk Td z 1
k=1
sk Td
provided |e | < 1.
Therefore the following pole mapping rule applies:

sk pole of Hc (s) pk , esk Td pole of Hc (s)


This rule corresponds to the following mappings s = f (z):

ln z
s= z = esTd
Td

or, equivalently (assuming s , + j and z , rej )


(
r = eTd
= Td

Observe that this mapping rule does not apply for zeros.

Aliasing
The impulse-invariance transformation IS NOT a one-to-one mapping. In fact s1 = + j1 and s2 = + j2 ,
will be mapped into the same point z = eTd ej1 Td , if 1 2 = 2k
Td .

I{z}
sTd
z=e
z = ej

Td s = 2k
T d

1 R{z}
(2k+1)
T s= Td
d

3
T
d


X  
2k
H(z)|z=esTd = Hc s + j
Td
k=

12
M ATLAB
The impulse-invariance transformation of a rational transfer function of a CT system can be done using:
[B,A] = impinvar(C,D,Fd)
where [C,D] and [B,A] are the numerator/denominator polynomial coefficients of the CT and its DT counterpart
system function, respectively.
Example: Impulse-invariance transformation
L 1
hc (t) = e2t u(t) Hc (s) = , Re [s] > 2
s+2

C = [1]; D = [1,2]; Td = 0.1;


[B,A] = impinvar(C, D, 1/Td)
B = 0.1
H(z) = 10.8187z 1 , |z| > 0.8187
0.1000
A=
1.000 -0.8187

Limitations of the impulse-invariance technique

As already observed the first important limitation is the aliasing. The reduction of the aliasing effects can be
obtained by reducing Td
More in general if the system function Hc (s) is not a proper function, the technique cannot be applied at all.
The replication formula would not converge at all.

Design procedure (lowpass)


Specification: p , s , Ap and As
1. Choose Td
(
p p = p /Td
2.
s s = s /Td

3. Design the equivalent analog Hc (s) (Butterworth or Chebyshev I)1

4. Poles mapping or M ATLAB conversion by means of impinvar

Example (Butterworth)
Specifications: p = 0.25, s = 0.4, Ap = 1dB, As = 30dB

op=0.25*pi; os=0.4*pi; Ap=1; As=30;


1. Td=0.1;
2. Op = op/Td; Os = os/Td;
3. [N,Oc] = buttord(Op,Os,Ap,As,s);

[C,D] = butter(N,Oc,s);
1 Because of the aliasing, filters with equiripple behaviour in the stopband are unsuited

13
4. [B,A] = impinvar(C,D,1/Td);

N
N =
9

Example (Chebyshev I)
Specifications: p = 0.25, s = 0.4, Ap = 1dB, As = 30dB

op=0.25*pi; os=0.4*pi; Ap=1; As=30;


1. Td=0.1;
2. Op = op/Td; Os = os/Td;
3. [N,Oc] = cheb1ord(Op,Os,Ap,As,s);
[C,D] = cheby1(N,Ap,Oc,s);
4. [B,A] = impinvar(C,D,1/Td);

N
N =
5

Example (Chebyshev II) [impinvex.m]


Specifications: p = 0.25, s = 0.4, Ap = 1dB, As = 30dB

op=0.25*pi; os=0.4*pi; Ap=1; As=30;


1. Td=0.1;
2. Op = op/Td; Os = os/Td;
3. [N,Oc] = cheb2ord(Op,Os,Ap,As,s);
[C,D] = cheby2(N,As,Oc,s);
4. [B,A] = impinvar(C,D,1/Td);

N
N =
5

14
3.2 Bilinear transformation
The bilinear transformation avoids the limitations of the impulse invariance due to the aliasing
It is a one-to-one nonlinear transformation between s-plane and z-plane
It is defined by the following relationship:

2 1 z1
s = f (z) ,
Td 1 + z 1

The design parameter Td is not subject to any limitation and can be chosen to simplify the analytical derivations
It satisfies all the realizability conditions and is the most popular mapping technique

Realizability
The bilinear transformation is formally obtained by:

H(z) = Hc (s)|s= 2 1z 1
Td 1+z 1

Therefore a generic factor (zero or pole) is transformed as follows:

2 1 z 1 2 1 z 1 (1 + z 1 )k Td /2
s k = k =
Td 1 + z 1 Td 1 + z 1
 
2(1 Td k /2) 1 + Td k /2 1
= ... = 1 z
Td (1 + z 1 ) 1 Td k /2

Eventually:
1 + Td k /2
k
1 Td k /2

Zero and pole mapping


Therefore the bilinear transformation can be obtained by individually mapping zeros and poles... having:
QM
(1 + z 1 )N M k=1 (1 zk z 1 )
H(z) = G QN 1 )
k=1 (1 pk z

where
1+Td k /2 1+Td sk /2
zk =
1Td k /2 , pk = 1T d sk /2

Td N M QM
   
Td
0 2 k=1 1k 2


G = QN  Td

k=1 1sk 2

Observe:
A rational Hc (s) always gives a rational H(z)

The mapping preserves the system order N


If M < N the # of zeros increases (1 + z 1 )N M (adjoining N M zeros in 1)

15
M ATLAB function for bilinear transformation
The M ATLAB bilinear transformation can be done either by zeros/poles mapping or by polynomial coefficients
conversion:

[zd, pd, G] = bilinear(zc,pc,beta0,Fd)


zeros k (zc), poles sk (pc) and gain 0 (beta0) of the analog system Hc (s); design parameter 1/Td
(Fd)
zeros zk (zd), poles pk (pd) and gain G (G) of the discrete system H(z)
[B,A] = bilinear(C,D,Fd)
numerator (C) and denominator (D) coefficients of the analog system Hc (s)
numerator (B) and denominator (A) coefficients of the discrete system H(z)

Example of bilinear transformation


5(s + 2) 5s + 10
Hc (s) = = 2
(s + 3)(s + 4) s + 7s + 12
Therefore:
beta0=5; zc=-2; pc=[-3;-4]; Td=2;
% C=[5,10]; D=[1,7,12]; Td=2;
[zd, pd, G] = bilinear(zc,pc,beta0,1/Td);
% [Bd, Ad] = bilinear(C,D,1/Td);

Mapping properties
Let z = rej and s = + j, therefore
2/Td + s 2/Td + + j
z = rej = =
2/Td s 2/Td j
hence
 
2 1/2

r < 1, if < 0
(2/Td + )2 +
r = |z| = r = 1, if = 0
(2/Td )2 + 2

r > 1, if > 0
and    

= tan1 + tan1
2/Td + 2/Td
On the unit circle we have:   
Td 2
= 2 tan1 = tan
2 Td 2

I{z}

s = f (z)

z = ej
s = j s=0

0 1 R{z}
s = j

16
the open left-half plane is mapped in the interior of the unit circle
j axis is mapped onto the unit circle
the open right-half plane is mapped outside the unit circle
= 0 = 0 and
NO ALIASING
causal and stable CT filters yield causal and stable DT filters

Frequency warping
The nonlinear relationship between and ,
  
1 Td 2
= 2 tan = tan ,
2 Td 2
gives rise to a nonlinear frequency scaling, known as frequency warping, which may cause distortion, both in magni-
tude and phase response.
10

10

2

8 = tan
8

Td 2

6
6

Linear
response

4
4

Flat 2
2

response
Linear
response /

0.2 0.4 0.6 0.8 1


2

1
|Hc (j)|

2
|H(ej )| Nonlinear
response
Linear Flat
response response
1

0.2 0.4 0.6 0.8 1

Observations:
since tan for small , then the relation between and is approximatively linear for || < 0.3 (no
warping)
in general flat responses cannot be distorted by the warping
warping distorts nonflat responses for || > 0.3 (Ex.: differentiators cannot be converted by bilinear transfor-
mation)
frequency bands are nonlinearly translated/scaled, thus prewarping is necessary:
2  
k
k = tan
Td 2
The value Td can be feely set and it is usually set to Td = 2 to simplify the derivations
phase response is affected in similar manner. As consequence phase linearity is not preserved

17
Design procedure (lowpass)
Specification: p , s , Ap and As
1. Set Td = 2
(
p p = tan(p /2)
2.
s s = tan(s /2)

3. Design the equivalent analog Hc (s)


4. Pole/zero/gain mapping or M ATLAB conversion by means of impinvar

Example (Butterworth)
Specifications: p = 0.25, s = 0.4, Ap = 1dB, As = 30dB

op=0.25*pi; os=0.4*pi; Ap=1; As=30;


1. Td=2;
2. Op = tan(op/2); Os = tan(os/2);
3. [N,Oc] = buttord(Op,Os,Ap,As,s);
[C,D] = butter(N,Oc,s);
4. [B,A] = bilinear(C,D,1/Td);

N
N =
8

Example (Chebyshev II) [bilinearex.m]


Specifications: p = 0.25, s = 0.4, Ap = 1dB, As = 30dB

op=0.25*pi; os=0.4*pi; Ap=1; As=30;


1. Td=2;
2. Op = tan(op/2); Os = tan(os/2);
3. [N,Oc] = cheb2ord(Op,Os,Ap,As,s);
[C,D] = cheby2(N,As,Oc,s);
4. [B,A] = bilinear(C,D,1/Td);

N
N =
5

18
4 Design examples for lowpass IIR filters
M ATLAB functions for bilinear transf.-based IIR design
M ATLAB provides functions to directly design discrete-time IIR, which incorporate the bilinear transformation.

These functions are overloads of the corresponding ones used for continuous-time filter design: buttord,
butter, cheb1ord, cheby1,... where the option parameter s is omitted.
(
[N,omegac] = buttord(omegap,omegas,Ap,As);
Butterworth
[B,A] = butter(N,omegac);

(
[N,omegac] = cheb1ord(omegap,omegas,Ap,As);
Chebyshev I
[B,A] = cheby1(N,A,pomegac);

(
[N,omegac] = cheb2ord(omegap,omegas,Ap,As);
Chebyshev II
[B,A] = cheby2(N,As,omegac);

(
[N,omegac] = ellipord(omegap,omegas,Ap,As);
Elliptic
[B,A] = ellip(N,Ap,As,omegac);

Warning: in this case omegap and omegas must be normalized:

omegap p /, omegas s /

In the following we will show several realistic examples [iirlpexe.m] using the above functions
Example (Digital Butterworth lowpass)
Specifications: p = 0.2, s = 0.3, Ap = 1dB, As = 50dB

op=0.2; os=0.3; Ap=1; As=50;


[N,oc] = buttord(op,os,Ap,As);
[B,A] = butter(N,oc);
% Plots...

[N oc]

ans =
17 0.2218

Example (Digital Chebyshev I lowpass)


Specifications: p = 0.3, s = 0.4, Ap = 0.5dB, As = 60dB

19
op=0.3; os=0.4; Ap=0.5; As=60;
[N,oc] = cheb1ord(op,os,Ap,As);
[B,A] = cheb1(N,Ap,oc);
% Plots...

[N oc]
ans =
10 0.3000

Example (Digital Chebyshev II lowpass)


Specifications: p = 0.35, s = 0.45, Ap = 0.1dB, As = 60dB

op=0.35; os=0.45; Ap=0.1; As=60;


[N,oc] = cheb2ord(op,os,Ap,As);
[B,A] = cheb2(N,As,oc);
% Plots...

[N oc]
ans =
12 0.4500

Example (Digital elliptic lowpass)


Specifications: p = 0.4, s = 0.55, Ap = 1dB, As = 80dB

op=0.4; os=0.55; Ap=1; As=80;


[N,oc] = ellipord(op,os,Ap,As);
[B,A] = ellip(N,Ap,As,oc);
% Plots...

[N oc]
ans =
7 0.4000

20
5 Frequency transformations of lowpass filters
Although the frequency transformation can be performed both in CT and in DT domains, there are some limitations
in the CT case that make the DT frequency transformation more general

Therefore we will analyse the DT transformations in more detail, and will give a brief look at the CT case, just for
completeness.

In particular, the key limitation of CT frequency transformation is that the subsequent CT to DT conversion may
be heavily affected be aliasing, if the impulse-invariance is used

5.1 Continuous-time frequency transformations


Frequency transformations for continuous-time filters have been studied extensively.
The following table summarizes the different transformations, assuming as template filter a lowpass with cutoff
frequency c = 1rad/s.

Filter type Transform. Design parameters


s
Lowpass s c c = cutoff frequency
c
Highpass s s c = cutoff frequency
(
s2 +1 2 1 = lower cutoff frequency
Bandpass s s(2 1 )
= upper cutoff frequency
( 2
s(2 1 ) 1 = lower cutoff frequency
Bandstop s s2 +1 2
2 = upper cutoff frequency

M ATLAB provides the following functions for analog filter conversion: lp2lp, lp2hp, lp2bp and lp2bs.
Example (Lowpass to bandpass analog conversion)
Specifications: Fp1 = 20Hz, Fp2 = 60Hz, Ap = 1dB, As = 40dB

Fp1 = 20; Fp2 = 60; Ap = 1; As = 40;

% LP design (elliptic)
Omegap = 1; Omegas = 1.5;
[N,Omegac]=ellipord(Omegap,Omegas,Ap,As,s);
[C,D] = ellip(N,Ap,As,Oc,s);

% LP->PB transformation
Omega0=sqrt(Omegap1*Omegap2);% Geometric mean
BW = Omegap2-Omegap1;
[B,A] = lp2bp(C,D,Omega0,BW);

Observe: LPPB and LPBS double the filter order!

21
5.2 Discrete-time frequency transformations
Problem formulation

Given Hlp (w) having cutoff frequency c



1
Find a transformation w = G(z 1 ), z , rej , w , pej
such that H(z) , Hlp (w)|w1 =G(z1 ) matches HP, BP or BS...

Constraints:
Rational H(z) G(z 1 ) rational in z 1
|w| < 1 |z| < 1 (to preserve stability)
|w| = 1 |z| = 1 (to be able to map the specifications)
(
j j jG(ej ) |G(ej )| = 1
e = |G(e )|e (allpass)
= G(ej )

General solution
It has been found that the most general allpass function satisfying the above conditions is
N
Y
1 1 z 1 k
w = G(z )= , with |k | < 1 k
1 k z 1
k=1

By properly choosing the values of N and k , we obtain a variety of mapping (see the following table for the most
useful ones)

Common discrete-time mappings LP(c ) LP(c ), HP(c ), BP(1 < 2 ), BS(1 < 2 )

Filter type Transform. Design parameters


z 1 sin[(c c )/2]
Lowpass w1 1z 1 = sin[(c +c )/2]
z 1 + cos[(c +c )/2]
Highpass w1 1+z 1 = cos[( c c )/2]
cos[(2 +1 )/2]

= cos[(2 1 )/2]


2
1 z +2 1 K = cot[(2 1 )/2] tan(c /2)
Bandpass w1 z2 z2 1 z 1 +1 1 = 2K/(K + 1)



2 = (K 1)/(K + 1)
cos[(2 +1 )/2]

= cos[( 2 1 )/2]


z 2 1 z 1 +2 K = tan[(2 1 )/2] tan(c /2)
Bandstop w1 2 z 2 1 z 1 +1
1 = 2/(K + 1)


2 = (1 K)/(1 + K)

22
LP(c ) HP(c )
As an example consider the LP HP transformation:

z 1 + ej +
w1 = G(z 1 ) = e j
=
1 + z 1 1 + ej

 
(1 2 ) sin
= tan1
2 + (1 + 2 ) cos
 
1 (1 2 ) sin
= tan
2 + (1 + 2 ) cos
In particular, the last equation allows the mapping of the desired band edge frequencies
The above nonlinear relationship between and (see picture) causes a frequency warping for 6= 0.


=
0.8

0.

8
=
0.
0.6

5

=

0.4

0
=

0.

0.2
=

5

0.

0.2 0.4 0.6 0.8

As in the bilinear transformation case, this warping does not distort piecewise-constant frequency response character-
istics.

Design procedure for LP HP


Specifications: s < p , Ap < As

1. p = 1rad
2. anchor the cutoff f. to the passband edge f.:

c = p and c = p

cos[(c +c )/2]
3. = cos[( c c )/2]
h i
(12 ) sin s
4. s = tan1 2+(1+ 2 ) cos
s
(prewarping of s )

5. Design a LP (Hlp (z)) with specifications: s , p , Ap , As


1
z +
6. Map z 1 1+z 1 to get the HP H(z)

Example (LP HP)


Specifications: s = 0.45, p = 0.6, Ap = 1dB, As = 15dB

os = 0.45*pi; op = 0.6*pi; Ap = 1; As = 15;


1-2 tp = 1; tc=tp; oc=op;
3 al = -(cos((tc+oc)/2))/(cos((tc-oc)/2));

23
4 ts=atan(-(1-al2)*sin(os)/
(2*al+(1+al2)*cos(os)));
5 % LP design (Chebyshev I)
[N,omegac]=cheb1ord(tp/pi,ts/pi,Ap,As);
[Blp,Alp] = cheby1(N,Ap,omegac);

1
z +
6 Given the prototype Hlp (z), it is easy to proceed analytically with the mapping z 1 = 1+z 1 ...

6 Design examples of IIR filters using M ATLAB


The procedure shown in the last example can be easily extended to all other transformations of interest.
In M ATLAB these procedures are incorporated in familiar digital filter design functions.
These functionalities are obtained again by pairs like (ellipord,ellip) properly overloaded, the former for
order determination the latter for filter design

The function prototypes for all kinds (Butterworth, Chebyshevs,...) present the same formalism, therefore we can
refer to only one type (Elliptic) for details.

Order determination (Elliptic)


Syntax: [N,omegac]=ellipord(omegap,omegas,Ap,As)
The frequencies, expressed in units of , have the following meaning:

Lowpass omegap < omegas


Highpass omegap > omegas
Bandpass omegap=[opL,opH] and omegas=[osL,osH],
such that osL < opL < opH < osH
Bandstop omegap=[opL,opH] and omegas=[osL,osH],
such that opL < osL < osH < opH
omegac provides the appropriate cutoff frequency (or frequencies) in each case.

Filter design (Elliptic)


Syntax:

Lowpass [B,A]=ellip(N,Ap,As,omegac), with omegac= p /


Highpass [B,A]=ellip(N,Ap,As,omegac,high), with omegac= p /
Bandpass [B,A]=ellip(N,Ap,As,omegac), with omegac= [pL /, pH /]
Bandstop [B,A]=ellip(N,Ap,As,omegac,stop), with omegac= [pL /, pH /]

Example (Butterworth highpass filter design) [butterHP.m]


Specifications: s = 0.5, p = 0.7, Ap = 1dB, As = 40dB

24
omegap = 0.7; Ap = 1; omegas = 0.5; As = 40;
[N,omegac] = buttord(omegap,omegas,Ap,As)
N =
8

omegac =
0.6739
[B,A] = butter(N,omegac,high);

% Plots...

Example (Chebyshev I bandpass filter design) [cheb1BP.m]


Specifications:
Lower stopband: [0, 0.25] Attenuation: 40dB
Passband: [0.3, 0.5] Ripple: 0.5dB
Upper stopband: [0.6, ] Attenuation: 50dB

omegap = [0.3 0.5]; omegas = [0.25 0.6];

Ap = 0.5; As = 50;
[N,omegac] = cheb1ord(omegap,omegas,Ap,As); N
N =
7

[B,A] = cheby1(N,Ap,omegac);
% Plots...

Example (Chebyshev II bandstop filter design) [cheb2BS.m]


Specifications:
Lower passband: [0, 0.2] Ripple: 0.5dB
Stopband: [0.3, 0.6] Attenuation: 40dB
Upper passband: [0.75, ] Ripple: 0.5dB

omegap = [0.2 0.75]; omegas = [0.3 0.6];


Ap = 0.5; As = 40;
[N,omegac] = cheb2ord(omegap,omegas,Ap,As); N

N =
5
[B,A] = cheby2(N,As,omegac,stop);
% Plots...

25
Example (Elliptic bandpass filter design) [ellipBP.m]
Specifications:
Lower stopband: [0, 0.2] Attenuation: 60dB
Passband: [0.3, 0.6] Ripple: 0.1dB
Upper stopband: [0.7, ] Attenuation: 60dB

omegap = [0.3 0.6]; omegas = [0.2 0.7];

Ap = 0.1; As = 60;
[N,omegac] = ellipord(omegap,omegas,Ap,As); N
N =
6

[B,A] = ellip(N,Ap,As,omegac);
% Plots...

26

Vous aimerez peut-être aussi