Dsp-unit 6.2 Window Based Fir Filters

Preview:

DESCRIPTION

fir filters

Citation preview

UNIT VI: FIR DIGITAL FILTERS

Contents 1. Introduction 2. Characteristics of FIR Digital Filters

1. Frequency Response 3. Design of FIR Digital filters using

1. Fourier series method 2. Windowing technique3. Frequency sampling technique4. Design examples

4. Comparison of IIR and FIR filters

Linear-Phase FIR Digital Filter Design

3.1:Fourier series Method (becomes part of windowing) 3.2:Windowing Method

3.3:Frequency sampling Method

3.1: Fourier series Method

• The desired frequency response Hd(ejω) of a system is periodic in 2π. From the Fourier series analysis we know that any periodic function can be expressed as a linear combination of complex exponentials.

• Therefore the desired frequency response of an FIR filter can be represented by the Fourier series

)1(][)(1

0

N

n

njd

jd enheH

3.1:Fourier series Method

• Where the frequency coefficients hd(n) are the desired impulse response sequence of the filter.

• The Z-transform of the sequence is given by

• Equ.3 represents a non-causal digital filter of infinite duration.

)2()(2

1][

deeHnh njjdd

)3(][)(

n

nd znhzH

3.1:Fourier series Method

• To get an FIR filter transfer function the series can be truncated by assigning

• Then

)4(0

][][ 2

1

otherwise

nfornhnh

Nd

21

212

1

21

212

122

1

...]2[]1[]0[

]1[]2[...][)(

N

N

N

N

zhzhzhh

zhzhzhznhzH

N

Nn

n

)5(][][]0[)(2

1

1

N

n

nn znhznhhzH

3.1:Fourier series Method

• For a symmetrical impulse response having symmetry at n=0

h[-n]= h[n]• Therefore the equ.5 can be written as n

• The above T.F is not physically realizable.• The realizability can be brought by multiplying

the equ.7 with • Where (N-1)/2 is delay in samples.

)7(][]0[)(2

1

1

N

n

nn zznhhzH

21 N

z

3.1: Fourier series Method

• From the equ.8 the causality was brought by multiplying the T.F with the delay factor.

• This modification does not effect the amplitude response of the filter.

• However the abrupt truncation of Fourier series results in oscillations in the pass band and stop band.

)8(][]0[)()(2

1

21

21

1

'

N

NN

n

nn zznhhzzHzzH

3.1: Fourier series Method

Gibbs phenomenon: As M increases, the maximum deviation from the ideal value decreases except near the point of discontinuity, where the error remains the same, however large the value M we choose. (i.e., as M increases, the maximum amplitude of the oscillation does not approach zero)

This oscillation are due to slow conversion of the Fourier series particularly near the points of discontinuity. This effect is known as “Gibb’s phenomenon”.

To reduce these oscillations, the Fourier coefficients of the filter are modified by multiplying the infinite impulse response with a finite weighting sequence w[n] called as

window and that technique called as windowing method.

3.1: Fourier series Method

Where

2

10

2

10

][][N

nfor

Nnfor

nwnw

2

10

2

1][][

][N

nfor

Nnfornwnh

nhd

After multiplying window w[n] with hd[n], we get a finite duration sequence h[n] that satisfies the desired magnitude response

3.2: Windowing Method

The frequency response H(ejω) of the filter can be obtained by convolution of Hd(ejω) and W(ejω) given by

)(*)()()(2

1)( )(

jjd

jjd

j eWeHdeWeHeH

Because both Hd(ejω) and W(ejω) are periodic functions, the operation often called as periodic convolution.

3.2: Windowing Method

• The transform of a window consists of central lobe and side lobes.

• The central lobe contains most of the energy of the window.

• To get an FIR filter, the sequence hd[n] is w[n] are multiplied and a finite length of non-causal sequence h[n] is obtained.

3.2: Windowing Method

Illustration of type of approximation obtained at a discontinuity of the ideal frequency response.

3.2: Windowing Method

• Therefore the window chosen for truncating the infinite impulse response should have some desirable characteristics.

3.2: Windowing Method

• From H(ejω) equ we find that the frequency response of the filter Hd(ejω) depends on the frequency response of window W(ejω).

•The realizable sequence g[n] is obtained by

shifting h[n] by α=(N-1)/2 number of samples.

1. The central lobe of the frequency response of the window should contain most of the energy and should be narrow.

3. The side lobes of the frequency response should decrease in energy rapidly as ω tends to π.

3.2: Windowing Method

2. The highest side lobe level of the frequency response should be small.

Desirable characteristics of Window W(ejω)

FIR Digital Filter SpecificationsFIR Digital Filter Specifications• Only the magnitude approximation problem• Four basic types of ideal filters with magnitude

responses as shown below (Piecewise flat)

1

0 c –c

HLP(e j)

0 c –c

1

HHP (e j)

11–

–c1 c1 –c2 c2

HBP (e j)

1

–c1 c1 –c2 c2

HBS(e j)

1

0 c –c

HLP(e j)

Filter Coefficients of FIR filters Ideal Low pass filter

Filter Coefficients of FIR filters Ideal Low pass filter

c

c

dedeeHnh njnjjdd

2

1)(

2

1][

j

ee

njn

ee

jn

enh

ccccc

c

jnjnjnjnnj

d 2

1

2

1

2

1][

n

nnh c

d

)sin(][

0 c – c

1

H HP ( e j )

Filter Coefficients of FIR filters Ideal High pass filter

Filter Coefficients of FIR filters Ideal High pass filter

c

c

dededeeHnh njnjnjjdd 2

1)(

2

1][

jn

eeee

jn

e

jn

enh

cc

c

c jnjnjnjnnjnj

d

2

1

2

1][

)sin()sin(1

][ cd nnn

nh

j

ee

j

ee

nnh

cc jnjnjnjn

d 22

1][

11–

–c1 c1 –c2 c2

HBP (e j)

Filter Coefficients of FIR filters Ideal Band pass filter

Filter Coefficients of FIR filters Ideal Band pass filter

2

1

1

22

1)(

2

1][

c

c

c

c

dededeeHnh njnjnjjdd

jn

eeee

jn

e

jn

enh

ccccc

c

c

c

jnjnjnjnnjnj

d

12212

1

1

22

1

2

1][

)sin()sin(1

][ 12 ccd nnn

nh

j

ee

j

ee

nnh

cccc jnjnjnjn

d 22

1][

1122

1

–c1 c1 –c2 c2

HBS(e j)

Filter Coefficients of FIR filters Ideal Band stop filter

Filter Coefficients of FIR filters Ideal Band stop filter

1

1 1

2

2

1)(

2

1][

c

c c

c

dedededeeHnh njnjnjnjjdd

2

1

1

2

2

1][

c

c

c

c

jn

e

jn

e

jn

enh

njnjnj

d

)sin()sin(sin(1

][ 12 ccd nnnn

nh

j

ee

j

ee

j

ee

nnh

cccc jnjnjnjnjnjn

d 222

1][

2211

jn

eeeeeenh

cccc jnjnjnjnjnjn

d

2112

2

1][

Filter Coefficients of FIR filters

Type Zero phase hd[n] Linear phase hd[n]Low Pass

High Pass

cdh 1]0[

0)sin(

][ nforn

nnh c

d c

dh ]0[

nfornh cd ][

nforn

nnh c

d )(

)sin(][

0

)sin()sin(][

nfor

n

nnnh c

d

nfornh cd 1][

nfor

n

nnnh c

d )(

)sin()sin(][

2

1N

factorDelay

Type Zero phase hd[n] Linear phase hd[n]Band Pass

Band Stop

12]0[ cc

dh

121]0[ cc

dh

0

)sin()sin(][ 12

nfor

n

nnnh cc

d

0

)sin()sin(sin(][ 12

nforn

nnnnh cc

d

nfornh ccd

12][

nfor

n

nnnh cc

d )(

)sin()sin(][ 12

nfornh ccd

121][

nfor

n

nnnnh cc

d )(

)sin()sin()sin(][ 12

Filter Coefficients of FIR filters

Rectangular Window

otherwise

Nnfor

nwR0

2

11

][

2

2

sin

sin)(

Nj

R eW

2

1

21

)(N

Nn

njjR eeW

Rectangular Window

21

21

...1...

NN jjjj eeee

)1(...121 Njjj eee

N

j

Njj

e

ee

N

1

12

1

•Spectrum of the rectangular window is given by

j

Nj

j

j

e

e

e

eN

1

12

2

22

22

jj

jj

ee

eeNN

Rectangular Window•The freq res is real and its zero occur when Nω/2=kлor ω=2kл/N

•The response for ω between 2π/N and -2π/N is called the MAIN LOBE and other lobes are known as SIDE LOBES.•The main lobe of the response is the portion that lies between the first two zero crossings. The side lobes are defined as the portion of the response for ω<-2π/N or ω>2π/N.

•As the window is made longer the main lobe becomes narrower and higher and side lobes becomes more concentrated around ω=0.•The main lobe width for the rectangular window is equal to 4π/N and the highest side lobe level is equal to approximately 22% main lobe amplitude or -13dB relative to the maximum value at ω=0.

•Frequency response & •log magnitude spectrum

for N=25

•Frequency response & •log magnitude spectrum

for N=51

•Frequency response of LPF

using Rectangular

Window for N=25

•Log magnitude response of LPF

using Rectangular

Window for N=25

Rectangular Window•As the desired response Hd(ejω) is of infinte Fourier coefficients. To get a finite impulse response filter we multiply hd[n] with a rectangular window .i.e.

•The frequency response of the truncated filter can be obtained by periodic convolution.

•We find that the frequency response differs from the desired response.

][][][ nwnhnh Rd

)(*)()()(2

1)( )(

jR

jd

jR

jd

j eWeHdeWeHeH

•The desired response of a LPF changes abruptly from pass band to stop band, but the frequency response changes slowly. This region of gradual change is called filter’s transition region, which is due to the convolution of the desired response with the window responses main lobe.

Rectangular Window•The width of the transition region depends on the width of the main lobe. As the filter length N increases , the main lobe becomes narrower decreasing the width of transition region.

•The convolution of the desired response and the window responses side lobes gives rise to the ripples in both pass band and stop band.

•The amplitude of the ripples is determined by the amplitudes of the side lobes and is un effected by the length of the window. So, increase in length N will not reduce the ripples, but increase it’s frequency.

•J.W.Gibbs showed that a finite length low pass filter will posses an 8.9% maximum ripple no matter how long the filter is made..

Rectangular Window

• Main Lobe Width:• Sidelobe Magnitude= -13 db• Stopband Attenuation=-21db

2

2

sin

sin)(

21

21

N

n

njjR

N

N

eeW

N

4

Rectangular Window

N=50

Rectangular Window•This effect where maximum ripple occurs just before and after the transition band is known as Gibbs phenomenon.

•The Gibbs phenomenon can be reduced by using a less abrupt truncation of filter coefficients.

•This can be achieved by using a window function that tapers smoothly towards zero at both ends.

•One such type of window is Triangular or Bartlett window.

Triangular or Bartlett Window

otherwise

Nnfor

N

n

nwT0

2

1

1

21

][

•The Fourier transform of the Triangular window is Triangular or Bartlett Window

2

41

2sin

sin)(

Nj

T eW

•The side lobe level is smaller than that of rectangular being reduced from -13dB to -25dB. However, the main lobe width is now 8л/N or twice that of the rectangular window.

Triangular or Bartlett Window

•We can find that triangular window produces a smooth magnitude response in both pass band and stop band. But it has the following disadvantages compared with rectangular window

1.The transition region is more

2.The attenuation in stop band is less.

•Because of these characteristics, the triangular window is not usually a good choice.

Raised Cosine Window

2

1

21

122

1

21

122

1

21

21

21

N

N

N

N

N

N

N

N n

nj

n

nj

n

nj eee

otherwise

Nnfor

nw Nn

0

2

1cos]1[

][ 12

21

21

12cos]1[)(

N

Nn

njNnj eeW

CBA

•The frequency response of is given by][nw

21

21

...1...

NN jjjj eeeeA

)1(...121 Njjj eee

N

j

Njj

e

ee

N

1

12

1

j

Nj

j

j

e

e

e

eN

1

12

2

22

22

jj

jj

ee

eeNN

Raised Cosine Window

2

2

sin

sin

N

A

21

12

12

12

21

12

...1...21

NNNN

NN jjjj eeeeB

12

12

21

12

1

12

1

N

NN

N

j

Njj

e

ee

1212

1212

21

NN

NNN

NNN

jj

jj

ee

ee

•Similarly

12

122

1

sin

sin

N

NNN

12

12

12

12

1

12

1

NN

NNNN

jj

Njj

ee

ee

Raised Cosine Window

12

122

1

sin

sin

N

NNN

B

12

122

1

sin

sin

N

NNN

C

In wα[n] substitution of

α=0.5 results in Hanning window

α=0.54 results in Hamming window

Raised Cosine Window

12

122

1

12

122

1

2

2

sin

sin

sin

sin

sin

sin)(

N

NNN

N

NNNN

jeW

otherwise

Nnfor

nw Nn

0

2

1cos]1[

][ 12

Hanning Window

12

12

12

12

2

2

sin

sin25.0

sin

sin25.0

sin

sin5.0)(

N

NNN

N

NNNN

jHn eW

otherwise

Nnfor

nw Nn

Hn

0

2

1cos5.05.0

][ 12

Hanning Window

Hanning Window

Hanning Window

•The main lobe width is twice that of the rectangular window, which results in doubling of the transition region of the filter.

•The peak side lobe ripple is -44dB relative to the main lobe. At high frequencies the stop band attenuation is even greater.

Hanning Window

• The magnitude of the sidelobe level is -31dB, Which is 18dB lower over that of rectangular spectral window.

Hamming Window

12

12

12

12

2

2

sin

sin23.0

sin

sin23.0

sin

sin54.0)(

N

NNN

N

NNNN

jH eW

otherwise

Nnfor

nw Nn

H

0

2

1cos46.054.0

][ 12

Hamming Window

Hamming Window

Hamming Window

•The main lobe width is twice that of the rectangular window, which results in doubling of the transition region of the filter.

•The first sidelobe peak is -53dB, an improvement of 9dB with respect to Hanning window filter. However at high frequencies the stop band attenuation is lower when compared to that of Hanning window.

Hamming Window• The peak sidelobe level is down at about 41dB from the main lobe peak, an improvement of 10dB relative to the Hanning window.

•Because the Hamming window generates less oscillation in the sidelobes than the Hanning window, for the same mainlobe width, the Hamming window is generally preferred.

Blackman Window

otherwise

Nnfor

nw Nn

Nn

B

0

2

1cos08.0cos5.042.0

][ 14

12

Blackman Window

Blackman Window

Blackman Window

•The peak sidelobe level is down about 57dB from mainlobe peak, an improvement of 16dB relative the Hamming window.

•The sidelobe attenuation of a lowpass filter using Blackman window is -74dB.

• The additional cosine term compared with Hanning and Hamming window reduce the sidelobes, but increases the mainlobe width to 12л/N.

Blackman Window

Bartlett

Hanning

Hamming

Blackman

Hamming

Hanning

Window Based Design

1. Compute

2. Compute and select window type

3. Choose N, the filter order, to meet transition width

4. Compute filter coefficients hd[n] and window coefficients w[n]

Given specifications: p ,, 21 and sEmploy the following procedure

sp

),min( 21

10log20

5. Compute the modified impulse response using

][][][ nhnwnh d

2

1

21

1

][2]0[)(N

N

n

nn zznhhzzH

6. The Transfer function of FIR digital filter is given by

Window Based Design

Pros and Cons of Window based Design

• Advantages– Easy to design– Can be applied to general linear system

design

• Disadvantages– Exceeds the specs everywhere except at

the edges of the passband and stopband– and cannot be independently

controlled. Have to design more conservatively for the smaller of the two

1 2

Window Type

Peak Sidelobe Amplitude

(relative)

(dB)

Approximate Width of Mainlobe

Peak Approximation Error 20 logδ

(dB)

Equivalent Kaiser

Windows

β

Transition Width of

Equivalent Kaiser

Window

Rectangular -13 -21 0

Bartlett -25 -25 1.33

Hanning -31 -44 3.86

Hamming -41 -53 4.86

Blackman -57 -74 7.04

N4

N8

N8

N8

N12

N81.1

N37.2

N01.5

N27.6

N19.9

Summary of WindowsSummary of Windows

Example.1Design an ideal high

pass filter with a frequency response

otherwise

Nnfor

nw Nn

Hn

0

2

1cos5.05.0

][ 12

4

45

0)(

for

foreeH

jj

d

Find the values of h[n] for N=11, using

a) Hanning window b) Hamming window

Solution: The freq Res is having a term ejω(N-1)/2 which gives h[n] symmetry about (N-1)/2=5 .i.e. we get a causal sequence. N=11

a) Hanning window

