http://elec3004.com
Digital Filters IIR & FIR
© 2019 School of Information Technology and Electrical Engineering at The University of Queensland
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAA
Lecture Schedule: Week Date Lecture Title 27-Feb Introduction 1 1-Mar Systems Overview 6-Mar Systems as Maps & Signals as Vectors 2 8-Mar Systems: Linear Differential Systems 13-Mar Sampling Theory & Data Acquisition 3 15-Mar Aliasing & Antialiasing 20-Mar Discrete Time Analysis & Z-Transform 4 22-Mar Second Order LTID (& Convolution Review) 27-Mar Frequency Response 5 29-Mar Filter Analysis 6 3-Apr Digital Filters (IIR) & Filter Analysis 5-Apr PS 1: Q & A 10-Apr Digital Filter (FIR) & Digital Windows 7 12-Apr FFT 8 17-Apr Active Filters & Estimation & Holiday 19-Apr 24-Apr Holiday 26-Apr 1-May Introduction to Feedback Control 9 3-May Servoregulation/PID 8-May PID & State-Space 10 10-May State-Space Control 15-May Digital Control Design 11 17-May Stability 22-May State Space Control System Design 12 24-May Shaping the Dynamic Response 29-May System Identification & Information Theory 13 31-May Summary and Course Review
ELEC 3004: Systems 3 April 2019 2
1 Follow Along Reading:
Today B. P. Lathi • Chapter 10 Signal processing and linear systems (Discrete-Time System Analysis 1998 Using the z-Transform) TK5102.9.L38 1998 – § 10.3 Properties of DTFT – § 10.5 Discrete-Time Linear System analysis by DTFT – § 10.7 Generalization of DTFT to the 풵 –Transform • Chapter 12 (Frequency Response and Digital Filters) • § 12.1 Frequency Response of Discrete-Time Systems • § 12.3 Digital Filters • § 12.4 Filter Design Criteria • § 12.7 Nonrecursive Filters
ELEC 3004: Systems 3 April 2019 3
ELEC3004 is 흅풊 −풆
ELEC 3004: Systems 3 April 2019 4
2 Periodic Signals: Writing them in the Fourier Domain & z-Domain • Synthesis:
ELEC 3004: Systems 3 April 2019 5
ퟏ Euler’s Identity: 풔풊풏 흎풕 = 풆풊⋅ 흎풕 − 풆−풊⋅ 흎풕 ퟐ풊 • The Discrete-Time Fourier Transform of a sinusoid
ELEC 3004: Systems 3 April 2019 6
3
Recap: IIR Filters = “Analog Filters” in Digital Form
ELEC 3004: Systems 3 April 2019 7
Filter Specification in the Frequency Domain Where:
1 = passband ripple (dB) |H(ω)| 2 = stopband attenuation (dB) ωp = passband edge (Hz) ωst = stopband edge (Hz) 1 ωc = cutoff frequency (@ 3dB)
N: filter type/order to meet
specification
2
ω ωp ωc ωst
Passband Transition Stopband
ELEC 3004: Systems 3 April 2019 8
4 Butterworth Filters
ELEC 3004: Systems 3 April 2019 9
Butterworth Filters • Butterworth: Smooth in the pass-band • The amplitude response |H(jω)| of an nth order Butterworth low pass filter is given by:
• The normalized case (ωc=1)
Recall that:
ELEC 3004: Systems 3 April 2019 10
5 Analog Filter Summary
Passband Stopband Transition MATLAB Design Filter Type Ripple Ripple Band Command Butterworth No No Loose butter Chebyshev Yes No Tight cheby Chebyshev Type II No Yes Tight cheby2 (Inverse Chebyshev) Eliptic Yes Yes Tightest ellip
ELEC 3004: Systems 3 April 2019 11
IIR Filter Design Methods
ELEC 3004: Systems 3 April 2019 12
6 IIR Filter Design Methods • Normally based on analogue prototypes – Butterworth, Chebyshev, Chebyshev 2, Elliptic, etc.
• Then transform 퐻 푠 → 퐻(푧)
• Three popular methods: 1. Impulse invariant – 퐻(푧): whose impulse response is a sampled version of ℎ(푡) (also step invariant) 2. Matched z–Transform – poles/zeros 퐻(푠) directly mapped to poles/zeros 퐻(푧) 3. Bilinear z – transform – left hand s – plane mapped to unit circle in z – plane
ELEC 3004: Systems 3 April 2019 13
Impulse Invariant Simplest approach, proceeds as follows:
1. Select prototype analogue filter 2. Determine H(s) for desired 휔 푐 and 휔 푠 푐푢푡표푓푓 푓푟푒푞. 푠푡표푝 푓푟푒푞. 3. Inverse Laplace • Calculate impulse response, ℎ(푡)
4. Sample impulse response ℎ 푡 푡=푛Δ푡푑 • ℎ[푛] = Δ푡푑 ℎ(푛Δ푡푑) 5. Take z-Transform of ℎ 푛 ⇒ 퐻(푧) – Poles: 푝푖 maps to exp (푝푖Δ푡푑) – Zeros: have no simple mapping
ELEC 3004: Systems 3 April 2019 14
7 Impulse Invariant [2] Useful approach when: • Impulse (or step) invariance is required – e.g., control applications • Designing Lowpass or Bandpass filters
Has problems when: • 퐻 휔 does not 0 as 휔 → ∞ • Ex: highpass or bandstop filters • If H(w) is not bandlimited, aliasing occurs!
ELEC 3004: Systems 3 April 2019 15
Matched z - transform • Maps poles/zeros in s – plane directly –to poles/zeros in z – plane
• No great virtues/problems
• Fairly old method –not commonly used –so we won’t consider it further
ELEC 3004: Systems 3 April 2019 16
8 Bilinear z - transform • Maps complete imaginary s –plane () – to unit circle in z -plane
• That is: map analogue frequency 휔푎 to discrete frequency 휔푑
• Uses continuous transform:
2 d t a tan t 2
흎 This compresses (warps) 흎 to have finite extent 풔 풂 ퟐ this removes possibility of any aliasing
ELEC 3004: Systems 3 April 2019 17
tan transform maps ωa to ωd ω t/2 Analogue ωa d Filter
|H(ωa)| 0 - 0 2 3 4 ωdt/2
Spectral compression |H(ωd)| due to the bilinear z -transform
Digital Filter
-ωs/2 0 ωs/2 ωs 3ωs/2 2ωs ωd Note,ELEC H(3004:ω Systemsd) periodic, due to sampling 3 April 2019 18
The bilinear transform
Transforming to s-domain
Remember: s = ja and tan = sin/cos
Where = dt/2
Using Euler’s relation This becomes… (note: j terms cancel)
Multiply by exp(-j)/exp(-j)
As z = exp(sdt) = exp(jdt)
ELEC 3004: Systems 3 April 2019 19
Bilinear Transform • Convert H(s) H(z) by • However, this substituting, transformation compresses the analogue frequency response, which means 21 z 1 – digital cut off frequency s will be lower than the t1 z 1 analogue prototype
Note: this comes directly from tan transform • Therefore, analogue filter must be “pre-warped” prior to transforming H(s) H(z)
ELEC 3004: Systems 3 April 2019 20
10 Bilinear Pre-warping
2 d t a tan t 2
a = d
ELEC 3004: Systems 3 April 2019 21
Bilinear Transform: Example • Design digital Butterworth lowpass filter – order, n = 2, cut off frequency 휔푑 = 628 rad/s – sampling frequency 휔푠 = 5024 rad/s (800Hz)
• Pre-warp to find 휔푎 that gives desired 휔푑 2 628 Note: ωd < ωa a tan 663 rad/s 1 2 800 due to compression 800
• Butterworth prototype (unity cut off) is, 1 H(s) s2 2s 1
ELEC 3004: Systems 3 April 2019 22
11 Bilinear Transform: Example [2] 푠 • De-normalised analogue prototype (푠’ = ) 휔푐 – 휔푐 = 663 rad/s (required 휔푎 to give desired 휔푑) 1 H(sd ) 2 s 2s 1 663 663 1 – Convert H(s) H(z) by substituting 21 z s 1 t1 z 1 H(z) 2 2800(1 z 1) 2800(1 z 1) 2 1 1 1 663(1 z ) 663(1 z ) 0.098z 2 0.195z 0.098 Note: H(z) has both H(z) poles and zeros z 2 0.942z 0.333 H(s) was all-pole
ELEC 3004: Systems 3 April 2019 23
Bilinear Transform: Example [3]
Y (z) 0.098z 2 0.195z 0.098 H (z) X (z) z 2 0.942z 0.333
• Multiply out and make causal: Y (z)(z 2 0.942z 0.333) X (z)(0.098z 2 0.195z 0.098)
Y (z)(1 0.942z 1 0.333z 2 ) X (z)(0.098 0.195z 1 0.098z 2 )
• Finally, apply inverse z-transform to yield the difference equation: y[ n ] 0.098 x [ n ] 0.195 x [ n 1] 0.098 x [ n 2] 0.942y [ n 1] 0.333 y [ n 2]
ELEC 3004: Systems 3 April 2019 24
12 Bilinear Transform: Example [4] Magnitude response
c
Digital compared to Analog: 1. Increased roll off and attenuation in stopband 휔 2. Nearly attenuation at 푠 2
ELEC 3004: Systems 3 April 2019 25
Bilinear Transform: Example [5]
Pole/Zero Plot
1
0.8
0.6
0.4
0.2
0
Imaginary Part Imaginary -0.2
-0.4
-0.6
-0.8
-1
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 Real Part
ELEC 3004: Systems 3 April 2019 26
13 Bilinear Transform: Example [6]
Phase response Increased phase delay
Bilinear transform has effectively increased digital filter order (by adding zeros)
ELEC 3004: Systems 3 April 2019 27
Bilinear Transform: Example [7]
Impulse Response 0.35
0.3
0.25
0.2
0.15 Amplitude
0.1
0.05
0
0 2 4 6 8 10 12 14 16 Samples
ELEC 3004: Systems 3 April 2019 28
14 Bilinear Transform: Example [8]
x[n] Canonical Implementation
0.942 -0.333 y[n] 0.098y'[n] 0.195y'[n 1] 0.098y'[n 2] y'[n] x[n] 0.942y'[n 1] 0.333y'[n 2]
z -1 z -1 y[n]’ of the difference equation 0.098 0.195 0.098 y[n] 0.098x[n] 0.195x[n 1] 0.098x[n 2] 0.942y[n 1] 0.333y[n 2] y[n]
ELEC 3004: Systems 3 April 2019 29
Bilinear Design Summary • Calculate pre-warping analogue cutoff frequency
• De-normalise filter transfer function using pre-warping cut-off
• Apply bilinear transform and simplify
• Use inverse z-transform to obtain difference equation
ELEC 3004: Systems 3 April 2019 30
15
BREAK
ELEC 3004: Systems 3 April 2019 31
Tutorial 3 (Week 6 & 7!) • Week 6: PS 1 Review • Week 7: FIR Filters • DCT, FFT & More!
ELEC 3004: Systems 3 April 2019 32
16 Fun Demo! Resize a “Screen Shot” • 10:1 Reduction of Picture of an LCD Screen…
Without Gaussian Filter First
WITH Gaussian Filter (σ=2)
• Moire ∵ of Aliasing of a Non Band-limited Signal
ELEC 3004: Systems 3 April 2019 33
Direct Synthesis (in the Z-Domain)
ELEC 3004: Systems 3 April 2019 34
17 Direct Synthesis • Not based on analogue prototype – But direct placement of poles/zeros
• Useful for – First order lowpass or highpass • simple smoothers
– Resonators and equalisers • Single frequency amplification/removal
– Comb and notch filters • Multiple frequency amplification/removal
ELEC 3004: Systems 3 April 2019 35
First Order Filter: Example • General first order transfer function – Gain, G, zero at –b, pole at a (a, b both < 1)
Remember: H(ω) = H(z)|z = exp(jwt)
G1 bz 1 H(z) 1 az 1
with a +ve & b –ve z = exp(jω) this is a lowpass filter i.e., G1 b o x H (0) exp(j) = -1 1= exp(j0) 1 a -b a G1 b H ( ) s/2 1 a
ELEC 3004: Systems 3 April 2019 36
18 First Order Filter: Example • Possible design criteria – cut-off frequency, 휔푐 • 3푑퐵 = 20 log ( 퐻 (휔푐) ) • e.g., at 휔 = , 푐 2 1+푏 • = 2 1+푎
– stopband attenuation • assume 휔푠푡표푝 = (Nyquist frequency) 퐻() 1 • e.g., = = i.e., two unknowns (a,b) 2 퐻(0) 21 two (simultaneous) design equations. H( ) (1b)(1 a) 1 H(0) (1 b)(1 a) 21
ELEC 3004: Systems 3 April 2019 37
Digital Resonator Design Prototype
• Second order ‘resonator’ – single narrow peak frequency response – i.e., peak at resonant frequency, 휔0
|H(ω)|2 1
x R 1/2 ω = 3dB width w 0
x
0 ω0 /2 ω
ELEC 3004: Systems 3 April 2019 38
19 Quality factor (Q-factor) • Dimensionless parameter that compares – Time constant for oscillator decay/bandwidth () to – Oscillation (resonant) period/frequency (0) • High Q = less energy dissipated per cycle f Q 0 0 f • Alternative to damping factor () as
1 2 2 Q 0 0 H(s) 2 2 2 s 2 s 2 2 0 0 s 0 s Q 0 • Note: Q < ½ overdamped (not an oscillator)
ELEC 3004: Systems 3 April 2019 39
Digital Resonator Design • To make a peak at 휔0 place pole – Inside unit circle (for stability) – At angle 휔0 distance R from origin • i.e., at location 푝 = 푅 exp (푗휔0) – R controls ω » Closer to unit circle sharper peak • plus complex conj pole at p* = R exp(-jw0)
1 Hz() 11 1R exp( j00 ) z 1 R exp( j ) z 1 1 2 2 1R exp j00 exp j z R z G 12 1a12 z a z Where (via Euler’s relation) 2 a1 2 R cos( 0 ) and a 2 R
ELEC 3004: Systems 3 April 2019 40
20 Digital Resonator Design
• Frequency response H(w) = H(z)|z = exp(jw) G H () 1R exp( j00 )exp( j ) 1 R exp( j )exp( j ) G 1a12 exp( j ) a exp( 2 j )
Note: we know the form of the 2nd equation from the previous slide
And a1 and a2 remain the same
ELEC 3004: Systems 3 April 2019 41
Digital Resonator Design
• Fixing unity gain at w0 (pole frequency)
– i.e., |H(w0)| = 1
G Hw(0 ) 1 1R exp( j0 )exp( j 0 ) 1 R exp( j 0 )exp( j 0 ) solving for G ,
2 GRRR(1 ) 1 2 cos(20 ) Design relationship between gain G and pole radius R
(at resonant frequency w0)
ELEC 3004: Systems 3 April 2019 42
21 Digital Resonator Design
• Magnitude squared response is given by
2 2 G H () 22 1 2RRRR cos( 00 ) 1 2 cos( ) • The 3dB bandwidth, w, occurs when 2 – |H(ω)| = ½ (remember G selected for |H(ω0)| = 1)
– two points ω1 and ω2 (on either side of ω0)
– ω = ω1 - ω2 • when pole, p, is close to the unit circle (R 1) 2(1 R ) i.e., closer pole is to unit circle, the sharper the peak Note: (1 - R) is pole distance to unit circle
ELEC 3004: Systems 3 April 2019 43
Resonator Design “Formula”
1. For specified resonant frequency ω0 – and 3 dB bandwidth ω
2. Calculate pole angle = 2ω0/ωs – i.e., 0 s 2 휔 3. Calculate pole radius 푅 = 1 − 2
4. Calculate 2 G (1 R) 1 2Rcos(2w0 ) R
5. Calculate filter coefficients (푎1, 푎2) 2 a1 2 R cos( 0 ) and a 2 R
ELEC 3004: Systems 3 April 2019 44
22 Digital Resonator: Example • Design a 2-pole resonator with • peak, 푓0 = 500퐻푧 • 3dB width, 푓 = 32퐻푧 • sampling frequency 푓푠 = 10푘퐻푧
• Normalise specification 푓0 • 휔0 = 2 = 0.1 푓푠 푓 • 휔 = 2 = 0.02 푓푠
• Calculate R (from 휔 2(1 − 푅)) • R = 0.99
• Then calculate G and 푎1 and 푎2 • 푮 = 0.0062, 푎1 = −1.8831 and 푎2 = 0.9801
ELEC 3004: Systems 3 April 2019 45
Discrete Filter Transformations • By convention, design Lowpass filters – transform to HighPass, BandPass, BandStop, etc.
• Simplest transformation – Lowpass H(z’ ) highpass H(z) – 퐻퐻푃(푧) = 퐻퐿푃 푧 푧’ −푧 휔 • reflection about imaginary axis ( 푠) 4 • changing signs of poles and zeros
• LP cutoff frequency, 휔퐶퐿푃 becomes • HP cut-in frequency: 휔 = 1 − 휔 퐶퐻푃 2 퐶퐿푃
ELEC 3004: Systems 3 April 2019 46
23 Lowpass highpass (z’ = -z) z - plane Lowpass Highpass prototype transform
wCLP wCHP o x x o
pL = ¼, zL = -1 pH = -¼, zH = 1
Poles/zeros reflected in imaginary axis: wCHP = ½ - wCLP Same gain @ ws/4 (i.e., /4) |H(wHP)| = |H(/2 - wLP)|
ELEC 3004: Systems 3 April 2019 47
Discrete Filter Transformations • Lowpass H(z’ ) highpass • Lowpass H(z’ ) Bandpass H(z) H(z) – Cut-off (3dB) frequency = – Centre frequency = w0 & wc (remains same) 3dB bandwidth = wc
cosw t z z' c 1 coswctz z z 2 cos(w t) z' 0 z 1 cos(wct)
Note: these are not the only possible BP and BS transformations!
ELEC 3004: Systems 3 April 2019 48
24 Discrete Filter Transformations • Lowpass H(z’ ) Bandstop H(z) – Centre frequency = 휔0 3dB bandwidth = 휔푐
z2 2/( k 1) z (1 k )/(1 k ) z ' 1 2/( k 1) z (1 k )/(1 k ) z2
cos(0t ) 2 kt tan (c ) cos(ct )
Note: order doubles for bandpass/bandstop transformations
ELEC 3004: Systems 3 April 2019 49
z - plane Lowpass Highpass prototype transform
o x x o
Bandpass Bandstop transform transform x o
o x x
x o
ELEC 3004: Systems 3 April 2019 50
25 Notch and Comb Filters • By positioning multiple pole/zero pairs – equally spaced around the unit circle
• Design a filter that removes/amplifies – frequencies at 푛 ⋅ 휔0 – i.e., frequency harmonics
• Can also remove/amplify multiple arbitrary frequencies
• Notch filter – removes multiple/single frequencies
• Comb filter – amplifies multiple/single frequencies
ELEC 3004: Systems 3 April 2019 51
Comb and Notch Filters
Comb Filter |H(ω)|
x o x o o x o x 0 /2 ω |H(ω)| Notch Filter o x o x x o x o 0 /2 ω
ELEC 3004: Systems 3 April 2019 52
26 Summary • Digital Filter Structures – Direct form (simplest) – Canonical form (minimum memory) • IIR filters – Feedback and/or feedforward sections • FIR filters – Feedforward only • Filter design – Bilinear transform (LP, HP, BP, BS filters) – Direct form (resonators and notch filters) – Filter transformations (LP HP, BP, or BS) • Stability & Precision improved – Using cascade of 1st/2nd order sections
ELEC 3004: Systems 3 April 2019 53
Next Time… • Digital Windows
& FIR!
• Review: – Chapter 10 of Lathi
• A signal has many signals [Unless it’s bandlimited. Then there is the one]
ELEC 3004: Systems 3 April 2019 54
27