19
Non-Recursive Digital Filter Design Digital Controller Design Digital Controls & Digital Filters Lectures 23 & 24 M.R. Azimi, Professor Department of Electrical and Computer Engineering Colorado State University Spring 2017 M.R. Azimi Digital Control & Digital Filters

Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Digital Controls & Digital FiltersLectures 23 & 24

M.R. Azimi, Professor

Department of Electrical and Computer EngineeringColorado State University

Spring 2017

M.R. Azimi Digital Control & Digital Filters

Page 2: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Approximation Methods: FIR Digital Filters

FIR filter are described by convolution summation:

y(n) =N−1∑k=0

h(k)x(n− k) x(n): Input signal y(n): Output signal

h(n): Impulse response (filter coefficients) N : Filter orderAdvantages:

1 Inherently stable.

2 Linear phase characteristic especially useful in applications where frequencydispersion due to non-linear phase is harmful e.g. speech and audio processing.

3 Quantization effects can be made small.

4 Implementation using parallel/pipeline processors because of inherentconcurrency.

Disadvantages:

1 For a sharp cut-off performance a large order filter is required =⇒ largecomputation time for implementation.

2 In some cases ”fractional delay” may be needed which can not be realizedby physical devices.

M.R. Azimi Digital Control & Digital Filters

Page 3: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Frequency Response of FIR Filters

The transfer function of a causal FIR filter is:

H(z) =N−1∑n=0

h(n)z−n

Let z = ejΩ (i.e. unit circle)

H(ejΩ) =N−1∑n=0

h(n)e−jΩn = DTFTh(n)

Sampling the frequency scale Ω = 2πkN

yieldsthe N elements of the DFT of h(n) as:

H(k) =N−1∑n=0

h(n)e−2πjknN = DFTh(n), k ∈ [0, N − 1]

and

h(n) = IDFTH(k) = 1N

N−1∑n=0

H(k)ejπjknN , n ∈ [0, N − 1]

Now, consider the following cases.

M.R. Azimi Digital Control & Digital Filters

Page 4: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Frequency Response of FIR Filters-Cont.

Case 1: Symmetric: h(n) = h(N − 1− n) and N odd

H(ejΩ) = e−jΩ(N−1)

2

(N−1)2∑

n=0

α(n) cos Ωn

whereα(n) , 2h

[(N−1)

2− n

], n ∈ [1, N−1

2]

α(0) , h(

(n−1)2

)φ(Ω) = −Ω (N−1)

2: linear

Group delay τg = − dφ(Ω)dΩ

= N−12

: Integer

Case 2: Symmetric: h(n) = h(N − 1− n) and N Even

H(ejΩ) = e−jΩ(N−1)

2

N/2∑n=1

β(n) cos [Ω(n− 1/2)]

where,β(n) , 2h(N

2− n), n ∈ [1, N/2]

Note that at Ω = π,H(ejΩ) = 0 i.e HPF can not be approximated.

M.R. Azimi Digital Control & Digital Filters

Page 5: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Frequency Response of FIR Filters-Cont.

Case 3: Anti-Symmetric: h(n) = −h(N − 1− n), h(N−12 ) = 0, and N odd

H(ejΩ) = e−jΩ(N−1)

2 ejπ/2(N−1)

2∑n=1

γ(n) sin Ωn

whereγ(n) , 2h

[(N−1)

2 − n], n ∈ [1, N−1

2 ]

Case 4: Anti-Symmetric: h(n) = −h(N − 1− n) and N even

H(ejΩ) = e−jΩ(N−1)

2 ejπ/2N/2∑n=1

δ(n) sin [Ω(n− 1/2)]

where,δ(n) , 2h(N2 − n), n ∈ [1, N/2]In the anti-symmetric case at Ω = 0, H(ejΩ) = 0. i.e. suitable forapproximating such filters as differentiators and Hilbert transforms

M.R. Azimi Digital Control & Digital Filters

Page 6: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Frequency Sampling Method

Design Methods

1 Windowing

2 Frequency sampling method

3 Computer aided design methods (CAD)

