Lecture 5 - Digital Filters

Lecture 5 - Digital Filters 5.1 Digital filtering Digital filtering can be implemented either in hardware or software; in the first case, the numerica...
Author: Karin Gibbs
17 downloads 0 Views 91KB Size
Lecture 5 - Digital Filters 5.1 Digital filtering Digital filtering can be implemented either in hardware or software; in the first case, the numerical processor is either a special-purpose chip or it is assembled out of a set of digital integrated circuits which provide the essential building blocks of a digital filtering operation – storage, delay, addition/subtraction and multiplication by constants. On the other hand, a general-purpose mini-or micro-computer can also be programmed as a digital filter, in which case the numerical processor is the computer’s CPU and memory. Filtering may be applied to signals which are then transformed back to the analogue domain using a digital to analogue convertor or worked with entirely in the digital domain (e.g. biomedical signals are digitised, filtered and analysed to detect some abnormal activity).

5.1.1 Reasons for using a digital rather than an analogue filter The numerical processor can easily be (re-)programmed to implement a number of different filters. The accuracy of a digital filter is dependent only on the round-off error in the arithmetic. This has two advantages: – the accuracy is predictable and hence the performance of the digital signal processing algorithm is known a priori. – The round-off error can be minimized with appropriate design techniques and hence digital filters can meet very tight specifications on magnitude and phase characteristics (which would be almost impossible to achieve with analogue filters because of component tolerances and circuit noise). 59

The widespread use of mini- and micro-computers in engineering has greatly increased the number of digital signals recorded and processed. Power supply and temperature variations have no effect on a programme stored in a computer. Digital circuits have a much higher noise immunity than analogue circuits.

5.1.2 The sampling process This is performed by an analogue to digital converter (ADC) in which the contin  

uous function is replaced by a “discrete function” , which is defined only 



 at 

, with . We thence only need consider the digitised sample set and the sample interval . Aliasing

!#"$ %'& 

)!#"*,+-. $% & 

( (one cycle every 4 samples) and also ( Consider (3 cycles every 4 samples) as shown in Fig. 5.1. Note that the resultant samples are the same. This result is referred to as aliasing. The most popular solution to this problem is to precede the digital filter by an analogue low-pass filter to 0/#0 ensure that any frequency above Hz is adequately suppressed. (This LPF is known as an “anti-aliasing” filter and is shown to the left of the1 A/D 23/4 converter on the block diagram of page 46). Without an anti-aliasing filter, Hz at the 152#/4 156#/4 output could have been produced either by Hz at the input. 7186#/0 Hz or With the anti-aliasing filter, any signal at Hz will be suppressed prior to 1 23/4 1 23/4 A/D conversion, i.e. coming out must represent going in. Since we cannot build perfect anti-aliasing filters, however, digital filters will normally have 0/4 their passband well below Hz. 5.1.3 Reconstruction of output waveform The data at the output of the D/A converter must be interpolated in order to reconstruct the filtered signal. Usually this takes the form of step or one-point interpolation (in which the value at the sample time is assumed to be the value of the function until the next sample time), followed by analogue low-pass filtering as shown in Fig. 5.2. The output low-pass filter is sometimes known as a recovery filter.

60

1

0.5

0

−0.5

−1

0

10

20

30

40

50

60

70

80

90

100

0

10

20

30

40

50

60

70

80

90

100

1

0.5

0

−0.5

−1

Figure 5.1: Aliasing.

5.2 Introduction to the principles of digital filtering We can see that the numerical processing is at the heart of the digital filtering process. How can the arithmetic manipulation of a sequence of numbers produce a “filtered” version of that sequence? Consider the noisy signal of figure 5.3, together with its sampled version: One way to reduce the noise might be to try and smooth the data. For example, we could try a polynomial fit using a least-squares criterion. If we choose, say, to fit a parabola to every group of 5 points in the sequence, then, for every point, we will make a parabolic approximation to that point using the value of the sample at that point together with the values of the 4 nearest samples (this forms a parabolic filter), as in Fig. 5.4

% 9 

:);=? @;BAC=? ; %





DFEHGI GJK#K L

where 9 ;

QKR:S % Q]R % *3;BA P

T>

QKR:S % 62

parabolic fit

-2 -1 0

1 2 centre point, k=0

Figure 5.4: Parabolic fit.

QKR %

% *3;=^2B_H; %  P T> H Q]R:S % which therefore gives:

;bGa4 =V00T>bGc! =\064T>dB =V*4T>be fGg2BT>4  ;BAh

;% 

 `GI4T>iGa4 UGjT>bGc! 7=kT>b! H=?4T>4 W * 

 N4T>iGI0 UGjT>bGc! UGg4T>dB UGlT>i! 7=^4T> 0   _

The centre point of the parabola is given by:

% 9 

Om QKR 

7=V00T> uGz! fGj2BT> {G|4 W 

This is a non-causal filter since a given output value o T>

T>depends  }=k! not only on , the input and the input previous inputs, but also on the current input T> ~={4 

. The problem is solved by delaying the calculation of the output value o (the centre point of the parabola) until all the 5 input values have been sampled 4  (i.e. a delay of where = sampling period), ie: 64

 o 

: 2 [ ` Ga2BT>

