CHAPTER 7(7.6,7.7,7.10)

41
CHAPTER 7 Digital Filter Design Wang Weilian [email protected] School of Information Science and Technology  Yunnan University

Transcript of CHAPTER 7(7.6,7.7,7.10)

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 1/41

CHAPTER 7

Digital Filter Design

Wang Weilian

[email protected]

School of Information Science and Technology

 Yunnan University

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 2/41

Outline

•About Digital Filter Design

• Bilinear Transformation Method of IIR Filter Design

• Design of Lowpass IIR Digital Filters

Design of Hignpass, Bandpass, and Bandstop IIR DigitalFilter 

• FIR Filter Design Based on Windowed Fourier Series

• Computer-Aided Design of Digital Filters

• Digital Filter Design Using MATLAB

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 3/41

FIR Filter Design Based on Windowed

Series

• Least Integral-Squared Error Design of FIR Filters

In practical application:the desired frequency

response is piecewise constant with sharp

transitions between bands.

Aim:Find a finite  –duration impulse response

sequence of the length 2M+1 whose DTFT

approximates the desired DTFT

In some sense.

one commonly used approximation criterion is to

minimize the integral-squared error.

)(ehj

 

][nht 

)(e H j

 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 4/41

FIR Filter Design Based on Windowed

Series

Integral-squared error 

The integral-squared error is minimum when

= for .

   

 

 

 d  j

d  j

t  e H e H 

)()(2

2

1

][][

1

21

22

2

][][

][][

nnd t 

d t 

 M n

 M 

n

 M 

 M n

n

hhnhnh

nhnh

nht 

nhd M n M 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 5/41

FIR Filter Design Based on Windowed

Series

•Impulse Response of Ideal Filters

Four commonly used frequency selective filters are the

lowpass,highpass,bandpass,bandstop filters.

• Example:lowpass filter 

zero-phase frequency response

The corresponding impulse response

so the impulse response is doubly infinite,not absolutely

summable,and therefore unrealizable.

.,0

,,1)(

  

 

 

  

c

c j

 LP  e H 

nn c

 LP  H    sin][

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 6/41

FIR Filter Design Based on Windowed

Series

By setting all impulse response coefficient outsidethe range equal to zero,we arrival at a

finite-length noncausal approximation of length

,which when shifted to the right yield

the coeffcients of a causal FIR lowpass filter:

 M n M 

12 M  N 

10,

,0

)(

))(sin(

N n

otherwise

 M n

 M n

n

c

 LP h  

 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 7/41

FIR Filter Design Based on Windowed

Series

• Gibbs phenomenon

The causal FIR filter obtained by simply

truncating the impulse response

coefficients of the ideal filters exhibit anoscillatory behavior in their respective

magnitude responses.which is more

commonly referred to as the Gibbsphenomenon.

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 8/41

FIR Filter Design Based on Windowed

Series

• Cause of Gibbs phenomenon:

The FIR filter obtained by truncation can be

expressed as: ][][][ nnn hh d t  

   

    

 

 d ee H e H 

j j

 j

t )()(

2

1)(

)(

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 9/41

FIR Filter Design Based on Windowed

Series

• Illustration of the effect of the windowing infrequency domain

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 10/41

FIR Filter Design Based on Windowed

Series

The window used to achieve simple truncation of the ideal filter is rectangular window:

So two basic reason of the oscillatory behavior:

(1)the impulse response of a ideal filter is infinitely

long and not absolutely summable.

(2)the rectangular window has an abrupt transition

to zero.

otherwise

 M nn R

,0

0,1][ 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 11/41

FIR Filter Design Based on Windowed

Series

• How to reduce the Gibbs phenomenon?

(1 )using a window that tapers smoothly to

zero at each end.

(2)providing a smooth transition from the

passband to the stopband.

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 12/41

FIR Filter Design Based on Windowed

Series

• Fixed Window Functions

Hann:

Hamming:

Blackman:

 M n M  M 

nnw

,)

12

2cos(1

2

1][

 

 M n M  M nnw

),12

2cos(46.054.0][  

)

12

2cos(5.042.0][

 M 

nnw

 

 M n M  M 

n

),

12

4cos(08.0

 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 13/41

FIR Filter Design Based on Windowed

Series

• Two important parameters:

(1)main lobe width.

(2)relative sidelobe level.

The effect of window function on FIR filter design

(1) the window have a small main lobe width will

ensure a fast transition from the passband to the

stopband.

(2)the area under the sidelobes small will reduce

the ripple

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 14/41

FIR Filter Design Based on Windowed

Series

• Designing an FIR filter 

(1)select a window above mentioned.

(2)get

(3)determine the cutoff frequency by setting:

(4)M is estimated using ,the value

of the constant c is obtain from table given.

][][ nwnnh hd 

2/)(     s pc

 M 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 15/41

FIR Filter Design Based on Windowed

Series

• Adjustable Window Functions

Windows have been developed that provide control

over ripple by means of an additional parameter.

(1)Dolph-Chebyshev window

(2)Kaiser window

 M 

k k   M 

nk 

 M 

 M nw T 

1 12

2cos)

12cos(2

1

12

1][

    

 

 M n M nw I 

 M n I 

,)(

1

][

0

2

0 )/(

  

  

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 16/41

FIR Filter Design Based on Windowed

Series

• Impulse Response of FIR Filters with aSmooth Transition

--One way to reduce the Gibbs phenomenon.

The simplest modification to the zero-phase

lowpass filter specification is to provide a

transition band between the passband and

stopband responses and to connect these

two with a first order spline function .

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 17/41

Computer-Aided Design of Digital

Filter 

•Two specific design approaches based initerative potimization techniques.

The aim is to determine iteratively the coefficients

of the digital transfer function so that the

difference between and for all

value of over closed subintervals of 

is minimized ,and usually the difference is

specified as a weighted error function givenby:

)(e j

 H  

)(e j

 D 

  0 

)(  )()()()( eeej j j

 D H W    

  

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 18/41

Computer-Aided Design of Digital

Filter 

•Chebyshev criterion

--to minimize the peak absolute value of the

weighted error 

• Least-p criterion

--to minimize the integral of pth power of the

weighted error function

)(  

)(max        R

)(  

 K 

i

 p

e DeW  i ji j

1

)()(    

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 19/41

Computer-Aided Design of Digital

Filter 

•Design of Equiripple Linear-Phase FIR Filter 

The frequency response of a linear-phase FIR filter 

is:

The weighted error function in this case involves

the amplitude response and is given by

)()(

2/

 

    

H  H  eee

j jN  j

)()()()(       D H W 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 20/41

Computer-Aided Design of Digital

Filter 

•Type 1 linear-phase FIR filter 

The amplitude response is :

It can be rewrite using the notation in the

form

Where

)cos(

2

2]

2

[)(2/

1

nn N h

 N h H 

 N 

n

  

 M  N  2

 M 

k k k a H 

0)cos(][)(   

 M k k  M hk a M ha 1],[2][],[]0[

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 21/41

Computer-Aided Design of Digital

Filter 

Type 2 linear-phase FIR filter 

The amplitude response is :

It can be rewrite in the form:

Where 

))2

