Discrete - Time and Systems

Z-Transform-FIR filters

Yogananda Isukapalli FIR filters-Review M y[]nbx= å k [n - k]...general difference equation for FIR filters k =0

Filter Order = M: No. of memory blocks required in the filter implementation

Filter Length, L = M+1: Total No. of samples required in calculating the output, M from memory (past) and one present sample

Filter coefficients {bk}: Completely defines an FIR filter. All the properties of the filter can be understood through the coefficients Z- transform of h[] n results in '', it is also known as 'system function ' Hz( )[]= å hnz-n n From the previous lecture recall that Transfer function Yz() Hz()= Xz() Þ Yz( )()= HX z ()z Notice the mathematical simplicity of the above result becomes a simple multiplicatio n hn[]*« xn []() H z Xz() Calculating the output of a FIR filter using Z- transforms Steps involved 1) Find the Z- transform of input x[ n ] ¥ Xz()= å xnz []-n n=-¥ 2) Find the Z- transform of impulse response h [ n ] M Hz()= å h [nz] -n n=0 3) Multiply X ( z ) and H (z ) to get Y() z 4) Obtain output y[] n by applying inverse Z- transform to Y ()z

--1 yn[]¬¾! ¾® Y( z) Why to operate in transforms? Z-TRANSFORM-DOMAIN M Hz ( )= å hnz [ ] -n n=0

{bk } TIME-DOMAIN FREQ-DOMAIN Fig 12.1 M M jwˆ jwˆ - jwˆ k y[n] = b x[n - k] He()= Hz () ˆ H (e ) = bke å k ze= jw å k=0 k=0 \ z= ejwˆ , makes both domains equal x[n] h[n] = d [n] -d [n -1] y[n] x[n] y[n]

jwˆ - jwˆ n x[n] jwˆ - jwˆ y[n] H (e ) = åh[n]e H (e ) = 1- e n

-n x[n] -1 y[n] Hz()= å hnz [] Hz()= 1- z n Fig 12.2 Same output from all three domains Computational complexity determines the domain Some of the filter properties are better understood in or Z-domains Z and frequency transforms are related Example 1 Calculating the transfer function of the FIR filter with impulse response co- efficients given by, {[]}{2,0,3,0,2}hn = -

{[]}{2,0,3,hn = - 0, 2} 4 Hz()= å hnz [] -n n=0 Hz( )=+ h [0] h[1] z----1234 + h [2] z + h [3]zhz + [4] =+ 2 0zzzz--12-- 3 0 - 3+ 2 - 4 = 2- 3z--2 + 2z 4 Example 2 Calculating the transfer function of the FIR filter described by the difference equation yn[]=+ xn [] 2[ xn -1]-3[ xn -2]-4[ xn -3] hn[]= bk hn[]= { 1,2,-3,-4} 3 H (zn)[= å hz] -n n=0 Hz( )=+ h [0] h [1]zhzhz---123 + [2] + [3] =+ 1 2z-12--34z--z 3 Example 3 Calculating the output of the FIR filter xn[ ]=+dd [ n -1]- [ n - 2] dd [ n -3]- [ n - 4] hn[ ]=+dd [ n ] 2 [ n -1] + 3 d [ n - 2] + 4 d [ n -3]

z -n0 !d[-nn0 ]¬¾® z Xz()= zzzz--1234- - + - - Hz()=+1324z-12 +zz--+ 3 !Yz()= XzHz () () =( zzzz----1234- + - )( 1++24zz - 13z- 2+ - 3) =zz--12+ (- 1++ 2) (1- 2++ 3) z - 3 (- 1+ 2- 3+ 4) z - 4 +(- 2+ 3- 4)zzz---567+ (- 3++ 4) (- 4) =z--12++zzzzzz 2 - 3 + 2 - 4- 3- 56+ -- 4 - 7 Apply the inverse Z- transform

--1 -n0 Z ! znn¬¾ ¾® d[-0 ] Yz()=+ z-1 z-2 + 2 z-34567+ 23zzzz----- + - 4 yn[ ]=++dd [ n -1] [ n - 2] 2 d [ n -3] + 2 d [ n - 4]- 3 d [ n -5] +dd [nn - 6]- 4 [ - 7] Example 4 Find the impulse response of the FIR filter xn[ ]= d [ n - 2] yn[ ]=+dd [ n ] 2 [ n -1] + 3 d [ n - 2] + 4 d [ n -3]

