0% found this document useful (0 votes)
32 views63 pages

Perancangan Filter FIR

Uploaded by

Ax
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views63 pages

Perancangan Filter FIR

Uploaded by

Ax
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 63

Chapter 7

Finite Impulse Response(FIR)


Filter Design
 Filter design steps
- The design of a digital filter involves five steps:
(1) Specifications of the filter requirements
(2) calculation of suitable filter coefficients
(3) Representation of the filter by a suitable structure (realization)
(4) Analysis of the effects of finite wordlength on the filter performance
(5) Implementation of filter in software and/or hardware

2/77
 Filter design
– Need to decide :
• Type of filter

• Amplitude and/or phase responses

• Tolerances

• Sampling frequency

• Wordlength of the input data

3/77
 Filter specifications
– Important parameters
 p peak passband deviation (or ripples)
 r stopband deviation

 p passband edge frequency ( 2 f )


p p

r stopband edge frequency (r 2 f r )

s sampling frequency (s 2 f s )

– Another important parameter


Filter order N

4/77
ILPF

Fig. 7-3.

5/77
 FIR coefficient calculation
N
y (n)  h(k ) x(n  k )
k 0

N
H ( z )  h(k ) z  k
k 0

– Most common methods used for calculating h(k )


• Window method
• Optimal method

6/77
 The window method of calculating FIR filter coefficients
– Step 1 : specify the desired frequency response of filter, H I ( )
– Step 2 : obtain the impulse response, hI (n) , of desired filter by
evaluating the inverse Fourier transform
– Step 3 : select a window function and then determine the number of
coefficients using the appropriate relationship between the filter
length and the transition width, f
– Step 4 : obtain values of w(n) for chosen window function and the
values h( n) hI (n) w(n)
of the actual FIR coefficient, , by multiplying by
h(n) hI (n) w(n) (7-
26)

7/77
Window method
 Design of FIR filter using window method
– Frequency response of filter, H I ( )
– Impulse response, hI (n)
1 
hI (n) 
2 

H I ( )e j n d  (7-
19)

– Ideal lowpass response


1  1 c
 
j n
hI (n)  1 e d  e j n d 
2  2  c

 2 f c sin(nc )
 , n 0, - n 
=  n  c
(7-
 2 fc , n 0 20)

8/77
Table 7.2 Summary of ideal impulse responses for standard frequency selective filters

hI (n)

hI (n) hI (n)

f c , f1 and f 2 are the normalized passband or stopband cutoff frequencies

9/77
Fig. 7-4.
(The frequency scale is normalized by T = 1)

10/77
 Truncation for FIR
h(n) hI (n) w(n) "windowing"

H(e j )  21 H I (e j ) W(e j )



 1
2 

H I (e j )W(e j (   ) )d

– Rectangular window

1 , n 0,1,..., N
w(n) 
0 , elsewhere

11/77
Fig. 7-5.

12/77
Fig. 7-6.

13/77
Fig. 7-7.

14/77
 Some common window functions
– Hamming window

0.54  0.46 cos 2 n / N  , 0 n  N


w n   (7-
 0 , elsewhere 21)

• Appropriate relationship between transition width and filter length

F 3.32 / N (7-
22)
where N is filter order and
F is normalized transition width

15/77
– Properties of common window functions

Fig. 7-8. Window functions: (a) Rectangular, (b) Hamming, (c) Blackman
16/77
Table 7.3 Summary of important features of common window functions

17/77
– Kaiser window
• Trade-off transition width against ripple
– using a ripple control parameter, 

  2 n  N
2 
 I0   1    

   N  
w n    , 0 n  N (7-
 I 0   23)

 0 , elsewhere

where I 0 ( x) is zero-order modified Bessel function of the first kind

2
L
 ( x / 2) k 
I 0 ( x) 1   
k 1  k ! 

where typically L 25


18/77
• Determination of parameter 
– by using the stopband attenuation requirement through empirical
relationships below
0, if A 21dB

 0.5842( A  21)0.4  0.07886( A  21), if 21dB  A  50dB
0.1102( A  8.7) if A  50dB

where A  20 log10 ( ) is the stopband attenuation value and
 min( p ,  s ) since the passband and stopband ripples are nearly equal

• The number of filter coefficients N

A  7.95
N  (7-
14.36f
25)

where f is the normalized transition width

19/77
 Example 7-2
– Obtain coefficients of FIR lowpass filter using
Hamming window
Passband cutoff frequency f p : 1.5kHz
Transition width f : 0.5kHz
Stopband attenuation  50dB
Sampling frequency f s : 8kHz

• Lowpass filter
 sin nc 
2
 c f , n 0
hI n   nc
 2 fc , n 0

F f / f s 0.5 / 8 0.0625

N 3.32 / F 3.32 / 0.0625 53.12


 N 54
