Design of Infinite Impulse Response (IIR) digital filters

advertisement
Design of Infinite Impulse Response (IIR) digital filters
Output from a digital filter is made up from previous inputs and previous outputs, using the
operation of convolution:
Two convolutionsare involved: one with the previous inputs, and one with the previous
outputs. In each case the convolving function is called the filter coefficients.
If such a filter is subjected to an impulse (a signal consisting of one value followed by zeroes)
then its output need not necessarily become zero after the impulse has run through the
summation. So the impulse response of such a filter can be infinite in duration. Such a filter is
called an Infinite Impulse Response filter or IIR filter.
Note that the impulse response need not necessarily be infinite: if it were, the filter would be
unstable. In fact for most practical filters, the impulse response will die away to a negligibly
small level. One might argue that mathematically the response can go on for ever, getting
smaller and smaller: but in a digital world once a level gets below one bit it might as well be
zero. The Infinite Impulse Response refers to the ability of the filter to have an infinite
impulse response and does not imply that it necessarily will have one: it serves as a warning
that this type of filter is prone to feedback and instability.
The filter can be drawn as a block diagram:
Coefficient calculation methods for IIR filters
While trying to compute the filter coefficients one has to select a method from a number of
approximation methods in order to calculate the values of dk and ck.
A simple way to obtain the IIR filter coefficients is to place poles and zeros judiciously in the
z-plane such that the resulting filter has the desired frequency response.
This approach is known as the pole-zero-placement method. Is only useful for very simple
filters, i.e. notch filtering, where the filter parameters (passband ripple) need not be specified
precisely.
A more efficient approach is first to design an analog filter satisfying the desired
specifications and then to convert it into an equivalent digital filter. Most IIR digital filters are
designed this way.
There are three main methods for converting an analog filter into a digital filter.
1) impulse invariance
2) the matched z-transform
3) bi-linear z-transform
Basic Concepts and illustrative design examples:
When a zero is placed at a point on the z-plane, the frequency response will be zero at the
corresponding point.
A pole on the other hand produces a peak at the corresponding frequency point.
Poles that are close to the unit circle give rise to large peaks whereas zeros close to or on the
circle throughs or minima.
Hence by strategically placing poles and zeros on the z-plane we can obtain simple lowpass or
other frequency selective filters.
An important point to remember is that :
In order for the filter coefficients to be real , the poles and zeros must be either real (i.e. lie on
the positive or negative real axis) or occur in complex conjugate pairs.
Fs/4
0
Fs/2
3Fs/4
0
Fs/4
(a)
Fs/2
3Fs/4
Frequency
(b)
(a) Pole zero diagram of a simple filter
(b) A sketch of its frequency response
Example1:
Illustrating the simple pole-zero method of calculating the filter coefficients a bandpass digital
filter is required to meet the following specifications:
(i)
(ii)
(iii)
complete signal rejection at DC and 250Hz.
A narrow passband centered at 125Hz
A 3dB bandwidth of 10Hz.
Assuming a sampling frequency of 500 Hz, obtain the transfer function of the filter by
suitably placing z-plane poles and zeros, and its difference equations.
Solution:
Since a complete rejection is required at zero and 250Hz we need to place zeros at the
corresponding points on the z-plane. These are at angles of 0° and 360×250/500=180° on the
unit circle.
To hava the passband centered at 125Hz requires us to place poles at ±360×125/500=±90°. To
ensure that the coefficients are real , it is necessary to have complex conjugate pole pair.
Im
z-1
0.937
z-1
Re
-1
z-1
z-1
-0.877969
(a)
(b)
(a) Pole-zero dıagram
(b) Block diagram representation of filter
The radius of the poles is determined by the desired bandwidth. An approximate relationship
between r, for r> 0.9, and bandwidth bw is:
r ≅ 1 − (bw / Fs )π
for our specifications bw =10Hz and Fs=500Hz . This leads to an r value of r= 0.937
∴
H [z ] =
(z − 1)(z + 1)
(z − re )(z − re
jπ / 2
− jπ / 2
)
=
z2 −1
1 − z −2
=
z + 0.877969 1 + 0.877969 z − 2
2
The difference equation is
y[n] = −0.877969 y[n − 2] + x[n ] − x[n − 2]
Î b0 = 1, b1 = 0 , b2=-1
and
a1 = 0 , a2=0.877969
Example 2:
(Using the pole-zero placement method to calculate coefficients of a notch filter)
Obtain by the pole-zero placement method the transfer function and the difference equation of
a simple digital notch filter that meets the following specifications.
Notch frequency
50Hz
3dB width of notch ±5Hz
sampling frequency 500 Hz
Solution:
To reject the component at 50Hz we place a pair of complex zeros at points on the unit circle
corresponding to 50Hz that is at angles of 360°×50/500=±36°.
To achieve a sharp notch filter and improved amplitude response on either side of the notch
frequency, a pair of complex conjugate poles are placed at a radius r < 1. The width of the
notch is determined by the locations of the poles. The relationship between the bandwidth and
radius is same as in the previous example.
Im
H[f ]
0.937
Re
0
50
250
Freqeuncy
The relationship between the bandwidth and the redius is applicable. Thus the radius of the
poles is 0.9372.
From the transfer function of the filter we have:
H [z ] =
[z − e ][z − e ] =
[z − 0.937e ][z − 0.9372e ] z
− j 36
− 36
j 36
36
2
1 − 1.6180 z −1 + z − 2
z 2 − 1.618 z + 1
=
− 1.5164 z + 0.8783 1 − 1.5164 z −1 + 0.8783 z − 2
The difference equation will be:
y[n] = x[n] − 1.6180 x[n − 1] + x[n − 2] + 1.5164 y[n − 1] − 0.8783 y[n − 2]
Î b0 = 1, b1 = -1.6180 , b2=1
and
a1 = -1.5164 , a2=0.8783
Impulse Invariant Method of Coefficient Calculation
In this method, starting with a suitable analog transfer function H(s) the impulse response h(t)
is obtained using the Laplace transform. The h(t) so obtained is suitably sampled to produce
h(nT), and the desired transfer function H(z) is then obtained by z-transforming h(nT) where
T is the sampling interval.
Example1: (theoretic)
Digitize an analog filter using impulse invariance method. The analog filter has a transfer
function given by:
H (s ) =
C
s− p
Solution:
If we apply the inverse Laplace transform we can get h(t) as below:
 C 
 = Ce pt
