## Introduction to Computer Control Systems

Lecture 4: Linearization + Basis of PID controller

Dave Zachariah

Div. Systems and Control, Dept. Information Technology, Uppsala University

December 9, 2014

## Today’s lecture: What and why?

Linearization

Why: Approximating real nonlinear systems with linear models.

PID controller

Why: Widely used, simple yet sufficiently powerful in many systems.

## Today’s lecture: What and why?

Linearization

Why: Approximating real nonlinear systems with linear models.

PID controller

Why: Widely used, simple yet sufficiently powerful in many systems.

## Linearization: Steady-state and deviation variables

y(t)

u(t) G

Most real systems arenonlinear and often modeled as:

˙x(t) = f (x(t), u(t)) y(t) = h(x(t), u(t)).

Linearization: Pick a point (x0, u0) of f (x, u). Use linearmodel to
describe system behaviour around (x_{0}, u_{0}):

(˙x(t) = f (x(t), u(t)) y(t) = h(x(t), u(t)) ≈

(˙˜x(t) =A˜x(t) + B˜u(t)

˜

y(t) =C˜x(t) + D˜u(t) When system is at rest ˙x = f (x0, u0) =0, we call (x0, u0) a stationary point. Note: could be more than one!

## Linearization: Steady-state and deviation variables

y(t)

u(t) G

Most real systems arenonlinear and often modeled as:

˙x(t) = f (x(t), u(t)) y(t) = h(x(t), u(t)).

Linearization: Pick a point (x0, u0) of f (x, u). Uselinear model to
describe system behaviour around (x_{0}, u_{0}):

(˙x(t) = f (x(t), u(t)) y(t) = h(x(t), u(t)) ≈

(˙˜x(t) =A˜x(t) + B˜u(t)

˜

y(t) =C˜x(t) + D˜u(t)

When system is at rest ˙x = f (x0, u0) =0, we call (x0, u0) a stationary point. Note: could be more than one!

## Linearization: Steady-state and deviation variables

y(t)

u(t) G

Most real systems arenonlinear and often modeled as:

˙x(t) = f (x(t), u(t)) y(t) = h(x(t), u(t)).

Linearization: Pick a point (x0, u0) of f (x, u). Uselinear model to
describe system behaviour around (x_{0}, u_{0}):

(˙x(t) = f (x(t), u(t)) y(t) = h(x(t), u(t)) ≈

(˙˜x(t) =A˜x(t) + B˜u(t)

˜

y(t) =C˜x(t) + D˜u(t) When system is at rest ˙x = f (x0, u0) =0, we call (x0, u0) a stationary point. Note: could be more than one!

## Linearization: Steady-state and deviation variables

Define deviation variables

x(t) = x(t) − x˜ 0

˜

u(t) = u(t) − u_{0}

Then linearize byfirst-order Taylor expansion around x0, u0:

˙˜x= ˙x − 0

= f (x0+ ˜x, u0+ ˜u)

≈ f (x_{0}, u_{0})

| {z }

=0

+∇_{x}f(x_{0}, u_{0})˜x+ ∇_{u}f(x_{0}, u_{0})˜u

=A˜x+ B˜u,

where A and B given by simple derivatives,

a_{ij} = ∂f_{i}(x, u)/∂x_{j} b_{i} = ∂f_{i}(x, u)/∂u,
evaluated at x = x_{0} and u = u_{0}.

## Linearization: Steady-state and deviation variables

Similarly, y0 = h(x0, u0) for the stationary point. Define

˜

y(t) = y(t) − y0

Then linearize byfirst-order Taylor expansion around x_{0}, u_{0}:

˜

y= h(x0+ ˜x, u0+ ˜u) − y0

≈ h(x_{0}, u_{0}) + ∇_{x}h(x_{0}, u_{0})˜x+ ∇_{u}h(x_{0}, u_{0})˜u − y_{0}

= ∇_{x}h(x_{0}, u_{0})˜x+ ∇_{u}h(x_{0}, u_{0})˜u + 0

=C˜x+ D˜u,

where C and D given by derivatives,

cj = ∂h(x, u)/∂xj D= ∂h(x, u)/∂u, evaluated at x = x0 and u = u0.

## Linearization: Example

Nonlinearsystem:

˙x1

˙x2

= −K√
x_{1}
x1−^{1}_{3}x2

+

_{1}

cu 0

Find equilibrium point: ˙x = 0

0 0

= −K√
x_{1}
x1−^{1}_{3}x2

+

_{1}

cu 0

With constant input u ≡ u_{0} we get solvex_{1} and x_{2}:
x1,0= 1

Kcu0 x2,0= 3

Kcu0 ⇒ x_{0} =

_{1}

Kcu0 3 Kcu0

## Linearization: Example

Nonlinearsystem:

˙x1

˙x2

= −K√
x_{1}
x1−^{1}_{3}x2

+

_{1}

cu 0

Find equilibrium point: ˙x = 0

0 0

= −K√ x1

x1−^{1}_{3}x2

+

_{1}

cu 0

With constant input u ≡ u_{0} we get solvex_{1} and x_{2}:
x1,0= 1

Kcu0 x2,0= 3

Kcu0 ⇒ x_{0} =

_{1}

Kcu0 3 Kcu0

## Linearization: Example

Nonlinearsystem:

˙x1

˙x2

= −K√
x_{1}
x1−^{1}_{3}x2

+

_{1}

cu 0

Find equilibrium point: ˙x = 0

0 0

= −K√ x1

x1−^{1}_{3}x2

+

_{1}

cu 0

With constant input u ≡ u_{0} we getsolve x_{1} and x_{2}:
x1,0= 1

Kcu0 x2,0 = 3

Kcu0 ⇒ x_{0} =

_{1}

Kcu0 3 Kcu0

## Linearization: Example, cont’d

Nonlinear system:

˙x1

˙x2

| {z }

˙ x

= −K√
x_{1}
x1−^{1}_{3}x2

+

_{1}

cu 0

| {z }

f (x,u)

Tolinearize around (u_{0}, x_{0}): Define

˜

u = u − u0 x˜= x − x0

weevaluatederivatives

a_{11}= ∂f_{1}/∂x_{1} a_{12}= ∂f_{1}/∂x_{2} b_{1} = ∂f_{1}/∂u
a_{21}= ∂f_{2}/∂x_{1} a_{22}= ∂f_{2}/∂x_{2} b_{2} = ∂f_{2}/∂u
at (u0, x0) so that

˙˜x1

˙˜x2

=

"

−_{2}^{√}^{K}_{x}

1,0 0

1 −^{1}_{3}

#

| {z }

A

˜x1

˜ x2

+

_{1}

c

0

|{z}

B

u

## Linearization: Example, cont’d

Nonlinear system:

˙x1

˙x2

| {z }

˙ x

= −K√
x_{1}
x1−^{1}_{3}x2

+

_{1}

cu 0

| {z }

f (x,u)

Tolinearize around (u_{0}, x_{0}): Define

˜

u = u − u0 x˜= x − x0

weevaluatederivatives

a_{11}= ∂f_{1}/∂x_{1} a_{12}= ∂f_{1}/∂x_{2} b_{1} = ∂f_{1}/∂u
a_{21}= ∂f_{2}/∂x_{1} a_{22}= ∂f_{2}/∂x_{2} b_{2} = ∂f_{2}/∂u
at (u_{0}, x_{0})

so that

˙˜x1

˙˜x2

=

"

−_{2}^{√}^{K}_{x}

1,0 0

1 −^{1}_{3}

#

| {z }

A

˜x1

˜ x2

+

_{1}

c

0

|{z}

B

u

## Linearization: Example, cont’d

Nonlinear system:

˙x1

˙x2

| {z }

˙ x

= −K√
x_{1}
x1−^{1}_{3}x2

+

_{1}

cu 0

| {z }

f (x,u)

Tolinearize around (u_{0}, x_{0}): Define

˜

u = u − u0 x˜= x − x0

weevaluatederivatives

a_{11}= ∂f_{1}/∂x_{1} a_{12}= ∂f_{1}/∂x_{2} b_{1} = ∂f_{1}/∂u
a_{21}= ∂f_{2}/∂x_{1} a_{22}= ∂f_{2}/∂x_{2} b_{2} = ∂f_{2}/∂u
at (u_{0}, x_{0}) so that

˙˜x1

˙˜x2

=

"

−_{2}^{√}^{K}_{x}

1,0 0

1 −^{1}_{3}

#

| {z }

A

˜x1

˜ x2

+

_{1}

c

0

|{z}

B

u

## Feedback approach: Use control error e(t)

y u

r

+

− ^{e} Controller G

Control error:

e(t) =r(t)−y(t)

Q: How should controller determine input u(t)based on error e(t)?

## Feedback approach: Use control error e(t)

y u

r

+

− ^{e} Controller G

Control error:

e(t) =r(t)−y(t)

Q: How should controller determine input u(t)based on error e(t)?

## Feedback approach: PID controller

y u

r

+

− ^{e} Controller G

A popular approach, set input u(t)based on:

present value of e(t): u(t) = Ke(t) (Proportional)

historyof e(t): u(t) = KRt

τ =0e(τ ) (Integral) changeof e(t): u(t) = K ˙e(t) (Derivative) where K are tuning constants.

## Feedback approach: PID controller

y u

r

+

− ^{e} Controller G

A popular approach, set input u(t)based on:

present value of e(t): u(t) = Ke(t) (Proportional) historyof e(t): u(t) = KRt

τ =0e(τ ) (Integral)

changeof e(t): u(t) = K ˙e(t) (Derivative) where K are tuning constants.

## Feedback approach: PID controller

y u

r

+

− ^{e} Controller G

A popular approach, set input u(t)based on:

present value of e(t): u(t) = Ke(t) (Proportional) historyof e(t): u(t) = KRt

τ =0e(τ ) (Integral) changeof e(t): u(t) = K ˙e(t)(Derivative) where K are tuning constants.

## PID controller: time-domain

y u

r

+

− ^{e}

## H

GA popular approach: the PIDcontroller u(t) = Kpe(t)

| {z }

P

+ Ki

Z t τ =0

e(τ )dτ

| {z }

I

+ Kd˙e(t)

| {z }

D

## PID controller: Laplace-domain

y u

r

+

− ^{e}

## H

GA popular approach: the PIDcontroller U (s) = KpE(s) + Ki

1

sE(s) + K_{d}sE(s)

=

Kp+Ki

s + K_{d}s

| {z }

transfer functionH(s)

E(s),

where E(s) = R(s) − Y (s).

## PID controller: Laplace-domain, cont’d

y u

r

+

− ^{e}

## H

GFinal value theorem: If e(t) has a final value, then it can be computed by

t→∞lim e(t) = lim

s→0sE(s)

Static error analysis: Study limit of e(t) when r(t) is a constant. On the board: Let r(t) = C for t ≥ 0. Then e(t) goes to 0 when H(s)G(s) contains an integrator 1/s.

## PID controller: Laplace-domain, cont’d

y u

r

+

− ^{e}

## H

GFinal value theorem: If e(t) has a final value, then it can be computed by

t→∞lim e(t) = lim

s→0sE(s)

Static error analysis: Study limit of e(t) when r(t) is a constant.

On the board: Let r(t) = C for t ≥ 0. Then e(t) goes to 0 when H(s)G(s) contains an integrator 1/s.

## PID controller: Laplace-domain, cont’d

y u

r

+

− ^{e}

## H

GFinal value theorem: If e(t) has a final value, then it can be computed by

t→∞lim e(t) = lim

s→0sE(s)

Static error analysis: Study limit of e(t) when r(t) is a constant.

On the board: Let r(t) = C for t ≥ 0. Then e(t) goes to 0 when H(s)G(s) contains an integrator 1/s.

## PID controller: Laplace-domain, cont’d

y u

r

+

− ^{e}

## H

G## G

_{tot}

Total system from reference r(t) to output y(t):

Y (s) = Gtotal(s)R(s)

On the board: Derive Gtotal(s) = _{1+H(s)G(s)}^{H(s)G(s)}

## PID controller: Laplace-domain, cont’d

y u

r

+

− ^{e}

## H

G## G

_{tot}

Total system from reference r(t) to output y(t):

Y (s) = Gtotal(s)R(s)
On the board: Derive G_{total}(s) = _{1+H(s)G(s)}^{H(s)G(s)}

## PID controller: practical concerns

PID controllers

1 have typically bad performancewhen there is a significant time-delay in the loop. They work nicely for relativelysmall time-delays.

2 with derivative-term amplify noise. Add a low-pass filterto term
by Kds ≈ _{1+εK}^{K}^{d}^{s}

ds, for a small ε.

3 candifferdepending on manufactures. It is important to know the configuration of the PID algorithm before tuning.

4 are often implemented in discrete timebut tuned using a continuous formulation

## Today’s lecture: What and why?

Linearization

Why: Approximating real nonlinear systems with linear models.

PID controller

Why: Widely used, simple yet sufficiently powerful in many systems.