21
Colorado State University Dept of Electrical and Computer Engineering ECE423 – 1 / 21 Lecture 6 - FIR Filter Design Methods James Barnes ([email protected]) Spring 2014

Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 1 / 21

Lecture 6 - FIR Filter Design Methods

James Barnes ([email protected])

Spring 2014

Page 2: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Hand Design Methods

Hand Design Methods

”Hand” DesignMethods FIR Design MethodsOverview

Notation

Fourier Series Method Fourier Series Simpleexample

Impulse Invariance -Basic Idea (Conceptual)

Impulse InvarianceExample (with a SimpleWindow Function)

Normalized vsUn-normalized SINCfunctions Impulse InvarianceExample (Cont’d)

Commonly-usedWindow Functions Window FunctionProperties

Filter Design byPole/Zero Placement Example - SecondOrder FIR

FIR Filter Classes

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 2 / 21

Page 3: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

”Hand” Design Methods

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 3 / 21

1. Impulse Invariance - sample continuous-time impulse response function.2. Fourier Series Method - sample desired frequency response function3. Pole/Zero Placement in z-domain

Page 4: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

FIR Design Methods Overview

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 4 / 21

Page 5: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Notation

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 5 / 21

Capital letters denote variables used in the continuous-time domain (exceptfor t):

Ts, F, Fs, F0,Ω,Ωs,Ωc

Lower case letters denote variables used in the discrete-time or sequencedomain.

f = F/Fs, f0 = F0/Fs, ω, ω0

Square brackets denote sequences, curved brackets denote functions ofcontinuous variables:

x[n], H(z)

In cases where the domain is not clear, a subscript c will be used to denote afunction in the continuous-time domain, subscript d for discrete-time domain,i.e.

Hd(z = ejω), Hc(s = jΩ)

Page 6: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Fourier Series Method

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 6 / 21

Basic Idea: ANY function of the discrete-time frequency ω, such as thefrequency response H(ejω) of a filter, is periodic in ω with a period of 2π .Therefore it can be expanded in a Fourier Series. The Fourier Seriescoefficients are the discrete-time impulse response function values h[n]:

FS : H(ejω) =

∞∑

n=−∞

X[n]e−jωn (1)

ZT : H(z) =

∞∑

n=−∞

h[n]z−n

z → ejω ⇒ H(ejω) =

∞∑

n=−∞

h[n]e−jωn (2)

⇒ X[n] = h[n] (3)

Page 7: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Fourier Series Simple example

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 7 / 21

Low pass filter with cutoff frequence ω0, implemented in FIR filter with M = 41 taps. Let H(ejω) = 1 for −ω0 ≤ ω ≤ ω0. Then using the inverse Fourier Series relation to

get the Fourier Coefficients:

X[n] = h[n] =1

∫ ω0

−ω0

ejωn

Changing the variable of integration to x = jωn, get

h[n] =1

2πjnejwn

ω0

−ω0

Therefore

h[n] =1

πn

ejω0n − e−jω0n

2j=

ω0

πsinc(ω0n) = 2f0sinc(2πf0n)

Now need to truncate to M=41 terms long and shift by (M-1)/2 terms to make h[n]causal. Get

h[n] =ω0

πsinc(ω0(n−

M − 1

2)), 0 ≤ n ≤ (M − 1)

Page 8: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Impulse Invariance - Basic Idea(Conceptual)

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 8 / 21

Start with a continuous-time impulse response hc(t) ↔ H(ejΩt)

Commonly start with Butterworth, Chebychev, elliptical analog filter

Multiply hc(t) by continuous-time window function w(t) defined to be non-zero over a restrictedrange.

f(t) = hc(t) · w(t) Derive a discrete-time impulse response function by sampling f(t): h[n] = Tsf(nTs) for

−M2

≤ n ≤ M2

for M even or −M−12

≤ n ≤ M−12

for M odd.

The sampling time Ts multiplier is a normalizing factor to preserve signal amplitude.

By sampling over a restricted range, we have truncated (”windowed”) hc(t) to make it finiteduration in time: f(t) = hc(t) · w(t)

