You are on page 1of 25

Design of Digital Filters

A digital lter is a linear shift-invariant discrete-time system that is realized using nite precision arithmetic. The design of digital lters involves three basic steps: The specication of the desired properties of the system. The approximation of these specications using a causal discrete-time system. The realization of these specications using nite precision arithmetic. These three steps are independent; here we focus our attention on the second step. The desired digital lter is to be used to lter a digital signal that is derived from an analog signal by means of periodic sampling. The specications for both analog and digital lters are often given in the frequency domain, as for example in the design of low pass, high pass, band pass and band elimination lters. Given the sampling rate, it is straight forward to convert from frequency specications on an analog lter to frequency specications on the corresponding digital lter, the analog frequencies being in terms of Hertz and digital frequencies being in terms of radian frequency or angle around the unit circle with the point z = -1 corresponding to half the sampling frequency. The least confusing point of view toward digital lter design is to consider the lter as being specied in terms of angle around the unit circle rather than in terms of analog frequencies. 1

Figure 4.1: Tolerance limits for approximation of ideal low-pass lter A separate problem is that of determining an appropriate set of specications on the digital lter. In the case of a low pass lter, for example, the specications often take the form of a tolerance scheme, as shown in Fig. 4.1. 1 1 | H (ej ) | 1, | | p | H (ej ) | 2 , s | | Many of the lters used in practice are specied by such a tolerance scheme, with no constraints on the phase response other than those imposed by stability and causality requirements; i.e., the poles of the system function must lie inside the unit circle. Given a set of specications in the form of Fig. 4.1, the next step is to nd a discretetime linear system whose frequency response falls within the prescribed tolerances. At this point the lter design problem becomes a problem in approximation. In the case of innite impulse response (IIR) lters, we must approximate the desired frequency response by a 2

rational function, while in the nite impulse response (FIR) lters case we are concerned with polynomial approximation.

4.1

Design of IIR Filters From Analog Filters:

The traditional approach to the design of IIR digital lters involves the transformation of an analog lter into a digital lter meeting prescribed specications. This is a reasonable approach because: The art of analog lter design is highly advanced and since useful results can be achieved, it is advantageous to utilize the design procedures already developed for analog lters. Many useful analog design methods have relatively simple closed-form design formulas. Therefore, digital lter design methods based on analog design formulas are rather simple to implement. An analog system can be described by the dierential equation
N

ck
k =0

M dk ya (t) dk xa (t) = d k dtk dtk k =0

(4.1)

And the corresponding rational function is Ha (s) =


M k k =0 dk s N k k =0 ck s

ya (s) xa (s)

(4.2)

The corresponding description for digital lters has the form


N k =0 M

ak y (n k ) = 3

k =0

bk x(n k )

(4.3)

and the rational function H (z ) =


M k k =0 bk z N k k =0 ak z

Y (z ) X (z )

(4.4)

In transforming an analog lter to a digital lter we must therefore obtain either H(z) or h(n) (inverse z-transform of H(z) i.e., impulse response) from the analog lter design. In such transformations, we want the imaginary axis of the s-plane to map into the unit circle of the z-plane, a stable analog lter should be transformed to a stable digital lter. That is, if the analog lter has poles only in the left-half of s-plane, then the digital lter must have poles only inside the unit circle. These constraints are basic to all the techniques discussed here.

4.1.1

IIR Filter Design By Impulse Invariance:

This technique of transforming an analog lter design to a digital lter design corresponds to choosing the unit-sample response of the digital lter as equally spaced samples of the impulse response of the analog lter. That is, h(n) = ha (nT ) Where T is the sampling period. Because of uniform sampling, we have H (ejT ) = or 1 H (z ) |z =esT = T
k =

(4.5)

1 T

k =

Ha (j + j

2 k) T

(4.6)

Ha (s + j

2 k) T

(4.7)

where s = j and = /T , is the frequency in analog domain and is the frequency in digital domain. 4

