nov'04cs3291 dsp sectn 51 cs 3291 : digital signal processing section 5: z-transforms &...

70
Nov'04 CS3291 DSP Sectn 5 1 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter is described by a linear difference equation. For example: 1) y[n] = x[n] + x[n-1] 2) y[n] = x[n] + x[n-1] - b y[n-2] Example 2 is recursive & can have infinite impulse-response.

Upload: roderick-mcdowell

Post on 17-Jan-2016

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 1

CS 3291 : Digital Signal Processing

Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter is described by a linear difference equation. For example:

1) y[n] = x[n] + x[n-1]

2) y[n] = x[n] + x[n-1] - b y[n-2]

Example 2 is recursive & can have infinite impulse-response.

Page 2: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 2

Introduction: • General causal discrete time filter has difference equation: N M y[n] = a i x[n-i] - b j y[n-j] i=0 j=1 which is of order max{N,M}. • Recursive if any b j is non-zero. • A 2nd order recursive filter has the diff equn:

y[n] = a 0 x[n] + a 1 x[n-1] + a 2 x[n-2] - b 1 y[n-1] - b 2 y[n-2]

• Frequency response of a discrete time filter:- H(e j ) = h[n]e - j n

n=-

Page 3: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 3

• Consider response of causal stable LTI system to {z n } i.e. { …, z-2, z-1, 1, z, z2, z3, ……… }

• By discrete time convolution, output is {y[n]} where y[n] = h[k] z n - k = z n h[k] z - k

k=- k=- = z n H(z) with H(z) = h[k] z - k

k=-• H(z) is "z-transform" of impulse-response.• Equivalent of Laplace transform. • H(z) is a complex number for any z.

Page 4: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 4

• For causal stable system, H(z) must be finite for z 1

H(z) = h[k] z - k h[k] z - k by causality k=0 k=0

= h[k] z - k k=0

h[k] when z 1 k=0

finite by defn of stability

Page 5: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 5

Some properties of H(z):(1) H(z) is complex no. for any z with z1.(2) Replacing z by e j , gives H(e j ) rel frequency-resp. On Argand diagram ("z-plane"), z = e j lies on unit circle.(3) If input is {z n }, the output is {H(z) z n }.

Real part of z

Imaginary part of z

Fig 2.1

z = exp(j )

1

Page 6: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 6

• System function is z-transform of {h[n]} : H(z) = h[k] z - n

n=-

• Frequency-response is DTFT of {h[n]} : H(e j ) = h[n]e - j n

n=-

• Replace z by e j

Page 7: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 7

Example 5.1:

Find H(z) for the non-recursive difference equation:

y[n] = x[n] + x[n-1]

Solution:

{h[n]} = { ... , 0, 1, 1, 0, ... },

therefore

H(z) = 1 + z - 1

Page 8: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 8

Example 5.2: Find H(z) for the recursive difference equation: y[n] = a 0 x[n] + a 1 x[n-1] - b 1 y[n-1]

Solution: Method used above becomes hard. Remember that if x[n] = z n then y[n] = H(z) z n ,

y[n-1] = H(z) z n - 1 etc.

• Substitute to obtain: H(z) z n = a 0 z n + a 1 z n - 1 - b 1 H(z) z n - 1

a 0 + a 1 z - 1

H(z) = 1 + b 1 z - 1 except when z = - b 1 .

• When z = -b 1 , H(z) = .

Page 9: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 9

• For the general discrete time filter: N M y[n] = a i x[n-i] - b j y[n-j] i=0 j=1

the same method gives:

a 0 + a 1 z - 1 + a 2 z - 2 + ... + a N z - N

H(z) = b 0 + b 1 z - 1 + b 2 z - 2 + ... + b M z - M

with b0 = 1.

• Given H(z) in this form, we can easily get its difference equn & hence its signal flow graph.

Page 10: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 10

Example 5.3: Give a signal flow graph for:

a 0 + a 1 z -1 + a 2 z - 2

H(z) = 1 + b 1 z - 1 + b 2 z - 2

Solution: The difference equation is:

y[n] = a 0 x[n] + a 1 x[n-1] + a 2 x[n-2] - b 1 y[n-1] - b 2 y[n-2]

• Signal flow graph readily deduced.

