You are on page 1of 11

Lecture 6 - Design of Digital Filters

6.1 Simple lters


There are two methods for smoothing a sequence of numbers in order to approximate a low-pass lter: the polynomial t, as just described, and the moving average. In the rst case, the approximation to a LPF can be improved by using a higher-degree polynomial: for example, instead of using a quadratic as in the example given in the previous lecture, we could have tted a least-squares quartic to the original noisy data. The effect of using a higher-degree polynomial is and a sharper cut-off in the to give both a higher degree of tangency at amplitude response. An example of a simple moving-average lter is the Hanning lter, for which:

   "!$#  %'&   !  %(&)#01

This lter produces an output which is a scaled average of three successive inputs, with the centre point of the three weighted twice as heavily as its two adjacent neighbours.

6.1.1 Design by z-domain arguments

2 43  1     !5# 3 687 ! 3 6 9 1 which has two zeroes at 3 9 !@# 3 !  43 !  1 9 i.e. 3 A&  . Remember that this corresponds to a double damping at the Nyquist frequency. This will give
attenuation of HF signals i.e. a LPF effect. Alternatively we could argue to put a 71

Taking the z-transfom we obtain a transfer function of the form

pole at DC, some fraction

(BDC)B 2 E3 1

 of the way along the real axis. This gives 3 68 7 &F  F & C C 3  3 687

and thus

G E3 1   F & C 3 687 1 3687IHP43 1 Q  % '&   !$CRS%T&  

and in difference terms in the digital time domain

which gives a LPF as a recurrent lter (which is thus an IIR lter). In general, we may use out knowledge of the Laplace design of transfer functions to argue the design in the z-domain as well. This is simple for low-order lters (as above), but would be tedious at higher orders there are other ways.

6.2 FIR designs based on window functions


FIR lters can also be designed from a frequency response specication. The equivalent sampled impulse response, which determines the coefcients of the FIR lter, can then be found by inverse (discrete) Fourier transformation (Discrete Fourier Transforms are not covered until later in the course but the example lter design below should still be easy to follow). Consider an ideal low-pass characteristic (brick-wall lter) with a cutoff frequency where sampling period: We know that the continuous impulse response is given by (and shown in Fig. 6.1):