Frequency Sampling MethodIdea: Given the frequency response of the desired filter, HDes(e

jΩ), sample it toobtain H(k) and then take IDFT of H(k) to get h(n).

Let the transfer function of the FIR filter be :

H(z) =N−1∑n=0

h(n)z−n

we know that

H(k) = H(z)|z= j2πk

N=N−1∑n=0

h(n)e−j2πkn

N , k ∈ [0, N − 1]

Additionally: h(n) = IDFTH(k) = 1N

N−1∑k=0

H(k)ej2πknN , n ∈ [0, N − 1]

Then,

H(z) =N−1∑n=0

[N−1∑k=0

H(k)ej2πknN

]z−n =

N−1∑k=0

H(k)N

N−1∑n=0

(ej2πkN z−1)n

M.R. Azimi Digital Control & Digital Filters

Page 7: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Frequency Sampling Method-Cont.

Now usingN−1∑n=0

an = 1−aN1−a , we get ,

N−1∑k=0

H(k)N

(1−ej2πkz−N )

(1−ej2πkN z−1)

=(1− z−N )

N︸ ︷︷ ︸H1(z)

N−1∑k=0

H(k)

(1− ej2πkN z−1)︸ ︷︷ ︸

H2(z)

which can be realized by cascade of a simple FIR (Comb) filter with an IIR system.

M.R. Azimi Digital Control & Digital Filters

Page 8: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Frequency Sampling Method

The term (1− z−N ) represents an FIR filter with frequency response

H1(ejΩ) = 1− e−jΩN = e−jΩN2

[ejΩ

N2 − e−jΩN

2

]= e−jΩ

N2 2j sin ΩN

2

The plot of |H1(ejΩ)| as a function of Ω is shown below.

The IIR part, H2(z), consists of parallel combination of N complex coefficient

1st order systems with poles at zk = ej2πkN on the unit circle. Of course these

poles will be cancelled with the zeros of H1(z) which also occur at zk = ej2πkN

since 1− z−N = 0 =⇒ z = (1)1/N =⇒ zk = ej2πkN , k ∈ [0, N − 1]

M.R. Azimi Digital Control & Digital Filters

Page 9: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Frequency Sampling Method

In order to have H(z) with real coefficients (physical realization) we require thatH(k) = |H(k)|ejθ(k) satisfy:

|H(k)| = |H(N − k)|andθ(k) = −θ(N − k), k ∈ [0, N − 1]

Now each pair of H(k) and H(N − k), k ∈ [0, N2

] gives a 2nd order system with realcoefficients. i.e:

Hk(z) = H(k)

1−ej2πkN z−1

+ H(N−k)

1−ej2π(N−k)

N z−1

=2|H(k)|[cos θ(k)−z−1 cos (θ(k)− 2πk

N)]

1−2 cos 2πkN

z−1+z−2

Note that for N odd there is no frequency sample for k = N/2 thus the correspondingterm does not exist.

M.R. Azimi Digital Control & Digital Filters

Page 10: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Frequency Sampling Method: Design Procedure

Given desired frequency response HDes(ejω) sample it to yield:

H(k) = HDes(ejΩ)|Ω= 2πk

N, k ∈ [0, N − 1]

Impose the following conditions on the magnitude |H(k)| and phase θ(k):

1 For linear phase: θ(k) = − (N−1)kπN

, k ∈ [0, N − 1]

2 For real coefficients: |H(k)| = |H(N − k)| and θ(k) = −θ(N − k)

Note for N even set H(N2

) = 0.

Example: Design an N = 11 order low-pass FIR filter whose cut-off frequencyfc = 2fs/11, where fs is the sampling frequency. Plot the magnitude response of thedesigned filter.

We start with ideal filter for HDes(ejΩ) and sample it with spacing between samples=

Ωs2πN

= fsN

. See below figure.

M.R. Azimi Digital Control & Digital Filters

Page 11: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Frequency Sampling Method: Design Procedure

We then impose the above conditions i.e.

|H(k)| = |H(N − k)| and