• Referred to as 2nd order or "bi-quadratic" IIR section in "direct form 1".

Page 11: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 11

x[n] a0

z-1 z-1

z-1 z-1

a1

a2

y[n]

-b1

-b2

Bi-quad IIR section in ‘direct form 1’

y[n] = a 0 x[n] + a 1 x[n-1] + a 2 x[n-2] - b 1 y[n-1] - b 2 y[n-2]

Page 12: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 12

To implement this signal flow-graph as a program:

X a0

z -1 z-1

z-1 z-1

a1

a2

Y

-b1

-b2

Y1

Y2

X1

X2

Page 13: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 13

X1=0; X2=0; Y1=0; Y2=0;

while 1

X = input(‘X=’);

Y = a0*X + a1*X1 + a2*X2 - b1*Y1 - b2*Y2;

disp(sprintf(‘Y = %f’ , Y) ) ; % output Y

X2 = X1; X1 = X ;

Y2 = Y1; Y1 = Y ;

end;

In MATLAB using floating pt arithmetic:

Page 14: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 14

K=1024;A0=round(a0*K); A1=round(a1*K); A2=round(a2*K); B1=round(b1*K); B2=round(b2*K);X1=0; X2=0; Y1=0; Y2=0;while 1 X = input(‘X=’) ; Y = A0*X + A1*X1 + A2*X2 - A1*Y1 - A2*Y2 ; Y = round(Y/K); % Divide by arith right shift disp(sprint(‘Y=%f’,Y)); % Output Y X2 = X1; X1 = X ; % Prepare for next time Y2 = Y1; Y1 = Y ;end;

In MATLAB using fixed pt arith & shifting:

Page 15: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 15

Alternative signal flow graphs: Re-order the two halves of Direct Form I

x[n] a0

z-1

z-1

a1

a2

y[n]

z-1

z-1

-b1

-b2

Impulse response not changed (Problem 5.10). Simplify to : x[n] y[n]

-b1

-b2

a0

z-1

z-1

a1

a2

W

W1

W2

Direct Form II

Page 16: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 16

"Direct Form II" signal flow graph:-

x[n] y[n]

-b1

-b2

a0

z-1

z-1

a1

a2

W

W1

W2

It is a 2nd order (bi-quad) section whose system function is: a 0 + a 1 z -1 + a 2 z - 2

H(z) = 1 + b 1 z - 1 + b 2 z - 2

Its difference equation is:- y[n] = a 0 x[n] + a 1 x[n-1] + a 2 x[n-2] - b 1 y[n-1] - b 2 y[n-2]i.e. exactly the same as Direct Form 1

Page 17: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 17

Direct Form II has minimum no. of delay boxes.Example: Given values for a 1 , a 2 , a 0 , b 1 & b 2 , write program to implement Direct Form II using normal arithmetic. Solution:

W1 = 0; W2 = 0; %For delay boxes while 1 X = input(‘X=’) ; % Input to X W =X - b1*W1 - b2*W2; % Recursive part

Y = W*a0 + W1*a1 + W2*a2; % Non-rec. part W2 = W1; W1 = W; % For next time disp(sprintf(‘Y=%f’,Y)); % Output Y using disp end; % Back for next sample

Page 18: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 18

% Direct Form II in fixed point arithmetic & shifting.

K=1024; A0=round(a0*K); A1=round(a1*K); A2=round(a2*K); B1=round(b1*K); B2=round(b2*K); W1 = 0; W2 = 0; %For delay boxes while 1 X = input(‘X=’) ; % Assign X to input W =K*X - B1*W1 - B2*W2; % Recursive part W =round( W / K); % By arith shift

Y = W*A0+W1*A1+W2*A2; % Non-rec. part W2 = W1; W1 = W; %For next time Y = round(Y/K); %By arith shift disp(sprintf( ‘Y=%f’, Y)); %Output Y using disp end; %Back for next sample

Page 19: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 19

System function:

• Expression for H(z) is ratio of polynomials in z - 1 .

• Remove restriction z 1, & call H(z) "system function".

• When z < 1 , H(z) need not be z-transform of {h[n]} & need not be finite.

• Nevertheless it is still useful to us.

Page 20: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 20

Poles and zeros of H(z)• For a general discrete time filter:- a 0 + a 1 z - 1 + a 2 z - 2 + ... + a N z - N

