Sei sulla pagina 1di 58

Building Control and

Automation

John Lygeros

Automatic Control Laboratory, ETH Zrich


www.control.ethz.ch
Where, when?
Lectures
Fridays, 10:00-12:00, HIL F10.3
Examples classes:
Mondays, 16:00-18:00, HIL C10.2
Assessment
End of semester examination
Homework exercises
Matlab exercises
M. Hohmann

2
Who and what?
Control theory
State equations
Solutions
J. Lygeros
Discrete time systems
State and parameter estimation
Feedback
PID control R. Smith
MPC Convex optimization
Energy hubs
Mixed Integer Linear Programs A. Bollinger (EMPA)
Market based
Automation
HVAC control
C. Gaehler (Siemens)

3
Reading material
Lecture notes
Slides, handouts, available on class webpage
Blackboard notes
Recommended book
K.J. strm and R.M. Murray: Feedback Systems: An Introduction for
Scientists and Engineers, Princeton U.P., 2008
h`p://www.cds.caltech.edu/~murray/amwiki/index.php/Main_Page
Other excellent books
G.F. Franklin, J.D. Powell, and A. Emami-Naeini, Feedback control of
dynamical systems, Prentice-Hall, 2006 (also used in Regesysteme I/II)
J. Hespanha, Linear Systems Theory, Princeton U.P., 2009
T. Kailath, Linear systems, Prentice-Hall, 1980
E.A. Lee and P. Varaiya, Structure and interpretation of signals and
systems, Addison-Wesley, 2002

4
Single room house

Heater
u(t) C Thermal
Capacitance

d(t) Disturbance:
xa (t) x(t) Internal gains,
Solar irradiation,
h

Room
Ambient Thermal Temperature
Temperature conductance

5
Dynamics

d
C x(t) = h xa (t) x(t) + u(t) + d(t)
dt

Given
Dierential equation
Initial temperature x(0) = x0
Inputs u(t), d(t), xa (t) for all t 0
Can determine
x(t) for all t 0

i.e. we can determine the future
And if we do not like the future, change it!
6
If only life were so simple!
In reality
1. Multiple rooms, zones, wall layers,
2. Bounded inputs
3. Constraints from user comfort, regulations,
4. Disturbances, uncertainty
5. Unknown parameters
6. Thermostats, heat pumps, device dynamics,
7. Interaction with multi-energy carrier grids
8.

7
Multiple zones
x5 (t)
y1 (t) h21 h25 h23 y2 (t)
x1 (t) x2 (t) x3 (t) x4 (t)
u1 (t) u2 (t) h20 u3 (t)

xa (t) yi (t) = Thermometer

ui (t) = Radiator

C2 x!2 (t) = h20 (xa (t) x2 (t)) + h21 (x1 (t) x2 (t)) +
h23 (x3 (t) x2 (t)) + h25 (x5 (t) x2 (t)) + u2 (t) + d2 (t)
8
State and input variables
x1 (t) d1 (t)
u (t)
x2 (t) d2 (t)
1
x(t) = x3 (t) !5 u(t) = u2 (t) ! 3 d(t) = d3 (t) !5
x4 (t) d4 (t)
u3 (t)
x5 (t) d5 (t)

h
ij
For i j, H ij = Ci (
if i is "neighbour" of j Generally h ij = h ji )

0 otherwise

H ii = H ij
ji

9
Dynamics
A b

H11 H12 0 0 H15 H


10
H 21 H 22 H 23 0 H 25 H 20

!
x(t) = 0 H 32 H 33 H 34 H 35 x(t) + H 30 xa (t) +
0 0 H 43 H 44 H 45 H
40
H 51 H 52 H 53 H 54 H 55 H 50

0 0 0 0
0
1
1
0 C1

C1

0 1
0 0 0
0 1
C2
0
C2


0 u(t) + 0 0 0 0 d(t)
1
0 0 C3
1

0 0 0 0 0 C4 0
1
C4


0 0 0 0 0 0 0 C5 1

B D 10
Measurements
Only some temperatures can be measured
Rooms 1 and 3 equipped with thermometers

x (t) 1 0 0 0 0
y(t) =
1
! 2 y(t) = x(t)
x3 (t) 0 0 1 0 0

C
System in prototypical linear form

! = Ax(t) + bxa (t) + Bu(t) + Dd(t)


x(t)
y(t) = Cx(t)

11
Structure of the dynamics
Matrix A
O diagonal elements non-negative
Diagonal elements negative
Diagonally dominant hii h ji
ji
Matrices A and B, vector b sparse (many zeros)

12
Parameter identication
Thermal capacities and conductivities usually
Ci hij
not exactly known
Would like to estimate their values from
measurements
Apply known input u(t), t [0,T ]
Measure resulting temperatures ym (t), t [0,T ]
Measure disturbances xa (t), d(t), t [0,T ]
Solve system to obtain y(t) = Cx(t), t [0,T ]
Change to optimize the match between
Ci , hij y(t)
predicted by the model and measured ym (t)
u(t), t [0,T ]
Applied input may be important

13
LTI systems in state space form
LTI = linear time invariant

x (t)
! = Ax(t) + Ev(t)
x(t) a
v(t) = u(t)

E = b B D

y(t) = Cx(t) + Fv(t) d(t)
State
space

v1 y1 x1

A nn E ! nm v2 y2 x2
y= x = n
v= "
m p

!
C pn F ! pm vm yp xn

Input vector Output vector State vector

14
LTI systems in state space form
a11 a12 ... a1n
For LTI systems state space equations
n coupled, rst order, linear dierential equations A = a21 a22 ... a2n

p linear algebraic equations
an1 an2 ... ann
Constant coecients
e ... e1m
x!1 (t) = a11x1 (t) + ...+ a1n xn (t) + e11v1 (t) + ...+ e1mvm (t) 11

E= ! " !
x!2 (t) = a21x1 (t) + ...+ a2n xn (t) + e21v1 (t) + ...+ e2mvm (t) e ... enm
n1
" c ... c1n
11

x!n (t) = an1x1 (t) + ...+ ann xn (t) + en1v1 (t) + ...+ enmvm (t) C=
c ... c
p1 pn

y1 (t) = c11x1 (t) + ...+ c1n xn (t) + f11v1 (t) + ...+ f1mvm (t)
f ... f1m
y2 (t) = c21x1 (t) + ...+ c2n xn (t) + f 21v1 (t) + ...+ f 2mvm (t) 11

F= ! " !
! f ... f pm
p1
y p (t) = c p1x1 (t) + ...+ c pn xn (t) + f p1v1 (t) + ...+ f pmvm (t)
15
System solution
Since system is time invariant, assume we are given
Initial condition x0 R
n

The input values v() :[0,T ] !


m

Compute the system solution x() : [0,T ] n

! = Ax(t) + Ev(t), t 0,T


x(0) = x0 and x(t)

If we can do this, then output y() : [0,T ] p

y(t) = Cx(t) + Fv(t), t 0,T

For simplicity assume input continuous function of time

16
State solution
The system solution is
t
x(t) = e x0 + e At A(t )
Ev( ) d
0

where 2 2 k k
A t A t
e = I + At +
At
+ ...+ + ... R nn

2! k!
State transition
matrix
and the integral is computed element by element
2 2
a t
e = 1+ at + + ... if a
(cf. Taylor series expansion: )
at

2!
17
Output solution
Simply combine state solution
t
x(t) = e x0 + e A(t ) Ev( ) d
At
0

with output map




y(t) = Cx(t) + Fv(t)
to obtain
t
y(t) = Ce x0 + Ce
At A(t )
Ev( ) d + Fv(t)
0

18
State solution structure
The solution consists of two parts:
t
x(t) = e x0 + e
At A(t )
Ev( ) d
0

Zero Zero
Total
transition
= Input + State
transition transition

v(t) = 0t x(t) = ZIT Linear function of initial state

Linear function of input


x0 = 0 x(t) = ZST
Convolution integral

19
Output solution structure
The solution consists of two parts:
t
y(t) = Ce x0 + C e
At A(t )
Ev( ) d + Fv(t)
0

Zero Zero
Total
Response
= Input + State
Response Response

v(t) = 0t y(t) = ZIR Linear function of initial state


x0 = 0 y(t) = ZSR Linear function of input
Convolution integral

20
The 2-norm
Definition: The 2-norm is a Fact: For all x, y R n
, a R
function i : R n R that to each
1. x 0 and x = 0 if & only if x = 0
x R n assigns a real number
n 2. ax = a x
x = i
x 2

i=1
3. x + y x + y

2
Exercise: Show that x = x T
x Exercise: Prove 1 and 2.

The 2-norm is a measure of size or length


R n
Distance between is x y
x, y

21
Inverse of a square matrix
Definition: The inverse of a matrix A R nn is a matrix A1 R nn
A1 A = AA1 = I
Definition: A matrix is called Fact: A is invertible if and
singular if it does not have an only if det(A) 0
inverse. Otherwise it is called
non-singular or invertible. Exercise: Show that
d b
1
1 adj(A) Adjoint matrix= matrix a b c a
A = of subdeterminants =
det(A) c d ad bc
transposed

Fact: A is invertible if and only if the system of linear


equations Ax = y has a unique solution x R n
for all y R n

22
Eigenvalues and eigenvectors
Definition: A (nonzero) vector w C n is called an eigenvector of
a matrix A R if there exists a number C such that
nn

Aw = w. The number is then called an eigenvalue of A

Eigenvalues and eigenvectors are in general complex even


if A is a real matrix
An nxn matrix has n eigenvalues (some may be repeated).
They are the solutions of the characteristic polynomial
det( I A) = n + a1 n1 + a2 n2 + + an = 0
The n eigenvalues of A are Exercise: Show that if w is an
called the spectrum of A eigenvector then so is aw for
any a C
23
Diagonalizable matrices
1 0 . . 0

0 2 . . 0

Awi = i wi A[ w1 w2 ... wn ] = [ w1 w2 ... wn ] . . . . .
. . . . .
W C nn
W
0 0 . . n

C nn
Definition: A is called
diagonalizable if W is invertible A = W W 1

Fact: If the eigenvalues of A are


distinct (i j if i j) then its
e-vectors are linearly independent

24
Symmetric, positive denite and
positive semi-denite matrices
Definition: A matrix is called Definition: A symmetric matrix
symmetric if A = AT is called positive definite if

Fact: Symmetric matrices x T Ax > 0 for all x 0. It is called


have real eigenvalues and positive semi-definite if x T Ax 0.
orthogonal eigenvectors
Fact: A matrix is positive
Fact: If A is symmetric then definite if and only if it has (real)
there exist U R nn orthogonal & positive e-values. It is positive
R nn diagonal such that semi-definite if and only if it has
(real) non-negative e-values.
A = U U T

25
Transition matrix computation
Change of coordinates using matrix of eigenvectors
Assume matrix diagonalizable

AW = W A = W W 1 Exercise: Prove
by induction that
Matrix of
Therefore Ak = W kW 1
e-vectors
t 1

e At
= We W
Exercise: Prove this
where e
1t
... 0

t

e =
0 ... e
n t

26
Example: 2 room building
u(t) Heating/
h21 u(t) ! cooling
input
x1 (t) x2 (t)
xa (t) ! Ambient
temperature
h10 h20
xa (t)
x (t) xa (t)
x(t) =
1
! 2 Temperature
each room
of

x2 (t) u(t)

v(t) = ! 4

d (t) d1 (t)
1
! 2 Internal gain of
d(t) = each room d2 (t)
d2 (t)

27
Example: 2 room building
h12 = h10 = h20 = 1, C1 = C2 = 1
For simplicity take
A b B D

dx(t) 2 1
= x(t) + 1 xa (t) + 1 u(t) + 1 0 d(t)
dt 1 2 1 0 0 1

= 2 1 x(t) + 1 1 1 0 v(t)
1 2 1 0 0 1

E
Eigenvalues of A:
1 = 3, 2 = 1
Eigenvectors of A: w1 = 1 , w2 = 1
1 1
28
Example: Transition matrix
1 1 Using Matlab:
e At = WetW 1 = 1 1 e3t 0t 1 1
1 1 0 e 2 >> A=[-2 1;1 -2];
>> [W,L]=eig(A)

W =
W e t W 1
0.7071 -0.7071
0.7071 0.7071

1 et + e3t et e3t
e =
At L =
t 3t
2 e e e +e
t 3t
-1 0
0 -3

29
Example: ZIT
No external inputs xa (t) = u(t) = d1 (t) = d2 (t) = 0
Zero Input Transition starting at
x(0) = x0 ! 2

x(t) = e x0At

1 et + e3t et e3t
= x0
2 e e e + e
t 3t t 3t

0 as t
Therefore ZIT 0 for all initial conditions

30
Example: Constant input
t

A(t )
General transition
x(t) = e x0
+ e At
Ev( ) d
0
For simplicity assume
u(t) = d1 (t) = d2 (t) = 0
xa (t) = xa constant
t t

x(t) = e At x0 + e A(t ) Ev( ) d = e At x0 + e A(t ) bxa d


0 0
t
1 e(t ) + e3(t ) e(t ) e3(t ) 1 x d
= e x0 +
At

2 e(t ) e3(t ) e(t ) + e3(t ) 1 a


0
t t
(t )
= e x0 + (t ) d x = e At x + e(t ) d 1 x
e
0
At
e a 0 1 a
0

31
Example: Constant input
=t
x(t) = e x0 + e
At (t )
1 xa
=0 1

=
1 et + e3t et e3t
t 3t
2 e e e +e
t 3t 0 ( )
x + 1 et 1 x
1 a

0 as t xa
as t
xa

Trajectories se`le to a state where all rooms