z -n0 !d[-nn0 ]¬¾® z Xz()= z-2 Yz()=+ 1 2 z--1 ++ 3z 23 4z - Yz() ! Hz()= Xz() 12++zzz-12 3--+ 4 3 =234=+z2 z + + z-1 z-2 h [ n ]=++++dd [ n 2] 2dd [ n 1] 3 [ n ]+ 4 [ n-1]... non causal Example 5 Calculating the output of the FIR filter An 0££ 4 xn[]= 0 elsewhere

n 1 2 0££n 3 hn[]= ( ) 0 elsewhere ¥ Xz()= å xnz []-n n=-¥ 4 ==+++++å Az-----n A (1 z1234 z z z ) n=0 ¥ Hz()= å hnz []-n n=-¥ 3 n ==å ( 1 2) z-n n=0 =+ (1 (12) zzz---12+ ( 14) + (1 8)) 3 !Yz()= HzXz () () =(1Az+++++----1234 z z z )(112 +( ) z - 1 +( 14) z - 2 +( 18) z - 3 ) =+Az (1( 3 2) --12 +( 7 4) z +( 15 8) z - 3 +( 15 8) z - 4 + ( 7 8) z---56+ ( 3 8) zz+ (18) 7 ) yn[] = A(dd[nn ]+ ( 3 2) [- 1]+ ( 7 4) d [ n- 2]+ ( 15 8) d [ n- 3] +( 15 8)ddd [nnn- 4]+ ( 7 8) [- 5]+ ( 3 8) [- 6] + ( 1 8)d [n - 7]) Cascading Systems

Fig 12.3 x[ n ]... input signal to the 1st FIRfilter h[ n ]... impulse response of the 1st FIRfilter w[ n ]... output of the 1st FIR filter and input to the 2 nd FIR filter y[ n ]... output of the 2nd filter , also this is the overall output

Fig 12.4

z hn[]= h1 [ n][* h2 n]¬¾® Hz()= H12 () zH( z) Cascaded system can be replaced by a single filter with system function H() z Example 1 The impulse responses in a cascaded system are hn1[]= dd [] n-- [ n 1] hn2[]=+dd [] n [ n- 1] Find the impulse response of an effective system that can replace the cascading arrangement

z -n0 !d[-nn0 ]¬¾® z zz hn1122 [ ]¬¾®Hz(), h [ n] ¬¾® H () z -1 Hz1()= 1- z -1 Hz2 ()=+ 1 z --11 - 2 H (z) ==HzHz12() ()= ( 1- z)( 1+ z) 1- z hn[]= d [nn]-d[- 2] Example 2 Consider a system described by the difference equations wn[]= 3[] xn-- xn [ 1] yn[]= 2[] wn-- wn [ 1] Find the impulse response of an effective system that can replace the cascading arrangement

hn11[]== bk () [3,1]-

hn1[]= 3[]dd n-- [ n 1]

hn22[]== bk () [2,1]-

hn2[]= 2[]dd n-- [ n 1] z -n0 !d[-nn0 ]¬¾® z zz h1122 [nhn ]¬¾® Hz(), [ ]¬¾® H () z -1 Hz1()= 3- z -1 Hz2 ()= 2- z --11 Hz()= HzHz12() ()= ( 3-- z)( 2 z ) --12 =+ 6 - 5zz hn[ ]= 6dd [ n ]-- 5 [ n 1]+ d [ n- 2] The system can now be expressed as one difference equation y[nxnxnxn ]= 6 [ ]-- 5 [ 1]+ [- 2] Example 3 The impulse response of an effective system, hn[ ]= dd [ n ]-- 2 [ n 1]+ 2 d [ n-- 2] d [ n - 3] Split the above filter into two cascaded filters such that the 1st system is described by, wn[]= xn []-- xn [ 1]

z -n0 !d[-nn0 ]¬¾® z Hz()= 1- 2 z---123+ 2 z- z hn1[]= dd [] n-- [ n 1] -1 Hz1()= 1- z ! Hz()= H12 () zH () z Hz() Hz2 ()= Hz1() 12- zzz---123+ 2 - = 1- z-1 =1- zz--12+ h2[nnn ]= dd [ ]-- [ 1]+ d [ n- 2] yn[ ]= wn [ ]- wn [-- 1]+ w [n 2]ü ýComplete system wn[]= x []nxn- [1]- þ