Figure 4.2: Mapping of s-plane into z-plane From the relationship z = eST it is seen that strips of width 2/T in the s-plane map into the entire z-plane as shown in Fig. 4.2. The left half of each s-plane strip maps into interior of the unit circle, the right half of each s-plane strip maps into the exterior of the unit circle, and the imaginary axis of length 2/T of s-plane maps on to once round the unit circle of z-plane. Each horizontal strip of the s-plane is overlaid onto the z-plane to form the digital lter function from analog lter function. The frequency response of the digital lter is related to the frequency response of the analog lter as H (ej ) = 1 T
k =

Ha (j

2 + j k) T T

(4.8)

From the discussion of the sampling theorem it is clear that if and only if Ha (j ) = 0, | | Then H (ej ) = 1 Ha (j ), | | T T 5 T

Figure 4.3: Illustration of the eects of aliasing in the impulse invariance technique Unfortunately, any practical analog lter will not be band limited, and consequently there is interference between successive terms in Eq. (4.8) as illustrated in Fig. 4.3. Because of the aliasing that occurs in the sampling process, the frequency response of the resulting digital lter will not be identical to the original analog frequency response. To get the lter design procedure, let us consider the system function of the analog lter expressed in terms of a partial-fraction expansion Ak k =1 s sk
N

Ha (s) =

(4.9)

The corresponding impulse response is


N

ha (t) =
k =1

Ak esk t U (t)

(4.10)

And the unit-sample response of the digital lter is then


N N

h(n) = ha (nT ) =
k =1

Ak e

sk nT

u(n) =
k =1

Ak (esk T ) U (n)

(4.11)