are at the ambient temperature, irrespective
of where the initial temperatures

32
Example: Constant input
x0 = 10
Say
2

10
xa=0o C 20
xa=20o C
9
18

8
16

7
14

6
12
x1, x2

x1, x2
5

10
4

8
3

6
2

1 4

0 2
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t t

33
Example: Constant input
What value will the state se`le to?
Se`le stop moving derivative w.r.t. time = 0

x(t)
! = Ax(t) + bxa = 0
1 2 1 1 xa 1
x(t) = A bxa = xa =
1 2 1 x
a
How do we know it will se`le to this value and not to
another value, or oscillate, or go o to innity, or ?
Look at distance between trajectory and steady state

e(t) = x(t) ( A 1bxa ) = x(t) + A 1bxa

34
Example: Constant input
20
A 1bxa
18

16

14

e(t) = x(t) + A1bxa


12

x2
x2

10

8
x(t)
6

2
x0
0
8 10 12 14 16 18 20

x1
x1

! = x(t)
e(t) ! = Ax(t) + bxa = Ae(t) e(t) = e At e(0) 0 as t
35
Notes: Diagonalizable matrices
For diagonalizable matrices, state transition matrix linear
combination of terms of the form eit
Generally i = j C, ,
So ZIT linear combination of terms of the form
if i = 0 ( = 0, = 0)
1
e t if i = ( 0, = 0)

t)
sin( and cos( t) if i = j ( = 0, 0)
t t
sin( t) and e cos( t) if i = j ( 0, 0)
e
i = j
Part of ZIT corresponding to
= 0, = 0
Constant if
Converges to 0 if < 0
Periodic if = 0, 0
Goes to innity if > 0
36
Typical ZIT for diagonalizable matrices

Im()

Re()

37
Stability: Zero input transition
Consider the system x(t) ! = Ax(t) + Ev(t)
Let x(t) be its ZIT x(t) = e At x0

Definition: The system is called stable if for all > 0


there exists > 0 such that
if x0 then x(t) for all t 0.
Otherwise the system is called unstable.

i.e. if the state starts small it stays small


or you can keep the state as close as you want to
0 by starting close enough
38
Asymptotic stability
Definition: The system is called asymptotically stable
if it is stable and in addition
x(t) 0 as t

i.e. not only do we stay close to 0 but also


converge to it
Note that denitions do not require
diagonalizable matrices

39
Diagonalizable matrices
Theorem: System with diagonalizable A matrix is:
Stable if and only if Re[i ] 0,i
Asymptotically stable if and only if Re[i ] < 0 i
Unstable if and only if i : Re[ i ] > 0

Proof: By inspection!
i t
Transition matrix linear combination of e
Re[
for all initial conditions ZIT tends
i ] < 0,i
to zero
ZIT remains bounded and for
Re[i ] 0 i
some initial conditions is periodic (or constant)
for some initial conditions ZIT
i : Re[i ] > 0
tends to innity
40
Non-diagonalizable matrices (examples)

A1 = 0 1 e A1t = 1 t Exercise: What are the


0 0 0 1 eigenvalues of A1 and A2?
What are the eigenvectors?
What goes wrong with their
A2 = 1 1 A2t
e = e t
te t
diagonalization?
0 1 0 e t

t t t 2 et
1 1 0 e te
A3 = 0 1 1 e =
At
t
2 t
0 0 1 0 e
0 0 et
te

41
Non-diagonalizable matrices (general)
Distinct e-values matrix diagonalizable (Fact 2.18)
1 = 2 = = r = j
Assume some e-value repeated r times,
In general, ZIT linear combination of terms of the form

1,t,t
2 ,,t r-1 if = 0, = 0
t t r-1 t
e ,te ,,t e if 0, = 0


sin( t),cos( t),t sin( t),,t r1
cos( t) if = 0, 0

e
t
sin( t),e t cos( t),,t r1e t cos( t) if 0, 0
Can be shown using generalized eigenvectors and Jordan
canonical form

42
Non-diagonalizable matrices (general)

Note that:
If < 0,

t k e t , t k e t cos t, t k e t sin t t
0
Hence ZIT tends to zero (for some initial states)
If > 0,

t k e t , t k e t cos t, t k e t sin t t

Hence ZIT tends to innity (for some initial states)

If
= 0,
1,cos t, sin t
remain bounded

t k , t k cos t, t k sin t t for k 1
ZIT may remain bounded or tend to innity
Cannot tell just by looking at e-values
43
Non-diagonalizable matrices: Stability

Theorem: The system is:
Asymptotically stable if and only if Re[i ] < 0 i
Unstable if i : Re[ i ] > 0

Subtle dierences with diagonalizable case


Asymptotic stability condition the same
Instability condition sucient but not necessary
Reason is that if then
i Re[i ] 0 but i Re[i ] = 0
stability not determined by e-values alone.
ZIT may remain bounded for all initial conditions
ZIT may go to innity for some initial conditions

44
Stability with inputs
! = Ax(t) + Ev(t)
x(t)
Consider the system
t

Zero state transition x(t) = e A(t ) Ev( ) d
0

Theorem: Assume that Re[i ] < 0 i . Then there


exists 0 such that ZST x(t) satisfies
v(t) M t 0 x(t) M t 0
If in addition v(t)
0 then x(t)
t
0. t

So small inputs lead to small states. If in addition


the input goes to zero, so does the state
Asymptotic stability needed, not enough
Re[i ] 0
45
Typical building dynamics
1. Matrix A typically has
Real eigenvalues
Linearly independent eigenvectors A diagonalizable
2. Diagonally dominant
Diagonal elements bigger (in magnitude) than sum of
o-diagonal elements
3. Diagonal elements negative

2+3 eigenvalues negative


Pure building dynamics stable
(not necessarily so with device, or other dynamics)

46
State feedback
Assume all states measured
Select input as a function of state to make the system
do something useful
E.g. Track reference temperatures, minimize costs,
Linear state feedback

u(t) = Kx(t), K R mn

Closed loop system dynamics

dx
(t) = ( A + BK ) x(t)
dt
Can we select K so that (A+BK) has nice eigenvalues?
47
Controllability and controller design

P = B AB A B R
n1 dim( x)dim( x)dim(u)

Controllability matrix, quanties


power of input to aect state


Theorem: If rows of P linearly independent, then K can be
chosen
such that eigenvalues of (A+BK) have any desired
(complex conjugate) values

Realistically not all choices of eigenvalues will be
suitable (e.g. due to input constraints)
Finding suitable ones requires careful tuning
48
State estimation
Not all states measured, only some through y(t)
Progressively construct estimate of the state x (t) R n
x (0) R n
Start with some (arbitrary) initial guess
Measure y(t) and v(t)
Update estimate using observer
dx!
(t) = Ax! (t) + Ev(t) + L y(t) Cx! (t) Fv(t)
dt
Mimic evolution of true state, plus correction term
Gain matrix L
Error dynamics
e(t) = x(t) x (t) e(t)
= (A LC)e(t)

49
Observability and observer design
Observability matrix, quanties state C
information contained in output
CA
Q= R npn

n1
CA

Theorem: If columns of Q linearly independent, then L can be
chosen such that eigenvalues of (A-LC) have negative real parts

State estimate converges to true state x (t) t


x(t)
Indeed can nd L to make eigenvalues of A-LC any
(complex conjugate) numbers we want
In reality noise complicates ma`ers, optimal L by
Kalman lter
50
Sampled Data Systems
Computers operate on bit streams
Value and time quantization
1. Variables can take nitely many values
2. Operations performed at xed clock period