h(t ) = L−1{H ( s )} = L−1 
s
−
p


According to the impulse invariant method, the impulse response of the equivalent digital
filter, h(nT), is equal to h(t) at the discrete times t=nT, n = 0,1,2,....
h(nT ) = h(t ) t = nT = Ce pnT
The transfer function of H[z] is obtained by z-transforming h(nT) :
H [z ] =
∞
∑ h(nT )z
−n
n=0
=
∞
=
∑ Ce
pnT − n
z
n =0
C
1 − e pT z −1
Thus from the results so far we can write :
C
C
→
s− p
1 − e pT z −1
To apply the impulse invariant method to a high order IIR filter with simple poles, the transfer
function H(s) is first expanded using partial fractions as the sum of single-pole filters:
H (s) =
C1
C2
CM
+
+ ......... +
=
s − p1 s − p2
s − pM
M
Ck
∑s− p
k =1
k
where pk are the poles of H(s).Since each term has the same form then we can say that:
M
Ck
→
s − pk
k =1
∑
M
Ck
∑1− e
k =1
p k T −1
z
High order IIR filters are normally realized as cascades or parallel combinations of standard
second order filter sections.
For case M = 2
C1
C2
C1
C2
+
→
+
p1T −1
s − p1 s − p2
1− e z
1 − e p 2T z −1
=
(
)
C1 + C2 − C1e p 2T + C 2 e p1T z −1
(
)
1 − e p1T + e p 2T z −1 + e ( p1 + p 2 )T z − 2
If the poles p1 and p2 are complex conjugates the C1 and C2 will also be complex conjugates
2Cr − [Cr cos( piT ) + Ci sin ( piT )]2e p r T z −1
C1
C1*
+
=
*
p1T −1
p
T
−
1
1− e z
1 − 2e p r T cos( piT )z −1 + e 2 p r T z − 2
1− e 1 z
Here Cr and Ci are the real and imaginary parts of C1 and
pr and pi are the real and imaginary parts of p1 .
Example:
Design a digital filter to approximate the following normalized analog transfer function:
H ( s) =
1
s + 2s + 1
2
Using the impulse invariant method obtain the transfer function, H(z), of the digital filter,
assuming a 3dB cutoff frequency of 150Hz and a sampling frequency of 1.28 kHz.
Solution:
First we need to frequency scale the normalized transfer function. This is achieved by
replacing s by s/α where α = 2π×150=942.4778
H ' (s ) = H (s )
s=s / α
=
C1
C2
α2
=
+
s 2 + 2αs + α 2 s − p1 s − p 2
where;
p1 =
− 2α (1 − j )
= −666.4324(1 − j ) , p 2 = p1*
2
C1 = −
α
2
j = −666.4324 j ,
C 2 = C1*
Since the poles are complex conjugates, the transformation is used to obtain the discrete-time
transfer function, H(z).
C r = 0,
Ci = −666.4324,
pi T = 0.5207,
p r T = −0.5207, e prT = 0.5941, sin( pi T ) = 0.4974,
cos( pi T ) = 0.8675 and e 2 prT = 0.3530
Using these values in the previously obtained expression we get H(z) as:
H [z ] =
393.9264 z −1
1 − 1.0308 z −1 + 0.3530 z − 2
If we substitute z = ejwT in the above equation the value of H[z] at w=0 is 1223, approximately
equal to the sampling frequency. Such large gain is characteristic of impulse invariant filters.
To keep the gain down and to avoid overflows when the filter is implemented , it is common
practice to multiply H[z] by T (or equivalently divide it by the sampling frequency).
H [z ] =
0.3078 z −1
1 − 1.0308 z −1 + 0.3530 z −2
Therefore, we have
b0 = 0
a1 = −1.0308
b1 = 0.3078
a 2 = 0.3530
The bilinear transformation
Let us consider the identity
s=
2(1 − z −1 )
1 + z −1
where, s and z are complex variables.
This is what is known as the bilinear transformation or Tustins transformation. The inverse of
this transformation is easily determined as
z=
2+ s
2−s
In the discrete domain we are interested in z values on the unit circle z = e jw whereas in the
Laplace domain s values on the imaginary axis (s=jΩ) is of importance. The transformation
and its inverse are well defined for all s on the imaginary axis where s = jΩ. Here Ω denotes
the analog frequencies in rad/sec.
The bilinear transformation ties the two frequency scales together as follows. Starting from
2(1 − z −1 )
s=
and letting z = e jw we obtain:
1 + z −1
s = jΩ =
(
) (
)
2 1 − e − jw
2 e jw / 2 − e − jw / 2
sin (w / 2 )
=
= 2i
= 2i tan( w / 2)
− jw
jw / 2
− jw / 2
cos(w / 2 )
e
+e
1+ e
and consequently the relation between the two frequency scales is given by
Ω = 2 tan (w / 2 )
We note that w=0 implies Ω=0 and for increasing w the continuous frequencies will also
increase and as wÆ π the ΩÆ∞. Hence the entire continuous time frequency region
Ω ∈ [0, ∞ ) is mapped to the upper half of the unit circle.
Transformed Transfer Function
One important application of the bilinear transformation is for the conversion of an analog
filter to a digital one. The transformation is applied as follows. Start from a Laplace domain
filter Ha(s) which is a rational function in the free variable s. A rational transfer function is the
quotient of two polynomials. The bilinearly transformed discrete time (Z-domain) transfer
function Hd[z] is defined as:
H d [z ] = H a (s )
s=
(
2 1− z −1
1+ z −1
) ≅ H d [z ]
Note that Hd[z] is also a rational transfer function. The MATLAB command bilinear performs
the bilinear transformation.
The following good properties can be identified:
•
•
•
It is easy to verify that the number of poles of Hd[z] and Ha(s) coincide. This means
that the order of the filter is unchanged.
If Ha(s) is a stable transfer function so is also Hd[z]
The complex filter response, i.e. both magnitude and phase, coincides for frequencies
related by:
[ ]
Ha ( jΩ) = Hd e jw
The last feature implies that the bilinear-transformation preserves the type of filter. If Ha(s) is
a low-pass filter then Hd[z] will also be a low-pass filter.
Analog IIR filter design
To design any of the four types analog IIR filters it is sufficient to base the design on an
analog IIR lowpass filter. This section briefly summarizes the design of analog LP IIR filters
based on filter prototypes.
An analog prototype LP-filter is given by :
H LPp ( s ) =
C
1
= n
n −1
p ( s ) s + p1 s + ...... + pn
where p(s) is a prototype polynomial. The type of LP filter defines the polynomial coefficients
and the various prototype polynomials can be found in standard textbooks. The MATLAB
commands buttap and cheb1ap gives the zeros and poles of the prototype filters. Examples
are given in the tables below:
Order
1
2
Prototype polynomial p(s)
s+1
s2+ 2 s + 1
Gain C
1
1
Table1 : Butterworth prototype polynomials
Order
1
2
Prototype polynomial p(s)
s+2.8628
s2+ 1.4256 s + 1.5162
Gain C
2.8628
1.4314
Table2 : Chebyshev type 1 prototype polynomials wit pass-band ripple 0.5dB.
All prototype polynomials have the 3dB cutoff frequency normalized to Ω=1rad/s. For a
particular design with a desired cut-off frequency of ΩLPc the filter is modified by scaling the
s variable with the inverse of the desired cut-off frequency. The final analog design is then;
H LP ( s ) = H LPp ( s )
s
=
1
n
n −1
 s 
 s 
 s 

 + p1 
 + .......... + p n−1 
 + p n
 Ω LPc 
 Ω LPc 
 Ω LPc 