7=\04T> {Gze =V060T> uGg4 H=V04T> {Gk2B fGg2BT> {Gj_ W r  H € T> ‚Gƒvw It is of importance to note that the equation o represents s

a discrete convolution of the input data with the filter coefficients; hence these coefficients constitute the impulse response of the filter. Proof:

T>

„

l

T>…3c†

 H t‡€

r r

T> ‚G?vw 

, except at , where . Then o s T>…3Jˆ a v ‡ 

Qs (all terms zero except when ). This is equal to s Q since . …3I < o `0a A 11!1 Therefore o ; ; etc . As there is a finite number of ’s, the s s s impulse response is finite. For this reason, non-recursive filters are also called Finite-Impulse Response (FIR) filters. As we will see, we may also formulate a digital filter as a recursive filter; in 

is also a function of previous outputs: which, the output o

LetT>…3

r r P r P r >T  {Gkvw H= Š o 

p q o  uGjv… ‘ w;0tZw#C=?`0 S ( =^N S (  =V1!11*=^ H S Q ( Ž Ž Ž

The  suffix ’ denotes the transform of the discrete sequence, not of the continuous . 65

(

   Œ : % A   hZw3C=^x* S =?w# S =\111] H S Q Œ Œ Œ Œ

Let us replace Ž

by a new variable Π, and rename

“‘ N;0

as

For many functions, the infinite series can S A be represented in “closed form”, in general as the ratio of two polynomials in Œ .

5.3.1 Examples of the z-transform step function

 



•”?  



‚– , = 1 for % = 111*= S Q =V11!1   hF‰= S A = S \ Œ Œ Œ Œ = 0 for

    h 'G Œ

 Œ

S A

by summation of a geometric progression6. Decaying exponential

t Ž

S — & G:˜  H : Ž

S —*Q (

% %  F= S — ( S A = S — ( S V = 111*= S —*Q ( S Q V = 111   t Œ Ž Œ Ž Œ Ž Œ     h 'G Œ



S — ( S A Ž Œ

Sinewaves

hV!"f™h‰G:˜  

:\!#"p 3™h\ ŽKš       h  '  G Œ



Q› ( G 

S Q› ( Ž š

 =  A ›( S 'G S › ( S A Žš Œ Ž š Œ 'Gke#"™h S A   h Œ 'G|!"7™h S A = S % Œ Œ Œ 6 strictly valid only if œK4ž3Ÿœ ¢¡ 66

5.3.2 The Pulse Transfer Function This is the name for ( Œ -transform of output)/( Œ -transform of input). r < for example of an FIR filter, be s at O\Let  1the 11 impulse OVv…response,  v>Y , with to £ .  s  at Let ¤ Œ be the Œ -transform of this sequence: r r Let ¥

  Œ

c„

,

s

A

at

% S =V1!11 S  t   dB 7=kT>b! S A =gT>4 S =\1110=kT>

S Q =V1!11 ¥ Œ Œ Œ Œ     The product ¤ Œ ¥ Œ is: r r S !T>4 7=gT>i! S A =V1!11T>

S Q     t¦  uGz! =\111 T> uGkvw H=V111 T> §G £ s s s s q ^

 This is nothing else than the value of the output sample at  . Hence  • the whole sequence is the Œ -transform of the output, say ¨ Œ , where ¨ Œ       ¤ Œ ¥ Œ . Hence the pulse transfer function, ¤ Œ , is the Œ -transform of the impulse response. For non-recursive filters:

r

S  t P r q ¤ Œ Œ R < s For recursive filters:

r

r

r

r

r

S  C= P r Š S    t P r q ¨ Œ 

:Ze#"*W™

g=|·#O %#E = ŽKšK¹ Žr5¿ š¹ r5¿ r r  Pr  › ¾ QeS (º@»xÀ = P r ¶ S › ¾ QeS (º@»xÀ 

U ¶  

7=\04T> {Gze =V060T> uGg4 H=V04T> {Gk2B fGg2BT> {Gj_ W

hence

%   t   xGy2}=V0 S A =\06 S =V0 S + Gg2 SHË    2[ ¨ Œ Œ Œ Œ Œ ¥ Œ 69

thus

%    Á @R ǵȅÉ,Ê  ` Ga2}=\0 S › ( =V*6 S › ( =V0 S + › ( Gk2 HS Ë › (  2[ ¤ Œ Ž š Ž š Ž š Ž š  S % ›(  ›( O   `06'=?B_he#"7™hƒGjÌhe#"p0™ha 2[ Ž š ¤ Žš

 m506=?4_te#"™h^GkÌO!#"p0™h§m m  › ( *mB 2[ Therefore ¤ Žš ™hzY7m  › ( 0mBÍ When m  › ( *mBY¤ 156ŽKš 36 ™hƒÎ)1_3ÏBÐ Y15B_ and ¤ ŽKš when , i.e. Ñ Ó ¤  ŽKš › ( tFGI0™h ÑNÒ i.e. linear phase (true 4 for any FIR filter with palindromic coefficients); all frequencies delayed by (as expected!)

70