Topic 6: Filters - Introduction ELEN E4810: Digital Signal Processing 1.

advertisement
ELEN E4810: Digital Signal Processing
Topic 6:
Filters - Introduction
1. Simple Filters
2. Ideal Filters
3. Linear Phase and FIR filter types
Dan Ellis
2013-10-16
1
1. Simple Filters


Filter = system for altering signal in
some ‘useful’ way
LSI systems:



Dan Ellis
are characterized by H(z) (or h[n])
have different gains (& phase shifts)
at different frequencies
can be designed systematically
for specific filtering tasks
2013-10-16
2
FIR & IIR

FIR = finite impulse response
no feedback in block diagram
no poles (only zeros)

IIR = infinite impulse response
feedback in block diagram
poles (and often zeros)
Dan Ellis
2013-10-16
3
Simple FIR Lowpass

1/
2
hL[n] = {1/2 1/2}
(2 pt moving avg.)
(
H L (z ) = 1+ z
1
2
1
)
z +1
=
2z
ej!/2+e-j!/2
( )=e
 HL e
j
1/
2
Dan Ellis
 j 2
-2 -1
hL[n]
1 2 3 4
n
1
ZP
zero at
z = -1
|HL(ej!)|
cos( 2)
π!
sample delay
2013-10-16
4
Simple FIR Lowpass


Filters are often
characterized by their
cutoff frequency !c:
1
1/√2
≈ 0.707
!c
π/2
π
!
Cutoff frequency is most often defined
as the half-power point, i.e.
(
H e

|H(ej!)|
If
)
{
}

H (e ) = cos( 2)
j c 2
=
1 max
2
then  c =
Dan Ellis
( )
H e
j 2
H =
1
2
H max
j
1 1
2 cos 2
= 2
2013-10-16
5
deciBels



Filter magnitude responses are
often described in deciBels (dB)
dB is simply a scaled log value:
=
dB = 20 log10 (level ) = 10 log10 ( power ) power
2
level
Half-power also known as 3dB point:
H cutoff = 12 H max
dB{ H cutoff } = dB{ H max } + 20 log10 ( 12 )
= dB{ H max }  3.01
Dan Ellis
2013-10-16
6
deciBels
We usually plot magnitudes in dB:
1
0
0.8
-3
|H(ej )| / dB
|H(ej )|

1/√2
0.6
-10
0.4
-15
0.2
0

-5
0
0.2
0.4
/
0.6
0.8
1
-20
0
0.2
0.4
/
0.6
0.8
1
A gain of 0 corresponds to -∞ dB
Dan Ellis
2013-10-16
7
Simple FIR Highpass

hH[n] = {1/2 -1/2}
-2 -1
n
2 3 4
-1/2
(
H H (z) = 1  z
1
2
1
)
( )
3dB point !c = π/2 (again)
Dan Ellis
zero at
z=1
z 1
=
2z
 H H e j = je j 2 sin ( 2)

1/
2
hH[n]
2013-10-16
1
ZP
|HH(ej!)|
!c
π/2
8
π!
FIR Lowpass and Highpass


Note:
hL[n] = {1/2 1/2}
hH[n] = {1/2 -1/2}
n
h
n
=
(1)
hL [n]
i.e. H [ ]
 H H (z ) = H L (z )

i.e. 180° rotation of
the z-plane,
π shift of frequency
response
Dan Ellis
2013-10-16
j
-j
−1
1
1
−1
z
-j
j
|HL(ej!)|
π
-z
!
2π
|HH(ej!)|
!
9
Simple IIR Lowpass
IIR → feedback, zeros and poles,
conditional stability, h[n] less useful
1+z
HLP (z) = K
1
z
x[n]
+
y[n]
z-1
+
z-1
0
0dB
10
|H(ej )|
1
1
-1
0
0.5
1
10
-20dB
0.5
10
-40dB
-2
z-plane
-1
-1
0
1
pole-zero
diagram
Dan Ellis
K
1
|H(ej )|
scale to make
gain = 1 at ! = 0
→ K = (1 - Æ)/2
1
0
1
-2
0
freq
/
frequency
response
2013-10-16
1
10
-1
10
0
freq
/ 10
FR on
log-log axes
10
Simple IIR Lowpass
max = 1
using K=(1-Æ)/2
1

1+ z
H LP (z ) = K
1
1  z
Cutoff freq. !c from H LP e j c
(
1  )
(

4
2
(1+ e
)
2
max
=
2
)(1+ e ) = 1
 j
