You are on page 1of 21

FIR & IIR FILTER DESIGN

Introduction As we have seen a LTI system also performs a type of discrimination or filtering among various frequency components at its input. The nature of filtering action is determined by the frequency response characteristics H(w) which in turn depends on system parameter like {ak} & {bk} in the difference equation. In the design of frequency selective filters, the desired filter characteristics are specified in frequency domain in terms of desired amplitude and phase response of the filter. In the filter design we determine the coefficients of a causal FIR or IIR filter which closely approximates the specification. Typical characteristics of ideal filter 1) Constant-gain in pass band (unity gain) 2) Zero gain in stop band 3) Linear phase response In practice, FIR filters are used when there is a requirement of linear phase characteristics within the pass band of the filter. If there is no requirement for linear phase characteristic either an IIR filter or FIR filter can be used. However an IIR filter has lower side lobes in the stop band than an FIR filter having the same number of parameters. For this reason if some phase distortion is tolerable or unimportant, an IIR filter is preferable primarily because of its easier implementation and less memory use and lower computational complexity. Today FIR and IIR digital filter design is greatly facilitated by the availability of numerous software programs. Our main objective is to give the reader the background necessary to select the filter that best matches the application and satisfies the design requirements. Linear Phase:- Let us assume a signal sequencer {x[n]} with frequency components w1<w<w2 is passed through a filter with frequency response

Ce jwn 0 w1 < w < w2 H ( w) = 0 else


c,no are constant. The output signal spectrum is given by Y(w)=X(w)H(w)=CX(w)e-jwno Y(n)=Cx(n-n0) ( by time shifting property of fourier transform) Thus the filter output is simply a delayed and amplitude scaled version of the input. A pure delay and amplitude scaling is tolerable and not considered as a distortion. H(w)= Ce jwno = ce j ( w) ( w) = wn0 = phase the derivative of phase w.r.t frequency has the units of delay d ( ( w)) rad Tg ( w) = = group...delay = = sec dw rad / sec It is the time delay that a signal component of frequency w undergoes as it passes from the input to the output of the system Now when phase (w) or phase is linear then group delay is constant . In this case all frequency components of the input signal undergo the same amount of time delay.

Ideal Filter & Practical filter Ideal filters are not practically realizable they serve as a mathematical idealization of practical filters as they are not causal, not absolutely sum able. We can approximate very close to practical physically realizable filters.
A.Sarkar ,ECE,JGEC page no 1

A.Sarkar ,ECE,JGEC page no 2

A.Sarkar ,ECE,JGEC page no 3

Design of Linear Phase FIR Filter using windows

A.Sarkar ,ECE,JGEC page no 4

now you have to consider the effect of windows operation on the desired frequency response Hd(w). Multiplication in time domain is equal to convolution in frequency domain and vice versa. So basically there are two difficulties with the implementation of designing a digital filter. 1) The impulse response is of infinite duration i.e. the filter is non causal 2) No finite amount of delay can make the impulse response realizable The infinite duration impulse response can be converted to a finite duration impulse response by truncating the infinite series at n=N. But this results in undesirable oscillation in the pass band and stop band of the digital filter(Gibbs Phenomenon, which manifests itself as a fixed percentage overshoot and ripple before and after the discontinuity in the frequency response) A more practical way is to use a finite weighing sequence w(n) called a window to modify hd(n) and also to control the convergence of the Fourier series. The truncation of the Fourier series is known to introduce ripples in the frequency response characteristics H(w) due to non uniform convergence of the Fourier series at a discontinuity. This oscillatory behavior near the band edge of the filter is called the Gibbs phenomenon. So the conclusion is multiplication of a sequence by rectangular window (similar to truncation) resulted in ripples in frequency domain.

A.Sarkar ,ECE,JGEC page no 5

A.Sarkar ,ECE,JGEC page no 6

A.Sarkar ,ECE,JGEC page no 7

A.Sarkar ,ECE,JGEC page no 8

A.Sarkar ,ECE,JGEC page no 9

