DSP & Digital Filters

Download Report

Transcript DSP & Digital Filters

Digital Filter Specifications
• We discuss in this course only the magnitude
approximation problem
• There are four basic types of ideal filters with
magnitude responses as shown below
1
Professor A G Constantinides
Digital Filter Specifications
• These filters are unealizable because their
impulse responses infinitely long noncausal
• In practice the magnitude response
specifications of a digital filter in the
passband and in the stopband are given with
some acceptable tolerances
• In addition, a transition band is specified
between the passband and stopband
2
Professor A G Constantinides
Digital Filter Specifications
j
• For example the magnitude response G (e )
of a digital lowpass filter may be given as
indicated below
3
Professor A G Constantinides
Digital Filter Specifications
• In the passband 0     p we require that
G (e j )  1 with a deviation   p
1   p  G (e j )  1   p ,    p
• In the stopband  s     we require that
G (e j )  0 with a deviation  s
G (e j )   s ,
4
s    
Professor A G Constantinides
Digital Filter Specifications
•
•
•
•
5
p
s
p
s
Filter specification parameters
- passband edge frequency
- stopband edge frequency
- peak ripple value in the passband
- peak ripple value in the stopband
Professor A G Constantinides
Digital Filter Specifications
• Practical specifications are often given in
terms of loss function (in dB)
j
G
(

)


20
log
G
(
e
)
10
•
• Peak passband ripple
 p   20 log10 (1   p ) dB
• Minimum stopband attenuation
 s   20 log10 ( s ) dB
6
Professor A G Constantinides
Digital Filter Specifications
• In practice, passband edge frequency Fp
and stopband edge frequency Fs are
specified in Hz
• For digital filter design, normalized
bandedge frequencies need to be computed
from specifications in Hz using
 p 2 Fp
p 

 2 FpT
FT
FT
 s 2 Fs
s 

 2 Fs T
FT
FT
7
Professor A G Constantinides
Digital Filter Specifications
• Example - Let Fp  7 kHz, Fs  3 kHz, and
FT  25 kHz
• Then
2 (7 103 )
p 
 0.56
3
25 10
2 (3 103 )
s 
 0.24
3
25 10
8
Professor A G Constantinides
Selection of Filter Type
• The transfer function H(z) meeting the
specifications must be a causal transfer
function
• For IIR real digital filter the transfer z 1
function is a realrational
1
 2function of  M
p0  p1z  p2 z    pM z
H ( z) 
d0  d1z 1  d 2 z 2    d N z  N
• H(z) must be stable and of lowest order N
for reduced computational complexity
9
Professor A G Constantinides
Selection of Filter Type
• For FIR real digital filter the transfer
function is a polynomial in z 1 with real
coefficients
N
H ( z )   h[n] z
n
n 0
• For reduced computational complexity,
degree N of H(z) must be as small as
possible
• If a linear phase is desired, the filter
coefficients must satisfy the constraint:
h[n]   h[ N  n] Professor A G Constantinides
10
Selection of Filter Type
11
• Advantages in using an FIR filter (1) Can be designed with exact linear phase,
(2) Filter structure always stable with
quantised coefficients
• Disadvantages in using an FIR filter - Order
of an FIR filter, in most cases, is
considerably higher than the order of an
equivalent IIR filter meeting the same
specifications, and FIR filter has thus higher
computational complexity
Professor A G Constantinides
FIR Design
FIR Digital Filter Design
Three commonly used approaches to FIR
filter design (1) Windowed Fourier series approach
(2) Frequency sampling approach
(3) Computer-based optimization methods
12
Professor A G Constantinides
Finite Impulse Response
Filters
• The transfer function is given by
N 1
H ( z )   h(n).z n
n 0
• The length of Impulse Response is N
• All poles are at z  0 .
• Zeros can be placed anywhere on the zplane
13
Professor A G Constantinides
FIR: Linear phase
• Linear Phase: The impulse response is
required to be h(n)  h( N  1  n)
• so that for N even:
N 1
2
H ( z )   h(n).z
n
n 0
N 1
2
  h(n).z
14
n 0
N 1
2
n
N 1
  h(n).z n
n N
N 1
2
2
  h( N  1  n).z
( N 1 n )
n 0

  h( n) z
n
z
m

mN
Professor A G Constantinides
FIR: Linear phase
• for N odd:
N 1
1
2

H ( z )   h(n). z
n 0
• I) On
C : z 1
+ve sign
H (e
15
j T
)e
n
z
m