H(z) = b 0 + b 1 z - 1 + b 2 z - 2 + ... + b M z - M with b0 = 1.

• Re-express as: (z N + a 1 z N -1 + ... + a N ) H(z) = K z M - N (z M + b 1 z M-1 + ... + b M ) where K = a 0/b 0

• Factorise denom & numerator polynomials: (z - z 1 )(z - z 2 )...( z - z N ) H(z) = K z M - N (z - p 1 )( z - p 2 )...(z - p M )

Page 21: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 21

• So z 1 , z 2 ,..., z N , are "zeros". p 1 ,p 2 ,..., p M , are "poles”.

• H(z) generally infinite with z equal to a pole.

• H(z) generally zero with z equal to a zero.

• For a causal stable system: H(z) must be finite for z 1.

Cannot be a pole with modulus 1.

All poles must satisfy p i < 1.

• On Argand diagram: poles must lie inside unit circle. no restriction on the positions of zeros.

Page 22: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 22

• Gain response in terms of poles & zeros:

e j - z1e j - z2...ej - zNH(e j ) = K e j - p1e j - p2...e j - pM

• Phase response:

Arg(H(e j )) = (M - N) + arg(e j - z 1 )+ ... + arg(e j - z N )

- arg(e j - p 1 ) - ... - arg(e

j - p M)

• On Argand diagram: e j - p1 is distance from p1 to e j

& Arg(e j - p1) is "pole angle" shown.

• Similarly for e j - z1, e j - p2, etc.

Page 23: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 23

Real part of z

Imag part of z

Fig 5.5: z-plane

exp(j)

P

|ej - p|

Arg(ej - p)

Page 24: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 24

“Distance rule”

Product distances from zeros to e j

H(e j ) = K Product distances from poles to e j

“Phase rule”:

Arg(H(e j )) = (M-N) + sum of zero angles - sum of pole angles.

Page 25: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 25

Real part of z

Imaginary part of z

exp(j )

P1

P2

Z1

Z2

Page 26: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 26

Example: Calculate gain-response of a filter with

1 + z - 1

H(z) = 1 - 1.273z - 1 + 0.81z - 2

Then plot poles & zeros of H(z) & comment on their effects:

Before we start, please give (1) its difference equation &

(2) its signal flow graph

Page 27: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 27

• Difference equation is:

y[n] = x[n] + x[n-1] + 1.273 y[n-1] - 0.81 y[n-2]

• Signal flow graph in (Direct Form 1) is:

x[n]

z-1 z-1

z-1

y[n]

1.273

-0.81

Page 28: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 28

• In Direct Form II, signal flow graph for::

y[n] = x[n] + x[n-1] + 1.273 y[n-1] - 0.81 y[n-2]

x[n]

y[n]

z-1

z-1

1.273

-0.81

Page 29: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 29

Gain response: z (z + 1) This is H(z) = hard work! z 2 - 1.273 z + 0.81

[ e j ] [1 + e j ] H(e j ) = e 2 j - 1.273 e j + 0.81

H(e j )2 = H(e j ) H * (e j ) = H(e j ) H(e - j )

[1 + e j ] [1 + e - j ] = [ e 2 j - 1.27 e j + 0.8] [ e - 2 j - 1.27 e - j + 0.81]

2 + 2 cos() = 3.28 - 4.61 cos() + 1.62 cos(2)

Page 30: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 30

• Plot the gain response against

Gain response calculated by "Excel"

0

2

4

6

8

10

12

14

16

0 0.5 1 1.5 2 2.5 3 3.5

Rel. Frequency

Gai

n

Page 31: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 31

• Second part of problem: z (z + 1) H(z) = z 2 - 1.27 z + 0.81

• Zeros of H(z): z = 0 & z = -1.

• Poles by solving: z 2 - 1.27 z + 0.81 = 0 ( in polar form).

• Assume poles are R e j and R e - j . Then: z 2 - 1.27 z + 0.81 = (z - R e j ) ( z - R e- j ) = z 2 - R( e j + e - j ) z + R 2 = z 2 - 2 R cos () z + R 2

R 2 = 0.81 & 2R cos() = 1.2 Hence R = 0.9 & = /4.