The width of the window Tw = M2Ts (for M even). The window function is defined to be 0

outside the width −Tw < t < Tw. Windowing is done in the time domain but commonly transform back to the frequency

domain to see what we got.

hd[n] = f(nTs) is a discrete-time function, but non-causal sequence, so cannot use for realtimeprocessing in this form.

To make hd[n] causal, delay by M2Ts for M even or M−1

2Ts for M odd.

Ex: hd[n] = f((n− M2)Ts) (for M even).

Page 9: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Impulse Invariance Example (with a SimpleWindow Function)

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 9 / 21

Spec: LPF with cutoff frequency F0 = 1500 Hz, Fs = 8000, ⇒ Hc(ej·2πFt) = 1 for

0 < F < F0

Also want order M=41, which will determine width of window function in timedomain. Chose rectangular window w(t) = 1 for −Tw < t < Tw , whereTw = M−1

2Ts = 20Ts = 2.5 · 10−3 sec.

Then

hc(t) =

∫∞

−∞

Hc(ej·2πFt)ej·2πFtdF (4)

=

∫ f0

−f0

1 · ej·2πFtdF (5)

=1

πtsin(2πF0t) = 2F0sinc(2πF0t) =

Ω0

πsinc(Ω0t) (6)

Note that there are two definitions of sinc(x), the ”normalized” definitionsinc(x) = sin(πx)

πx and the ”unnormalized” definition, used here,

sinc(x) = sin(x)x (see next slide).

Page 10: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Normalized vs Un-normalized SINCfunctions

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 10 / 21

Page 11: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Impulse Invariance Example (Cont’d)

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 11 / 21

Note that hc(t) is

Of length ±∞ - truncate with windowing function Continuous-time - fix by sampling Non-causal - fix by delaying

For our simple rectangular window, the windowed impulse response functionf(t) = hc(t) for −Tw < t < Tw, 0 elsewhere.

Sample and delay to geth[n] = Ts · f((n− M−1

2)Ts) = 2f0sinc(2πf0(n− M−1

2)) = ω0

πsinc(ω(n− M−1

2)).

Same result Fourier Series method.

Page 12: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Commonly-used Window Functions

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 12 / 21

The abrupt edge of rectangular windowing function allows frequencies beyond the cutoffto leak through (sinc function in the frequency domain with significant side-lobes). Betterwindow functions are:

Barlett window

w(t) =

2

NTs

t + 1 , −N

2Ts < t < 0

−2

NTs

t + 1, 0 ≤ t <N

2Ts

0 , otherwise

(1)

Hanning Window

w(t) =

0.5 + 0.5 cos

(

NTs

t

)

, −N

2Ts < t <

N

2Ts

0 , otherwise

(2)

Hamming Window

w(t) =

0.54 + 0.46 cos

(

NTs

t

)

, −N

2Ts < t <

N

2Ts

0 , otherwise

(3)

Blackman Window

w(t) =

0.42 + 0.5 cos

(

NTs

t

)

− 0.08 cos

(

NTs

t

)

, −N

2Ts < t <

N

2Ts

0 , otherwise

(4)

Page 13: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Window Function Properties

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 13 / 21

Window functions with softer edges produce better results at the expense ofincreased computation:

Window Main Lobe Width Max Side Lobe

Rectangular 4πN+1fs -13 dB

Bartlett 8πN fs -25 dB

Hanning 8πN fs -31 dB

Hamming 8πN fs -41 dB

Page 14: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Filter Design by Pole/Zero Placement

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 14 / 21

From knowledge of how pole/zero locations affect frequency response, wecan create simple filters through placement of poles and zeros

Most convenient to use factored form of transfer function

H(z) = b0ΠM

k=0(1− zkz−1)

ΠNk=0(1− pkz−1)

(7)

For an FIR filter, the frequency response in terms of the zero locations isgiven by

H(ejω) = b0ΠMk=0(1− zke

−jω) (8)

which can be readily evaluated from the zero locations.