N  1

 h
z
 2 
N 1 


 2 
we have for N even, and
N 1  N 1
 jT 
 2
2


N  1 
 
.  2h(n).cos T  n 

2 
n 0
 AG Constantinides
Professor
FIR: Linear phase
• II) While for –ve sign
H (e
jT
)e
N 1  N 1
 jT 

2
 2 
N  1 


.  j 2h( n).sin  T  n 

2 
n 0


• [Note: antisymmetric case adds  / 2 rads to
phase, with discontinuity at   0 ]
• III) For N odd with +ve sign
H (e
jT
)e
N 1
 jT 
 2  
N 3
2
16
N  1


 h
  2 

N  1  
 
  2h(n).cosT  n 
 
2  
n 0
 

Professor A G Constantinides
FIR: Linear phase
• IV) While with a –ve sign
H (e
jT
)e
N 3
N 1 

 jT 
2
 2  

N  1  
 
 
  2 j.h(n).sin T  n 
2  
 
 n0

• [Notice that for the antisymmetric case to
have linear phase we require
N  1
h

  0.
 2 
The phase discontinuity is as for N even]
17
Professor A G Constantinides
FIR: Linear phase
• The cases most commonly used in filter
design are (I) and (III), for which the
amplitude characteristic can be written as a
polynomial in
T
cos
18
2
Professor A G Constantinides
FIR: Linear phase
For phase linearity the FIR transfer
function must have zeros outside the
unit circle
19
Professor A G Constantinides
FIR: Linear phase
• To develop expression for phase response
set transfer function
1
H ( z )  h0  h1z  h2 z
2
 ...  hn z
n2
1
• In factored form
n1
1
n
H ( z )  K  (1  i z ). (1  i z )
i 1
i 1
• Where
,
iin conjugates
1, i  1
K
zeros occur
20
is real &
Professor A G Constantinides
FIR: Linear phase
H ( z )  KN1 ( z ) N 2 ( z )
• Let
where
n1
N1 ( z )   (1  i z 1 )
i 1
n2
N 2 ( z )   (1  i z 1 )
i 1
• Thus
n1
1
n2
1
ln( H ( z ))  ln( K )   ln(1   i z )   ln(1   i z )
i 1
21
i 1
Professor A G Constantinides
FIR: Linear phase
• Expand in a Laurent Series convergent
within the unit circle
• To do so modify the second sum as
n2
1
n2
1
n2
1
i 1
i
 ln(1 i z )   ln(i z )   ln(1 
i 1
22
i 1
z)
Professor A G Constantinides
FIR: Linear phase
• So that
n1
n2
1
ln(H ( z ))  ln(K )  n2 ln(z )   ln(1   i z )   ln(1  z )
i
i 1
i 1
• Thus
1

N1
sm
m1
m
ln(H ( z ))  ln(K )  n2 ln(z )  
z
m

N2
sm
m
z
m
• where
smN1
23

n1
m

 i
i 1
sNm2
n1
   i m
i 1
Professor A G Constantinides
FIR: Linear phase
N1
s
• m are the root moments of the minimum
phase component
• sNm2 are the inverse root moments of the
maximum phase component
• Now on the unit circle we have z  e j
and
H (e j )  A( )e j ( )
24
Professor A G Constantinides
Fundamental Relationships
N1
N2
s
s
ln(H (e j ))  ln(K )  jn2   m e jm  m e jm
m
m 1 m

ln( H (e j ))  ln( A( )e j ( ) )  ln( A( ))  j ( )
• hence (note Fourier form)
smN1 sNm2
ln( A( ))  ln(K )   (

) cos m
m
m 1 m

smN1 sNm2
 ( )  n2   (

) sin m
m
m 1 m

25
Professor A G Constantinides
FIR: Linear phase
• Thus for linear phase the second term in the
fundamental phase relationship must be identically
zero for all index values.
• Hence
• 1) the maximum phase factor has zeros which are
the inverses of the those of the minimum phase
factor
• 2) the phase response is linear with group delay
equal to the number of zeros outside the unit circle
26
Professor A G Constantinides
FIR: Linear phase
• It follows that zeros of linear phase FIR
trasfer functions not on the circumference
of the unit circle occur in the form
 e 
i
27
 ji 1
Professor A G Constantinides
Design of FIR filters: Windows
(i) Start with ideal infinite duration h(n)
(ii) Truncate to finite length. (This produces
unwanted ripples increasing in height near
discontinuity.)
~
(iii) Modify to
h (n)  h(n).w(n)
Weight w(n) is the window
28
Professor A G Constantinides
Windows
Commonly used windows
Rectangular 1
2n
1
N 1
Bartlett
n 
N
2
2n 