The system function of the digital lter H(z) is given by H (z ) = Ak sk T z 1 ) k =1 (1 exp


N

(4.12)

In comparing Eqs. (4.9) and (4.12) we observe that a pole at s=sk in the S-plane transforms to a pole at expsk T in the Z-plane. It is important to recognize that the impulse invariant design procedure does not correspond to a mapping of the S-plane to the Z-plane.

4.1.2

IIR Filter Design By Approximation Of Derivatives:

A second approach to design of a digital lter is to approximate the derivatives in Eq. (4.1) by nite dierences. If the samples are closer together, the approximation to the derivative would be increasingly accurate. For example, suppose that the rst derivative is approximated by the rst backward dierence dya (t) y (n) y (n 1) |t=nT (1) [y (n)] = dt T (4.13)

Where y (n) = ya (nT ). Approximation to higher-order derivatives are obtained by repeated application of Eq. (4.13); i.e., d dk1 ya (t) dk ya (t) | = ( ) |t=nT (k) [y (n)] = (1) [(k1) [y (n)]] t=nT dtk dt dtk1 For convenience we dene (0) [y (n)] = y (n) Applying Eqs. (4.13), (4.14) and (4.15) to (4.1), we obtain
N k ==0

(4.14)

(4.15)

ck [y (n)] = 7

(k )

M k =0

dk (k) [x(n)]

(4.16)

Where y (n) = ya (nT ) and x(n) = xa (nT ). We note that the operation (1) [ ] is a linear shift-invariant operator and that (k) [ ] can be viewed as a cascade of (k) operators (1) [ ]. In particular, Z [(1) [x(n)] = [ and Z [(k) [x(n)] = [ 1 z 1 k ] X (z ) T 1 z 1 ]X (z ) T

Thus taking the z-transform of each side in Eq. (4.16), we obtain H (z ) =


M 1z 1 k k =0 dk [ T ] N 1z 1 k k =0 ck [ T ]

(4.17)

Comparing Eq. (4.17) to (4.2), we observe that the digital transfer function can be obtained directly from the analog transfer function by means of a substitution of variables s= 1 z 1 T (4.18)

So that, this technique does indeed truly correspond to a mapping of the s-plane to the z-plane, according to Eq. (4.18). To investigate the properties of this mapping, we must express z as a function of s, obtaining z= 1 1 sT

Substituting s = j , i.e., imaginary axis in s-plane z = 1 1 j T 1 1 1 = + 1 j T 2 2 1 1 1 + j T + [ ] = 2 2 1 j T 8

Figure 4.4: Mapping of s-plane to z-plane corresponding to rst backward-dierence approximation to the derivative 1 + j T 1 [1 + ] 2 1 j T 1 1 = [1 + ej 2 tan (T ) ] 2

(4.19)

Which corresponds to a circle whose center is at z=1/2 and radius is 1/2, as shown an Fig. 4.4. It is easily veried that the left half of the s-plane maps into the inside of the small circle and the right half of the s-plane maps onto the outside of the small circle. Therefore, although the requirement of mapping the j -axis to the unit circle is not satised, this mapping does satisfy the stability condition. In contrast to the impulse invariance technique, decreasing the sampling period T, theoretically produces a better lter since the spectrum tends to be concentrated in a very small region of the unit circle. These two procedures are highly unsatisfactory for anything but low pass lters. An alternative approximation to the derivative is a forward dierence and it provides a mapping into the unstable digital lters. 9

4.1.3

IIR Filter Design By The Bilinear Transformation:

In the previous section a digital lter was derived by approximating derivatives by dierences. An alternative procedure is based on integrating the dierential equation and then using a numerical approximation to the integral. Consider the rst - order equation c1 ya (t) + c0 ya (t) = d0 xa (t) (4.20)

Where ya (t) is the rst derivative of ya (t). The corresponding analog system function is Ha (s) = d0 c0 + c 1 s

We can write ya (t) as an integral of ya (t), as in ya (t) =


t t0

ya (t)dt + ya (t0 )

In pparticular, if t = nT and t0 = (n 1)T , ya (nT ) =


nT (n1)T

ya ( )d + ya ((n 1)T )

If this integral is approximated by a trapezoidal rule, we can write ya (nT ) = ya ((n 1)T ) + However, from Eq. (4.20), ya (nT ) = Substituting into Eq. (4.21) we obtain [y (n) y (n 1)] = d0 T c0 [ (y (n) + y (n 1)) + (x(n) + x(n 1))] 2 c1 c1 10 d0 c0 ya (nT ) + xa (nT ) c1 c1 T [y (nT ) + ya ((n 1)T )] 2 a (4.21)

where y (n) = y (nT ) and x(n) = x(nT ). Taking the Z-transform and solving for H(z) gives H (z ) = d0 Y (z ) = 2 1z 1 X (z ) c0 + c 1 T 1+z 1 (4.22)

From Eq. (4.22) it is clear that H(z) is obtained from Ha (s) by the substitution 2 1 z 1 s= T 1 + z 1 That is, H (z ) = Ha (s) |s= 2 1z1
T 1+z 1

(4.23)

(4.24)

This can be shown to hold in general since an N th - order dierential equation of the form of Eq. (4.1) can be written as a set of N rst-order equations of the form of Eq. (4.20). Solving Eq. (4.23) for z gives z= 1+ T s 2 T 1 2s (4.25)

The invertible transformation of Eq. (4.23) is recognized as a bilinear transformation. To see that this mapping has the property that the imaginary axis in the s-plane maps onto the unit circle in the z-plane, consider z = ej , then from Eq. (4.23), s is given by s = 2 1 ej T 1 + ej 2 j sin(/2) = T cos(/2) 2 j tan(/2) = T = + j Thus for z on the unit circle, = 0 and and are related by T = tan(/2) 2 11

Figure 4.5: Mapping of analog frequency axis onto the unit circle using the bilinear transformation or = 2 tan1 (T /2)

This relationship is plotted in Fig. (4.5), and it is referred as frequency warping. From the gure it is clear that the positive and negative imaginary axis of the s-plane are mapped, respectively, into the upper and lower halves of the unit circle in the z-plane. In addition to the fact that the imaginary axis in the s-plane maps into the unit circle in the z-plane, the left half of the s-plane maps to the inside of the unit circle and the right half of the s-plane maps to the outside of the unit circle, as shown in Fig. (4.6). Thus we see that the use of the bilinear transformation yields stable digital lter from stable analog lter. Also this transformation avoids the problem of aliasing encountered with the use of impulse invariance, because it maps the entire imaginary axis in the s-plane onto the unit circle in the z-plane. The price paid for this, however, is the introduction of a distortion in the frequency axis. 12

Figure 4.6: Mapping of the s-plane into the z-plane using the bilinear transformation

4.1.4

The Matched-Z Transform:

Another method for converting an analog lter into an equivalent digital lter is to map the poles and zeros of Ha (s) directly into poles and zeros in the z-plane. For analog lter Ha (s) = the corresponding digital lter is H (z ) =
M k =1 (1 N k =1 (1 M k =1 (s N k =1 (s

sk ) pk )

(4.26)

esk T z 1 ) epk T z 1 )

(4.27)

where T is the sampling interval. Thus each factor of the form (s-a) in Ha (s) is mapped into the factor (1 eaT z 1 ).

4.1.5

Characteristics Of Commonly Used Analog Filters:

From the previous discussion it is clear that, IIR digital lters can be obtained by beginning with an analog lter. Thus the design of a digital lter is reduced to designing an 13

appropriate analog lter and then performing the conversion from Ha (s) to H (z ). Analog lter design is a well - developed eld, many approximation techniques, viz., Butterworth, Chebyshev, Elliptic, etc., have been developed for the design of analog low pass lters. Our discussion is limited to low pass lters, since, frequency transformation can be applied to transform a designed low pass lter into a desired high pass, band pass and band stop lters. Butterworth Filters: Low pass Butterworth lters are all - pole lters with monotonic frequency response in both pass band and stop band, characterized by the magnitude - squared frequency response | Ha () |2 = 1 = 1 + (/c )2N 1+ 1
2 (/ p) 2N

(4.28)

Where, N is the order of the lter, c is the -3dB frequency, i.e., cuto frequency, p is the pass band edge frequency and 1/(1 +
2

) is the band edge value of | Ha () |2 . Since

the product Ha (s)Ha (s) and evaluated at s = j is simply equal to | Ha () |2 , it follows that Ha (s)Ha (s) = 1 s2 N ) 1 + ( 2
c

(4.29)

The poles of Ha (s)Ha (s) occur on a circle of radius c at equally spaced points. From Eq. (4.29), we nd the pole positions as the solution of s2 = (1)1/N = ej (2k+1)/N , k = 0, 1, , , N 1 2 c and hence, the N poles in the left half of the s-plane are sk = c ej/2 ej (2k+1)/2N , k = 0, 1, , N 1 14 (4.30)

= k + j k

(4.31)

Note that, there are no poles on the imaginary axis of s-plane, and for N odd there will be a pole on real axis of s-plane, for N even there are no poles even on real axis of s-plane. Also note that all the poles are having conjugate symmetry. Thus the design methodology to design a Butterworth low pass lter with 2 attenuation at a specied frequency s is Find N, N=
2 log[(1/2 ) 1] log(/ ) = 2 log(s /c ) log(s /p )

(4.32)

where by denition, 2 = 1/ 1 + 2 . Thus the Butterworth lter is completely characterized by the parameters N, 2 , and the ratio s /p or c . Then, from Eq. (4.31) nd the pole positions sk , k = 0, 1, , N 1. Finally the analog lter is given by Ha (s) = 1 k ==1 (s sk )
N

(4.33)

Chebyshev Filters: There are two types of Chebyshev lters. Type I Chebyshev lters are all-pole lters that exhibit equiripple behavior in the pass band and a monotonic characteristic in the stop band. On the other hand, type II Chebyshev lters contain both poles and zeros and exhibit a monotonic behavior in the pass band and an equiripple behavior in the stop band. The zeros of this class of lters lie on the imaginary axis in the s-plane. The magnitude squared of the frequency response characteristic of type I Chebyshev 15

Figure 4.7: Type I Chebysehev lter characteristic lter is given as | Ha () |2 = where 1 1+


2 T 2 (/ ) p N

(4.34)

is a parameter of the lter related to the ripple in the pass band as shown in Fig.

(4.7), and TN is the N th order Chebyshev polynomial dened as cos(N cos1 x), cosh(N cosh1 x), | x | 1 |x|>1

TN (x) =

(4.35)

The Chebyshev polynomials can be generated by the recursive equation

TN +1 (x) == 2xTN (x) TN 1 (x), where T0 (x) = 1 and T1 (x) = x. At the band edge frequency = p , we have 1 1+

N = 1, 2,

= 1 1

16

or equivalently
2

1 1 (1 1 )2

(4.36)

where 1 is the value of the pass band ripple. The poles of Type I Chebyshev lter lie on an ellipse in the s-plane with major axis r1 = p and minor axis r2 = p where is related to 2 1 2 (4.38) 2 + 1 2 (4.37)

according to the equation =[ 1+


2

+1

]1/N

(4.39)

The angular positions of the left half s-plane poles are given by k = (2k + 1) + , k = 0, 1, , N 1 2 2N (4.40)

Then the positions of the left half s-plane poles are given by sk = k + j k , k = 0, 1, , N 1 where k = r2 cos k and k = r1 sin k . The order of the lter is obtained from N = = where, by denition 2 =
2 log[( 1 2 + 2 1 2 (1 + 2 ))/

(4.41)

2 ]

s log[ + p

cosh1 ( ) s ) cosh1 ( p

s 2 ( ) 1] p

(4.42)

1 . 1+ 2

17

Finally, the Type I Chebyshev lter is given by Ha (s) = 1 k =1 (s sk )


N

A Type II Chebyshev lter contains zero as well as poles. The magnitude squared response is given as | Ha () |2 = 1 1+
2 [T 2 ( s )/T 2 ( s )] N p N

(4.43)

where TN (x) is the N-order Chebyshev polynomial. The zeros are located on the imaginary axis at the points zk = j s , k = 0, 1, . . . , N 1 sin k (4.44)

and the left-half s-plane poles are given sk = k + j k , k = 0, 1, . . . , N 1 where k = and k = s r1 sin k
2 2 r2 cos2 k + r1 sin2 k

(4.45)

s r2 cos k
2 2 r2 cos2 k + r1 sin2 k

(4.46)

(4.47)

The here is related to the ripple in the stop band through the equation =

1+

Finally, the Type II Chebyshev lter is given by


N

2 1 2 2

1 N

Ha (s) =

s zk k =1 s sk

(4.48)

The other approximation techniques are elliptic (equiripple in both passband and stopband) and Bessel (monotonic in both passband and stopband). 18

Figure 4.8: Frequency response plot of the example

4.2

Examples:

I Design a digital lter to satisfy the following characteristics. (i) -3dB cuto frequency of 0.5 rad. (ii) Magnitude down at least 15dB at 0.75 rad. (iii) Monotonic stop band and pass band Using (a) Impulse invariant technique (b) Approximation of derivatives (c) Bilinear transformation technique

Solution
a) Impulse Invariant Technique From the given digital domain frequency, nd the corresponding analog domain fre19

quencies. c =
c T

and s =

s T

where T is the sampling period and 1/T is the sampling frequency and it always corresponds to 2 radians in the digital domain. In this problem, let us assume T = 1 sec. Then c = 0.5 and s = 0.75 Let us nd the order of the desired lter using N= log ( 12 1)
2 s 2 log( ) c

Where 2 is the gain at the stop band edge frequency s . 15 dB = 20 log 2 2 = 10 20 = 0.1778 N= Order of lter N =5. Then the 5 poles on the Butterworth circle of radius c = 0.5 are given by s0 = 0.5ej ( 2 + 10 ) = 0.485 + j 1.493 s1 = 0.5ej ( 2 + 10 ) = 1.27 + j 0.923 s2 = 0.5ej ( 2 + 10 ) = 1.57 + j 0.0 s3 = 0.5ej ( 2 + 10 ) = 1.27 j 0.923 s5 = 0.5ej ( 2 + 10 ) = 0.485 j 1.493 20
9 7 5 3 15

1 log( (0.1778) 2 1) 2 log( 00..75 ) 5

= 4.219

Then the lter transfer function in the analog domain is 1 (s + 0.485 j 1.493)(s + 1.27 j 0.923)(s + 1.57)(s + 1.27 + j 0.923)(s + 0.485 + j 0.923)
5

Ha (s) = =

Ak k =1 (s sk )

where Ak s are partial fraction coecients of Ha (s). Finally, the transfer function of the digital lter is Ak , where sk s are the poles on the Butterworth circle sk 1 k =1 (1 e z )
5

H (z ) =

b) H (z ) = Ha (s) |s= 1z1 =1z 1


T

H (z ) =
k =1

1 (1 z 1 sk )

c) For the bilinear transformation technique, we need to prewarp the digital frequencies into corresponding analog frequencies. i.e., =
2 T

