2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer...

10

Click here to load reader

Transcript of 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer...

Page 1: 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer function: 1 0 () N j jn n H ehneω ω − − = =∑ Also, in order to have a linear

2. Finite Impulse Response Filters (FIR)

2.2. Methods for FIR filters implementation

2.2. Methods for FIR filters implementation

1. The window method.2. Frequency characteristic uniform sampling.3. Maximum error minimizing.4. Least-squares error minimizing

1( ) ( )2

j jnd dh n H e e d

πω ω

π

ωπ −

= ∫

From the Fourier series decomposition:

( ) ( )j jnd d

nH e h n eω ω

∞−

=−∞

= ∑

Let’s consider the desired (ideal) transfer function( )j

dH e ω

– It is a periodical function over ω with a 2π period.

2.2.1. The window method 2.2.1. The window method

We may consider the FIR coefficients to be:

( ) ( ), 0,..., 1dh n h n n N= = −

– we keep the first N coefficients of the ideal hd (n).

A standard FIR filter has the transfer function:1

0( ) ( )

Nj jn

nH e h n eω ω

−−

=

= ∑

Also, in order to have a linear phase FIR filter we must apply the restrictions presented in the previous chapter

Page 2: 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer function: 1 0 () N j jn n H ehneω ω − − = =∑ Also, in order to have a linear

Frequency characteristic restrictions

Tip 0 ( )H ω 0 ( )H ω în 0ω =

0 ( )H ω în ω π=

Zerouri obligatorii

Se pot proiecta

1 ( ) ( )1

2

0

' cos

N

na n nω

=∑

fără con-strângeri

fără con-strângeri

fără con-strângeri

FTJ FTS FTB FOB

2 ( )2

1

1' cos2

N

nb n n ω

=

⎛ ⎞−⎜ ⎟⎝ ⎠

∑ fără con-strângeri 0 1z = −

FTJ FTB

3 ( ) ( )1

2

1

' sin

N

nc n nω

=∑ 0 0 1z = şi

1z = −

FTB tr. Hilbert

diferenţiator

4 ( )2

1

1' sin2

N

nd n n ω

=

⎛ ⎞−⎜ ⎟⎝ ⎠

∑ 0 fără con-strângeri 1z =

FTS FTB

tr. Hilbert diferenţiator

Frequency characteristic restrictions

-π 0 π 2π 3π

( )0H ω

ω

00

( ) '( )cosP

nH a n nω ω

=

=∑

Type 1: H0 even function and π symmetrical

-π 0 π 2π 3π

( )0H ω

ω

Type 2: H0 even function and π asymmetrical

01

1( ) '( )cos( )2

P

nH b n nω ω

=

= −∑

Frequency characteristic restrictions

Type 3: H0 odd function and π asymmetrical

01

( ) '( )sinP

nH c n nω ω

=

=∑

Type 4: H0 odd function and π asymmetrical

01

1( ) '( )sin( )2

P

nH d n nω ω

=

= −∑

-π 0 π 2π 3π

( )0H ω

ω

-π 0 π 2π 3π

( )0H ω

ω

[ ]0( ) ( ) , ,j

d dH H e ωω ω π π= ∈ −

0

12( ) ( )

Njjd dH e e H

ωω ω−

−=

For the types 1 and 2, is an even function:0 ( )H ω

The corresponding linear phase term:

2.2.1. The window method

Step 1. Choose a desired (ideal) zero phase transfer function and add the linear phase term.

Page 3: 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer function: 1 0 () N j jn n H ehneω ω − − = =∑ Also, in order to have a linear

For the types 3 and 4, is an odd function:0 ( )H ω

The corresponding linear phase term:

2.2.1. The window method

Step 1. Choose a desired (ideal) zero phase transfer function and add the linear phase term.

( )

( ) ( ]

( ) [ )0

, 0,

, ,0

0, 0

jd

jd d

H e

H H e

ω

ω

ω π

ω ω π

ω

⎧ ∈⎪⎪= − ∈ −⎨⎪

=⎪⎩(0) 0dH =

0

12( ) ( )

Njjd dH e je H

ωω ω−

−=

Step 2. Determine the Fourier series (infinite terms) decomposition of the Hd (ejω)

( ) ( ) , 0, , 1dh n h n n N= = −

2.2.1. The window method

1( ) ( )2

j jnd dh n H e e d

πω ω

π

ωπ −

= ∫

Step 3. Establish the real filter coefficients

2.2.1. The window method

Keeping a finite number of terms is equivalent with multiplying with a temporal window w(n):

( ) ( ) ( )dh n h n w n=