1  cos

Hann
 N 
Hamming 0.54  0.46 cos 2n 
•
•
•
•
•
• Blackman
•
• Kaiser
29


 N 
2n 
 4n 
0.42  0.5 cos

0
.
08
cos



 N 
 N 
2

2
n

J 0  1  

  J 0 ( )
 N  1 



Professor A G Constantinides
Kaiser window
• Kaiser window
β
30
2.12
Transition
width (Hz)
1.5/N
Min. stop
attn dB
30
4.54
2.9/N
50
6.76
4.3/N
70
8.96
5.7/N
90
Professor A G Constantinides
Example
• Lowpass filter of length 51 and  c   / 2
Lowpass Filter Designed Using Hamming window
0
Gain, dB
Gain, dB
Lowpass Filter Designed Using Hann window
0
-50
-100
-50
-100
0
0.2
0.4
0.6
0.8
1
0
0.2
0.4
0.6
0.8
1
Gain, dB
/
/
Lowpass Filter Designed Using Blackman window
0
-50
-100
31
0
0.2
0.4
0.6
/
0.8
1
Professor A G Constantinides
Frequency Sampling Method
c   / 2
• In this approach we are given H (k ) and
need to find H (z )
• This is an interpolation problem and the
solution is given in the DFT part of the
course
N
1 N 1
1 z
H ( z )   H (k ).
2
N k 0
j k
1  e N .z 1
• It has similar problems to the windowing
approach
32
Professor A G Constantinides
Linear-Phase FIR Filter
Design by Optimisation
• Amplitude response for all 4 types of linearphase FIR filters can be expressed as

H ( )  Q( ) A( )
where
1,
for Type 1

 cos(/2), for Type 2

Q( )  
 sin( ), for Type 3
sin( / 2), for Type 4
33
Professor A G Constantinides
Linear-Phase FIR Filter
Design by Optimisation
• Modified form of weighted error function
E ( )  W ( )[Q( ) A( )  D( )]
D ( )
 W ( )Q( )[ A( )  Q ( ) ]
~
~
 W ( )[ A( )  D( )]
where
~
W ( )  W ( )Q( )
~
D( )  D( ) / Q( )
34
Professor A G Constantinides
Linear-Phase FIR Filter
Design by Optimisation
• Optimisation Problem - Determine a~[k ]
which minimise the peak absolute value
of
L
~
~
~
E ( )  W ( )[  a [k ] cos( k)  D( )]
k 0
over the specified frequency bands   R
• After a~[k ] has been determined, construct
the original A(e j ) and hence h[n]
35
Professor A G Constantinides
Linear-Phase FIR Filter
Design by Optimisation
Solution is obtained via the Alternation
Theorem
The optimal solution has equiripple behaviour
consistent with the total number of available
parameters.
Parks and McClellan used the Remez
algorithm to develop a procedure for
designing linear FIR digital filters.
36
Professor A G Constantinides
FIR Digital Filter Order
Estimation
Kaiser’s Formula:
N
 20 log10 (  p s )
14.6( s   p ) / 2
• ie N is inversely proportional to transition
band width and not on transition band
location
37
Professor A G Constantinides
FIR Digital Filter Order
Estimation
• Hermann-Rabiner-Chan’s Formula:
D ( p ,  s )  F ( p ,  s )[( s   p ) / 2 ]2
N
( s   p ) / 2
where
38
D ( p , s )  [a1 (log10  p )2  a2 (log10  p )  a3 ] log10  s
 [a4 (log10  p )2  a5 (log10  p )  a6 ]
F ( p ,  s )  b1  b2 [log10  p  log10  s ]
with a1  0.005309, a2  0.07114, a3  0.4761
a4  0.00266, a5  0.5941, a6  0.4278
b1  11.01217, b2  0.51244
Professor A G Constantinides
FIR Digital Filter Order
Estimation
• Fred Harris’ guide:
A
N
20(s   p ) / 2
where A is the attenuation in dB
• Then add about 10% to it
39
Professor A G Constantinides
FIR Digital Filter Order
Estimation
• Formula valid for  p   s
• For  p   s , formula to be used is obtained


p
by interchanging and s
• Both formulae provide only an estimate of
the required filter order N
• If specifications are not met, increase filter
order until they are met
40
Professor A G Constantinides