θ(k) = − (N−1)kπN

= 10kπ11

, k ∈ [0, 10]

These combined yield,

H(k) =

e−j

10kπ11 k = 0, 1, 2 and k = 9, 10

0 k ∈ [3, 8]

Then take size N = 11 IDFT of H(k) i.e. h(n) = IDFTH(k)11 which gives

h(0) = 0.06942, h(1) = −0.05403, h(2) = −0.10945, h(3) = 0.04733,h(4) = 0.31938, h(5) = 0.45455, h(6) = 0.31938, h(7) = 0.04733,h(8) = −0.10945, h(9) = −0.05403, h(10) = 0.06942

Note that these are symmetric due to the linear phase condition imposed. Magnituderesponse of the designed filter is shown (thick line) which exhibits a rather large ripplein both passband and stopband.To reduce the ripple effect, one can add a sample in the transition (wider transitionregion) region, i.e.

M.R. Azimi Digital Control & Digital Filters

Page 12: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Frequency Sampling Method: Design Procedure

H(k) =

e−j

10kπ11 k = 0, 1, 2 and k = 9, 10

0.5e−j10kπ

11 k = 3 and k = 80 k ∈ [4, 7]

The resulting filter coefficients are:h(0) = 0.00987, h(1) = 0.02244, h(2) = −0.07168, h(3) = −0.03989,h(4) = 0.30643, h(5) = 0.54545, h(6) = 0.30643, h(7) = −0.03989,h(8) = −0.07168, h(9) = 0.02244, h(10) = 0.00987

The magnitude response is shown (thin line) which shows much less ripple effects at acost of wider transition region (must increase the order). Note that one can try tooptimize the choice of the amplitude of the introduced sample.

M.R. Azimi Digital Control & Digital Filters

Page 13: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Design of Digital Controller-Classical method

Goal: Design compensators to achieve certain desired characteristics e.g.,steady-state accuracy, transient response, relative stability, sensitivity, etc.

1 Steady-State Accuracy:Desired ess ≈ 0 =⇒ poles at z = 1 =⇒ more lags =⇒ less stable

2 Transient Response:Desired: Reduce tr =⇒ increase BW =⇒ less noise immunity

3 Relative Stability:Desired: Small Mp =⇒ increase in tr, slower response

4 Sensitivity: Variation of system parameters wrt change in temperature, humidity,aging, altitude, etc.Measured by STα = ∂T

∂α. aT

where T (z) = G(z)1+G(z)

and α is a system parameter,e.g.,

STG = 11+G(z)

or in frequency domain STG = 11+G(ejΩ)

which implies,

Reduce sensitivity STG =⇒ Increase open loop gain G(ejΩ) =⇒ Instabilityproblems.

M.R. Azimi Digital Control & Digital Filters

Page 14: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Digital PID Controller

Recall from ECE 411, for PID controller:

Gc(s) = KP +KI/s+KDs

where KP : proportional gain, KI integrator gain, and KD derivative gain.

Though bilinear z-mapping can be used for the integrator:

1/s→ T2

(z+1)z−1)

it cannot be used for the derivative part. But we can use backward difference method:

y(t) = dx(t)dt≈ x(t)−x(t−∆T )

∆T, ∆T = 1, t = nT

y(n) = x(n)−x(n−1)T

=⇒ Y (z) = (X(z)−z−1X(z))T

=⇒ Y (z)X(z)

= (z−1)zT

Thus, the mapping is s→ (z−1)Tz

which yields digital PID transfer function:

Gc(z) = KP +KIT2

(z+1)(z−1)

+KD(z−1)Tz

= a0z2+a1z+a2z(z−1)

: Second order IIR filter

where a0 = KP +KIT/2 +KD/T , a1 = −KP +KIT/2− 2KD/T , a2 = KD/T ,b1 = −1, and b2 = 0

Design of PID controllers involves finding KP , KI , and KD to meet the desiredperformance criteria.

M.R. Azimi Digital Control & Digital Filters

Page 15: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Digital PID Controller-Cont.