• Poles of H(z): z = 0.9 e j /4 & z = 0.9 e - j/4

Page 32: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 32

• Poles & zeros plotted on z-plane

Real(z)

Imag(z)

P1

P2

Z1 Z2

Page 33: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 33

• Pole P1 causes gain response to peak at =/4.

• Zero Z 2 causes gain to be zero at = .

• Z 1 has no effect on gain (only phase)

• P 2 will have little dramatic effect.

• Instead of calculating gain response exactly, we can estimate its shape by "distance rule".

Page 34: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 34

Estimating gain-response from poles & zeros:

Real(z)

Imag(z)

P1

P2

Z1 Z2

Estimated distances Estimated gain0 2 * 1 / [0.7 * 0.7] 4/4 1.8 * 1 / [1.3 * 0.1] 12/2 1 * 1.5 / [0.7 * 1.7] 1 1 * 0 / [1.5 * 1.5] 0

Page 35: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 35

3 dB points• Gain resp. most interesting around = /4.• Peak caused by P 1 close to unit circle.• If = /4 & increases slightly, distance P1 to e j changes dramatically.

distances from P2, Z1 & Z2 do not.• Consider effect of increasing by 0.1

P1 0.1

0.1

1

1

E

0.1

Real (z)

Imag(z)

D

P1

E

0.1

0.1

0.1414

D

Page 36: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 36

• Increasing by 0.1 increases pole distance from 0.1 to 0.12.

• Effect of multiplying pole distance by 2:

• Assuming other distances change little, gain will decrease by 2. • This is a 3 dB reduction in gain.

• Same if is decreased from /4 to /4 - 0.1.

“3 dB pts” around peak at = /4 are: /4 + 0.1 & /4 - 0.1 radians/sample

• Can now draw reasonably accurate sketch of G() against :

Page 37: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 37

2

4

6

8

/4 3

Gain

"3 dB points"

Page 38: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 38

Comments:

• Sketch not as accurate as Excel graph, but useful for design.• Assume we wanted slightly different gain response• Re-position poles and/or zeros.

Effect on gain of a zero close to the unit circle:-

• Assume zero is at z = (1 - ) e j with small.

3 dB pts around spectral trough at = : at + & -

• Gain increased to 3 dB above the minimum.

Page 39: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 39

Example: Calculate phase response of H(z). Then estimate it from pole/zero diagram.Solution: e j / 2 [ 2 cos (/2) ]H(ej) = e j - 1.27 + 0.81 e - j

e j / 2 [ 2 cos (/2) ] = [1.81 cos( ) - 1.27 ] - j [0.19 sin( ) ]

As cos (/2) 0 for 0 : 0.19 sin() Arg[H(e j )] = - arctan 2 1.81 cos() - 1.27

Hard work as well!

Page 40: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 40

Phase response by Excel

-20

0

20

40

60

80

100

120

140

0 0.5 1 1.5 2 2.5 3 3.5

Rel. frequency

Lag

(deg

rees

)

Page 41: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 41

Estimating phase response from pole/zero plot:

exp(j )

Imaginary part of z

Real part of z

Z1 Z2

P1

P2

Page 42: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 42

Example: An FIR filter has the difference eqn:

y[n] = x[n] - 0.95 x[n-1] + 0.9 x[n-2] Plot its poles & zeros & estimate its gain (& phase) resp.

Solution: H(z) = 1 - 0.95 z - 1 + 0.9 z - 2

z 2 - 0.95 z + 0.9 = z 2

(z - 0.95 e j / 3)(z - 0.95 e - j / 3) = ( z - 0 ) 2

Page 43: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 43

Zeros at z = 0.95 e j / 3 & 0.95 e - j / 3 . Two poles, both at z = 0.Poles or zeros at z = 0 do not affect gain response.They do affect the phase response. Complete as an exercise.

Page 44: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 44

Design of IIR notch by pole/zero placement

• By strategically locating poles & zeros in the z-plane.

• 2nd order 'notch' filter to eliminate an unwanted sinusoidal component without severely affecting rest of signal.

• Assume frequency of sinusoid: =/4,

• Zero on unit circle at z = exp(j/4) = z1.

• Must have complex conjugate at z2 = exp(-j/4).

Page 45: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 45

Real part of z

Imaginary part of z

Z1

Z2

