dsp u lec08 fir filter design

Post on 25-Dec-2014

3.919 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Fir Filter Design

TRANSCRIPT

5 l lEC533: Digital Signal Processing

Lecture 8FIR Filter Design

8.1 – FIR Filter

The basic FIR filter is characterized by the following:

∑−

=

−=1

0)()()(

N

kknxkhny

1N

∑−

=

−=1

0)()(

N

k

kzkhzH

where, h(k); k=0,1,…, N-1 are the impulse response coefficients of the filter.• Filter order= N-1.• Filter Length=NFilter Length N

• FIR filters can have an exactly linear phase response.

8.2 – Linear Phase Response & Its Implications

• A filter is said to have linear phase response if its phase response satisfies one of the following relationships;

αωωθ −=)( 1

•where α, β are constants.

αωωθ =)(αωβωθ −=)(

1

2, β

If condition is satisfied, the filter will have a constant group & constant phase delay responses & the impulse response of the filter must have positive ( ) i

1

⎫⎧(even) symmetry. i.e.,odd is N if Nn

fil )fllf( i bl ⎪⎪⎪⎫

⎪⎪⎪⎧ −

=2

1........1,0

even is N if 1-Nn

nNhnhfilters)oftypesallfor(suitable

⎪⎪

⎪⎬

⎪⎪

⎪⎨

=−−=

2........1,0

);1()(

HPF) for suitable(not ⎪⎪

⎭⎪⎪

⎩2

2)1( −= Nα

8.2 – Linear Phase Response & Its Implications – cont.cont.

When condition is satisfied, the filter will have a constant group delay only & the impulse response of the filter will have a negative (odd) symmetry. i.e.,

2

odd is N if 2

1........1,0

⎪⎪⎪⎫

⎪⎪⎪⎧ −

=

N

Nn

even is N if 1-2

........1,0 );1()(

tors)Diffrentia and rsTransformeHilbert for (suitable

⎪⎪⎪

⎪⎬

⎪⎪⎪

⎪⎨ =−−−=

NnnNhnh

;2)1( −= Nα

⎪⎭⎪⎩

2/πβ =

8.3 - Filter Types

• The desired (Ideal) frequency response of different filters:

LPF HPF

ω (normalized)

BPF BSFBPF BSF

1ω 2ω 2ω1ω1ω

The amplitude response is periodic in frequency with a period ωs & symmetric around the Nyquist frequency ωN = ωs /2.

8.4 – Deriving Filter Impulse Response

As HD(ω) is the desired amplitude response & it is periodic in frequency with period ωs ,We can obtain the filter impulse response hD(n) – filter coefficients ak’s-period ωs ,We can obtain the filter impulse response hD(n) filter coefficients ak sby evaluating the IDTFT of HD(ω) as follows;

njDD enhH ωω −

∞∑= .)()( DTFT

m −∞=

ωπ

ωωπ

ωω

ωωπ

πdedeHnh njnj

DDc

c.1

21.)(

21)( ∫∫ −−

==ω

⎤⎡⎤⎡

c

ccnj

nfnf

jne c ω

ππ

ω

ω

ω )sin(222

1⎥⎦

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡=

cc

c

nf

fjc

ωω

)sin(2=

⎦⎣⎦⎣ −

cnωWhere fc is the normalized cutoff frequency

8.5 – Ideal Impulse Response for Different Filter Types

where fc,f1 and f2 are the normalized passband or stopband edge frequencies.

8.6 - FIR Filter Specification

)H(e jw

• ‐ passband edge frequency

• ‐ stopband edge frequencypωsω

δ

Ap = 20 log10 (1 + δp) dB

• ‐ peak ripple value in the passband

• ‐ peak ripple value in the stopbandsδpδ

Peak passband ripple (dB)

As = -20 log10 (δs) dB

∆(ω)= ωs - ωp≡ Transition width

p pp ( )

Stopband attenuation (dB)

Transition Width

8.7 – FIR coefficient Calculation Methods

• The filter coefficients - h(n)- can be calculated by using several methods as the window, optimal, & frequency

li h dsampling methods.

• All of these methods can lead to linear phase FIR filter.

)H(ejw

8.8 – Window Method

1

ω

∞- ∞

2)W(ejw w(nT)

noncausal

ω ω( ) 21-N( ) 21-N−

)()( TjTj WH ωω ⊗Gibb’s  )h(nT).w(nT(n)h =)()( TjTj eWeH ωω ⊗Oscillations

)h(nT).w(nT(n)hw

Noncausal change to causal by shifting by (N‐1)/2 

8.8.1 – Effect of the Window Size

As we increase the width of the window (n), its spectrum will be sharper & the result of convolution will be near to ideal.

A th lti id l i l d t l d t FIR filt th id lAs the resulting ideal impulse response does not lead to FIR filter, the ideal impulse response can be truncated by setting hD(n)=0; for n>M (say). But this introduces the so called Gibb’s oscillations.

Filter designed by windowing method has equal passband and stopband ripplesFilter designed by windowing method has equal passband and stopband ripples

M=5 M=50M=20

This is done by multiplying the ideal impulse response by rectangular window of the form:the form:

⎩⎨⎧

=01

)(nwMn ,...,1,0; = 2)1(; −= NM

; else where

8.9 – Some Common Window Functions

• A practical approach to design an FIR filter is to multiply the ideal impulse response by a window function, w(n), whose duration is finite other than the

l d Th l d h l l drectangular window. This leads to the resulting impulse response decaying smoothly towards zero, so the Gibb’s oscillations will be reduced. But the transition width will be wider than the case when the rectangular window is used.

8.9.1 – Rectangular Window

⎨⎧1

)(nwMn ,...,1,0; = 2)1(; −= NM

⎩⎨= 0

)(nw; else where

time frequency

8.9.2 – Hanning Window

⎪⎨⎧ + )2cos(5.05.0)( N

nπ ⎨⎧ −≤≤−− 2)2(2)2( NnN (N odd)

⎪⎩

⎪⎨

+=0

)cos(5.05.0)( Nnw; else where ⎩

⎨ ≤≤− 22 NnN (N even)

time frequency

8.9.3 – Hamming Window

⎪⎧ )2( nπ ⎨⎧ −≤≤−− 2)2(2)2( NnN (N odd)

⎪⎩

⎪⎨⎧ +=

0)2cos(46.054.0)( N

nnw

π; else where ⎩

⎨⎧

≤≤−≤≤

222)2(2)2(

NnNNnN

(N even)

time frequency

8.9.4 – Blackman Window

⎪⎨⎧

−+

−+= )

14cos(08.0)

12cos(5.042.0)( N

nN

nnw

ππ

⎪⎩ 0 ; else where

⎩⎨⎧

≤≤−−≤≤−−22

2)2(2)2(NnNNnN (N odd)

(N even)

time frequency

8.10 – Summary of Important Features of Common Window Functions

8.11 – FIR Design Steps by WindowingStep 1: Specify the ‘ideal’ or desired frequency response of filter, HD(ω).

Step 2: Obtain the impulse response, hD(n), of the desired filter by evaluating p p p D( ) f f y gthe inverse DTFT. For the standard frequency selective filters the expressions for hD(n) are summarized in table stated in slide 7

Step 3: Select a window function that satisfies the passband or attenuationStep 3: Select a window function that satisfies the passband or attenuation specifications & then determine the number of filter coefficients using the appropriate relationship between the filter length & the transition width, ∆f (expressed as a fraction of the sampling frequency).

Step 4: Obtain values of w(n) for the chosen window function & the values of the actual FIR coefficients, h(n), by multiplying hD(n) by w(n) h(n)= hD(n) w(n)

Step 5: shift the filter coefficients by (N-1)/2 to achieve a causal filter

It is clear that the window method is straightforward & involves a minimal amount of computational effort. On the other hand, it should be said that the resulting filter is not optimal, that is in many cases a filter with a smaller number of coefficients can be designed using other methods.

Example

Obtain the coefficients of an FIR LPF to meet the specifications given below;• Passband edge frequency 1.5 kHz• Transition width 0.5 kHz• Stopband attenuation >50 dB• Sampling frequency 8 kHz

SolutionSelect hD(n) for LPF which is given by 0;)sin(2)( ≠= n

nnfnh c

cD ωω

The table in slide 17 indicates that the Hamming, Blackman, or Kaiser window ill i f h b d i i W ill h H i

n cω0;2)( == nfnh cD

will satisfy the stopband attenuation requirements. We will use the Hamming window for simplicity. Now ∆f =0.5/8=0.0625. F N 3 3/ ∆f 3 3/0 0625 52 8 l t N 53 oddFrom N=3.3/ ∆f =3.3/0.0625=52.8, let N=53 odd

The filter coefficients are obtained from h(n)= hD(n) w(n); -26 ≤ n ≤ 26

Example – cont.he filte coefficients a e obtained f om h(n) hD(n) w(n); 6 ≤ n ≤ 6

where 0;)sin(2)( ≠= nn

nfnhc

ccD ω

ω

02)( fh 0;2)( == nfnh cD

2626);532cos(46.054.0)( ≤≤−+= nnnw π

Because of the smearing effect of the window on the filter response, the cutoff frequency of the resulting filter will be different from that given in the specifications. To account for this, we will use fc that is centered on the transition band:

53

f∆′

Nothing that h(n) is symmetrical, we need only to compute values for h(0),h(1), …,h(26)

kHzkHzfff cc 75.1)25.05.1(2 =+=∆+=′ 1.75/8 = 0.21875

g ( ) y , y p f ( ), ( ), , ( )& then use the symmetry property to obtain the other coefficients.n=0: hD(0) = 2 fc = 2 * 0.21875 = 0.4375

w(0) = 0.54 + 0.46 cos(0) = 1w(0) 0.54 0.46 cos(0) 1h(0) = hD(0) w(0) = 0.4375

n=1:

Example – cont.312190)21875.0360sin()2187502sin(21875.02)1( =

×=×

×= πhn 1:

w(1) = 0.54 + 0.46 cos(2π/53) = 0.54 + 0.46 cos(360/53) = 0.99677h(1) = h( 1) = h (1) w(1) = 0 31118

31219.0)21875.02sin(21875.02

)1( ==××

ππDh

h(1) = h(-1) = hD(1) w(1) = 0.31118

n=2: 06013.02

)5.157sin()21875.022sin(21875.022

21875.02)2( ==××××

×=

ππ

πDh

w(2) = 0.54 + 0.46 cos(2π*2/53) = 0.54 + 0.46 cos(720/53) = 0.98713h(2) = h(-2) = hD(2) w(2) = 0.06012

n=26: 011310)218750226sin(21875.02)26( −=×××

= πhn=26:

w(26) = 0.54 + 0.46 cos(2π*26/53) = 0.54 + 0.46 cos(9360/53) = 0.08081h(26) = h( 26) = h (26) w(26) = 0 000914

01131.0)21875.0226sin(21875.0226

)26( −=××××

= ππDh

h(26) = h(-26) = hD(26) w(26) = - 0.000914

Example – cont.• We note that the indices of the filter coefficients run from -26 to 26. To make the filter causal (necessary for implementation) we add 26 to each index so that the indices start at zero. The filter coefficients, with indices adjusted, are listed in the following table. The spectrum of the filter (is plotted) would indicate that the specifications were satisfied.

top related