In MATLAB lp2lp performs this design from a given prototype.
s→
Ω LPc
HP,BP and BS filter design
Three other type of designs, high-pass , band-pass, and band-stop can all be generated from a
low-pass filter using special frequency transformation. We assume that HLP(s) is a low-pass
filter with -3dB cutoff frequency ΩLPc and stop band frequency at ΩLPs as illustrated in figure
1.
Figure 1: The four standard filters : LP= low-pass, HP=high-pass,
BP=band-pass, BS=band-stop
High-pass design
A high-pass design is achieved from a low-pass filter by the transformation
H HP ( s ) = H LP ( s )
s→
Ω 2I
s
 Ω2
= H LP  I
 s



where
Ω HPc
Ω 2I
=
Ω LPc
Ω HPs =
Ω 2I
Ω LPs
Here Ω I =1 is a valid scaling. In MATLAB the function lp2hp performs this design from a
given prototype.
2
Analog IIR design summary
Assume the resulting filter order is given. This immediately constrains the width of the
transition zone and we only have to design the position of the cut-off frequencies.
1) Identify the cut-off frequencies (ΩXXlc and ΩXXhc) of the design specification. From them
2
determine Ω I and the cut-off frequency Ω LPc of the low-pass filter.
2) Design a low-pass filter with the desired Ω LPc using a low-pass prototype filter (e.g.
Butterworth or Chebyshev). If the final design is a BP or BS filter, then this low-pass filter
should have half the order of the final desired design.
3) Use the corresponding frequency transformation to finally obtain the desired filter.
Digital IIR filter design
The design of an IIR filter is rather straightforward when using the bilinear transformation
technique. Most of the work is done when designing the analog filter.
Recall that if an analog filter is converted to a digital one via the bilinear transformation we
obtain the relation:
As the bilinear transformation preserves the type of filter (LP, BP etc.) we only need to make
sure that the cut-off frequencies gets mapped to the correct place. The design technique is
summarized here:
1. Start by identifying the discrete time frequencies describing the cutoff frequencies.
Use normalized frequencies in radians where w = π represents half the
samplingfrequency ( w = 2πf/fs).
2. Calculate the corresponding analog frequencies using Ω = 2 tan (w / 2 )
3. Design an analog filter Ha(s) based on the specifications as described in section before.
4. Use the bilinear transformation to obtain the final digital (Z-domain) filter.
Example 1
Example2:
Download