Fig 12.5 Example 4: Cascading of filters has an important practical application Undoing the effects of the first filter Example: Communication channel Undoing the effects of channel on signal is called

Yz()= H1 ()z HzXz2 () () if Y() z= X () z

Þ HzHz12() ()= 1 -1 Assume H1 ( z )= 1- z 1 Hz2 ()= 1- z-1 Z-Transform & Unit circle The frequency or wˆ -- domain is a subset of z domain The general expression for Z is, z= re jwˆ , where, ' r ' is the radius of the circle z= ejwˆ , makes both domains equal jwˆ He()= Hz () ˆ ze= jw ˆ ! z= ejw = 1, the unit circle has a unique significance in the z- domain Gray dots, z= {- j,1, j} ìüpp wˆ = íý- ,0, îþ22

General Z- plane z= ejwˆ , special case z- domain= wˆ - domain Fig 12.6

Note that 'wˆ ' is the discrete- time frequency discussed in previous lectures -pwp££¬ˆ ¾® -11 £z £ Periodicity in wpˆ --- domain 2 radians , one cycle in z - domain Zeros & Poles Consider the transfer function of an FIR filter Hz()= 1- 2 z---12+ 2 z- z3 Convert the above function as a polynomial in ' z ' (12- zz-1233+ 2--- zz) Hz( ) = z3 z32- 221zz+ - = z3 write the numerator in factored form, z3 - 221(1)()()zz233+ - = zzeze--jjpp -- (1)(zzeze--jjpp33 )( -- ) H ()z = z3 Zeros....The values of z for which H()0 z = In this example , H( z )== 0 for z{ 1,, ejjpp33 e- } Poles....The values of z for which H() z ® ¥ H( z )® ¥ for z = { 0,0,0} note that z3 = 0 results in 3 roots It is also known as a 3rd order pole at z = 0 Significance of zeros in an p j FIR system : 3 ze2 = Except for a constant FIR system is completely characterized by the zeros 3 poles z1 = 1 The difference equation which desribes the relation between x[ n ] and y[n ], can

p be found with the knowledge - j 3 of zero locations ze3 = Fig 12.7 Example 1 Find the poles and zeros for the transfer function? Hz( ) = 13- z--12+ 2 z Converting into a polynomial in '' z zz2 - 32+ Hz()= z2 write the numerator in factored form , zz2 - 3+= 2 ( z-- 2)( z 1)

zeros==[ z1,][2, z2 1] nd polesp= [,1 p2 ]== [0,0] 2 order pole at z = 0 Example 1 continued…

Fig 12.8 Notice that both the zeros are on real axis, also notice one pole is not included in the unit circle. There is a double pole at z=0 Example 2 Find the poles and zeros of an FIR system described by the difference equation, yn[]= xn []--x [n 1]+ x [n - 2] Theimpulseresponsefunctionisgivenby hn[ ]= dd [ n ]-- [ n 1]+ d [ n- 2]

z -n0 !d[-nn0 ]¬¾® z Hz( )1= - z--12+ z Converting into a polynomial in '' z zz2 - +1 Hz()= z2 write the numerator in factored form , zz233- +=1( ze--jjpp )( ze- ) zeros= [, ejjpp33 e- ], both on unit circle poles==[0,0] 2nd order pole at z = 0

p 3 2 poles - p 3

Fig 12.9 Example 3 The zeros and poles of an FIR filter are given, zeros= [, ejjpp4 e- 4 ] poles = [0,0] Find the difference equation of the filter The numerator is obtained through multiplication of factors ()(ze--jjp 442 ze- p ) = z- 2 z+1 denominator through poles, z2 zz2 - 21+ Hz()= z2 = 1- 2zz--12+ Apply inverse Z- transform, hn[]= ddd [] n-- 2[ n 1]+ [ n- 2] The difference equation yn[]= xn []-- 2[ xn 1]+ xn [- 2]

Notice that, because of conjugate zeros a sinusoid signal with p 4 frequency p 4 will be nulled out by this FIR filter