20/77
• Using Hamming window
h(n) hI (n) w(n) 0 n 54

w(n) 0.54  0.46 cos(2 n / 54) 0 n 54


– Considering the smearing effect of the window function

f c'  f p  f / 2 (1.5  0.25) 1.75[kHz ] (centered on the transition band)


 f c  f c' / f s 1.75 / 8 0.21875 (normalized)

  N 
 2 f c sin  ( n  )c 
2 N
 , n  , 0 n N
 N 2
hI (n)  (n  )c
 2
 N
 2 fc , n
2
21/77
– Symmetrical function h(n)
» Calculation of h(0), h(1), , h(27)
» Using the symmetry property to obtain the other coefficients

2 0.21875
n 0 : hI (0)  sin( 27 2 0.21875)
 27 2 0.21875
 0.00655
w(0) 0.54  0.46 cos(0) 0.08
h(0) hI (0) w(0)  0.00052398

2 0.21875
n 1 : hI (1)  sin( 26 2 0.21875)
 26 2 0.21875
 0.011311
w(1) 0.54  0.46 cos(2 / 54)
0.08311
h(1) hI (1) w(1)  0.000940057
22/77
2 0.21875
n 2 : hI (2)  sin(  25 2 0.21875)  0.00248397
 25 2 0.21875
w(2) 0.54  0.46 cos(2 2 / 54)
0.092399
h(2) hI (2) w(2) 0.000229516
  

2 0.21875
n 26 : hI (26)  sin(  12 0.21875)
 12 0.21875
0.312936
w(26) 0.54  0.46 cos(2 26 / 54)
0.9968896
h(26) hI (26) w(26) 0.3112226

n 27 : hI (27) 2 f c 2 0.21875 0.4375


w(27) 0.54  0.46 cos(2 27 / 54) 1
h(27) hI (27) w(27) 0.4375
23/77
Fig. 7-9.

24/77
 Example 7-3
– Obtain coefficients using Kaiser window
Stopband attenuation : 40dB
passband attenuation : 0.01dB
Transition region f : 500 Hz
Sampling frequency f s : 10kHz
Passband cutoff frequency f p : 1200 Hz

• From filter specifications


20 log(1   p ) 0.01dB,  p 0.00115

 20 log( r ) 40dB,  r 0.01

  r  p 0.00115
 20 log(0.00115) 58.8dB
25/77
• Using Kaiser window
– The number of filter order N
A  7.95 58.8  7.95
N  70.82
14.36F 14.36(500 /10000)

N 71
– The ripple parameter

 0.1102(58.8  8.7) 5.52

– Normalized cutoff frequency


f c 1200  f / 2 1450 Hz

f c  f c' / f s 1, 450 /10, 000 0.145

26/77
– Calculation of FIR coefficients

 N 
2 f c sin   n   c 
 2 
hI (n)  , 0 n  N
 N
 n   c
 2

h(n) hI (n) w(n)

27/77
– Symmetrical function h(n)
» Calculation of h(0), h(1), , h(35)
» Using the symmetry property to obtain the other coefficients

2 0.145
n 0 : hI (0)  sin(  35.5 2 0.145)
 35.5 2 0.145
0.00717
  2n  N  
2

I0   1    
  N   I (0)
w(0)    0 0.023
I0 ( ) I 0 (5.52)

h(0) hI (0) w(0) 0.000164935

28/77
2 0.145
n 1: hI (1)  sin(  34.5 2 0.145)
 34.5 2 0.145

0.0001449

   69  
2

I 0  5.52 1    
  71   I (1.3)
w(1)    0 0.0337975
I 0 (5.52) I 0 (5.52)

h(1) hI (1) w(1) 0.000004897

29/77
2 0.145
n 2 : hI (2)  sin(  34.5 2 0.145)
 33.5 2 0.145

0.007415484

   69  
2

I 0  5.52 1    
  71   I (1.8266)
w(2)    0 0.04657999
I 0 (5.52) I 0 (5.52)

h(2) hI (2) w(2) 0.000345413


  

30/77
2 0.145
n 35 : hI (35)  sin(  0.5 2 0.145)
 0.5 2 0.145

0.280073974

   1 
2

I 0  5.52 1    
  71   I (5.51945)
w(35)    0 0.999503146
I 0 (5.52) I 0 (5.52)

h(35) hI (35) w(35) 0.279934818

31/77
Fig. 7-10.

32/77
33/77
The optimal method

 Basic concepts
– Equiripple passband and stopband
E ( ) W ( )[ H I ( )  H ( )]

Weighted Weighting Ideal desired Practical


Approx. error function response response

– Mathematically expressed as
min[max E ( ) ]
over the passbands and stopbands

34/77
Practical response
Ideal response

Fig. 7-11.