tan( ) 2 0.5 ) = 2 rad. 2

c = 2 tan(

and s = 2 tan( Then the order of the lter


1 log( (0.1778) 2 1)

0.75 ) = 4.828 rad. 2

N=

2 log( 4.828 ) 2 21

The pole locations on the Butterworth circle with radius c = 2 are s0 = 2ej ( 2 + 4 ) = 1.414 + j 1.414 s1 = 2ej ( 2 + 4 ) = 1.414 j 1.414 Then the lter transfer function in the analog domain is 1 (s + 1.414 j 1.414)(s + 1.414 + j 1.414)
3

Ha (s) =

Finally, the transfer function of the digital lter is

H (z ) = Ha (s) |s= 2 1z1 =2 1z1


T 1+z 1

1+z 1

H (z ) =

1z 1 (2 1+ z 1

1 1z 1 + 1.414 j 1.414)(2 1+ + 1.414 + j 1.414) z 1

II Design a digital lter using impulse invariant technique to satisfy following characteristics (i) Equiripple in pass band and monotonic in stop band (ii) -3dB ripple with pass band edge frequency at 0.5 radians. (iii) Magnitude down at least 15dB at 0.75 radians. Solution: Assuming T=1, p = 0.5 and s = 0.75 The order of desired lter is
2 log[( 1 2 )+ 2 1 2 (1 + 2 ))/

N=

2 ]