Page 46: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 46

• System function with these zeros is:

H(z) = (z - z 1)( z - z 2 ) = z 2 - 1.414z + 1.

• Introduce double pole at z = 0 to obtain:

z 2 - 1.414z + 1. H(z) = z 2

= 1 - 1.414 z -1 + z - 2

• This is the system function of an FIR filter.

• Use “distance rule” to estimate its gain-response:

Page 47: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 47

Real part of z

Imaginary part of z

Z1

Z2

Dist. from Z1 Dist. from Z2 Product0 0.75 0.75 0.6/4 0 1.4 0/2 0.75 1.85 1.43/4 1.4 2 2.8 1.85 1.85 3.4

Page 48: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 48

0

0.5

1

1.5

2

2.5

3

3.5

4

0 0.785 1.57 2.355 3.14

radians/sample

Gai

n

This is not a very good notch filter.

Page 49: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 49

• Eliminates tone at = /4, but severely affects spectrum.• Improved by placing poles p1 & p2 close to z1 & z2

Imaginary part of z

Real part of z

Z1

Z2

P1

P2

exp(j )

0.9

0.9

Page 50: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 50

• Take p1 = 0.9 e j / 4 , p2 = 0.9e - j / 4

(z - z1)(z - z2)

H(z) = (z - p1)(z - p2)

(z - e j / 4 )(z - e - j / 4 )

= (z - 0.9 e j / 4 )(z - 0.9 e - j / 4 )

Page 51: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 51

z2 - (e j / 4 + e - j / 4 ) z + 1 = z2 - 0.81 (e j / 4 + e - j / 4 ) z + 0.81

z2 - ( 2 cos (/4) ) z + 1 = z2 - 0.81 (2 cos(/4) ) z + 0.81

z2 - 1.414z + 1

= z2 - 1.273z + 0.81

1 - 1.414z - 1 + z - 2

= 1 - 1.273z - 1 + 0.81z-2

Page 52: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 52

a0 + a1 z - 1 + a2 z - 2

= 1 - b 1 z - 1 + b2 z - 2 with a

0 = 1, a

1 = -1.414, etc.

Direct form 1 realisation:-x[n] a0

z-1 z-1

z-1 z-1

a1

a2

y[n]

-b1

-b2

Page 53: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 53

x[n] y[n]

z-1

z-1

-1.414

W

W1

W2

1.273

-0.81

Direct form II realisation:-

Page 54: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 54

% Program to implement the notch:-