35/77
 min[max E ( ) ]
 equiripple passband and stopband of the resulting filter response,
with the ripple alternating in sign between equal amplitude levels
 The minima and maxima are known as extrema.
 For linear lowpass filters, for example, there are either m+1 or m+2
extrema,
m=(N+1)/2, type 1 filter
m= N/2, type 2 filter

36/77
Fig. 7-12. Extremal frequencies

37/77
– The procedure of optimal method
• Use the alternation theorem (Parks and McClellan) to find the optimum
set of extremal frequencies
• Determine the frequency response using the extremal frequencies
• Obtain the impulse response coefficients

38/77
 Optimal FIR filer design
– Transfer function of lowpass filter
N
H ( z )  h(k ) z  k (7-
k 0 28)
where h(n) h(  n)

• Symmetric property gives


N /2 N /2
H ( ) h(0)   2h(k ) cos kT  a(k ) cos kT
k 1 k 0

where a (0) h(0) and a (k ) 2h(k ) , k 1, 2, , N / 2

39/77
• Let f  / 2 f s T / 2 be defined by normalized frequency, then
– Normalize as f p / f s  f p , f r / f s  f r
-> Normalized passband :  0, f p 
-> Normalized stopband :  f r , 0.5

• Desired magnitude response

1, 0  f  fp (7-
H I ( f ) 
0, f r  f 0.5 30)

• Weighting function
1
 , 0  f  fp
W  f   k (7-
 1 , f r  f 0.5 31)

40/77
a(k ) k 0,1, 2, , N / 2

min[max E ( f ) ]

N /2
H ( f )  H (e j 2 f
)  a (k ) cos k 2 f (7-
k 0 32)

E ( f ) W ( f )[ H ( f )  H I ( f )] (7-
33)

for f in  0, f p  and  f r , 0.5

41/77
– Alternation theorem
• Let F  0, f p    f r , 0.5
• H ( f ) H I ( f ) is the unique best approximation if and only if E ( f ) is
equiripple at F and has at least m+2 extremal points in , that is, there
exists
f 0  f1   f l (l m  1)

such that
E ( f i )  E ( f i 1 )  e, i 0,1, , l  1 (7-
34)

where e max E( f )
f  0, f p  &  f r ,0.5 

42/77
• From equations (7-33) and (7-34)

W ( fi )  H ( fi )  H I ( fi )   ( 1)i e, i 0,1, 2, , m  1 (7-


35)

• Equation (7-32) into equation (7-35) yields


m
e

k 0
a(k ) cos 2 kf i  H I ( f i )  ( 1)i
W ( f i )
, i 0,1, 2, , m 1

• Matrix form

 1 cos 2 f 0 cos 4 f 0  cos 2 mf 0 1/ W ( f 0 )   a(0)   H I ( f 0 ) 


 1 cos 2 f cos 4 f1  cos 2 mf1  1/ W ( f1 )   a(1)   H I ( f1 ) 
 1  
            
    
 1 cos 2 f m cos 4 f m  cos 2 mf m (  1) m / W ( f m )   a(m)   H I ( f m ) 
 1 cos 2 f m 1 cos 4 f m 1  cos 2 mf m 1 (  1) m ! / W ( f m 1 )   e   H I ( f m 1 ) 

43/77
– Summary
Step 1. Choose filter length as 2m+1
Step 2. Choose m+2 points of fi in F
Step 3. Calculate a(k ) and e using equation (7-36)
Step 4. Calculate E ( f ) using equation (7-29). If E ( f )  e , go to step 5,

otherwise go to step 6
Step 5. Determine
h(0)mlocal
a(0), minima
h(k ) a(or
k )maxima
/ 2 k points
1, 2, , m
Step 6. Obtain , ,
then the optimal filter Nis given by
H ( z )  h(k ) z  k
k 0

44/77
 Example 7-4
– Specification of desired filter
• Filter length : 3
•  pT 1[rad], rT 1.2[rad] , k 2

N 2m  1 3
 m 1  m  2 3

• Choose three frequencies and normalize them,


two of them are cutoff frequencies, the third one arbitrarily
f 0 0.5 / 2 , f1 1/ 2 , f 2 1.2 / 2

45/77
• From H I ( f 0 ) H I ( f1 ) 1, H I ( f 2 ) 0, W ( f 0 ) W ( f1 ) 1/ 2 and W ( f 2 ) 1

 1 0.8776 2   a(0)   1 
 1 0.5403  2   a(1)   1 
    
 1 0.3624 1   e   0 

a (0)  0.645, a(1) 2.32,


e  0.196

H ( f )  0.645  2.32 cos 2 f (7-


37)
• The error at f 0 and f1 is 2x0.196= 0.392, and the error at f 2 is 0.196.
=> not have E ( f )  e
=> Not the characteristic of the optimal filter

