Top Banner
Ideal Filters One of the reasons why we design a filter is to remove disturbances ) ( n s ) ( n v ) ( n x ) ( ) ( n s n y Filter SIGNAL NOISE We discriminate between signal and noise in terms of the frequency spectrum F ) ( F S ) ( F V 0 F 0 F 0 F F ) ( F Y 0 F 0 F
26

FIR

Dec 13, 2014

Download

Business

Umesh Kumar

finite impulse response
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: FIR

Ideal Filters

One of the reasons why we design a filter is to remove disturbances

)(ns

)(nv

)(nx )()( nsny Filter

SIGNAL

NOISE

We discriminate between signal and noise in terms of the frequency spectrum

F

)(FS

)(FV

0F0F 0F F

)(FY

0F0F

Page 2: FIR

Conditions for Non-Distortion

Problem: ideally we do not want the filter to distort the signal we want to recover.

IDEAL

FILTER

)()( tstx )()( TtAsty Same shape as s(t), just scaled and delayed.

0 200 400 600 800 1000-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

0 200 400 600 800 1000-2

-1.5

-1

-0.5

0

0.5

1

1.5

2

Consequence on the Frequency Response:

otherwise

passbandtheinisFifAeFH

FTj

0)(

2

F

F

|)(| FH

)(FH

constant

linear

Page 3: FIR

For real time implementation we also want the filter to be causal, ie.

0for 0)( nnh

h n( )

n

since

0

)()()(k

knxkhny only spast value

FACT (Bad News!): by the Paley-Wiener Theorem, if h(n) is causal and with finite energy,

dH )(ln

ie cannot be zero on an interval, therefore it cannot be ideal. )(H

dHH )(log)0log()(log1 2 1

2

Page 4: FIR

Characteristics of Non Ideal Digital Filters

|)(| H

p

IDEAL

Positive freq. only

NON IDEAL

Page 5: FIR

Two Classes of Digital Filters:

a) Finite Impulse Response (FIR), non recursive, of the form

)()(...)1()1()()0()( NnxNhnxhnxhny

With N being the order of the filter.

Advantages: always stable, the phase can be made exactly linear, we can approximate any filter we want;

Disadvantages: we need a lot of coefficients (N large) for good performance;

b) Infinite Impulse Response (IIR), recursive, of the form

)(...)1()()(...)1()( 101 NnxbnxbnxbNnyanyany NN

Advantages: very selective with a few coefficients;

Disadvantages: non necessarily stable, non linear phase.

Page 6: FIR

Finite Impulse Response (FIR) Filters

Definition: a filter whose impulse response has finite duration.

h n( )

n

h n( )x n( ) y n( )

h n( ) 0h n( ) 0

Page 7: FIR

Problem: Given a desired Frequency Response of the filter, determine the impulse response .

Hd ( )h n( )

Recall: we relate the Frequency Response and the Impulse Response by the DTFT:

n

njddd enhnhDTFTH )()()(

deHHIDTFTnh njddd )(

2

1)()(

Example: Ideal Low Pass Filter

c c

Hd ( )

A

csin1

( ) sinc2

c

c

cj n cd

nh n Ae d A A n

n

)(nhd

n

c4

DTFT

Page 8: FIR

Notice two facts:

• the filter is not causal, i.e. the impulse response h(n) is non zero for n<0;

• the impulse response has infinite duration.

This is not just a coincidence. In general the following can be shown:

If a filter is causal then

• the frequency response cannot be zero on an interval;

• magnitude and phase are not independent, i.e. they cannot be specified arbitrarily

h n( )

h n( ) 0

H( )H( ) 0

As a consequence: an ideal filter cannot be causal.

Page 9: FIR

Problem: we want to determine a causal Finite Impulse Response (FIR) approximation of the ideal filter.

We do this by

a) Windowing

-100 -50 0 50 100-0.1

-0.05

0

0.05

0.1

0.15

0.2

0.25

-100 -50 0 50 100-0.1

-0.05

0

0.05

0.1

0.15

0.2

0.25

-100 -50 0 50 100-0.1

-0.05

0

0.05

0.1

0.15

0.2

0.25

-100 -50 0 50 1000

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

-100 -50 0 50 1000

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

)(nhd

)(nhw

rectangular window

hamming window )(nhw

infinite impulse response(ideal)

finite impulse response

L L

L L

L L

L L

Page 10: FIR

b) Shifting in time, to make it causal:

-100 -50 0 50 100-0.1

-0.05

0

0.05

0.1

0.15

0.2

0.25

-100 -50 0 50 100-0.1

-0.05

0

0.05

0.1

0.15

0.2