Example.1 Cont..d

With N=11

9045.0cos5.05.0]1[]1[

15.05.0]0[

5

HnHn

Hn

ww

w

otherwise

nfornw

n

Hn0

5cos5.05.0][ 5

345.0cos5.05.0]3[]3[

655.0cos5.05.0]2[]2[

53

52

HnHn

HnHn

ww

ww

0cos5.05.0]5[]5[

0945.0cos5.05.0]4[]4[

55

54

HnHn

HnHn

ww

ww

Example.1 Cont..dThe filter coefficient equation is

4

4

2

1)(

2

1][ dededeeHnh njnjnjj

dd

jn

eeee

jn

e

jn

enh

jnjnjnjnnjnj

d

44

4

4

2

1

2

1][

)sin()sin(1

][ 4

nn

nnhd

j

ee

j

ee

nnh

jnjnjnjn

d 22

1][

44

41]0[ dh

Example.1 Cont..dThe desired filter coefficients are

75.011]0[ 414

dh

159.0)sin()2sin(2

1]2[]2[ 4

2 dd hh

045.0)sin()5sin(5

1]5[]5[ 4

5 dd hh

225.0)sin()sin(1

]1[]1[ 4 dd hh

075.0)sin()3sin(3

1]3[]3[ 4

3 dd hh

0)sin()4sin(4

1]4[]4[ 4

4 dd hh

Example.1 Cont..dThe filter coefficients using Hanning window are

204.0)9045.0)(225.0(]1[]1[]1[]1[ Hnd whhh

75.0)1)(75.0(]0[]0[]0[ Hnd whh

104.0)655.0)(159.0(]2[]2[]2[]2[ Hnd whhh

0)0)(045.0(]5[]5[]5[]5[ Hnd whhh

026.0)345.0)(015.0(]3[]3[]3[]3[ Hnd whhh

0)0945.0)(0(]4[]4[]4[]4[ Hnd whhh

][][][ nwnhnh Hnd

Example.1 Cont..d

The transfer function of the filter is given by

5

1

][75.0)(n

nn zznhzH

332211 026.0104.0204.075.0)( zzzzzzzH

8765

4325'

026.0104.0204.075.0

204.0104.0026.0)()(

zzzz

zzzzHzzH

The transfer function of the realizable filter is given by

Example.1 Cont..dThe causal filter coefficients using Hanning window are

026.0]8[]2[ hh

75.0]5[ h

104.0]7[]3[ hh

0]10[]9[]1[]0[ hhhh

204.0]6[]4[ hh

21

12cos46.054.0][ N

Nn

H nfornw b) Hamming window

Example.1 Cont..d

912.0cos46.054.0]1[]1[

146.054.0]0[

5

HH

H

ww

w

398.0cos46.054.0]3[]3[

682.0cos46.054.0]2[]2[

53

52

HH

HH

ww

ww

08.0cos46.054.0]5[]5[

1678.0cos46.054.0]4[]4[

55

54

HH

HH

ww

ww

Example.1 Cont..dThe filter coefficients using Hamming window are

2052.0)912.0)(225.0(]1[]1[]1[]1[ Hd whhh

75.0)1)(75.0(]0[]0[]0[ Hd whh

1084.0)682.0)(159.0(]2[]2[]2[]2[ Hd whhh

0036.0)08.0)(045.0(]5[]5[]5[]5[ Hd whhh

03.0)398.0)(015.0(]3[]3[]3[]3[ Hd whhh

0)1678.0)(0(]4[]4[]4[]4[ Hd whhh

][][][ nwnhnh Hd

Example.1 Cont..d

The transfer function of the filter is given by

5

1

][75.0)(n

nn zznhzH

5533

2211

0036.003.0

1084.02052.075.0)(

zzzz

zzzzzH

108765

4325'

0036.003.01084.02052.075.0

2052.01084.003.00036.0)()(

zzzzz

zzzzHzzH

The transfer function of the realizable filter is given by

Example.1 Cont..dThe causal filter coefficients using Hamming window are

03.0]8[]2[ hh

75.0]5[ h

1084.0]7[]3[ hh

0036.0]10[]0[ hh

2052.0]6[]4[ hh

0]9[]1[ hh

•The mainlobe width is inversely proportional to N. An increase in window length decreases the transition band of the filter.

•However, the minimum stopband attenuation is independent of N and is a function of the selected window.

• From comparison of window parameters, we can find that a trade-off exists between the mainlobe width and the sidelobe amplitude.

Kaiser Window

•To overcome this problem Kaiser has chosen a class of windows based on the prolate spheroidal functions.

•These functions have the property that they are limited as much as possible in both time and frequency domains.

• In this process the designer may often have to settle for a window with undesirable design specifications

Kaiser Window•Thus in order to achieve prescribed minimum stop Band attenuation and pass band ripple, the designer must find a window with an appropriate sidelobe level and then choose N to achieve prescribed transition width.

Kaiser Window

• is zeroth order modified Bessel function of the First Kind

otherwise

nI

Inw NN

n

k

0

,)(

1][ 2

12

1

0

20

2

00 2!

1)(

k

kx

kxI

(.)0I

• controls sidelobe level (Stopband Attenuation)

• The filter order N controls the Mainlobe width.

Kaiser Window based design

1. Determine hd[n] using Fourier series method for an ideal frequency response.

psB 1

11010 log20log20 ps and

psc 21

2. Choose and determine),min( 21

3. Determine LPF

spB psc 21

HPF

2211 ,min psspB

222211 , Bpc

Bpc

BPF

2211 ,min sppsB

222211 , Bpc

Bpc

BSF

Kaiser Window based design

4. Choose parameter β from the following equation

50)7.8(1102.0

5021)21(07886.0)21(5842.0

2104.0

ss

sss

s

for

for

for

2136.14

95.7219222.0

ss

s

for

forD

5. Choose parameter D from the following equation

Kaiser Window based design

6. Choose filter order for the lowest odd value of N

1B

DN sf

otherwise

nI

Inw NN

n

k

0

,)(

1][ 2

12

1

0

20

7. Compute the window sequence using

Kaiser Window based design

8. Compute the modified impulse response using

][][][ nhnwnh dk

2

1

21

1

][2]0[)(N

N

n

nn zznhhzzH

9. The Transfer function of FIR digital filter is given by

Kaiser Window based design

Comparison between FIR and IIR Digital Filter

Comparison between FIR and IIR Digital Filter

S No FIR filter IIR filter

1 The impulse response of this filter is restricted to finite number of samples.

The impulse response of this filter extends over an infinite duration

2 FIR filters can have precisely linear phase

IIR filters do not have linear phase

3 Closed form design equations do not exist.

A variety of frequency selective filters can be designed using closed form design formulas.

Comparison between FIR and IIR Digital Filter

S No FIR filter IIR filter

4 Most of the design methods are iterative procedures, requiring powerful computational facilities for their implementation

These can be designed using only a hand calculator and tables of Analog filter design parameters.

5 Greater flexibility to control the shape of their magnitude response.

Less flexibility specially for obtaining non-standard frequency response.

Comparison between FIR and IIR Digital Filter

S No FIR filter IIR filter

6 In this filters, the poles are fixed at the origin, high selectivity can be achieved by using a relatively high order for the transfer function

The poles are placed anywhere inside the unit circle, high selectivity can be achieved with low-order transfer function

7 Always stable. Not always stable.

8 Errors due to round off noise are less severe.

Errors due to round off are more severe.

Recommended