Example: Given plant transfer function, Gp(s) = 10(s+1)(s+2)

, design a PID controller

D(z) to meet desired specs.

Loop transfer function is,

G(z) = D(z)(1− z−1)Z[

10s(s+1)(s+2)

]= D(z) 0.0453(z+0.904)

(z−0.905)(z−0.819)

First consider the uncompensated case, D(z) = 1, then closed loop transfer function is:

T (z) = C(z)R(z)

= G(z)1+G(z)

= 0.0453(z+0.904)

z2−1.679−0.782

The CE is,ρ(z) = z2 − 1.68z + 0.78 = 0 =⇒ z1,2 = 0.84± j0.28

Hence |z1,2| ≈ 0.885 < 1 =⇒ i.e. stable

However, since the loop transfer function doesn’t have any pole at z = 1, steady-stateerror is not zero.

M.R. Azimi Digital Control & Digital Filters

Page 16: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Digital PID Controller-Cont.

css = limz→1

(1− z−1)C(z) = limz→1

0.0453(z+0.904)

z2−1.679−0.782= 0.84

Thus, ess = 1− 0.84 = 0.16. The step response is shown below which reveals this fact.

For ess = 0 we then use an integral controller,

D(z) = KP +KIT2

(z+1)(z−1)

= (KIT+2KP )z+(KIT−2KP )(z−1)

Then, the loop transfer function becomes,

G(z) = D(z) 0.0453(z+0.904)(z−0.905)(z−0.819)(z−1)

=(2KP+KIT )(z+

KIT−2KPKIT+2Kp

)(z+0.094)

(z−1)(z−0.905)(z−0.819)

M.R. Azimi Digital Control & Digital Filters

Page 17: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Digital PID Controller-Cont.

Clearly, ess = 0 because of pole at z = 1. To simplify the design, we choose KI andKP to cancel pole at z = 0.905 (near unit circle)

KI−2KPKIT+2KP

= −0.905 =⇒ KPKI

= 1.0026

Now, choose KP = 1 =⇒ KI = 0.997

D(z) = 1.05(z−0.905)(z−1)

The loop transfer function with PI controller:

G(z) = 0.0453(z+0.904)(z−1)(z−0.819)

Step response for three different valuesof KP and hence KI are shown. As canbe seen the response either has a highMax overshoot or long rise time.

M.R. Azimi Digital Control & Digital Filters

Page 18: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Digital PID Controller-Cont.

We can achieve both goals while ess = 0 using a PID controller,

D(z) = a0z2+a1z+a2z(z−1)

The PID parameters KP ,KI ,KD must be determined to satisfy certain desired specs.First, we choose to cancel both poles of uncompensated system with those of PID.Additionally, we add another requirement that ramp error constant

Kv = 5 =⇒ ess = 1/Kv = 1/5 = 0.2.

Kv = 1T

limz→1

(1− z−1)G(z) = 5KI =⇒ KI = 1

a0z2 + a1z + a2 = (z − 0.905)(z − 0.819)a0 = KP +KI

T2

+ KDT

a1 = KIT2−KP − 2KD

T

a2 = KDT

=⇒KP = 1.45KD = 0.43KI = 1

The open loop and closed-loop transfer functions are,

G(z) = 0.263(z+0.904)z(z−1)

T (z) = 0.263(z+0.904)

z2−0.737z+0.238

M.R. Azimi Digital Control & Digital Filters

Page 19: Digital Controls & Digital Filters Lectures 23 & 24 23-24.pdf · Non-Recursive Digital Filter Design Digital Controller Design Frequency Sampling Method The term (1 z N) represents

Non-Recursive Digital Filter Design Digital Controller Design

Digital PID Controller-Cont.

For this system CE is,

ρ(z) = z2 − 0.737z + 0.238 = 0 =⇒ z1,2 = 0.37± j0.32

Hence |z1,2| ≈ 0.48 < 1 =⇒ i.e. much closer to the origin of the unit circle.

The step response is shown which has a max overshoot of 4% while offering a goodrise time.

M.R. Azimi Digital Control & Digital Filters