`Ya@bRc ed

#0b pDq q U rV X1tsvuIw0xgye `Y 6 aY f (6.1) bW`Y f The sampled impulse response h%  (which would be obtained by taking the inverse DFT of the discrete equivalent brick-wall frequency characteristics) is the sampled version of the continuous W function. It is not possible to implement h f 1i
the corresponding low-pass lter design because: 72

gf 1

1 U WV X

0.25 0.2 0.15 g[k] 5 0 t 5 10 g(t) 0.1 0.05 0 0.05 0.1 10

0.25 0.2 0.15 0.1 0.05 0 0.05 0.1 10 5 0 kT (T=1) 5 10

Figure 6.1: Impulse response of brick wall lter in (left) continuous and (right) discrete time domains.

an innite number of coefcients would be required the impulse response is that of a non-causal system and .

(&

(1

 h%  exists between

A rst solution hence we could, 1. Truncate the expression for

h at some reasonable value of , say 10.

2. Shift all the coefcients by the same number.

g f i g h % Q 9ed  % l&)m4 dkj for the lter, we can also obtain its transfer function g g U 43 1k f gn9eh d 36 dj As before, we can obtain the actual frequency response of the lter by evaluating U E3 1 on the unit circle (i.e. U  s uIwpo 1 ). This is shown in Fig 6.3 using both
linear and logarithmic plots for the amplitude response. 73

This is shown in Fig 6.2. Now that we have the difference equation

0.25 0.2 0.15 shift g[k] 0.1 0.05 0 0.05 0.1 0 5 10 k 15 20

Figure 6.2: Impulse response of brick wall lter shifted.


1.4
10
1

1.2

10

0.8

0.6

10

0.4
10
2

0.2

/4
0 0 20

/4

40

60

80

100

120

140

10

20

40

60

80

100

120

140

Figure 6.3: Linear (left) and log (right) responses for 21 and 11 coefcients in the brick wall lter. Better solution The truncation of the impulse response is equivalent to multiplying it by a rectangular window function. This leads to an overshoot and ripple before and after the discontinuity in the frequency response a phenomenom known as Gibbs phenomenom (the overshoot is about 9% see previous Fig). The amplitude of the overshoot does not decrease if more and more coefcients are included in the digital lter. A more successful way of designing an FIR lter is to use a nite weighting sequence . There are a number of such sequences, for example the Hamming,

q % 

74

C !   &FC1vuxw { &F|i}@~}| t q % sr 0 elsewhere yz  If C@v this is the Hamming window, if C@v this is the Hanning, or raised
cosine, window. Fig 6.4 shows the 11 point Hamming window. The Fourier
1 0.8 0.6 w[k] 0.4 0.2 0 0

Hanning or Kaiser windows.

6 k

10

12

Figure 6.4: 11 point Hamming window. transform of these windows consists of a central lobe which contains most of the energy and side lobes which generally decay very rapidly. The use of such a window to reduce the Fourier coefcients for the higher frequency terms leads to a reduction in ripple amplitude, at the expense of a slightly worse initial cut-off slope. The frequency response of the 21-coefcient FIR lter Fig. 6.3 is shown in Fig. 6.5 together with that of the equivalent windowed ) using lter (the lter weights on this case being computed from a Hamming window.

hS% QhS% 4 q 

6.2.1 FIR lter design conclusion


FIR lters are usually found in applications where waveform distortion due to non-linear phase is harmful. As the 2 examples of lters studied illustrate, FIR lters with exactly linear phase can be designed (they must have an impulse response which is either symmetrical i.e. palindromic coefcients or purely 75

1.4

1.2

/4

0.8

0.6

0.4

0.2

20

40

60

80

100

120

140

Figure 6.5: Hamming window removing overshoot. anti-symmetrical). FIR lters are mostly realised as non-recursive structures; such lters are always stable. However, if a sharp cut-off in the amplitude response is required, a large number of coefcients are needed (usually 100).

76

6.3 Design of IIR lters


Most recursive lters have an innite impulse response, because of the feedback of previous outputs. Practical Innite-Impulse-Response (IIR) lters are usually based upon analogue equivalents (Butterworth, Chebyshev, etc.), using a transformation known as the bilinear transformation which maps the -plane poles and zeros of the analogue lter into the -plane. However, it is quite possible to design an IIR lter without any reference to analogue designs, for example by choosing appropriate locations for the poles and zeroes on the unit circle (Remember: wherever there is a zero on the unit circle, i.e. complete attenuation of that frequency; on the other hand, when there is a pole near the unit circle, i.e. high gain at that frequency).

U  s uew0o 1k

U  s uIwpo 1

6.4 Bilinear transformation


The technique of digitizing an analogue design is the most popular IIR lter design technique, since there is a large amount of theory on standard analogue lters available (some of which was explored in the rst half of this lecture course). The bilinear -transform is a mathematical transformation from the -domain to the -domain which preserves the frequency characteristics and is dened by:

687 where d sampling period d #  ! & 33 8 67 Under this mapping, the entire V axis in the -plane is mapped onto the unit circle in the 3 -plane; the left-half -plane is mapped inside the unit circle and the right-half -plane is mapped outside the unit circle. The bilinear transformation gives a non-linear relationship between analogue frequency ` and digital frequency ` . Since the frequency response of a digital lter is evaluated by setting 3 s uIwpo : V a #d  F & s 6 uIweo d # s uIw o  !Ps 6 Iu w o s uIw 99 o # ` ie. d$
77

d & s 6 uIw o # V ` F d # !Ps 6 uIw9 o $ 9 ` d #