j
1


e
1


e
(
)(
) 2
 j c
c
j c
c
2
1  sin  c
 cos  c =
 =
2
cos  c
1+ 
Design Equation
Dan Ellis
2013-10-16
11
Simple IIR Highpass
HHP (z) = K
1 z
1
1
1
1
z
0.5
Pass ! = π → HHP(-1) = 1
→ K = (1+Æ)/2
Dan Ellis
-0.5
-1
|H(ej )| / dB
1
|H(ej )|
Design Equation:
1  sin  c
=
cos  c
(again)
0
1
0.5
-1
z-plane
1
0
0
-10
1
-20
-30
0
0
0.5 Freq
2013-10-16
/
1
-40 -2
10
-1
10 Freq
12
0
/
10
Highpass and Lowpass

Consider lowpass filter:
HLP (e ) =
j

Then:
1
HLP (e ) =
j
1
0
0
large
1
0
large
0
• Highpass
• c/w (-1)nh[n]
just another z poly

However, |1 HLP (z)| = 1 |HLP (z)|
(unless H(ej!) is pure real - not for IIR)
Dan Ellis
2013-10-16
13
Simple IIR Bandpass
2
1
1 z
H BP ( z ) =
2 1   (1+  )z 1 + z 2
(1+ z )(1  z )
0
0.5
1
1
2 2
1
1  2r cos   z + r z
 (1+  )
where r =  cos  =
2 
1
Center freq  c = cos 

1  2
3dB bandwidth B  cos 
2 


1
Dan Ellis
2013-10-16
-1
0
z-plane
1
1
1/√2
B
0.5
0
|H(ejw)| / dB
Design
=K
r
0.5
|H(ejw)|
1
1
0
0.5
/
1
0
B
-10
-20
-30
-40 -2
10
-1
10
14
/
0
10
Simple Filter Example
Design a second-order IIR bandpass
filter with !c = 0.4π, 3dB b/w of 0.1π
 c = 0.4   = cos  c = 0.3090
2
B = 0.1 
= cos(0.1 )   = 0.7265
2
1+ 
2
1
1 z
H BP ( z ) =
2 1   (1+  )z 1 + z 2
2
0.1367 1  z
=
sensitive..
1
2
1  0.5335z + 0.7265z

(
Dan Ellis
2013-10-16
)
15
M
Simple IIR Bandstop
zeros at !c (per 1 - 2r cosµ z-1 + r2z-2)
1
2
1+  1  2z + z
H BS ( z ) =
2 1   (1+  )z 1 + z 2
0
-0.5
same poles as HBP
2013-10-16
z-plane
-1
-1
|H(ejw)|
Design eqns:
1
 c = cos    = cos  c
1  2 
B = cos 
2
1+  
1
1
 =

1
2
cos B
cos B
Dan Ellis
0.5
0
1
1
B
0.5
0
|H(ejw)| / dB

1
0
0.5
/
1
/
10
0
-10
-20
-30
-40 -2
10
-1
10
16
0
Cascading Filters

Repeating a filter (cascade connection)
makes its characteristics more abrupt:
|H(ej!)|
H(ej!)
h
!
H(ej!)

H(ej!)
H(ej!)
|H(ej!)|3
h3
!
Repeated roots in z-plane:
1
ZP
Dan Ellis
2013-10-16
17
Cascading Filters

Cascade systems are higher order
e.g. longer (finite) impulse response:
h[n]
h[n]∗h[n]
1/
2
-2 -1
2 3 4
-1/2

n
1/
4
-2 -1
2 3 4
h[n]∗h[n]∗h[n]
n
1/
8
-2 -1
2
4
n
-3/8
-1/2
In general, cascade filters will not be
optimal (...) for a given order
Dan Ellis
2013-10-16
18
Cascading Filters
Cascading filters improves rolloff slope:
!c
|H(ej )|

0
-10
-20
2nd order
-6dB/oct
-30
-12dB/oct
-40
-50
-60
4th order
-2
10