1(cos(

2

12)(

2/)1(

1

nn N 

h H  N 

n

  

2

121],

2

12[2][

M k k 

 M hk b

)cos(][)2

cos(

))2

1(cos(][)(

2/)12(

0

2/)12(

0

k k b

k k b H 

 M 

 M 

  

  

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 22/41

Computer-Aided Design of Digital

Filter 

•Type 3 linear-phase FIR filter 

The amplitude response is :

It can be rewrite in the form:

)sin(22)(

2/

1nn

 N 

h H 

 N 

n  

)cos()(sin

)sin(][)(

1

0

0

k k c

k k c H 

 M 

 M 

  

  

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 23/41

Computer-Aided Design of Digital

Filter 

•Type 4 linear-phase FIR filter 

The amplitude response is :

It can be rewrite in the form:

))2

1(sin(]

2

1[2)(

2/)1(

1

nn N 

h H  N 

n

  

)cos(][)2

sin(

)2

1(sin][)(

2/)12(

0

2/)12(

1

k k d 

k k d  H 

 M 

 M 

  

  

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 24/41

Computer-Aided Design of Digital

Filter 

•The amplitude response for all four types of linear-phase FIR filters can be expressed in the

form

• Then the we modify the form of the weight

approximation function as:

)()()(     AQ H 

)()()()()(

)()()()()(

wQ D AQW 

 D AQW 

    

      

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 25/41

Computer-Aided Design of Digital

Filter 

Using the notions and

we can rewrite it as:

Then we determine the coefficients to

minimize the peak absolute value of the

weighted approximation error over the specifiedfrequency bands

)()()(     QW W 

)(/)()(     Q D D

)()()()(       D AW 

 ][k a

 R 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 26/41

Computer-Aided Design of Digital

Filter 

•Alternation Theorem

The amplitude function is the best unique

aproximation of the desired amplitude response

obtained by minimizing the peak absolute valu

of if and only if there exist at least

extremal angular frequencies, ,in a

closed subset R of the frequency range

such that and

with for all in the range

)(  A

)(    2 L

    110,,

 L

  0    110

 L )()(

1     

ii

    )(i i 10 Li

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 27/41

Digital Filter Design Using Matlab

•IIR Digital Filter Design Using Matlab

• Steps:(1)determine the filter order N and

the frequency scaling factor Wn .

[N,Wn]=buttord(Wp,Ws,Rp,Rs)

[N,Wn]=cheb1ord(Wp,Ws,Rp,Rs)

[N,Wn]=cheb2ord(Wp,Ws,Rp,Rs)[N,Wn]=ellipord(Wp,Ws,Rp,Rs)

Where Wp=2Fp/FT and Ws= 2Fs/FT .

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 28/41

Digital Filter Design Using Matlab

• (2)determine the coefficients of thetransfer function.

[b,a]=butter(N,Wn)

[b,a]=cheby1(N,Rp,Wn)

[b,a]=cheby2(N,Rs,Wn)

[b,a]=ellip(N,Rp,Rs,Wn)

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 29/41

Digital Filter Design Using Matlab

•FIR Digital Filter Design Using Matlab

• Steps(1).estimate the filter order from the given

specification.

remezord ,kaiserord

• (2)determine the coefficient of the transfer 

function using the estimated order and the filter 

specification.

remez

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 30/41

Digital Filter Design Using Matlab

FIR Digital Filter Order Estimation Using Matlab[N,fpts,mag,wt]=remezord(fedge,mval,dev)

[N,fpts,mag,wt]=remezord(fedge,mval,dev,FT)

For FIR filter design using the Kaiser window,thewindow order should be estimated using

kaiserord

[N,Wn,beta,ftype]=kaiserord(fedge,mval,dev)

[N,Wn,beta,ftype]=kaiserord(fedge,mval,dev,FT)

C=kaiserord(fpts,mval,dev,FT,’cell’) 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 31/41

Digital Filter Design Using Matlab

•Equiripple Linear-phase FIR Design Using Matlab

--emplying the Parks-McClellan algorithm.

b=remez(N,fpts,mag)

b=remez(N,fpts,mag,wt)

b=remez(N,fpts,mag,’ftype’) 

b=remez(N,fpts,mag,wt,’ftype’) 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 32/41

Digital Filter Design Using Matlab

•FIR equiripple lowpass filter of Example 7.27 for N=28

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

-200

-150

-100

-50

0

50

 \omega/pi\ 

     G    a     i    n ,     d

     B

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 33/41

Digital Filter Design Using Matlab

Gain response of the FIR equiripple bandpassfilter of Example 7.28.

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 34/41

Digital Filter Design Using Matlab

Window-based FIR Filter Design Using Matlab

• Steps:

(1)estimate the order of the FIR filter.

(2)select the type of the window and compute its

coefficient.

(3)compute the desired impluse response of the

ideal filter.

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 35/41

Digital Filter Design Using Matlab

Window Generation

W=blackman(L)

W=hamming(L)

W=hanning(L)

W=chebwin(L,Rs)

W=kaiser(L,beta)

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 36/41

Digital Filter Design Using Matlab

• Filter Design

fir1 is used to design conventional lowpass,highpass,

bandpass,bandstop and multiband FIR filter.

b=fir1(N,Wn)

b=fir1(N,Wn,’ftype’) 

b=fir1(N,Wn,window)

b=fir1(N,Wn,’ftype’window) 

b=fir1(……,’noscale’) 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 37/41

Digital Filter Design Using Matlab

A example of a conventional lowpass FIR filter 

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

-300

-250

-200

-150

-100

-50

0

50

 \omega/pi\ 

     G    a     i    n ,     d

     B

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 38/41

Digital Filter Design Using Matlab

Filter Design

fir2 is employed to design FIR filters with arbitarily

shaped magnitude response.

b=fir2(N,f,m)

b=fir2(N,f,m,window)

b=fir2(N,f,m,npt)

b=fir2(N,f,m,npt,window)

b=fir2(N,f,m,npt,lap,window)

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 39/41

Digital Filter Design Using Matlab

A Examples of multilevel filter 

--Magnitude response of the multilevel filter 

designed with fir2

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

1.1

1.2

 /pi

    m    a    g    n     i     t    u     d    e

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 40/41

Digital Filter Design Using Matlab

Least-squares Error FIR Filter Design UsingMatlab

firls  –to design any type of multiband linear-phase

FIR filter based on the least-squares method

b=firls(N,fpts,mag)

b=firls(N,fpts,mag,wt)

b=firls(N,fpts,mag,’ftype’) 

b=firls(N,fpts,mag,wt,’ftype’) 

7/28/2019 CHAPTER 7 7.6 7.7 7.10

http://slidepdf.com/reader/full/chapter-77677710 41/41

Digital Filter Design Using Matlab

A example of the linear-phase FIR lowpass filter 

--Gain response of the linear-phase FIR lowpass

filter 

0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 1

-180

-160

-140

-120

-100

-80

-60

-40

-20

0

20

    g    a     i    n ,     d

     B