Some desirable characteristics of window: 1) The central lobe of the frequency response of the window should contain most of the energy and should be narrow 2) The highest side lobe level of the frequency response should be small 3) The side lobes of the frequency response should decrease in energy as w tends to PI. 4) The width of the transition band ( on either side of discontinuity ) depends on the width of the main lobe . Ripples are coming from the side lobes of window response which produces error. Rectangular window A.Sarkar ,ECE,JGEC page no 10

The Rectangular window sequence is given by

1..... ( N 1) / 2 <= n <= ( N 1) / 2 wR (n) = 0.....else WR = (e ) =


jw ( N 1) / 2 n = ( N 1) / 2

jwn

= e jw( N 1) / 2 + .... + e jw + 1 + e jw + .... + e jw( N 1) / 2 = e jw( N 1) / 2 (1 + e jw + .... + e jw( N 1) ) = e jw( N 1) / 2 (1 e jwn ) /(1 e jw ) e jwn / 2 (1 e jwn ) e jwn / 2 e jwn / 2 sin wn / 2 = jw / 2 = = e (1 e jw) ) e jw / 2 e jw / 2 sin w / 2
The transition width of the main lobe is equal to 4/M (2/M (-2/M ). Zeros will always push down the response and poles will always push up the response. FIR filter contains M zeros and are distributed within unit circle( Zero will occur when wM/2=K) where K is an integer. w=2k/M Main lobe is the portion that lies between first two zero crossing . as window is made larger , the main lobe width becomes narrower and higher at w=0 H(ejw)=N But the peak side lobes becomes more concentrated around w-0 and relative side lobe level compared to main lobe decreases.( area under each side lobe remains unchanged w.r.t changes in M). As M is increased main lobe becomes narrow resulting in a sharp transition but smoothing is reduced because large side lobes of W(w) results in undesirable ringing effect. So it is a trade off between sharp transition and small ripples in pass band and stop band. The desired response of a LPF changes abruptly from pass band to stop band but actual frequency response changes slowly. This region of gradual change is called transition region, which is due to convolution of main lobe of window and desired response. The convolution of the desired response and the window responses side lobes gives rise to ripple in both pass band and stop band. The amplitudes of the ripples are dictated by the amplitude of the side lobes. So increase in M results in ripples occurs more frequently. The effect of maximum ripple occurs just near before and after the transition band is known as GIBBS phenomenon. These undesirable effects can be reduced by using a window which does not contain abrupt discontinuities (tapers smoothly toward zero at both ends) and have corresponding lower side lobes in the frequency domain characteristics.

DESIGN OF IIR FILTERS FROM ANALOG FILTERS Analog filter design is a mature and well developed field. The techniques described in this section are all based on converting an analog filter into a digital filter. The most common technique used for designing IIR digital filters known as indirect method, involves first designing an analog prototype filter and then transforming the prototype to a digital filter. For the given specification of a digital filter, the derivation of filter transfer function requires three steps 1) Map the desired digital filter specifications into those for an equivalent analog filter 2) Derive the analog transfer function for the analog prototype 3) Transform the transfer function of the analog prototype into an equivalent digital filter transfer function

A.Sarkar ,ECE,JGEC page no 11

We recall that an analog LTI system with system function H(s) is stable if its all poles lies in the left side of the s plane. If the conversion from analog filter to digital filter is to be effective it should posses two properties

A.Sarkar ,ECE,JGEC page no 12

A.Sarkar ,ECE,JGEC page no 13

A.Sarkar ,ECE,JGEC page no 14

This transformation is a one to -one mapping from the s-domain to the z-domain. i.e it is a mapping that transforms the j axis into the unit circle in the z plane only once. Also it presents in a stable digital filter as all the poles in the LHP of S-plane are mapped into points inside the unit circle of the z-domain. Derivation:Let the system function of the analog filter be H(s)=b/(s+a) The differential equation describing the analog filter can be obtained as H(s)=Y(s)/X(s)=b/(s+a) sY(s)+aY(s)=bX(s) taking inverse Laplace transformation dy (t ) + ay (t ) = bx(t ).......(1) dt Now apply either method 1 or method 2 which results same Method1:The above equation is integrated between the limits (nT-T) and nT A.Sarkar ,ECE,JGEC page no 15

dy(t ) dt + a y (t )dt = b x(t )dt.....(2) dt nT T nT T nT T The trapezoidal rule for numerical integration is given by nT T a(t )dt = [a(nT ) + a(nT T )] 2 nT T applying it in equation (2) y(nT)-y(nT-T)+aT/2 y(nT)+ aT/2 y(nT-T)=bT/2 x(nT) bT/2 x(nT-T)
Method 2: y(t) can be approximated by trapezoidal formulae y(t)= y ' ( )d + y (t 0 ) at t=nT and to=nT-T yields
t0 t

nT

nT

nT

T ' [ y (nT ) + y ' (nT T )] + y[nT T ].....(3) 2 from the equation (1) we obtain y ' (nT ) = ay(nT ) + bx(nT ).....(4) substituting equation (4) in equation (3) T y (nT ) = [ ay (nT ) + bx(nT ) ay (nT T ) + bx(nT T )] + [ y ' (nT T )] 2 which implies aT aT bT y (nT ) + y (nT ) (1 ) y (nT T ) = [ x(nT ) + x(nT T )] 2 2 2 with y(n)=y(nT) and x(n)=x(nT) we obtain aT aT bT (1 + ) y ( n ) (1 ) y ( n 1) = [ x ( n ) + x ( n 1)] 2 2 2 taking z transform of this difference equation is aT aT 1 bT (1 + )Y ( Z ) (1 )Z Y (Z ) = [1 + Z 1 ] X ( Z ) 2 2 2 bT bT (1 + Z 1 ) (1 + Z 1 ) Y (Z ) 2 2 = = H (Z ) = aT aT aT X (Z ) (1 (1 + Z 1 ) 1+ ) Z 1 (1 Z 1 ) + 2 2 4 T dividing numerator and denominator by (1 + Z 1 ) we get 2 b b H (Z ) = .....comparing...H ( S ) = ...we..get 1 s+a 2 (1 + Z ) +a T ((1 Z 1 )) y (nT ) =
S= 2 (1 Z 1 ) ......known.. AS ..Bilinear..Transform T (1 + Z 1 )

Let Z=rejw and s=+j

A.Sarkar ,ECE,JGEC page no 16

2 z 1 2 re jw 1 2 r cos w 1 + jr sin w 2 r cos w 1 + jr sin w r cos w + 1 jr sin w = = = T z + 1 T re jw + 1 T r cos w + 1 + jr sin w T r cos w + 1 + jr sin w r cos w + 1 jr sin w = 2 r 2 cos w 1 + r 2 sin 2 w + j 2r sin w 2 r 2 cos w 1 + r 2 sin 2 w + j 2r sin w = 2 2 2 2 T (r cos w + 1) 2 + r 2 sin 2 w T 1 + r cos w + 2r cos w + r sin w r 2 1 2 2r sin w + j 2 2 T 1 + r + 2r cos w 1 + r + 2r cos w

S= + j =

if r<1 then

r 2 1 2 = 2 T 1 + r + 2r cos w = 2 2r sin w 2 T 1 + r + 2r cos w

2 sin w 2 2 sin w / 2 cos w / 2 = T 1 + cos w T 2 cos 2 w / 2 w 2 <0 and if r>1 then >0 and if r=1 =0 and = tan T 2 1 T w = 2 tan 2 It can be noted that the entire range in is mapped only once into the Range <=w<= . However as shown in figure, the mapping is non linear and the lower frequencies in analog domain are expanded in the digital domain, where as the higher frequencies are compressed. This is due to the non linearity of the arc tangent function and usually called as frequency warping. It can be eliminated by another technique called PreWarping the analog filter. =

A.Sarkar ,ECE,JGEC page no 17

Analog Low Pass ButterWorth Filter Design The magnitude function of the butterwoth LPF is given by 1 H ( j) = ....(1) where N=1,2,3.order of the filter and c is the cut off frequency. 2N 1+ c

A.Sarkar ,ECE,JGEC page no 18