46/77
• Choose a new set of fi
1 1.2
f 0  , f1 , f 2 0.5
2 2

H I ( f 0) 1, H I ( f1) H I ( f 2) 0, W ( f 0) 0.5, and W ( f1) W ( f 2) 1

 1 0.5403 2   a(0)   1 
 1 0.3624  1  a(1)   0 
    
 1 1 1   e   0 

a(0) 0.144, a(1) 0.45,


For this filter for all f in
e 0.306

( f ) 0.306
•Transfer of the optimalEfunction  0,1/ 2  and 1.2 / 2 , 0.5
H ( f ) 0.144  0.45cos 2 f (7-
38)

H ( z ) 0.225  0.144 z  1  0.225 z  2 (7-39)


47/77
Fig. 7-13. Characteristics of filter H(f)

48/77
 Optimal method using MATLAB
– Based on Parks-McClellan and Remez algorithm
– Calculation of coefficients for FIR filter using Remez

b remez(N,F, M )

b remez(N,F, M, WT )

where N is the filter length


F is the normalized frequency band edges
M is the magnitude response
WT is the relative weight between ripples

49/77
 Example 7-5
– Specification of desired filter
• Pass band : 0 – 1000Hz
• Transition band : 500Hz
• Filter length : 45
• Sampling frequency : 10,000Hz
– Normalized frequency band edges
F [0, 0.2, 0.3, 1]

– Magnitude response
M [1 1 0 0]

50/77
Table 7-4. Impulse response coefficients

51/77
Fig.7-14. Frequency response of filter

52/77
 Example 7-6
– Specification of desired filter
• Pass band : 3kHz – 4kHz
• Transition band : 500Hz
• Pass band ripple : 1dB
• Rejection band attenuation : 25dB
• Sampling frequency : 20kHz

– Frequency band edges and magnitude response

F [2500, 3000, 4000, 4500]

M [0 1 0]

53/77
• Estimation of filter length
– Pass and rejection band ripples
Ap

10 20  1  Ar
 p  Ap  r 10 20

10 20  1
where A p and Ar are ripples of dB scale in pass and rejection band

– Using Remezord in MATLAB

54/77
Table 7-5. Impulse response coefficients of
filter

55/77
Fig. 7-15. Frequency response of filter

56/77
Frequency sampling method
 Design of FIR filter
– Taking N samples of the frequency response at intervals of kFs / N ,
k 0,1,  , N  1
– Filter coefficients h(n)

N1
1
h( n) 
N
 H
k 0
( k ) e j (2 / N ) nk
(7-
40)

where H (k ) , k 0,1,  , N  1 are samples of desired frequency response

57/77
– Linear phase filters with positive symmetrical impulse response
• For N even

 N2  1 
1 
h( n)   2 H (k ) cos[2 k (n   ) / N ]  H (0)  (7-
N  k 1  41)
 

where  ( N  1) / 2

• For N odd
– Upper limit in the summation is ( N  1) / 2

58/77
Fig. 7-16.

59/77
 Example 7-7
1  N /2 1 
(1) Show the h(n)    2 H (k ) cos[2 k (n   ) / N ]  H (0) 
N  k 1 
• From equation (7-40)

N1
1
h( n) 
N
 H (k ) e
k 0
j 2 nk / N

N1
1

N
 H (k ) e
k 0
 j 2 k / N
e j 2 kn / N
N1
1

N
 H (k ) e
k 0
j 2 ( n   ) k / N

N1
1

N
 H (k ) cos[2 k (n   ) / N ]  j sin[2 k (n   ) / N ]
k 0
h(n) is real value N1
1


is symmetryN
 H (k ) cos[2 k (n   ) / N ]
k 0

h( n)

1  N /2 1 
h(n)    2 H (k ) cos[2 k ( n   ) / N ]  H (0)  (7-
N  k 1  42)
60/77
(2) Design of FIR filter
• Specification of desired filter
– Pass band : 0 – 5kHz
– Sampling frequency : 18kHz
– Filter length :9
• Selection of frequency samples at intervals of kf s / N
 1, k 0,1, 2
H (k ) 
 0, k 3, 4

Fig. 7-17. 61/77


• Coefficient of FIR filter using equation (7-42)

Table 7-6.

62/77
Comparison of the window, optimum
and frequency sampling methods
 Optimal method
– Easy and efficient way of computing FIR filter coefficients
– Making filter with good amplitude response characteristics for reasonable
values of N
 Window method
– In the absence of the optimal software or when the passband and stopband
ripples are equal, the window method represents a good choice
– Particularly simple method to apply and conceptually easy to understand
 Frequency sampling method
– Filters with arbitrary amplitude-phase response can be easily designed
– Lack of precise control for the location of the bandedge frequencies or the
passband ripples

63/77

You might also like