-1
10
/
0
10
But: 3dB cutoff frequency will change
(gain at !c → 3N dB)
Dan Ellis
2013-10-16
19
Interlude: The Big Picture
DTFT
IR
X(ej ) =
y[n] = h[n]
x[n]
x[n]e
DTFT
j n
n
Y (ej ) = H(ej )X(ej )
IDTFT
x[n – k]
\HejW\
3
x[n] =
X(ej )ej
h[k]
n
i i
+
n
0
n
µ[n]
=
1
IZT
LCCDE
j=0
x[n]
p0
j]
dk y[n
1
z
y[n]
z-1
p1
-d1
z-1
z-1
p2
-d2
z-1
Dan Ellis
W
X(ej ) = X(z)|z=ej
1
|z | >
| |
ZT
Y (z) = G
k]
pj x[n
j
0
n
k=1
+
W
0
x[n]z
N
pj x[n
1
0
n
i
M
d
ZT
n
0
n
[HejW]
X (z )
yc [n] + yp [n] =
y[n] =
1
2
2
j]
pj z
j
M
j=1 (1
N
k=1 (1
1
kz
1)
X(z)
j
2013-10-16
)
jz
20
X(z)
2. Ideal filters

Typical filter requirements:



“Ideal” characteristics
would be like:


gain = 1 for wanted parts (pass band)
gain = 0 for unwanted parts (stop band)
no phase distortion etc.
|H(ej!)|
“brickwall
LP filter”
!
What is this filter?

Dan Ellis
can calculate IR h[n] as IDTFT of ideal
response...
2013-10-16
21
Ideal Lowpass Filter

Given ideal H(ej!):
(assume µ(!) = 0) −π
h[n] = IDTFT {H e j }
−!c
( )

1
= 2    H (e j )e jn d
=
1
2
c

0
π
!c
e jn d
c
sin  c n
 h[n] =
n
Ideal lowpass filter
Dan Ellis
2013-10-16
22
!
Ideal Lowpass Filter
sin  c n
h[n] =
n
h[n]
0.2
0.15
(sinc)
0.1
0.05
0
-0.05
-20

-15
-10
-5
0
5
10
15
Problems!
n

doubly infinite (n = -∞..∞)

no rational polynomial → very long FIR
excellent frequency-domain characteristics
poor time-domain characteristics
(blurring, ringing – a general problem)

Dan Ellis
2013-10-16
23
Practical filter specifications



Dan Ellis
• allow transition band
1
!
-1
Pass band
-40
Stop band
Transition
|H(ej!)| / dB
• allow PB ripples
• allow SB ripples
lower-order realization (less computation)
better time-domain properties (less ringing)
easier to design...
2013-10-16
24
3. Linear-phase Filters

|H(ej!)| alone can hide phase distortion




differing delays for adjacent frequencies
can mangle the signal
Prefer filters with a flat phase response
e.g. µ(!) = 0 “zero phase filter”
A filter with constant delay øp = D at all
freqs has µ(!) = −D! “linear phase”
j
 jD ˜
(zero-phase)
 H (e ) = e
H ( ) pure-realportion
Linear phase can ‘shift’ to zero phase
Dan Ellis
2013-10-16
25
Time reversal filtering
v[n]
H(z)
x[n]






u[n]= v[-n] w[n]
Time
Time
H(z)
reversal
reversal
y[n]
v[n] = x[n]∗h[n] → V(ej!) = H(ej!)X(ej!)
u[n] = v[-n] → U(ej!) = V(e-j!) = V*(ej!) if v real
w[n] = u[n]∗h[n] → W(ej!) = H(ej!)U(ej!)
y[n] = w[-n] → Y(ej!) = W*(ej!)
= (H(ej!)(H(ej!)X(ej!))*)*
→ Y(ej!) = X(ej!)|H(ej!)|2
Achieves zero-phase result
Not causal! Need whole signal first
Dan Ellis
2013-10-16
26
Linear Phase FIR filters


(Anti)Symmetric FIR filters are almost
the only way to get zero/linear phase
4 types: Odd length
Even length
Type 1
Type 2
Symmetric
0
Antisymmetric
(L-1)/2
L-1
n
Type 4
Type 3
n
Dan Ellis
n
2013-10-16
n
27
Linear Phase FIR: Type 1
Length L odd → order N = L - 1 even
 Symmetric → h[n] = h[N - n]
(h[N/2] unique)
N
j
H e
=  h[n]e jn

( )
linear phase
D = -µ(!)/! = N/2
=e
n=0
 j N2
(
h[
N
2
] + 2
h[ N2  n] cos n
N /2
n=1
~
pure-real H(!) from cosine basis:
~
H(!)
1
n=1
0.5
!
0
n=2
-0.5
-1
0.4
Dan Ellis
)
2013-10-16
0.2
0
0.2
0.4
0.6
28
0.8
/
1
Linear Phase FIR: Type 1
Impulse response
Magnitude response
5
dB
4
= -D!
0.5
10
3
0
2
0
-0.5
1
0
Phase response
20
0
1

2
3
4
5
6
7
8
n
-10
-
-0. 5
0
0.5
-
-0. 5
Where are the N zeros?
N
h[n] = h[ N  n]  H ( z ) = z H ( 1z )
thus for a zero ≥
H ( ) = 0  H
( )=0
1

Reciprocal
pair
0
0.5
-2º
Conjugate
reciprocal
constellation
Reciprocal zeros
No reciprocal
(as well as cpx conj) on u.circle
Dan Ellis
2013-10-16
29
Linear Phase FIR: Type 2



Length L even → order N = L - 1 odd
Symmetric → h[n] = h[N - n]
(no unique point)
( )
H e
j
=e
 j N2
Non-integer delay
of N/2 samples
( N+1) / 2
n=1
1
h[ N+1

n
cos

n

(
]
2
2)
~
H(!)
from double-length cosine basis
1
n - 1/2 = 1/2
0.5
always
zero
at !=º
n - 1/2 = 11/2
0
0.5
1
0.4
Dan Ellis
n - 1/2 = 21/2
0.2
0
0.2
2013-10-16
0.4
0.6
0.8
/
1
30
Linear Phase FIR: Type 2
Impulse Response
5
Magnitude Response
dB
20
4
3
0
2
1
0
-20
0
2
4
6
8
-
10
-0.5
0
0.5
-0.5
0
0.5
1
0.5
0.5
0
0
-0.5
-0.5
-1
-2
-1
0
1
2
-
Pole-zero diagram

Phase Response
Zeros: H (z ) = z N H (1z )
LPF-like
N
j
at z = -1, H (1) = (1) H (1)  H e = 0
odd
Dan Ellis
2013-10-16
( )
31
Linear Phase FIR: Type 3



Length L odd → order N = L - 1 even
Antisymmetric → h[n] = –h[N - n]
h[N/2]= –h[N/2] = 0
( ) = n=1 h[
H e
N /2
j
= je
 j N2
µ(!) = º/2 - !·N/2
Antisymmetric
º/2 phase shift in
addition to linear phase
Dan Ellis
(
N
2
(
 n] e
2
 j ( N2 n )
e
 j ( N2 +n )
h[ N2  n] sin n
N /2
n=1
1
)
)
n=1
0.5
0
odd
functions
n=2
zero at
= 0,
-0. 5
-1
-0. 4
2013-10-16
-0. 2
0
0.2
0.4
0.6
0.8
32
/
1
Linear Phase FIR: Type 3
Impulse Response
Magnitude Response
2
20
0
0
-2
-20
0
2
4
6
8
-
10
-0.5
0
0.5
-0.5
0
0.5
0.5
0
-0.5
-2
-1
0
1
2
-
Pole-zero diagram

Zeros: H (z ) = z N H (1z )
Phase Response
 H (1) = H (1) = 0 ; H (1) = H (1) = 0
Dan Ellis
2013-10-16
33
Linear Phase FIR: Type 4



Length L even → order N = L - 1 odd
Antisymmetric → h[n] = -h[N - n]
(no center point)
N /2
 j N2
j
1
H e
= je
2 h[ N+1

n
sin

n

( 2)
]
2
( )
n=1
offset sine basis
º/2 offset
fractional-sample
delay
1
n - 1/2 = 1/2
0.5
0
odd
functions
n - 1/2 = 11/2
0.5
1
0.4
Dan Ellis
0.2
2013-10-16
0
0.2
0.4
0.6
34
0.8
/
1
Linear Phase FIR: Type 4
Impulse Response
4
dB
20
2
0
0
-2
-4
Magnitude Response
-20
0
2
4
6
8
1
-
10
-0.5
0
0.5
-0.5
0
0.5
0.5
0
0
-0.5
-1
-2
0
2
-
Pole-zero diagram

Phase Response
Zeros: H (1) = H (1) = 0
(H(-1) OK because N is odd)
Dan Ellis
2013-10-16
35
4 Linear Phase FIR Types
Antisymmetric
Symmetric
Odd length
1
2
~
H(!)
h[n]
3
n ZP
n
4
º
D
º
D
~
H(!)
h[n]
~
H(!)
h[n]
!
D
Dan Ellis
Even length
!
n ZP
º
D
2013-10-16
ZP
~
H(!)
h[n]
n
!
ZP
36
!
Download