y(t) yk

51
Sampled Data Systems
In embedded computational systems digital
computer has to interact with analog environment.
Measurements of physical quantities processed by
computers
Decisions of computer applied to physical system
Requires transformation of real valued signals of real
time to discrete valued signals of discrete time and
vice-versa
Analog to digital conversion (A/D or ADC)
Digital to analog conversion (D/A or DAC)

52
Sampled Data Systems
Usually value quantization is quite accurate.
Here we ignore value quantization, we concentrate
on time quantization.
Assume:
ADCsample every T
DACzero order hold

53
Sampled Data Systems
uk

COMPUTER

Z.O.H

SYSTEM
! = Ax(t) + Ev(t)
x(t)
y(t) = Cx(t) + Fv(t) u(t)

xa (t), d(t)

54
Sampled Data Linear Systems
How does linear system with sampling and zero
order hold look like from computer?

! = Ax(t) + Ev(t)
x(t) A ! nn
E ! nm



y(t) = Cx(t) + Fv(t) C ! pn
F ! pm

v(t) = vk for all t [kT ,(k + 1)T )



t [kT ,(k + 1)T )
For
t
x(t) = e A(tkT )
x(kT ) + e A(t ) Ev( )d
kT

55
Exact discretization
After a couple of steps of calculus

Let xk = x(kT ), vk = v(kT ), yk = y(kT ). Then

xk+1 = Axk + Evk T


with A = e , E = e A(T ) E d
AT
0

yk = Cxk + Fvk C = C, F = F

+ Exact, no approximation involved


- Matrices can be complicated
A and E
- In particular nice structure (sparsity, ) may be lost
56
Euler approximation
We approximate

x((k + 1)T ) x(kT ) + Tx(kT


! )
= x(kT ) + T ( Ax(kT ) + Ev(kT ))

As before we set xk = x(kT ), vk = v(kT ), yk = y(kT )
xk+1 = Axk + Evk A = I + AT , E = TE
yk = Cxk + Fvk C = C, F = F
- Inexact, need T small for reasonable approximation
+ Preserves structure (sparsity, )
57
Discrete Time Linear Systems:
Solutions
Solution: Given x0 R and vk R , k = 0,1,, N 1 find
n m

xk R n and yk R p ,k = 0,1,, N
k1 Exercise: Prove
xk = A x0 + A
k ki1
Evi this by induction
i=0 (take A0 = I)

ZIT ZST

k1
yk = C A x0 + C A
k ki1
Evi + Fvk
i=0
58

Potrebbero piacerti anche