prof. brian l. evans dept. of electrical and computer...

26
Prof. Brian L. Evans Dept. of Electrical and Computer Engineering The University of Texas at Austin EE345S Real-Time Digital Signal Processing Lab Spring 2006 Lecture 6 Infinite Impulse Response Filters

Upload: others

Post on 19-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

• Prof. Brian L. Evans• Dept. of Electrical and Computer Engineering• The University of Texas at Austin

EE345S Real-Time Digital Signal Processing Lab Spring 2006

Lecture 6

Infinite Impulse Response Filters

Page 2: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 2

Digital IIR Filters• Infinite Impulse Response (IIR) filter has impulse

response of infinite duration, e.g.

• How to implement the IIR filter by computer?Let x[k] be the input signal and y[k] the output signal,

[ ] ][21

kukhk

��

���

�=1

1

0

21

1

1

41

21

21

)(−

−−∞

= −=++=�

���

�=�z

zzzH k

k

k

...Z

)()( 21

)( )(

21

1

1)()()(

)()(

)( 1

1zXzYzzYzX

zzXzHzY

zXzY

zH =−�−

==�= −

][]1[21

][ ][]1[21

][ )()( 21

)( 1 kxkykykxkykyzXzYzzY +−=�=−−�=− −

Recursively compute output, given y[-1] and x[k]

Page 3: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 3

Different Filter Representations• Difference equation

Recursive computation needs y[-1] and y[-2]

For the filter to be LTI,y[-1] = 0 and y[-2] = 0

• Transfer functionAssumes LTI system

• Block diagram representation

Second-order filter section (a.k.a. biquad) with 2 poles and 0 zeros

][]2[81

]1[21

][ kxkykyky +−+−=

Σx[k] y[k]Unit

Delay

UnitDelay

1/2

1/8

y[k-1]

y[k-2]

21

21

81

21

1

1)()(

)(

)()(81

)(21

)(

−−

−−

−−==

++=

zzzXzY

zH

zXzYzzYzzY

Poles at –0.183 and +0.683

Page 4: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 4

Digital IIR Biquad• Two poles and zero, one, or two zeros

• Take z-transform of biquad structure

• Real coefficients a1, a2, b0, b1, and b2 means poles and zeros in conjugate symmetric pairs αααα ± j ββββ

22

11

22

110

1)()(

)()(

)()(

)( −−

−−

−−++===

zazazbzbb

zVzY

zXzV

zXzY

zH

Σx[k]Unit

Delay

UnitDelay

v[k-1]

v[k-2]

v[k]

b2

a1

a2

b1

Σ y[k]b0

Page 5: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 5

Digital IIR Filter Design• Poles near unit circle indicate filter’s passband(s)

• Zeros on/near unit circle indicate stopband(s)• Biquad with zeros z0 and z1, and poles p0 and p1

Transfer function

Magnitude response

( )( )( )( )10

10 )(pzpzzzzz

CzH−−−−=

( )( )( )( )10

10

)(pepezeze

CeH jj

jjj

−−−−= ωω

ωωω

10

10

)(

pepe

zezeCeH

jj

jjj

−−

−−=

ωω

ωωω

Distance from point on unit circle ejωωωω and pole location p0

|a – b| is distance between complex numbers a and b

Page 6: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 6

Digital IIR Biquad Design Examples• Transfer function

• Poles (X) & zeros (O) in conjugate symmetric pairs– For coefficients in unfactored transfer function to be real

• Filters below have what magnitude responses?

Re(z)

Im(z)

XOO X Re(z)

Im(z)

O

OX

XRe(z)

Im(z)O

O

X

X

( )( )( )( )

( )( )( )( )1

11

0

11

10

10

10

1111

)( −−

−−

−−−−=

−−−−=

zpzpzzzz

Cpzpzzzzz

CzH

lowpasshighpassbandpassbandstop

allpassnotch?

Page 7: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 7

A Direct Form IIR Realization• IIR filters having rational transfer functions

• Direct form realization– Dot product of vector of N +1

coefficients and vector of currentinput and previous N inputs (FIR section)

– Dot product of vector of M coefficients and vector of previous M outputs (FIR filtering of previous output values)

– Computation: M + N + 1 MACs– Memory: M + N words for previous inputs/outputs and

M + N + 1 words for coefficients

MM

NN

zazazbzbb

zAzB

zXzY

zH −−

−−

−−−+++===

1

)()(

)()(

)( 11

110

...��

=

=

− =��

���

� −N

n

nn

M

m

mm zbzXzazY

01

)( 1 )(

��==

−+−=M

mk

N

nk mkyankxbky

10

][ ][ ][

Page 8: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 8

Filter Structure As a Block Diagram

=

=

+−=

M

mk

N

nk

mkya

nkxbky

1

0

][

][ ][

Σx[k] y[k]

y[k-M]

x[k-1]

x[k-2] b2

b1

b0

UnitDelay

UnitDelay

UnitDelay

x[k-N] bN

Feed-forward

a1

a2

y[k-1]

y[k-2]

UnitDelay

UnitDelay

UnitDelay

aM

Feedback Note that M and Nmay be

different

Page 9: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 9

Another Direct Form IIR Realization• When N = M,

– Here, Wm(z) = bm X(z) + am Y(z)– In time domain,

• Implementation complexity– Computation: M + N + 1 MACs– Memory: M + N words for previous inputs/outputs and

M + N + 1 words for coefficients

• More regular layout for hardware design

( ) mN

mm

mN

mmm zzWzXbzzYazXbzXbzY −

=

=�� +=++= )()( )()()()(

10

10

�=

−+=

+=M

mm

mmm

mkwkxbky

kyakxbkw

10 ][][][

][][][

Page 10: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 10

Filter Structure As a Block Diagramx[k]

x[k-1]

x[k-2] b2

a1

a2

b1

y[k]b0

UnitDelay

UnitDelay

UnitDelay

x[k-N] bN

y[k-1]

y[k-2]

UnitDelay

UnitDelay

UnitDelay

y[k-M]aM

Feed-forward Feedback

�=

+=

+=

M

mm

m

mm

mkw

kxbky

kyakxbkw

1

0

][

][][

][ ][][

Note that M = N

impliedbut can be different

Page 11: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 11

Yet Another Direct Form IIR• Rearrange transfer function to be cascade of an an

all-pole IIR filter followed by an FIR filter

– Here, v[k] is the output of an all-pole filter applied to x[k]:

• Implementation complexity (assuming M ≥≥≥≥ N)– Computation: M + N + 1 = 2 N + 1 MACs– Memory: M + 1 words for current/past values of v[k] and

M + N + 1 = 2 N + 1 words for coefficients

)()(

)( where)()()(

)()()(

zAzX

zVzBzVzA

zBzXzY ===

=

=

−=

−+=

N

nn

M

mm

nkvbky

mkvakxkv

0

1

][ ][

][ ][][

Page 12: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 12

Filter Structure As Block Diagram

Σx[k]Unit

Delay

UnitDelay

v[k-1]

v[k-2]

v[k]

b2

a1

a2

b1

Σ y[k]b0

UnitDelay

v[k-M]bNaM

Feed-forward

Feedback

M=2 yields a biquad

=

=

−=

−+=

N

nn

M

mm

nkvbky

mkvakxkv

0

1

][ ][

][ ][][

Note that M = N impliedbut they can be different

Page 13: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 13

Demonstrations (DSP First)• Web site: http://users.ece.gatech.edu/~dspfirst

• Chapter 8: IIR Filtering Tutorial (Link)• Chapter 8: Connection Betweeen the Z and

Frequency Domains (Link) • Chapter 8: Time/Frequency/Z Domain Moves for

IIR Filters (Link)

Page 14: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 14

Stability• A digital filter is bounded-input bounded-output

(BIBO) stable if for any bounded input x[k] such that | x[k] | ≤ B < ∞, then the filter response y[k] is also bounded | y[k] | ≤ B < ∞

• Proposition: A digital filter with an impulse response of h[k] is BIBO stable if and only if

– Any FIR filter is stable– A rational causal IIR filter is stable if and only if its poles

lie inside the unit circle

∞<�∞

−∞=

|][| khn

Review

Page 15: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 15

[ ] azza

kuaZ

k >−

↔ − for 1

1 1

Stability• Rule #1: For a causal sequence, poles are inside the

unit circle (applies to z-transform functions that are ratios of two polynomials) OR

• Rule #2: Unit circle is in the region of convergence. (In continuous-time, imaginary axis would be in region of convergence of Laplace transform.)

• Example:

Stable if |a| < 1 by rule #1 or equivalentlyStable if |a| < 1 by rule #2 because |z|>|a| and |a|<1

Review

Page 16: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 16

Z and Laplace Transforms• Transform difference/differential equations into

algebraic equations that are easier to solve• Are complex-valued functions of a complex

frequency variableLaplace: s = σ + j 2 π fZ: z = r e j ω

• Transform kernels are complex exponentials: eigenfunctions of linear time-invariant systemsLaplace: e– s t = e–σ t – j 2 π f t = e–σ t e – j 2 π f t

Z: z–k = (r e j ω)–k = r–k e– j ω k

dampening factor oscillation term

Page 17: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 17

Z and Laplace Transforms• No unique mapping from Z to Laplace domain

or from Laplace to Z domain– Mapping one complex domain to another is not unique

• One possible mapping is impulse invariance – Make impulse response of a discrete-time linear time-

invariant (LTI) system be a sampled version of the continuous-time LTI system.

H(z) y[k]f[k]

Z

H(s)( )tf~ ( )ty~

Laplace

TsezzHsH |)()(

==

Page 18: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 18

Impulse Invariance Mapping• Impulse invariance mapping is z = e s T

Laplace Domain Z Domain Left-hand plane Inside unit circle Imaginary axis Unit circle Right-hand plane Outside unit circle

1

Im{z}

Re{z}

s = -1 ± j � z = 0.198 ± j 0.31 (T = 1 s)

s = 1 ± j � z = 1.469 ± j 2.287 (T = 1 s)

ππ1

21

1 maxmax >�=�= sff�

1

1

-1

-1

Im{s}

Re{s}

fjs 2 π=

Page 19: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 19

Impulse Invariance Derivation

( ) [ ] ( )

( ) [ ] ( )

( ) ( ) ( )

[ ]( ) ( ) [ ]

[ ] ( ) [ ]

( ) ( ) ( )zFzHzY

zkfzHzky

ez

ekfsHeky

sFsHsY

kTtkyty

kTtkftf

k

k

ok

k

sT

k

kTs

k

ksT

k

k

:Let

~~

~

~

0

00

0

0

=

=

=

=

=

−=

−=

��

��

=

−∞

=

=

−∞

=

=

=

δ

δ

H(z) y[k]f[k]

Z

H(esT)( )tf~ ( )ty~

Laplace

Optional

Page 20: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 20

Analog IIR Biquad• Second-order filter section with 2 poles and 2 zeros

– Transfer function is a ratio of two real-valued polynomials– Poles and zeros occur in conjugate symmetric pairs

• Quality factor: technology independent measure of sensitivity of pole locations to perturbations– For an analog biquad with poles at a ± j b, where a < 0,

– Real poles: b = 0 so Q = ½ (exponential decay response)– Imaginary poles: a = 0 so Q = ∞ (oscillatory response)

∞<≤−

+= Qaba

Q21

where2

22

Page 21: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 21

Analog IIR Biquad• Impulse response with biquad with poles a ± j b

with a < 0 but no zeroes:– Pure sinusoid when a = 0 and pure decay when b = 0

• Breadboard implementation– Consider a single pole at –1/(R C). With 1% tolerance on

breadboard R and C values, tolerance of pole location is 2%– How many decimal digits correspond to 2% tolerance?– How many bits correspond to 2% tolerance?– Maximum quality factor is about 25 for implementation of

analog filters using breadboard resistors and capacitors.– Switched capacitor filters: Qmax ≈ 40 (tolerance ≈ 0.2%)– Integrated circuit implementations can achieve Qmax ≈ 80

) cos( )( θ+= tbeCth ta

Page 22: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 22

Digital IIR Biquad• For poles at a ± j b = r e ± j θθθθ, where is

the pole radius (r < 1 for stability), with y = –2 a:

– Real poles: b = 0 so r = | a | and y = ±2 r which yields Q = ½ (exponential decay response C0 an u[n] + C1 n an u[n])

– Poles on unit circle: r = 1 so Q = ∞ (oscillatory response)– Imaginary poles: a = 0 so y = 0 so

– 16-bit fixed-point DSPs: Qmax ≈ 40 (extended precision accumulators)

∞<≤−

−+= Q

ryr

Q21

where)1( 2

)1(2

222

22 bar +=

2

2

11

21

rr

Q−+=

Page 23: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 23

Analog/Digital IIR Implementation• Classical IIR filter designs

Filter of order n will have n/2 conjugate roots if n is even or one real root and (n-1)/2 conjugate roots if n is odd

Response is very sensitive to perturbations in pole locations

• Robust way to implement an IIR filterDecompose IIR filter into second-order sections (biquads)Cascade biquads in order of ascending quality factorsFor each pair of conjugate symmetric poles in a biquad,

conjugate zeroes should be chosen as those closest in Euclidean distance to the conjugate poles

Page 24: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 24

Classical IIR Filter Design• Classical IIR filter designs differ in the shape of

their magnitude responsesButterworth: monotonically decreases in passband and

stopband (no ripple) Chebyshev type I: monotonically decreases in passband but

has ripples in the stopbandChebyshev type II: has ripples in passband but monotonically

decreases in the stopbandElliptic: has ripples in passband and stopband

• Classical IIR filters have poles and zeros, except that analog lowpass Butterworth filters are all-pole

• Classical filters have biquads with high Q factors

Page 25: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

6 - 25

Analog IIR Filter Optimization• Start with an existing (e.g. classical) filter design• IIR filter optimization packages from UT Austin

(in Matlab) simultaneously optimizeMagnitude responseLinear phase in the passbandPeak overshoot in the step responseQuality factors

• Web-based graphical user interface (developed as a senior design project) available at

http://signal.ece.utexas.edu/~bernitz

Page 26: Prof. Brian L. Evans Dept. of Electrical and Computer ...signal.ece.utexas.edu/~arslan/courses/realtime/lectures/06_IIR_Filter… · EE345S Real-Time Digital Signal Processing Lab

Analog IIR Filter Optimization• Design an analog lowpass IIR filter with δδδδp = 0.21

at ωωωωp = 20 rad/s and δδδδs = 0.31 at ωωωωs = 30 rad/s withMinimized deviation from linear phase in passbandMinimized peak overshoot in step responseMaximum quality factor of second-order sections is 10

Linearizedphase in

passband

Minimized peak overshoot

OriginalOptimized

0.0±j28.0184-0.1636±j19.989961.0

0.0±j20.2479-5.3533±j16.95471.7

zerospolesQ

initi

al

-1.2725±j35.5476-1.0926±j21.824110.00

-3.4232±j28.6856-11.4343±j10.50920.68

zerospolesQ

optim

ized