0.25

)(nhw)()( Lnhnh w

Page 11: FIR

Effects of windowing and shifting on the frequency response of the filter:

a) Windowing: since then )()()( nwnhnh dw )(*)(2

1)(

WHH dw

cc

)(dH

0 0.5 1 1.5 2 2.5 3-120

-100

-80

-60

-40

-20

0

20

0 0.5 1 1.5 2 2.5 3-120

-100

-80

-60

-40

-20

0

20

0 0.5 1 1.5 2 2.5 3-120

-100

-80

-60

-40

-20

0

20

40

0 0.5 1 1.5 2 2.5 3-120

-100

-80

-60

-40

-20

0

20

40

*

*

|)(| W |)(| wHrectangular window

hamming window

0 0.5 1 1.5 2 2.5 3-120

-100

-80

-60

-40

-20

0

20

Page 12: FIR

0 0.5 1 1.5 2 2.5 3-120

-100

-80

-60

-40

-20

0

20

attenuation

For different windows we have different values of the transition region and the attenuation in the stopband:

transition region

Rectangular -13dB

Bartlett -27dB

Hanning -32dB

Hamming -43dB

Blackman -58dB

N/4N/8

N/8

N/8

16 / N

nattenuatio

-100 -50 0 50 100-0.1

-0.05

0

0.05

0.1

0.15

0.2

0.25

L L

12 LN

)(nhw

n

with

Page 13: FIR

Effect of windowing and shifting on the frequency response:

b) shifting: since then )()( Lnhnh w Lj

w eHH )()(

Therefore

phase.in shift )(H)H(

magnitude, on theeffect no )()(

w L

HH w

See what is ).(wH

For a Low Pass Filter we can verify the symmetry Then ).()( nhnh ww

)cos()(2)0()()(1

nnhhenhHn

wwnj

nww

real for all . Then

otherwise ,'

passband; in the 0)(

caretdonHw

Page 14: FIR

The phase of FIR low pass filter:

passband; in the )( LH Which shows that it is a Linear Phase Filter.

0 0.5 1 1.5 2 2.5 3-120

-100

-80

-60

-40

-20

0

20

don’t care

)(H

dB

)(H

degrees

Page 15: FIR

Example of Design of an FIR filter using Windows:

Specs: Pass Band 0 - 4 kHz

Stop Band > 5kHz with attenuation of at least 40dB

Sampling Frequency 20kHz

Step 1: translate specifications into digital frequency

Pass Band

Stop Band 2 5 20 2 / / rad

0 2 4 20 2 5 / / rad

40dB

F kHz54 10

2

2

5

10Step 2: from pass band, determine ideal filter impulse

response

h n ndc c( )

sinc sinc2n

5

2

5

Page 16: FIR

Step 3: from desired attenuation choose the window. In this case we can choose the hamming window;

Step 4: from the transition region choose the length N of the impulse response. Choose an odd number N such that:

8

10

N

So choose N=81 which yields the shift L=40.

Finally the impulse response of the filter

h n

nn

( ). . cos , ,

2

50 54 0 46

2

800 80sinc

2(n - 40)

5 if

0 otherwise

Page 17: FIR

The Frequency Response of the Filter:

H( )

H( )

dB

rad

Page 18: FIR

A Parametrized Window: the Kaiser Window

The Kaiser window has two parameters:

N

Window Length

To control attenuation in the Stop Band

0 20 40 60 80 100 1200

0.5

1

1.5

n

][nw 0

1

10

5

Page 19: FIR

There are some empirical formulas:

A

Attenuation in dB

Transition Region in rad

N

Example:

Sampling Freq. 20 kHz

Pass Band 4 kHz

Stop Band 5kHz, with 40dB Attenuation

,5

2 P 2

S

dBA

radPS

4010

3953.3

45

N

Page 20: FIR

Then we determine the Kaiser window

),( Nkaiserw

][nw

n

Page 21: FIR

Then the impulse response of the FIR filter becomes

][

)(

)(sin][ nw

Ln

Lnnh c

ideal impulse response

with 20

921 SPc

221245 LLN

Page 22: FIR

][nh

n

dBH |)(|

(rad)

Impulse Response

Frequency Response

Page 23: FIR

Example: design a digital filter which approximates a differentiator.

Specifications:

• Desired Frequency Response:

kHzF

kHzFkHzFjFH d 5 if 0

44 if 2)(

• Sampling Frequency

• Attenuation in the stopband at least 50dB.

kHzFs 20

Solution.

Step 1. Convert to digital frequency

||2

if 0

5

2

5

2- if 000,20

)()(2/

jFjFHH

s

FFdds

Page 24: FIR

Step 2: determine ideal impulse response

5

2

5

2

000,202

1)()(

dejHIDTFTnh njdd

From integration tables or integrating by parts we obtain

a

xa

edxxe

axax 1

Therefore

0 if 0

0 if 5

2sin

25

2cos

5

4000,20

)( 2

n

nn

n

n

n

nhd

Page 25: FIR

Step 3. From the given attenuation we use the Blackman window. This window has a transition region region of . From the given transition region we solve for the complexity N as follows

N/12

N

121.0

5

2

2

which yields . Choose it odd as, for example, N=121, ie. L=60. 120N

Step 4. Finally the result

120

4cos08.0

120

2cos5.042.0

)60(5

)60(2sin

2605

)60(2cos

5

4000,20)(

2

nn

n

n

n

n

nh

1200for n

Page 26: FIR

0 20 40 60 80 100 120 140-3

-2

-1

0

1

2

3x 10

4

0 0.5 1 1.5 2 2.5 30

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2x 10

5

0 0.5 1 1.5 2 2.5 3 3.5-250

-200

-150

-100

-50

0

50

100

150

Impulse response h(n)

)(H

dBH )(

Frequency Response