( ) 0, pentru 0, 1w n n N⎡ ⎤= ∉ −⎣ ⎦

The effect in the Z transform domain is:

{ }Z ( ) ( )d dh n H z= { }( ) Z ( )W z w n=

( ) ( ) ( ) ( )( ) ( )zd dh n h n w n H W z H z= ←⎯→ ∗ =

2.2.1. The window method

And in the frequency domain:

( ) ( )1( ) ( ) ( ) ( )2

j j ju j ud dH e H W e H e W e du

πω ω ω

ππ−

= ∗ = ∫

In order to maintain the linear phase characteristic, the windowing sequence must be symmetrical:

( ) ( 1 )w n w N n= − −

12

0( ) ( )NjjW e e W

ωω ω−

−= ⋅

Page 4: 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer function: 1 0 () N j jn n H ehneω ω − − = =∑ Also, in order to have a linear

2.2.1. The window method

The amplitude-frequency characteristics for the usual windows have a main lobe centered in ω=0and a number of secondary lobes with a decreasing levels.

( )jW e ω

ω0

The Gibbs effect

( )jdH e ω

1

ω

( )jH e ω

A frequency transition band between the passband and the stopband.– It depends on the main lobe of the window

characteristicThe amplitude characteristic has ripples both inthe passband and in the stopband.

– They depend on the amplitude of the secondary lobes of the window characteristic

The rectangular window

Is defined by: 1, 0, 1( )

0, in restD

n Nw n

⎧ ⎡ ⎤∈ −⎪ ⎣ ⎦= ⎨⎪⎩

1

-2 -1 0 1 2 ...... N-1 N N+1 n

( )Dw n

1

10

1( )1

NNn

Dn

zW z zz

−−−

−=

−= =

−∑

The spectrum is:

12

sin1 2( ) 11 sin2

NjN jjD j

NeW e ee

ω ωωω

ω

ω

−− −

−= =

0 ( )DW ω

The rectangular window frequency characteristic

( )jDW e ω

2 20 2 2N Nπ π π π ω

N

Page 5: 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer function: 1 0 () N j jn n H ehneω ω − − = =∑ Also, in order to have a linear

First secondary lobe amplitude

The maximum is for: sin 12N ω = ±

The first frequency the maximum is obtained: 3deci .

2 2N

Nπ πω π ω= + =

3

0

( ) 1 1 2 10, 23 3 5( )2

jN

Dj

D

W eNW e

N

π

π π≈ ⋅ = ≈ = or -13dB

sin2( ) 1sin2

jD

N

W e ωω

ω=

First secondary lobe amplitude

0dB

( )( )

jD

jD

W eW e

ω

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5-70

-60

-50

-40

-30

-20

-10

0

frecvenţă normată

-13dB

The rectangular window

-21dB1

ω

( )jH e ω

In the real filter characteristics, there will result ripples with a maximum level of -21dB in the stopband.

The Hamming windows

Are defined by:2 1(1 )cos ( ) , 0, 1

( ) 20, else

H

n n Nw n N

πα α⎧ ⎛ ⎞ ⎡ ⎤− − + ∈ −⎪ ⎜ ⎟ ⎣ ⎦= ⎝ ⎠⎨⎪⎩

They are depending on parameter α .– For α=0.54 we get the default Hamming window.– For α=0.5 we get the Hann window.

Page 6: 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer function: 1 0 () N j jn n H ehneω ω − − = =∑ Also, in order to have a linear

The Hamming windows2 1(1 )cos ( ) , 0, 1

( ) 20, else

H

n n Nw n N

πα α⎧ ⎛ ⎞ ⎡ ⎤− − + ∈ −⎪ ⎜ ⎟ ⎣ ⎦= ⎝ ⎠⎨⎪⎩

0 5 10 15 20 25 30 35 40 450

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

The Hamming windows

The first and the last window samples:

(0) ( 1) (1 )cosH Hw w NNπα α= − = − −

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

0, elseH

n n Nw n N

πα α⎧ ⎛ ⎞ ⎡ ⎤− − + ∈ −⎪ ⎜ ⎟ ⎣ ⎦= ⎝ ⎠⎨⎪⎩

For large N they are almost 0 for α≈0.5

(0) ( 1) 2 1H Hw w N α= − ≅ −

Compared to the rectangular window (with an abrupt transition at the end of the window), the Hamming windows introduce a smooth transition.

The Hamming windows

( ) ( )H Dw n w nα=

( ) ( )j jH DW e W eω ωα=

where is the rectangular window spectrum: ( )jDW e ω

0

12( ) ( )

NjjD DW e e W

ωω ω−

−=

0

sin2( ) 1sin2