The form of this non-linearity is shown in Fig. 6.6 for the case . For small values of , the mapping is almost linear; for most of the frequency scale, however, the mapping is highly non-linear.

d #

3.5 3 2.5

1.5 1 0.5 0 0 0.5

1.5

Figure 6.6: The bilinear mapping function. The cut-off frequencies of a digital lter will therefore be tangentially warped compared with those of the analogue lter from which it was designed. In order to compensate for this undesirable effect, it is necessary to pre-warp the required cut-off frequencies before designing the analogue lter. Thus

the desired set of digital lter cut-off frequencies is determined rst. For and ). example, if there are four critcial cut-off frequencies, Using the frequency warping relationship derived above, the lter cut-off frequencies are converted to a new set of analogue cut-off frequencies, and . Finally, an analogue lter is designed with the appropriate warped cut-off frequencies. Applying the bilinear transformation to this analogue lter gives a digital lter with the desired cut-off frequencies. 78

` 7 ` 9 `t

aI

a 7 ` 9 `I

ae

6.4.1 Example: design of IIR lter using bilinear z-transform


Design a digital low-pass Butterworth lter with a 3dB cut-off frequency of 2kHz and minimum attenuation of 30dB at 4.25kHz for a sampling rate of 10kHz. Answer

0  Hz; hence d  6 sec.  ` 7 #0b#'  rads/sec; a 9 #0b #'  rads/sec.

Apply pre-warping transformation:

# v a 7 d #' v#pbve#e  d #  e( rads/sec ` 7 d5    v # #d v ` 9 d #' v v  #0b@v rads/sec `    9 # (ie. #" kHz and  v kHz this shows the warping effect near 4 ) 7 9 9 The order of lter required can now be worked out as before: g h h w g h h7Ed  e  e E w g 7Ed7 7 meets the specication

U  1k 9 ! #pY9 `Y!) Y9  Substitute ` `Yk"# o 9 in above equation and use the bilinear transfor7 mation o 9 7e6 : 74 1 9 "#  9  9 k 1 o U 43  o 9 1 9  7e6 1 9 ! #  o 9 1 9 v#e   7e6 e 1!  o 9 1 9  v#e  1 9 74 74 e
79

For a second-order Butterworth LPF,

(NB:

 o 9 1 factor cancels out) v#ee 1 U E3  1 9 !  #   7e6 e 1!$v#  7e47 6 e 74 e #  3 687 ! 3 6 9 U E3 1kv#ee #"e&)v!5  # 3 687 !$vee 3 6 9 # 3 687 ! 3 6 9 U E3 1v#e  &Fv !5 e 3 687 !$v  e# 3 6 9

`v#  % v!v      (&  !Dv#ee  (&#0v!veS%l&  Q& v  #&P#p


In order to check the magnitude characteristics of the frequency response, rewrite as:

from which we can nally write the following difference equation:

5 ! # ! 3 3 9  1 v e # e  U E3 & ) v $ ! v 39 3  e# dc gain: ` d 3  which gives U   1  3dB cut-off frequency ` 7 d @v  b Thus  b! V "  b1!  x u w v b ! " b $ ! # x u w v V  s u k 1 v # Udz W &)ve  uw v  b! V v  bR1!Pv  e# uxw "b! V vb W t  V v # 5 ! " # s u k 1 @ v e # ie. U  d which gives U~ ve  & v # $ ! " e # e V z
80

U 43 1

You can also check the 30dB minimum attenuation requirement by working out .

 s d z u 1

6.4.2 Conclusion
With recursive IIR lters, we can generally achieve a desired frequency response characteristic with a lter of lower order than for a non-recursive lter (especially if elliptic designs are used). A recursive lter has both poles and zeroes which can be selected by the designer, hence there are more free parameters than for a non-recursive lter of the same order (only zeroes can be varied). However, when the poles of an IIR lter are close to the unit circle, they need to be specied very accurately (typically 3 to 6 decimal places) if instability is to be avoided.

81

You might also like