Fig 12.10 Example 4, Application: Nulling filters The Graphical Design of a Comb filter • In medical applications, the 60Hz frequency of the power supply is often “picked up” by the test equipment (EKG recorder) • Also harmonically related such as f2 = 2x60 = 120Hz, and f3 = 3x60 = 180 Hz are generated because of non-linear phenomena. • The object of a digital is to eliminate or suppress these unwanted frequencies which distort or mask up the signals of interest Thus the desired response of the filter would be, Assume a sampling frequency of 360Hz

M

Fig 12.11 0 60 120 180 f Hz p/3 2p/3 p q rad Thus we have :

q1 = w1T = 2p(60)/360 = p/3

q2 = w2T = 2p(120)/360 = 2p/3

q3 = w3T = 2p(180)/360 = p 1) Complex zeros must occur in conjugate pairs 2) q = 0 is added to eliminate any DC component in the signal

Actual Response

0 60 120 180 f Hz Fig 12.12 p/3 2p/3 p q rad p 2p 4p 5p j j j j H(z) = (z -1)(z -e 3 )(z -e 3 )(z -e jp )(z -e 3 )(z -e 3 ) H(z) = z6 -1 Implies : y[n] = x[n + 6]- x[n]

But the above obtained filter is non-causal !! To make it causal filter we place six poles at z = 0.

6 z -1 - H(z) = \Þ H(z) = (1- z 6 ) z6 Thus the required causal FIR comb filter is: y[n] = x[n]- x[n -6] Filter properties & the location zeros There is an extremely close relationship between the of the filter and the location of zeros on the unit circle

One can design a filter with required frequency by placing zeros in the appropriate place. The difference equation of the filter can be obtained by multiplying the factors associated with zeros Example: Running average filter L-1 yn[]= å xn [- k ] k =0 The system function L-1 1- z-L Hz()== z-k å -1 k =0 1- z zL -1 = zL-1 ( z -1) Zeros.. from numerator , zL -10= zk==eLj2p kL, 0,1,2...- 1 Zeros are equally spaced around thecir cle Poles.. from numerator , zzL-1(1)0- = zLth-1 = 0, L- 1 order pole at 0 And another pole at z = 1 Note that this pole and zero at z= 1 get cancelled

The primary reason for the filter to become a lowpass filter is this cancellation of the zero at z= 1 due to the pole present in the same location Example 1 L = 11 Running average filter

Equi spaced zeros More gap bewteen zeros close to z = 1 Fig 12.13

Fig 12.14 3 dimensional view of the frequency response

Fig 12.15 If the zeros locations are known , the transfer function L-1 of the filter can be obtained through , H() z= Õ ( 1- ejkL21p z- ) k =1 Example 2 L = 10 Running average filter

9th order pole at z = 0 More gap bewteen zeros close to z = 1

Fig 12.16

Fig 12.17 Example 3 L = 10 Band pass filter A simple trick :cancel the zero in a different location Transfer function shifts; L-1 Hz()= å z-k ejkkL2p 0 k =0 k0 ! determines the Fig 12.18 shift Since there is no conjugate zero. this result s in a complex filter Fig 12.19 same example due to conjugate symmetry this results in a filter with real coefficients 1 L-1 Hz()=+å z-k ejkkL2p 0 2 k =0 1 L-1 å z-k e- jkkL2p 0 2 k =0 Fig 12.20 Hz()=+ H12 () z H () z

Fig 12.21 FIR filter with two zeros

Notice changes in the impulse response h[n] and the frequency response as the complex zero pair is moved around the unit circle (changing the angle of the zeros)

Fig 12.22 hn[ ]= dwdd [ n ]-- 2cos(ˆ ) [ n 1]+ [ n- 2] FIR filter with three zeros; one is held fixed at z = -1

Notice changes in the impulse response h[n] and the frequency response as the complex zero pair is moved around the unit circle (changing angle)

Fig 12.23 FIR filter with ten zeros equally spaced around the unit circle Notice changes in the impulse response h[n] and the frequency response as the zero at z = 1, is moved radially

Fig 12.24 FIR filter with ten zeros equally spaced around the unit circle Notice changes in the impulse response h[n] and the frequency response as the zero pair at 72 degrees is moved radially.

Fig 12.25 Reference James H. McClellan, Ronald W. Schafer and Mark A. Yoder, “7.5-7.8 -- First”, Prentice Hall, 2003