D

N

ωω

=

21 ( )2

j j nN N

De e w nπ πα−

−21 ( )

2j j nN N

De e w nπ πα − −−

2( )1 ( )2

j jN N

De W eπ πωα −−

−2( )1 ( )

2j jN N

De W eπ πωα − +−

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

0, elseH

n n Nw n N

πα α⎧ ⎛ ⎞ ⎡ ⎤− − + ∈ −⎪ ⎜ ⎟ ⎣ ⎦= ⎝ ⎠⎨⎪⎩

The Hamming windows

Therefore:

1 2( )2

NjNeπω−

− −

12( )

NjjHW e e

ωω−

−=

0 0 0 0

1 2 1 2( ) ( )2 2H D D DW W W W

N Nα π α πω α ω ω ω− −⎛ ⎞ ⎛ ⎞= ⋅ + − + +⎜ ⎟ ⎜ ⎟

⎝ ⎠ ⎝ ⎠

0

12( ) ( )

NjjH DW e e W

ωω α ω−

−= ⋅ −

0

1 2( )21 2

2

Nj jN N

De e WN

π πωα πω−

− − +− ⎛ ⎞− +⎜ ⎟⎝ ⎠

with:

12

jNeπα−

−1 2( )

2Nj

Neπω−

− −0

2DW

Nπω⎛ ⎞− −⎜ ⎟

⎝ ⎠

0( )HW ω⋅

12

N jj jNe e eπω π

− −−=

12

Nj jNe eπ ω−− −

= −

Page 7: 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer function: 1 0 () N j jn n H ehneω ω − − = =∑ Also, in order to have a linear

The Hamming windows

0( )HW ω =

0( )DWα ω⋅

0

1 22 DW

Nα πω− ⎛ ⎞+ −⎜ ⎟

⎝ ⎠ 0

1 22 DW

Nα πω− ⎛ ⎞+ +⎜ ⎟

⎝ ⎠

( )0

jHW e ω

2Nπ 4

Nπ 6

Nπ2

ω

αN

The Hamming windows

( )( )0

dB

jH

jH

W e

W e

ω

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5-90

-80

-70

-60

-50

-40

-30

-20

-10

0

frecvenţă normată

The Hamming windows

We get a double width main lobe than the rectangular window

8Nπ⎛ ⎞

⎜ ⎟⎝ ⎠

the secondary lobe level is much lower than the rectangular window (–41dB).The resulted filter characteristic will have lower ripples, less than -54dB.

The Blackman window

The amplitude-frequency characteristic will have:– a 3rd time larger main lobe than the rectangular

window characteristic.– the secondary lobes will have an amplitude lower than

–58 dB of the main lobe. – Therefore, the amplitude-frequency characteristic’s

ripples of the filter will be less than –74 dB.

( )

2 1 4 10,42 0,5 cos 0,08 cos ,2 2

0, 1

0, in rest

B

n nN N

w nn N

π π⎧ ⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞− ⋅ + + ⋅ +⎪ ⎜ ⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠⎝ ⎠ ⎝ ⎠⎪= ⎨ ⎡ ⎤∈ −⎪ ⎣ ⎦⎪⎩

Page 8: 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer function: 1 0 () N j jn n H ehneω ω − − = =∑ Also, in order to have a linear

The Bartlett window

( )

2 1 1, 02 2

2 1 12 , 12 2

0 , in rest

BT

Nn nN

Nw n n n NN

⎧ −⎛ ⎞+ ≤ ≤⎜ ⎟⎪ ⎝ ⎠⎪⎪ −⎛ ⎞= − + ≤ ≤ −⎨ ⎜ ⎟

⎝ ⎠⎪⎪⎪⎩

Is a triunghiular window defined by:

The amplitude-frequency characteristic will have– the same main lobe width like the Hamming window – with higher secondary lobes amplitude (–25 dB),– and the filter characteristics ripples of –26 dB.

Fereastra Kaiser

where I0(α) is the modified Bessel function of 0 order.

We have two adjusting parameters, α şi N:– Changing α we can adjust the secondary lobes level

and, therefore the filter characteristics. – Choosing N we can adjust the transition bandwith.

( )( )

2

0

0

2 11 12

, 0, 1

0 , in rest

K

I nN

w n n NI

α

α

⎧ ⎛ ⎞⎛ ⎞⎛ ⎞⎪ ⎜ ⎟− + −⎜ ⎟⎜ ⎟⎪ ⎜ ⎟⎝ ⎠⎝ ⎠⎝ ⎠= ⎨ ⎡ ⎤∈ −⎣ ⎦⎪⎪⎩