s log[ + p

s 2 ( ) 1] p

where 20 log 1 1+
2

= 3 dB

22

i.e., 10 log(1 +
2 2

) = 3dB

= 100.3 1 = 0.9952 = 0.9976

and 20 log 2 = 15 dB 2 = 100.75 = 0.1778 Hence [( 1 (0.1778)2 + 1 (0.1778)2 (1 + 0.9952))/0.9976 0.1778]


2 ( 00..75 ) 1] 5

N =

log[ 00..75 + 5

= 2.48 3

The order of lter, N = 3. The 3 poles on the ellipse are determined by 1+


2

=[

+1

1 N

=[

1 + 0.99762 + 1 1 ] 3 = 1.341 0.9976

r1

2 + 1 = p 2 (1.341)2 + 1 = 0.5 2 1.341 = 1.639 23

r2 = p

2 1 2 (1.341)2 1 = 0.5 2 1.341 = 0.469

The angles, k = The poles are at sk = r2 cos k + jr1 sin k 4 4 ) + j 1.639 sin( ) 6 6 (2k + 1) + , k = 0,1 ,2 2 2N

s0 = 0.469 cos(

= 0.2345 + j 1.419

s1 = 0.469 cos( ) + j 1.639 sin( ) = 0.469 + j 0.0 8 8 ) + j 1.6939 sin( ) 6 6

s2 = 0.469 cos(

= 0.2345 j 1.419 The analog lter transfer function is given by Ha (s) = = 1 (s + 0.2345 j 1.419)(s + 0.469)(s + 0.2345 + j 1.419)
3

Ak k =1 (s sk )

where Ak s are the partial fraction coecients. 24

Finally, the digital lter transfer function is given by H (z ) = Ak sk 1 ) k =1 (1 e z


3

25