At =0 , maximum response is unity at =c ,response is 0.707 , which corresponds to -3dB point. The ideal response is shown by dashed line. The function is monotonically decreasing. It can be seen that the magnitude response approaches the ideal low pass characteristics as N increases. From The equation (1) we can get the magnitude square function of a normalized butterworth filter( to 1 rad/sec cut off frequency) as 1 2 H ( j ) = ....( 2) Now the transfer function of a stable filter can be derived by putting =s/j in 2N 1+ c equation(2) 2 1 H ( j) = H ( j) 2 = H ( s 2 ) = H ( j) H ( j) = 2N s 1+ j 1 1 H ( s) H ( s) = = N 2N 1 + ( 1) S 1 + ( s 2 ) N The above relationship tells us that this function has poles in the LHP as well as in the RHP due to two factors H(S) and H(-S). H(S) has roots in LHP and H(-S) has roots in RHP. We can get the roots by equating the denominator to zero. These poles will appear always as complex conjugate pair. 1 + ( s 2 ) N = 0 for N odd S =1=e
2N 2N j2k

SK = e

j 2 K N

....where..K = 1,2,...,2 N
j ( 2 K 1) 2N

for N even S =-1=e

j(2k-1)

SK = e

....where..K = 1,2,...,2 N

for N=3 , S6=1 Six poles are separated by 360/6=600 and all the poles lie in unit circle. We will consider the poles in the LHP for stability. Transfer function will look like

Example:

A.Sarkar ,ECE,JGEC page no 19

1 4 4 2 2 + j sin + j sin )) ))( s (cos ( s + 1)( s (cos 3 3 3 3 1 H (S ) = 1 3 1 3 ) )( s + + j ( s + 1)( s + j 2 2 2 2 1 1 1 H (S ) = = = 2 2 1 3 ( s + 1)( s 2 + s + 1) 2 1 3 s s s + + + + ) ( 1 )( (s + 1) s + + 4 4 2 2 H (S ) = for N=2 S 2 N = 1 = e j ( 2 K 1)
SK = e S1=ej/4 S2=ej3/4 S3=ej5/4 S4=ej7/4
j ( 2 K 1) 2N

... fork = 1,2...2 N

H(S)=

1 1 1 1 = = = 2 2 2 1 1 j j 1 1 s + 2s + 1 j 1 s 2 + 2s + + + s+ s + s + 2 2 2 2 2 2 2 2 List of butterworth polynomial

Order N 1 2 3 4

Denominator of H(s) s+1 s 2 + 2s + 1 (s + 1)(s 2 + s + 1)

(s 2 + 0.76537s + 1)(s 2 + 1.8477s + 1)

The unnormalized poles are given by sk= cSk .The transfer function of such type of butterworth filter can be obtained by substituting s->s/c Order of butterworth filter The filter was restricted to -3db attenuation at c. Now let the maximum passband attenuation in positive dB is p( <3 dB) at passband frequency p and s is the minimum stopband attenuation in positive dB at stopband frequency s. Now the magnitude function can be written as 1 H ( j ) = 2N 2 1+ p 1 2 H ( j) = 2N 2 1+ p taking log on both sides

A.Sarkar ,ECE,JGEC page no 20

2N 2 20 log H ( j) = 10 log 1 10 log 1 + p but from the figure at =p the attenuation is equal to p 20 log H ( j p ) = p = 10 log 1 + 2

0.1 p = log 1 + 2 ..taking ..anti log ... 1 + 2 = 10


0.1 p

= (10 1) ....(1) at =s the minimum stopband attenuation is equal to s 2n 2 S 20 log H ( j s ) = 10 log 1 log 1 + p 2n 2 S S = 10 log 1 + p 2n 0.1 S = log 1 + 2 S p
2 S p
2n

0.1 p

= 10 0.1 S 1....(2)

substituting (1) into (2) we get


0.1 S S 1 = 10 0.1 p 10 1 p the order of the filter N which is rounded off to the next higher integer value 2n

log N

10 0.1 S 1 10 log
0.1 p

S p

log N log

S p

where... = 10 0.1S 1

1/ 2

...and .. = = 10 0.1 P 1

1/ 2

A.Sarkar ,ECE,JGEC page no 21

You might also like