2.2.2 Frequency characteristic sampling method

Let it be the desired characteristicand N the desired length for the filter.

( )jdH e ω

( ) ( )k kj jdH e H eω ω= 0,..., 1k N= −

We impose that for N equally spaced frequencies2

k kNπω = 0,..., 1k N= −

the desired characteristic and the designed filter one are equal:

2.2.2 Frequency characteristic sampling method

( )2 21

0

Njk jknN N

dn

H e h n eπ π− −

=

⎛ ⎞= ⋅⎜ ⎟

⎝ ⎠∑ 0,..., 1k N= −

That gives a N equation system

with N unknowns ( ){ } 0, , 1n Nh n

= −

Also, the previous relation is the Discrete Fourier Transform H(k) of the sequence h(n):

( ){ }( ) ( )2

DFTjk

NdH e h n k H k

π⎛ ⎞= =⎜ ⎟

⎝ ⎠0,..., 1k N= −

Page 9: 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer function: 1 0 () N j jn n H ehneω ω − − = =∑ Also, in order to have a linear

2.2.2 Frequency characteristic sampling method

Therefore can be computed from the Inverse transform:

( ){ } 0, , 1n Nh n

= −

( ) ( )2

IDFTjk

Ndh n H e n

π⎧ ⎫⎛ ⎞⎪ ⎪= ⎨ ⎬⎜ ⎟⎪ ⎪⎝ ⎠⎩ ⎭

0,..., 1n N= −

( )2 21

0

1 N jk jknN N

dk

h n H e eN

π π−

=

⎛ ⎞= ⋅⎜ ⎟

⎝ ⎠∑ 0,..., 1n N= −

( ) ( )1

0

Nn

nH z h n z

−−

=

= ⋅∑2 21 1

0 0

1N N jk jkn nN Nd

n kH e e z

N

π π− −−

= =

⎛ ⎞= ⋅ ⋅⎜ ⎟

⎝ ⎠∑ ∑

2.2.2 Frequency characteristic sampling method

( )2 21 1

1

0 0

1n

N Njk jkN N

dk n

H z H e e zN

π π− −−

= =

⎛ ⎞ ⎛ ⎞= ⋅ ⋅⎜ ⎟ ⎜ ⎟

⎝ ⎠ ⎝ ⎠∑ ∑

2

2 21 1

1 1

1 1

jk N N NN

jk jkN N

e z z

e z e z

π

π π

⋅ − −

− −

− ⋅ −= =

− ⋅ − ⋅

( )

2

1

20 1

1

1

jkN

dN N

jkk N

H ezH z

N e z

π

π

− −

= −

⎛ ⎞⎜ ⎟

− ⎝ ⎠= ⋅− ⋅

H(z) function is actually a polynomial in z–1, theexpressions are dividing .

211

jkNe zπ

−− 1 Nz−−

211

0

nN jk

N

ne z

π−−

=

⎛ ⎞⋅⎜ ⎟

⎝ ⎠∑

211

0

nN jk

N

ne z

π−−

=

⎛ ⎞⋅⎜ ⎟

⎝ ⎠∑

2.2.2 Frequency characteristic sampling method

( )jH e ω

( )jdH e ω1

0 1 2 3 4 5 6 7 8 2Nπω ⎛ ⎞×⎜ ⎟

⎝ ⎠

( ) ( )k kj jdH e H eω ω=

2.1.3.2 Metoda eşantionării caracteristicii de frecvenţă

Ondulaţiile pot fi reduse:– acceptând o bandă de tranziţie mai largă,

– sau impunând un număr de eşantionare cu valori intermediare între 0 şi 1 în această bandă,

– sau lăsând neprecizate valorile câtorva eşantioane în zona de tranziţie, gradele de libertate rămase fiind utilizate pentru minimizarea ondulaţiilor.

Page 10: 2. Finite Impulse Response Filters (FIR) 1. The window … standard FIR filter has the transfer function: 1 0 () N j jn n H ehneω ω − − = =∑ Also, in order to have a linear

2.1.3.2 Metoda eşantionării caracteristicii de frecvenţă

În cazul când se doreşte obţinerea unui filtru cu coeficienţi reali , caracteristica impusă trebuie să fie o funcţie circular conjugat simetrică:

( ){ } 0,..., 1n Nh n

= −⊂ R

( )2 2jk j N kN N

d dH e H eπ π

−∗⎛ ⎞ ⎛ ⎞=⎜ ⎟ ⎜ ⎟

⎝ ⎠ ⎝ ⎠

Dacă această condiţie nu este respectată, vor rezulta coeficienţi complecşi.

0,..., 1k N= −