W1=0; W2=0; % for delay boxes while 1==1 X = input(‘X=’) ; % Input to X W =X + 1.273*W1 - 0.881*W2; % Recursive pt Y = W + 1.414*W1 + W2; % Non-rec. pt W2=W1; W1=W; % For next time disp( sprintf(‘Y=%f’,Y); % Send Y to output end; % Back for next sample

Page 55: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 55

Why is this a notch filter?

When not close to /4:

• distances from z1 & p1 to e j approx same;

• similarly for distances from z2 and p2 ;

• hence the gain 1.

When is close to /4: • gain changes significantly if changes;

• at = /4 the gain will be zero.

Page 56: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 56

Calculation of gain-response of notch filter

1 - 1.414z - 1 + z - 2

H(z) = 1 - 1.273z - 1 + 0.81z-2

freqz( [ 1 -1.414 1], [1 -1.273 0.81 ] );

Page 57: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 57

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-100

-50

0

50

100

Normalized Frequency ( rad/sample)

Pha

se (

degr

ees)

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-60

-40

-20

0

20

Normalized Frequency ( rad/sample)

Mag

nitu

de (

dB)

Page 58: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 58

Estimation of gain-response:

• Can avoid the need for a computer,

& also learn more about design process for notch filter. • We know that G() 1 at frequencies not close to the notch. • But how close is close?• How good is the notch filter? • Can answer this question by specifying filter's 3dB bandwidth.

• Difference between ‘3dB frequencies’: L and U

i.e. frequencies where G() crosses 0.707 (-3dB)

Page 59: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 59

1

G()

0.7

0

/4 UL

0 dB

-3 dB

• ‘3-dB’ band-width of notch is: U - L radians/sample.

Page 60: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 60

1

G()

0.7

0

/4 /4 + /4 -

0 dB

-3 dB

• If we know , we know how sharp the notch is.

Page 61: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 61

To estimate 3dB bandwidth of notch• Poles placed at distance from zeros as shown.

X

Z1

Z2

P1

P2

1-

1-

imag

Real

ej

Page 62: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 62

Ωj1

Ωj1Ωj

e top from distance

e toz from distance |)H(e|

• Close to = /4 we can neglect effect of p2 & z2 .

Page 63: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 63

P1

E

Z

P1

1

1

E

Real

Imag(z)

Z

• G( ) 1 when not close to When is G() 1/2 ?

• G(/4 + ) is gain at E.

• When is small, gain at E is EZ EP1

when =

22

22

Page 64: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 64

•When poles are at distance from zeros on unit circle, the 3dB frequencies are at ( /4 + ) and ( /4 - ) radians/sample. • Given (= 0.1 say) can sketch gain-response easily:

1

G()

0.7

0

/4 /4 + /4 -

0 dB

-3 dB

Page 65: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 65

• When poles are at distance from zeros,

‘3-dB bandwidth’ of notch is 2 radians/sample.

• Given the required 3-dB band-width for a notch filter, we can readily calculate and go on to design the filter.

• A popular exam question.

Page 66: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 66

Example:

A digital filter with a sampling rate of 200 Hz is required to eliminate an unwanted 50 Hz sinusoidal component of an input signal without affecting the magnitudes of other components too severely. Design a 2nd order "notch" filter for this purpose whose 3dB bandwidth is not greater than 3.2 Hz.

Solution:Notch frequency is (50/200)fS = fS/4 or /2 radians/sample.3-dB band-width is (3.2 / 200)fS = 0.016 fS = 0.016 x 2 = 0.1 radians/sampleTherefore 2 = 0.1 and = 0.05.Place poles & zeros & design filter as before.

Page 67: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 67

Problems:

1 Find H(z) for the following difference equations (a) y[n] = 2x[n] - 3x[n-1] + 6x[n-4] (b) y[n] = x[n-1] - y[n-1] - 0.5y[n-2]

2 Show that passing {x[n]} thro’ H(z) = z - 1 produces {x[n-1]}.3 Find H(z) for the difference equation: y[n]=x[n]-0.9y[n-1] by two methods: 4 Give difference equation & give a signal flow graph for: 1 + 3 z - 1 + 2z - 2

H(z) = 1 + 0.9z - 1

Plot poles & zeros & roughly sketch its gain response.

Page 68: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 68

5 Calculate the impulse response of the digital filter with 1 H(z) = 1 - 2 z - 1

Draw its signal flow graph, plot its poles and zeros and comment on them.6 Plot poles & zeros for the following difference equation: y[n] = x[n] - 0.9x[n-1] + 0.81x[n-2] + 0.95y[n-1] - 0.9025y[n-2] on z-plane and estimate gain and phase responses.7 Show that if r - z - 1

H(z) = 1 - r z - 1 H(e j ) = 1 for all . Plot pole & zero of H(z) when r = 0.9 and estimate phase response.

Page 69: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 69

8 Write high level language program, or give flow diagram to implement difference equation given in Prob. 2.6.9. Modify your program for prob 8 so that it uses only integers.10. If LTI systems L1 & L2, with imp-responses {h1[n]} & {h2[n]} are arranged as below, calculate overall impulse- response. Show that this is affected by interchanging L 1 & L 2 .

L1 L2 x[n] y[n]

{h1[n]} {h2[n]}

11. Considered in these notes.

Page 70: Nov'04CS3291 DSP Sectn 51 CS 3291 : Digital Signal Processing Section 5: z-transforms & IIR-type discrete time filters Remember: A discrete time filter

Nov'04 CS3291 DSP Sectn 5 70

12 Show that z-transform of {h[n]} with z = exp(sT) becomes Laplace transform of a sequence of analogue impulses weighted by samples of {h[n]}. T is sampling period.13 The z-transform of a sequence {x[n]} can be found & poles & zeros calculated. If { ..,0,1,0,0,0.729,0,...} is input to: y[n] = x[n] - x[n-1] + 0.9y[n-1] - 0.81y[n-2], calculate output sequence by tabulation, then explain result by plotting poles & zeros of the filter & input sequence on z-plane.