Note that for real system (real input x[n] → real output y[n], the frequencyresponse must have Hermitian symmetry H∗(e−jω) = H(ejω). This requiresthe zeros to lie on the real axis or be in complex conjugate pairs.

Page 15: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Example - Second Order FIR

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 15 / 21

Complex conjugate zeros at z0 = r0e±jωo

H(z) = (1− roejωoz−1)(1− roe−jωoz−1) = 1− 2rocosωoz−1 + r2oz−2

Impulse response h[n] = 1,−2rocosωo, 1 Plot for ωo = ±3π/4

Page 16: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

FIR Filter Classes

Hand Design Methods

FIR Filter Classes Linear Phase FIRFilter Linear Phase -Conditions on h[k]

Linear Phase -Location of Poles/Zeros

Special Filter Types

FIR Direct andTransposed Forms

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 16 / 21

Page 17: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Linear Phase FIR Filter

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 17 / 21

Linear phase means filter acts as a fixed delay for all frequencies in passband – nophase distortion.

Let H(ejΩ) = Hr(Ω)ejΘ(Ω), where Hr(Ω) is a real function of Ω.

Then for an input X(Ω) = ejΩt, we get an output Y (Ω) = Hrej(Ωt+Θ(Ω))

If Θ(Ω) = −Ωτ , with τ constant, then Y (Ω) = Hr(Ω)ejΩ(t−τ)

⇒ the only affect of H is to delay all frequencies by τ

The above was shown in continuous-time but holds in the discrete-time domain aswell.

Page 18: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Linear Phase - Conditions on h[k]

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 18 / 21

h[k] must be real

⇒ H∗(−jω) = H(jω) ⇒ poles/zeros must lie on real z-axis or come in complex conjugatepairs.

h[k] must be symmetric about its center point

If support of h[k] is k=0. . . M-1 (order M), then h[k] = h[M - k -1]). Prf: Assume M even

Then H(z)=∑M−1

k=0 h[k]z−k =∑(M/2)−1

k=0 h[k][z−k + z−(M−k−1)]

H(z) = Z(M−1)/2∑(M/2)−1

k=0 h[k][z−(k−(M−1)/2) + zk−(M−1)/2]

Let z = ejω. Then H(ejω) = ejω(M−1)/2

∑(M−1)/2k=0 h[k]2cos(ω(k − (M − 1)/2)) = Hr(ω)ejω(M−1)/2,

where Hr is REAL ⇒ Θ(ω) = −M−1

2ω: LINEAR PHASE

If h[k] is anti-symmetric about its center point, Θ(ω) = −M−12

ω + π2

:LINEAR term plus constant phase shift of 90 for all frequencies.

Page 19: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Linear Phase - Location of Poles/Zeros

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 19 / 21

We have two conditions :

H(z) = H∗(z∗) - Hermitian symmetry ⇒ h[k] is real

⇒ poles/zeros all lie on unit circle or come in pairs which are symmetric in areciprocal distance sense about the unit circle.

Page 20: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

Special Filter Types

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 20 / 21

Differentiator

Continuous time G(s) = s ⇒ G(Ω) = jΩ = ejπ/2Ω Discrete-time filter design procedure with Impulse Invariance:

window/delay/sample, plot in Matlab

Integrator

Continuous time G(s) = 1/s ⇒ G(Ω) = 1jΩ = e−jπ/2

Ω

Hilbert TransformerG(jΩ) =

−j 0 < Ω ≤ πj −π < Ω < 0

Page 21: Lecture 6 - FIR Filter Design Methods · 2 ≤ n ≤ M 2 for M even or −M−1 2 ≤ n ≤ M−1 2 for M odd. The sampling time Ts multiplier is a normalizing factor to preserve

FIR Direct and Transposed Forms

Colorado State University Dept of Electrical and Computer Engineering ECE423 – 21 / 21

We are not physically building filters but writing software to perform thefiltering algorithms, but if we WERE building the filters out of registers,adders, and multipliers, there are design considerations which would lead usto choose one type of implementation over another. There are two types ofimplementations: