Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 41

CHAPTER 7

Digital Filter Design


Wang Weilian
wlwang@ynu.edu.cn
School of Information Science and Technology
Yunnan University

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 Digital


Filter

FIR Filter Design Based on Windowed Fourier Series

Computer-Aided Design of Digital Filters

Digital Filter Design Using MATLAB

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 ht [n] of the length 2M+1 whose DTFT
j

j
(
)
(
H t e approximates the desired DTFT hd e )

In some sense.
one commonly used approximation criterion is to
minimize the integral-squared error.

FIR Filter Design Based on Windowed


Series
Integral-squared error
1

H t (e

j d
) H d (e )

ht[n] hd [n]

M 1

ht[n] hd[n] h [n] h [n]

n M

2
d

n M 1

The integral-squared error is minimum when ht n


= hd n for M n M .

2
d

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

H (e
LP

1, c ,

0, c .

The corresponding impulse response

LP

[ n]

sin c

so the impulse response is doubly infinite,not absolutely


summable,and therefore unrealizable.

FIR Filter Design Based on Windowed


Series
By setting all impulse response coefficient outside
the range M n M equal to zero,we arrival at a
finite-length noncausal approximation of length

N 2 M 1 ,which when shifted to the right yield

the coeffcients of a causal FIR lowpass filter:

sin( c (n M ))

h n
LP

(n M )
0, otherwise

,0 n N 1

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 an
oscillatory behavior in their respective
magnitude responses.which is more
commonly referred to as the Gibbs
phenomenon.

FIR Filter Design Based on Windowed


Series
Cause of Gibbs phenomenon:
The FIR filter obtained by truncation can be
expressed as:
[ n ] [ n ] [ n ]

H t (e

1
)
2

H d (e ) (e

j ( )

) d

FIR Filter Design Based on Windowed


Series
Illustration of the effect of the windowing in
frequency domain

FIR Filter Design Based on Windowed


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

1,0 n M

[ n]

0, otherwise

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.

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.

FIR Filter Design Based on Windowed


Series
Fixed Window Functions
Hann:

1
2n
w[n] 1 cos(
) , M n M
2
2M 1

Hamming: w[n] 0.54 0.46 cos(

Blackman:

2n
), M n M
2M 1

2n
w[n] 0.42 0.5 cos(
)
2M 1
4n
0.08 cos(
), M n M
2M 1

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

FIR Filter Design Based on Windowed


Series
Designing an FIR filter
(1)select a window above mentioned.
(2)get

h n hd [n] w[n]

(3)determine the cutoff frequency by setting:


c ( p s) / 2

c

M

(4)M is estimated using


,the value
of the constant c is obtain from table given.

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
M
1 1
k
2nk
w[n]
2 T k ( cos
) cos

2M 1
2
M

1
2
M

1
k 1

(2)Kaiser window

(n / M )
I 0
w[n]
, M n M
I 0 ( )
2

FIR Filter Design Based on Windowed


Series
Impulse Response of FIR Filters with a
Smooth 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 .

Computer-Aided Design of Digital


Filter
Two specific design approaches based in iterative
potimization techniques.
The aim is to determine iteratively the coefficients
of the digital transfer function so that the
j
j
difference between H ( ) and D(e ) for all
value of over closed subintervals of0
is minimized ,and usually the difference is
specified as a weighted error function ( )given
by:

( ) W (e ) H (e ) D(e )

Computer-Aided Design of Digital


Filter
Chebyshev criterion
--to minimize the peak absolute value of the
weighted error ( )

max ( )
R

Least-p criterion

--to minimize the integral of pth power of the


weighted error function ( )
K


i 1

W (e

j i

) D(e

j i

Computer-Aided Design of Digital


Filter
Design of Equiripple Linear-Phase FIR Filter
The frequency response of a linear-phase FIR filter
is:

jN / 2

H (e ) e

H ( )

The weighted error function in this case involves


the amplitude response and is given by

( ) W ( ) H ( ) D( )

Computer-Aided Design of Digital


Filter
Type 1 linear-phase FIR filter
The amplitude response is :
N /2
N
N

H ( ) h[ ] 2 h
n cos(n)
2

n 1 2

It can be rewrite using the notation


M

form

N 2M in the

H ( ) a[k ] cos(k )
k 0

Where

a[0] h[ M ], a[k ] 2h[ M k ],1 k M

Computer-Aided Design of Digital


Filter
Type 2 linear-phase FIR filter

The amplitude response is :

H ( ) 2

( N 1) / 2

n 1

1
N 1
h
n cos( (n ))
2
2

It can be rewrite in the form:


( 2 M 1) / 2

1
H ( ) b[k ] cos( (k ))
2
k 0

( 2 M 1) / 2
cos( ) b[k ] cos(k )
2 k 0
Where

2M 1
2M 1
b[k ] 2h[
k ],1 k
2
2

Computer-Aided Design of Digital


Filter
Type 3 linear-phase FIR filter
The amplitude response is :

H ( ) 2 h
n sin(n)

n 1 2
N /2

It can be rewrite in the form:

H ( ) c[ k ] sin(k )
k 0

M 1

sin c( k ) cos(k )
k 0

Computer-Aided Design of Digital


Filter
Type 4 linear-phase FIR filter
The amplitude response is :

H ( ) 2

( N 1) / 2

h[

n 1

N 1
1
n] sin( (n ))
2
2

It can be rewrite in the form:

H ( )

( 2 M 1) / 2

k 1

1
d [k ] sin (k )
2

( 2 M 1) / 2
sin( ) d [k ] cos(k )
2 k 0

Computer-Aided Design of Digital


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

form

H ( ) Q( ) A( )

Then the we modify the form of the weight


approximation function as:

( ) W ( ) Q( ) A( ) D( )
D( )
W ( )Q( ) A( )

Q( w)

Computer-Aided Design of Digital


Filter

Using the notions W ( ) W ( )Q ( ) and

D( ) D( ) / Q ( ) we can rewrite it as:

( ) W ( ) A( ) D( )

Then we determine the coefficients a[k ] to


minimize the peak absolute value
of the
weighted approximation error over the specified
frequency bands
R

Computer-Aided Design of Digital


Filter
Alternation Theorem
The amplitude function A( ) 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

L2

extremal angular frequencies, 0 ,1 , L ,in


a
1
closed subset R of the frequency range 0

and ( ) (
( ) for all i in the range

with

L 1

i 1

0 i L 1

such that

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 .

Digital Filter Design Using Matlab


(2)determine the coefficients of the
transfer 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)

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

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,the
window 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)

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)

Digital Filter Design Using Matlab


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

Gain,dB

-50

-100

-150

-200

0.1

0.2

0.3

0.4

0.5
0.6
\omega/pi\

0.7

0.8

0.9

Digital Filter Design Using Matlab


Gain response of the FIR equiripple bandpass
filter of Example 7.28.
20
0
-20

Gain,dB

-40
-60
-80
-100
-120
-140
-160

0.1

0.2

0.3

0.4

0.5
0.6
\omega/pi\

0.7

0.8

0.9

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.

Digital Filter Design Using Matlab


Window Generation
W=blackman(L)
W=hamming(L)
W=hanning(L)
W=chebwin(L,Rs)
W=kaiser(L,beta)

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,ftypewindow)
b=fir1(,noscale)

Digital Filter Design Using Matlab


A example of a conventional lowpass FIR filter
50
0

Gain,dB

-50
-100
-150
-200
-250
-300

0.1

0.2

0.3

0.4

0.5
0.6
\omega/pi\

0.7

0.8

0.9

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)

Digital Filter Design Using Matlab


A Examples of multilevel filter
--Magnitude response of the multilevel filter
designed
with fir2
1.2
1.1
1

magnitude

0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2

0.1

0.2

0.3

0.4

0.5

/pi

0.6

0.7

0.8

0.9

Digital Filter Design Using Matlab


Least-squares Error FIR Filter Design Using
Matlab
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)

Digital Filter Design Using Matlab


A example of the linear-phase FIR lowpass filter
--Gain response of the linear-phase FIR lowpass
filter
20

0
-20
-40

gain,dB

-60
-80
-100
-120
-140
-160
-180

0.1

0.2

0.3

0.4

0.5
0.6
\omega/pi\

0.7

0.8

0.9

You might also like