You are on page 1of 175

ACI-21086 TUT

Control System Design with Matlab Control , Modelling and Simulation

Application 1. Tank With Two Inflows Consider the tank illustrated in Figure 1a. The temperature T (unit C ) and the level (height) h of water ( m ) inside the tank should be controlled using an inflow of hot water with a constant temperature Th and an inflow of cold water with a constant temperature Tc . We are more interested in controlling of the water volume V ( m ) inside the tank or (in certain running conditions) the volume flowrate qout ( m
3 o

/ s ) out of

the tank but measuring the level is easy. Let the variable and adjustable volume flowrates of the hot and cold water be q h and q c ( m / s ) , respectively. Denote the variable temperature of the outflow with Tout . The tank is equipped with an efficient mixer to produce an even distribution of water temperature.

q h , Th

q c , Tc

qout , Tout v out


Figure 1a. The structure diagram of the process.

If qout is due to pumping , the process may be presented by e.g. the block diagram shown in Figure 1b:

qout
control inputs

disturbance variables to be controlled

qh qc

Figure 1b. The block diagram of the process

However, we will later assume, that the outflow is due to gravity. Then qout is not a free disturbance but depends on the level h . Denote the set points of h and T with href and Tref , respectively. The system is a MIMO (Multiple-Input-Multiple-Output) system. Heuristic multivariable control It is obvious that the volume and the level depend on the sum of the two incoming flowrates,

ua = qh + qc

(1a) 1

It is also quite clear that the temperature depends at least to some extent on the flowrate ratio

ub =

qh qc

(1b)

In simple heuristic control we adjust the variables ua and ub using SISO (Single-Input-Single-Output) control principles and solve then qh and qc so that equations (1a) & (1b) are satisfied. In such a case ua is formed from the set point of (e.g.) alone or the actuating error of the level while ua is formed from the set point alone or the actuating error of the temperature, and the flowrates are calculate using the solution formulae of (1a) & (1b) ,

qh = qc =

u a ub = q h (u a , u b ) 1 + ub ua = q c (u a , u b ) 1 + ub

(2a)

(2b)

These formulae may be solved with e.g. the following ST commands (Symbolic Toolbox of Matlab) : q = solve('qh + qc = ua','qh/qc = ub','qh,qc') % object qh = q.qh % picking a single variable from an object pretty(qh) % so pretty , so pretty qc = q.qc pretty(qc) The formulae (2a) & (2b) define a TITO (Two-Inputs-Two-Outputs) system. This system is the end part of a MIMO controller. Since its outputs are inputs of the process, we call this system with the name precompensator (of the process). Note that the pre-compensator model was found by inversion of model (1) which therefore is an inverse model of the pre-compensator! Below find rough block diagrams of both the pre-compensator alone and the whole feedback control system:

ua ub

pre compensator
Figure 2a. A precompensator

qh qc

m1

sensor1

href Tref

con1
+

ua ub
pre compensator

qh qc
MIMO process

con 2
_

m2

sensor 2

Figure 2b. Heuristic MIMO control of the example process.

The initial tuning of the controller con1 (P/I/PI controller?) may be based on any model or/and empirical data which can explain the relationship of ua and h . Even a measured or simulated step response is enough, and design knowledge gained in the basic course may be exploited. In a similar way the initial tuning of the controller con 2 (P/I/PI controller?) may be based on information about the relationship of ub and T . This will be demonstrated in computer sessions. More serious design and analysis becomes possible as soon as adequate mathematical models become available:

Modelling of the process using volume and energy balances Consider a very short time range t ... t + dt , the length dt of which is the differential of time. During the infinitesimally short time interval a differential volume dVh (unit m ) of hot water will flow into the tank a differential volume dVc of cold water will flow into the tank a differential volume dVout of water will flow out from the tank This will affect the volume V (and the level h ) as well as the water temperature T in the tank. The temperature is affected, since the energy balance of water in the tank is changing due to the flowing volumes. Volume and the level. The volume inside the tank will change from V to V + dV where the differential volume change dV is
3

change of volume in the tank

dV {

volume of hot water flowing in

dVh {

volume of cold water flowing in

dVc {

dVout {

outflowing volume

The moving volumes are proportional to the extremely small time dt and the corresponding flowrate:

dV = q h dt + qc dt qout dt
The ratio of the volume change and the time change is

dV = q h + q c q out dt
Denote the derivative dV / dt by

& . We have got the ODE1 model V


(3)
2

& = q + q q := q V h c out
Let the cross section area of the tank be a (unit m ). Then the water volume inside the tank is

V = ah
The level is therefore

(4)

h=

V a

(5)

ODE = Ordinary Differential Equation

The flowrate of the outflow is

q out = a o v out
2

(6)

where a o is the cross section area of the outlet pipe (unit m ) and v out is the flow speed of water (unit m / s ). A rough model of the flow speed may be obtained from the so called Bernoulli law. After some approximations (see DB 2.8) the velocity model often initially selected is

vout = 2 g h
where g is the gravity acceleration , roughly

(7)

9.8 m / s 2 . This yields for the outflow the rough model


(8)

q out = a o 2 gh

However, because of ignoring some physical phenomena and approximations of terms included in the model this model should be equipped with an extra correcting multiplier k to give a better match between the experimental results and model responses. Therefore let the outflow model be

q out = k a o 2 gh

(9)

The parameter k may be determined empirically. For example, values of the level at different times may be measured during a time period with zero flowrates q h , q c of inflows. The parameter k may then be adjusted to produce simulation results comparable to empirical results. In fact, the level for zero flowrates q h , q c may be derived a solution formula, from which a relevant value of k may be easily derived. For simplicity the product k a o is later represented by a o , and the corrected (calibrated) value of a o in question is called the effective cross section area (of the outlet pipe). The model needed will consist of submodels (3) , (5) and (9).

& = q we In Simulink the submodel (3) may be implemented either using a State-Space block (for V select A = 0 and ) or using the Integrator block: it follows from the submodel (3) that

V = q = (qh + qc qout )
The submodels (3), (5) and (9) may be combined into a single ODE of the level,

(10)

& & = V = qh + qc ao 2 g h =: f = f ( h , q , q ) h 1 1 h c a a
Temperature. Derivation of temperature models is typically based on energy considerations. Assume perfect mixing so that at any time an even spatial temperature distribution is obtained at all points inside the tank. Then Tout = T , too. The temperature of a water is changed from T to (T + T ) due to the additional energy

(11)

Q equal to
(12)

Q = c m T c 4.2 kJ /(kg o C ) , and m is the mass of water. Let the water volume corresponding to the mass m be V . These variables are related to each
where c is the heat capacity coefficient of water , other through the density

m V
3

(13)

Density of water at low enough positive temperatures is roughly 1000 kg / m . Solving the mass gives

m = V
So the energy change may be presented as

(14)

Q = c V T
Assume that there are no energy losses through the walls of the tank. Assume initially, that

(15)

Tc T Th .

Then the differential net energy change of the water inside the tank during the infinitesimally short time period t ... t + dt is

dQ = c dVh (Th T ) c dVc (T Tc ) 144 4 2444 3 144 4 2444 3


where, the first term

dVh of hot water gives to the tank water, while the second term is the energy the differential volume dVc receives from the tank water.
represents energy , which the differential volume

The model above may be written as

cV dT = c q h dt (Th T ) + c q c dt (Tc T )
In fact, this model is valid even, when the temperature inequality above is not satisfied: in that case giving/ receiving a negative energy n is interpreted as receiving/giving the positive energy ( n ). Now the latest equation yields an ODE model of the temperature,

c V

dT = c qh (Th T ) + c qc (Tc T ) dt

(16a)

Solving the temperature derivative gives

dT & q h (Th T ) + q c (Tc T ) (Tc T ) q c + (Th T ) q h =T = = =: f 2 dt V ah


where the specific heat coefficient c does not appear due to cancellation. Lets summarize the result: A Non-Linear State Space Model of a Tank with Two Inflows

(16b)

& = qh + qc ao 2 g h = f ( h , q , q ) h 1 h c a

(17a)

& = (Th T ) qh + (Tc T ) qc = f ( h , T , q , q ) T 2 h c ah


qout = ao 2 g h
V = ah
Physical constants:

(17b)

(18a) (18b)

g = 9.8 m / s 2 .

Units:

[h] = m , [q] = m 3 / s , [a] = m 2 , [T ] = oC


5

Simulink In Simulink implementation of the model we may exploit blocks familiar from linear models as well as blocks

& and T & . The derivatives may for non-linear algebraic functions in forming the derivative functions h also be formed conveniently using Fcn blocks, the input vectors of which may be formed with Mux blocks. Integrators will then be needed to form the actual response functions. Details will be studied in an exercise session.
The steady state (equilibrium) We should find steady state (equilibrium , stationary) values of the process variables to e.g. initialize some simulations or to check the accuracy of simulated results. Lets therefore study this topic next: We know/guess, that the system may have equilibriums , where the inputs and outputs have constant values. If this happens, the constant outputs have zero derivatives. Then the models (17) and (18) imply the steady state relationships (for constant IO functions)

& = qh + qc ao 2 g h 0=h a & = qh (Th T ) + qc (Tc T ) 0=T ah

( h constant at steady state)

(19a)

( T constant at steady state)

(19b)

Lets solve the constant values of the inputs for given constant values of the outputs. Matlab offers fsolve for that purpose, but lets derive another equations which may be solved more efficiently: The non-linear equations (19) are satisfied, if and only if the expressions above the division line are zero,

1 q h + 1 q c = a o 2 gh

(20a) (20b)

(Th T ) q h + (Tc T ) q c = 0
This is a set of two linear equations (despite of non-linearity of the ODE model)! So we can present these equations using matrix notation:

1 q h a o 2 gh 1 T T T T q = 0 h c c 1442443 { 1 4 24 3
M q w

(21)

Matlab. Given the symbolical values (assuming access to ST = Symbolic Toolbox) or numerical values of the constants this linear vector equation may be solved with Matlab as follows (in using ST first introduce symbolic variables with sym or syms before giving the commands suggested below) 2: M = [1,1 Th-T,Tc-T] w = [ao*sqrt(2*g*h) 0] help slash q = M\w qh = q(1) qc = q(2)
2

% or:

M = [1,1;Th-T,Tc-T]

% or:

w = [ao*sqrt(2*g*h) ; 0]

A comma is here used to separate between the columns, because it is more detectable than a space also possible for that purpose.

Rough model around the steady state through linearization Linearization is discussed in DB 2.3 and DB 2.8 and in the pdf material of the basic course . Note that the linear model is explaining roughly how the system behaves around a so called operating point (OP), which often is also an equilibrium point (EP). In succesfull control of our tank both the closed-loop system and the subsystems (sensors, SISO controllers, pre-compensator, process) operate around their own operating points. Then e.g. the behaviour of each subsystem may be explained using a suitable linear model for each subsystem. This has been discussed for SISO systems in the basic course. Lets here extend the discussion for the MIMO systems, starting from the pre-compensator: Linear pre-compensator. Let the operating point values of ua and ub be ua and ub , respectively (how would you get these values in practice?). We want to estimate how much the flowrates differ from their OP values

qh = qh (ua , ub ) qc = qc (ua , ub )
if ua and ub will differ from ua and ub , respectively:

ua ub

pre compensator

qh qc

(in OP)

ua + ua ub + ub

pre compensator

qh + qh qc + qc

(around OP)

Figure 3. The precompensator in and around Operating Point.

We wish to obtain a linear pre-compensator which is able to approximate the flowrate variations:

u a ub
Figure 4.

linear pre compensator

h q c q

(around OP)

A linear precompensator for approximation of the non-linear precompensator h is an estimate of qh etc. around Operating Point. Here q

The exact (actual) output perturbations are

qh = qh (ua + ua , ub + ub ) qh (ua , ub ) qc = qc (ua + ua , ub + ub ) qc (ua , ub )


Close enough to OP we may use the first order Taylor approximation formula (DB 2.3)

(22a) (22b)

g ( x1 + x1 , x2 + x2 ) g ( x1 , x2 ) +

g g ( x1 , x2 ) x1 + ( x1 , x2 ) x2 x1 x2

(23)

Lets apply this separately for both flowrate perturbations:

qh qc

qh q h (ua , ub ) ua + h (ua , ub ) ub =: q ua ub qc q c (ua , ub ) ua + c (ua , ub ) ub =: q ua ub

(24a)

(24b)

For our example functions we obtain by appropriate differentiations and OP substitutions

h = q c = q

ub ua u a + ub 1 + ub (1 + ub ) 2 ua 1 u a ub 1 + ub (1 + ub ) 2

(25a)

(25b)

A standardized model of the linear pre-compensator is

h = k ha ua + k hb ub q c = k ca ua + k cb ub q

(26a) (26b)

k ha = k ca =

ub 1 + ub
1 1 + ub

k hb = k cb =

ua (1 + ub ) 2 ua (1 + ub ) 2

(26c)

(26d)

h by qh . It is common to drop away or ignore from the very beginning the hats , i.e. to replace e.g. q
In doing so it is important to remember that in general the actual change qh differs at least slightly from

h . This practice will be also adopted here. the estimated change q


Figure 5 gives an elementary block diagram for the linear constant-coefficient model (26ab). A rougher presentation is available in Figure 6.

u a

k ha
+

q h

k hb

k ca u b
+ +

k cb

q c

Figure 5. An elementary block diagram of the pre-compensator. Here e.g. qh is an estimate of the actual perturbation of the flowrate qh . 8

u a ub

linear pre compensator

qh qc

(around OP)

Figure 6. A linear precompensator for approximation around Operating Point. Here e.g. qh is an estimate of the actual perturbation of the flowrate qh .

Expressions of the partial derivative functions were derived using the ST commands below: syms ua ub kha = diff(qh,ua) pretty(kha) khb = diff(qh,ub) khb = simple(khb) pretty(khb) kca = diff(qc,ua) pretty(kca) kcb = diff(qc,ub) pretty(kcb) % define symbolic variable % partial derivative

% a simplifier

The OP values may be configured with subs and limit.

Approximation of Derivatives Numerical approximations of ordinary and partial derivatives are typically calculated using difference approximations. The most typical approximations are those of Euler, finite

x 0

d f ( x + x ) f ( x ) f ( x) dx x
f ( x , x + x 2 ) f ( x1 , x 2 ) f1 ( x1 , x 2 ) 1 1 2 x 2 x 2

x 2 0

where x 2 is either negative (backward approximation) or positive (forward approximation). Sometimes engineers select another approximation, the central difference approximation , e.g.

d f (x + ) f (x ) f ( x) 2 dx

0 < 2 0

f1 f ( x , x + 2 ) f ( x1 , x2 2 ) ( x1 , x2 ) 1 1 2 2 2 x2

Process. Below a star (*) as a superscript refers to a steady-state (Equilibrium Point) value of the variable in question. Assume now, that the input variables will deviate from their EP values:
* q h (t ) = q h + q h (t )

* q c (t ) = q c + q c (t )

(27a)

In that case the output variables will deviate from their steady state values:

h(t ) = h * + h(t )

T (t ) = T * + T (t )

(27b) 9

These presentations are called the perturbation presentations. Sometimes h and T are assigned desired values. Then we should roughly estimate the deviations q h and q c needed to achieve the desired response changes h ,

T . Sometimes output deviations should be found for input deviations.

The mutual relationship of the deviations,


* q h (t ) = q h (t ) q h

, ,

* q c (t ) = qc (t ) q c

(28a) (28b)

h(t ) = h(t ) h *

T (t ) = T (t ) T *

may be described to some accuracy using a linear model , provided that the deviations are close enough to zero. The tasks needed to derive this rough linear model form a procedure called linearization. A linear model is obtained in the following steps: (1) (2) (3) Substitute the perturbation presentations and simplify the derivative term , Apply first order Taylor polynomial expansions for functions of the deviations , Simplify the resulting model to give the derivatives of the output deviations as simple a presentation as possible. Taking into account the information of the steady state model (OP = EP) simplifies a lot!

Linear Model of Level

dh qh + qc ao 2 g h = f1 ( h, qh , qc ) dt a d * * * (h + h) = f1 (h * + h, q h + q h , q c + qc ) dt
dh * dh * * + = f 1 (h * + h, q h + q h , q c + q c ) dt dt {
0

(nonlinear ODE)

(perturbations)

(derivative term simplified!)

& = f (h * + h, q * + q , q * + q ) h 1 h h c c

(nonlinear ODE for perturbations)

Use now a first order Taylor approximation (with the partial derivatives evaluated using steady state values , as indicated by below by the notation f = f ( z1 ,..., z n ) f for deviations close enough to zero ,
* * * := f ( z1 ,..., z n ) ) )

f ( x1 + x1 , x 2 + x 2 , x3 + x3 ) f ( x1 , x 2 , x3 ) +
This yields the approximation

f f f x1 + x 2 + x3 x1 * x 2 * x3 *

(29)

& f (h * , q * , q * ) + k h + k q + k q h 1 1 2 3 h c h c 1 4 4 24 4 3
derivative of level at steady state , = 0

k1 =

f1 h

=
*

ao 1 1 a g 1 a g (2 g ) = o = o 1 2 3 * * a 2 2 g h derivative a a 2h * 2 g h 14 4 244 3 of the


derivative of the square root inner function

(30a)

10

k2 =

1 f1 = qh * a 1 f1 = qc * a

(30b)

k3 =

(30c)

Write now = instead of to get a linear ODE , the solution of which will approximate (estimate) the actual level deviation to a precision

& = k h + k q + k q h 1 2 h 3 c
Linear Model of Temperature

(30d)

& = qh (Th T ) + qc (Tc T ) f ( h, T , q , q ) T 2 h c ah & = f (h * + h, T * + T , q * + q , q * + q ) T 2 h h c c


Approximate, assuming deviations close enough to zero :

(nonlinear ODE)

(Do you agree?)

& f (h * , T * , q * , q * ) + k h + k T + k q + k q T c h c 2 4 5 6 7 1 44 4 24h4 4 3
derivative of T in steady state , = 0 !

(31a)

k4 =

f 2 h f 2 T
f 2 qh

=
*

* * 0 (Th T * ) + qc (Tc T * ) qh = =0 * * ah h a h* h* * * * ao 2 g h * qh qc qout = = ah* V* ah*

(31b)

k5 =
k6 =

=
*

(31c)

=
*

Th T * Th T * = ah* V*

(31d)

f k7 = 2 qc

Tc T * Tc T * = = ah* V*
to get a linear ODE , the solution of which will approximate

(31e)

Write now = instead of the actual temperature deviation:

& = k T + k q + k q T 5 6 h 7 c
Linear ODEs (30d) , (31f) with the parameters obtained above form a rough model of the process.

(31f)

11

Derivation of a Linear Precompensator from a Linear Process Model Our linear tank model is of a more general form

&1 = a1 y1 + b11 u1 + b12 u 2 y & 2 = a 2 y 2 + b21 u1 + b22 u 2 y


The models (32a) and (32b) are MISO models (Multiple-Input-Single-Output). So here the process model consists of two MISO models. The models (32) may be transformed to two SISO models by the simple variable change

(32a) (32b)

f1 = b11 u1 + b12 u 2 f 2 = b21 u1 + b22 u 2


Indeed, the model (32) can now be written as two decoupled and so SISO equations,

(33a) (33b)

&1 = a1 y1 + f 1 y & 2 = a2 y2 + f 2 y
Now f 1 may perhaps be chosen using SISO control principles based on the actuating error e1 associated with y1 . In a similar way, we try to select f 2 to depend on e 2 . Here we can exploit SISO controller structures familiar from the elementary course. If we will succeed in that, the actual control inputs may be solved from Equations (33). The linear set of equations in question,

(34a) (34b)

b11 u1 + b12 u 2 = f1 b21 u1 + b22 u 2 = f 2


has a unique solution, if and only if

(35a) (35b)

d := b11 b22 b12 b21 0


The solution given the condition (35c) is of the linear form

(35c)

u1 = k11 f1 + k12 f 2 u 2 = k 21 f1 + k 22 f 2 k11 = k 21 = b22 d


b21 d
,

(36a) (36b)

k12 = k 22 =

b12 d

(36c)

b11 d

(36d)

The multivariable control approach is illustrated by the following figure, where I-controllers are used as the SISO controllers and the sensors are modelled using Time Constant Models :

12

Figure 7. Multivariable control for a MISO process. Decoupling: The gain choices (36cd) yield f 1 = w1 and f 2 = w2 , which imply the decoupled models (34ab) for the process outputs. Each gain k i will be chosen based on the parameters ai , Ti and specifications given for y i .

Application 2. Heated Tank Consider another tank, later called the Heated Tank, illustrated in the Figure below:

qin , Tin

qout , Tout

Figure 8. Heated Tank.

13

The temperature T and the level (height) h of water inside the tank should be controlled using heat power (heat flow) P produced by an electrical heater with electrical power Pe and an inflow of cold water at a constant temperature Tin and with adjustable volume flowrate q in . The possibly variable volume flowrate q out of the outflow will depend on a demand of the next subprocess. The tank is equipped with an efficient mixer to produce an even distribution of water temperature. Assume Tout = T . A simplified model of the process is

& = qin q out h a

&= T

qin (Tin T ) + ah

P c

& = 1 P + 1 P P e Te Te
where a is the cross section area of the tank,

is the density of water, c is the heat capacity coefficient

of water, Te is the heater time constant (sometimes regarded as positive, sometimes rounded down to zero). Derivation of the level and temperature models have been presented in the basic course. Linearization of the model above at an operating point yields a linear approximating ODE model of the form

&(t ) = h

q in (t ) q out (t ) a

& (t ) = k T + k P + k q T 2 3 4 in & (t ) = P
1 1 P(t ) + Pe (t ) Te Te

where the constant coefficients k 2 , k 3 , k 4 depend on the operating point. Find the formulae of them! Here we may design a precompensator using simple arguments of ordinary feedforward control. If the heater time constant is regarded as zero, we may e.g. apply constant-gain-feedforward compensation together with two simple controllers. The solution is illustrated in Figure 9 assuming proportional controllers and ideal sensors. The effect of the flowrate deviation qin to x is included in the model

x = k3 ( k ff qin + ...) + k 4 qin = ( k 4 + k3 k ff ) qin + ...


An obvious choice of the feedforward gain to achieve decoupling (at the operating point) to two SISO systems occurs if ( k 4 + k 3 k ff ) becomes zero. This suggests the feedforward gain

k ff =

k4 k3

If the heater time constant is positive, decoupling is still possible (close to EP) with a suitable dynamic feedforward compensator. A block diagram similar to that above could be used to find a unrealizable feedforward compensator. To get a realizable compensator a more careful design is needed. A possible solution is illustrated in Figure 10. 14

1 sensor_h deviation of qin dqin deviation of h dh

e1 Step dhref

Kp1 Gain3

dqin

dqin

1/a s tf1

dqout k4 feedforward gain kff Gain4 Gain deviation of qout

disturbance!

w dPe e2 Step dTref Kp2 Gain2 dP k3 Gain1 dP deviation of heat power

1 s-k2 tf2

dT deviation of T

1 sensor_T

Figure 9. Simple Decoupling Algebraic Multivariable Control of Heated Tank

1 Th.s+1 level sensor deviation of qin dqin Integrator 1 T1.s+1 Step dhref filter_h diff_h e1 K*Ta.s+K Tb.s+1 phase lead circuit Ta > Tb derivative of dqin u1 Gain3 d1 1 s dqin dqin 1/a Gain2 d2 k4 Gain feedforward correction f 1 T2.s+1 Step dTref filter_2 diff_T e2 Kp.s+Ki s PI controller u2 Sum dPe 1 Te.s+1 heater dPe deviation of electrical power 1 TT.s+1 temperature sensor Gain1 dP deviation of heat power Scope_T dP k3 Sum2 z disturbance! w Sum1 x 1 s-k2 tf2 dqout deviation of qout diff. s tf1 Scope_h deviation of h dh

dT deviation of T

Figure 10. Decoupling Dynamic Multivariable Control of Heated Tank

The motivation and the design principles of the feedforward correction will be explained in detail in the lecture. The block Integrator both helps us to find a realizable feedforward compensator and reduces inaccuracies of level control due to a constant outflow or linearly changing set point of h but causes undesirable phase lag of 90 in the level loop. To compensate part of the phase lag a phase lead & in . controller is used in the level loop to form q
o

15

Identification of Parameters of Static Models You may have already studied the Ordinary Least Squares (OLS) Fits for models which are linear with respect to the unknown parameters. This topic is also covered shortly in FPW 9.4.1 with a nice Example 9.7 where a second order polynomial model

y = ao + a1 t + a1 t 2 + v
is fitted to observation pairs ( ti , yi ) so that v is regarded either as zero mean noise or equation error. Matlab offers a nice tool for the job, polyfit. Below forming the interesting arrays is further explained, and some additional info is given to enable more general fits. The arrays of Example 9.7 can be derived also as follows: first turn around the model and present all the additive terms as products of a known measurement and an unknown paramter,

1 ao + ti a1 + ti2 a2 = yi vi
Here unity measurement was intoduced for a parameter which initially had no measurement. Next write the model individually for all possible observation pairs ( ti , yi ) ,

1 ao + t1 a1 + t12 a2 = y1 v1
2 1 ao + t 2 a1 + t 2 a2 = y 2 v2
2 1 ao + t3 a1 + t3 a 2 = y 3 v3

M
Then write this as vector identity,

1 ao + t1 a1 + t12 a2 y1 v1 2 1 ao + t 2 a1 + t 2 a2 = y2 v2 2 1 ao + t3 a1 + t3 a 2 y 3 v3 M M
Present the LHS as a product of data matrix H and a parameter vector x , and express the RHS as a vector difference of a data vector y and unknown noise vector v ,

1 t1 t12 y1 ao 2 1 t 2 t 2 a = y2 2 1 1 t3 t3 y3 a2 1 2 3 M M M M 2 4 1 3 x 1 4 244 3
H y

v1 v 2 v3 M 2 1 3
v

We should select x to make H x to approximate y well enough, i.e. to make (noise or equation error vector) v to approximate zero vector well enough. The accuracy of the fit is here measured in terms of Sum of Squares, which for m observations is given by

J = vi2 = v T v
i =1

This performance index equals to the square of the Euclidean norm of v , see norm. The OLS (Ordinary Least Squares) estimate of x is initially defined as any minimizer of J . A unique minimizer is desired. If 16

the solution is not unique, one should make some modifications or pick a minimizer with a minimized norm. FPW presents a classical normal equation strategy (important for some theoretical studies) , some solution strategies of which may be unreliable in some cases. Fortunately Matlab tools slash (\) and lscov solve the problem in a more reliable way. So do some sequences of commands based on the tools qr or svd . In some cases one may also use pinv . Weighted Least Squares (WLS) One sometimes needs weighting of the elements of v . FPW discusses this on a general level and presents again classical formulae important for some theoretical studies but sometimes ill-conditioned and inefficient. Matlab tool lscov can handle different weightings wanted from different reasons. In this course we ignore statistical reasons but discuss only deterministic ones.

WLS by slash A weighted performance index is

J = (i vi ) 2
i =1

where each equation error vi is devoted a weight carefully!). The weighted errors

i of its own (before vi and their vector v are

squaring , read the formula

1 v1 vi = i vi v = M v m m
The performance index now becomes OLS performance index of

v ,

J = vi2 = v T v
i =1

Lets now look if OLS tools can be applied to some modified arrays. Define a column vector

of weights as

1 M = m
Now

v may expressed using Matlab language as

v = diag ( ) v = D v , D = diag ( )
where

diag ( ) denotes a diagonal square matrix with the kth diagonal element being Dkk = k . On

the other hand, the weighted error vector is

v = D ( y H x) = D y D H x
But this means that the minimum of J may perhaps be found with slash or the simplest call of lscov from the weighted arrays

H = DH

y = D y
17

Remark. In Matlab diag(a)*b for a vector a and a column vector a.*b while diag(a)*B for a vector a and a matrix multiplication of two matrices,

b can also be formed using an element-by-element-multiplication

B with several columns can be formed using element-by-element


b11 L b1n M L M b b L m1 mn 4 1 4244 3
B

a1 b11 L a1 b1n a1 L a1 diag ( a ) B = M L M = M L M .* a b a b a a L L m mn m m m m1 4 1 4 244 3


A

The matrix A of weights may be formed from a using repmat . Another possibility to create A is to use the product

a1 L a1 a1 A = M L M = M [1 L 1] a a L m m am
where the row vector is available by ones after its dimension is picked with size or length.

WLS by lscov Another presentation of J is

J = i2 vi2
i =1

where we weight after squaring. This presentation is convenient for lscov , in the documentation of which the numbers

i2 are called counts. When reading the documentation notice that


w1 v1 L vm ] M = v T diag ( w) v w v m m

w1 v + ... + wm v = v1 w1 v1 + ... + vm wm vm = [v1


2 1 2 m

Weighting due to Forgetting Factor Sometimes one selects the exponentially weighted quadratic performance index

I = m k vk2 = k =1 k =1

mk

vk

where the last weight (for k = m ) is normalized to unity value. The parameter is called the forgetting factor . The sequence of weighting factors for increasing k is here increasing for 0 < < 1 , constant for = 1 (OLS!) and decreasing for > 1 . 18

Simple methods for empirical modelling a) Simple Identification of Time Constant, Delay and Gain from a Step Response If a SISO system with a scalar input u and a scalar output y has Time Constant T , Delay d and Gain (dc gain) K , then the IO behaviour of the system may be represented by the differential equation

& (t ) + y (t ) = K u(t d ) Ty
where u is assumed to be zero for negative times. The corresponding tf (transfer function) is

G( s ) =

K exp( d s ) T s +1

A CST presentation of the model may be formed from numerical values of the parameters in various ways, even with a single command, G = tf(K,[T,1],'InputDelay',d) The model is BIBO stable iff (if and only if) sequel assume that T > 0 .

T 0 . Because the case T = 0 is very trivial we will in the

Consider the step response of the system when the amplitude of the input step is is y (0) = 0 . This response has e.g. the following properties or features: 1) Final Value : 2) Interesting Sample Value : 3) Tangent Line Property at

u and the initial output

y () = K u
y ( d + T ) = ( 1 exp( 1) ) y ( )

t=d :

The tangent line plotted at t = d crosses Final Value Level at the time ( d + T ) .

4) Rise Time from

10% change to 90% change:

Tr = ln(9) T
Ts = d + ln(50) T

5) Settling Time for

2% accuracy of change:

6)

IE (Integral-of-Error) :

IE =

( y() y(t ) ) dt = y() (d + T )

Figure.

IE for a positive Final Value equals to the area of the shaded region between the axes and the step response curve.
19

7)

ITE = ISE =

t ( y () y (t ) ) dt =

1 y () ( ( d + T ) 2 + T 2 ) 2

8)

( y () y (t ) ) 2 dt = y 2 () (d + T )
2

If the shape of the empirical step response y encourages us to assume the model structure presented, we can first estimate from the empirical step response three features which together as a set depend separately enough on all the model parameters and then tune the model parameters to imply the same numerical values for the features selected. Example 1. Use Features 1 , 4 and 5: Estimate first from the experimental step response

y ( ) , Rise

Time Tr and Settling Time Ts . Then find parameter values which can explain the numerical values found:

K=
T=

y ( ) u
Tr ln(9)

(from Feature 1)

(from Feature 4)

d = Ts ln(50) T

(from Feature 5)

Example 2. Use Feature 1 as above together with Features 6 , 8 as follows: estimate first IE and ISE from the experimental step response by numerical integration (e.g. by trapezoidal integration using trapz) and solve then the Delay and the Time Constant from the equations

y () ( d + T ) = IE y 2 ( ) ( d + T ) = ISE 2

Here slash is the most recommendable tool for a Matlab user. Outside Matlab use the solution formulae

IE ISE T = 2 y ( ) y 2 ( )
d = 2 ISE IE 2 y () y ()

b) Line Fit Identification of Time Constant and Gain from a Step Response The following may be applied for delayless monotone step responses. Note that such a response may sometimes be formed from a delayed response by removing the delay with appropriate time shifting. The step response function discussed in the previous section but for zero delay is

y (t ) = K u (1 exp( t / T ))

, t0

Its transient part is defined and formed as

x(t ) = y () y (t ) = K u exp( t / T )

, t0
20

Assume first that x has only positive values. Then the natural logarithm of the transient is

z (t ) = ln( x (t )) = ln( y () y (t )) = ln( K u ) +


This is of the form

1 t T

, t0

z = c1 t + c2

1 / T while c2 equals to ln( K u ) . We may now make a line fit to observation pairs ( t , z ) with e.g. polyfit. After c1 , c2 has been solved we may select model parameters with
where c1 equals to

T=

1 c1

K=

exp(c2 ) u

If x gets only negative values, apply the procedure above first for ( x ) but rememeber to correct the sign of K to match the final value of y . If x gets both positive and negative values, one can start by removing the observations with the rarer sign and proceed then as above.

c) Estimation of damping factor and natural frequency from an experimental step response A zero-less second order tf may be written in the form

G( s ) =
where

2 K n , n 0 2 s 2 + 2 n s + n

is the damping factor ,

is the natural (angular) frequency and

K is the dc gain .

This model was discussed in e.g. DB 2.4 , 5.3 , 5.5 , 8.2 , most often assuming unity dc gain ( K = 1 ). A method for estimating the parameters was given by DB. Below another procedure will be described.

y for an input step amplitude u and zero initial value will converge to the finite final value y () = K u . We may estimate the IE and ITE performance indices of the empirical response y ,
Given the stability condition of the model is In that case the step response

n 0

> 0 & n > 0 .

IE =

[ y() y(t )] dt

ITE =

t [ y () y (t )] dt

For the corresponding step response of a stable system with tf

G( s ) we have in general

IE = G(0) u

ITE =

G(0) u 2

For the current second order tf above we obtain from these formulae the results

IE = 2

K u n

4 2 1 ITE = 2 2 K u n n

The Greek parameters may be found the presentations 21

IE 2 ITE n = y () y ()

1 / 2

IE n y () 2

Again we have

K=

y () u

Estimate first y ( ) , then estimate the formulae above!

IE , ITE with e.g. trapz and finally compute the parameters from

d) Modelling of a MIMO System from Step Responses The figure below shows some step response data of Application 1:

The times of the input steps are t = 100 and t = 350 . The system has nearly reached an equilibrium before each change, and so only an input is changed in essence within a step experiment. Within the time range 100 t 350 we can exploit a suitable SISO identification method to model both the effect of qh to h

T . In a similar way the data of the time range 350 t 600 may be exploited to explain the effect of qc to both h and T . Let
and the effect of qh to

u1 = q h , u 2 = q c , y1 = h , y 2 = T
22

Lets use first order delayed sub-models. Denote the Gain, Time Constant and Delay from u j to yi with

K ij , Tij and d ij , respectively. Find these parameters for all IO pairs! If the experimental responses can be
described accurately with the models selected , the following linear model might be useful:

u1

Gain Time Constant Delay

K11 T11 d11

y1
+

Gain Time Constant Delay

K12 T12 d12


K 21 T21 d 21 K 22 T22 d 22
+ +

Gain Time Constant Delay


u 2

Gain Time Constant Delay

y 2

The experimental results above could also be explained with infinitely many non-linear models but lets try to keep things simple. Note that the block diagram above includes four differential equations while the physical model of our example system included only two differential equations. This deserves some attention later. Stability analysis through time domain simulation Suppose that nominal analysis predicts a stable closed-loop control system. Call the system here stable iff it has a convergent step response. Unfortunately, the sub-models are typically to some extent inaccurate. One should pay some attention to this fact. There are many ways to study the problem. It is e.g. common to analyze the effect of gain and delay inaccuracies. Quite often one inserts in ones thoughts extra gain blocks and extra delay blocks in some signal paths and studies which values of gains and/or delays lead to loss of stability. In the block diagram below there are extra blocks 1 , 2 in example positions for the purpose:

sen1
_ +

con1
+

pre w2 compensator

MIMO process

con2

sen2
23

Here 1 could be a gain block while 2 could be a delay block or vice versa. Alternatively, both blocks could be delay blocks or gain blocks. Each uncertainty block could also be inserted in a position different from that above, e.g. to follow a SISO controller or sensor. In all cases one can present conditions on stability in terms of a model parameter included in 1 and a model parameter associated with 2 , even on a parameter plane. Note that any block could include both a gain and a delay. In classical SISO control one is interested in upper gain margin and delay margin. Lets generalize the concepts here for a MIMO system in the most simplest way: Upper Gain Margin. Let 1 , 2 be identical gain blocks with a common gain . If the closed-loop system has a convergent step respone for any above unity value the gain margin is said to be infinite. Otherwise the smallest value of above unity value leading to a non-convergent step response is called the gain margin. Delay Margin. Let 1 , 2 be identical delay blocks with a common delay defined as the smallest positive delay

d . The delay margin is

d leading to a non-convergent step response.

Example of dde23-simulation of a Time-Delay System You are taking a shower and want to control the water temperature. Your co-operation with the mixer is modelled with a gain and an integrator, the water tube is modelled with a delay, and you use your ideal toe as an ideal temperature sensor:

The system has the delay-differential equation model

& (t ) = k T (t ) T (t ) = k T (t ) T (t ) = k T (t ) T (t d ) T mix ref mea ref out ref mix


Tout (t ) = Tmix (t ) = T0 for t 0
Command: help dde23 Create a subroutine (with file name showering.m) : function Tmixder = showeringm(t,Tmix,Tout,k,Tref) % Tmixder = showeringm(t,Tmix,Tout,k,Tref) % The ODE: Tmixder = k*(Tref - Tout) ;

Simulate : T0 = 10 % initial temperature Tref = 37 % new set point 24

d = 1 tmax = 10 k = exp(-1)/d % critical damping help ddeset opt = ddeset('AbsTol',1e-8, 'RelTol',1e-6) delays = d sol = dde23('showeringm',delays,T0,[0,tmax],opt,k,Tref) time = sol.x Tmix = sol.y plot(time,Tmix) , ylabel('T_m_i_x') , grid % Plot Tout , % Tout(t) = Tmix(t-d) % Tout(t+d) = Tmix(t) : plot(time+d,Tmix), ylabel('T_o_u_t') , grid axis([0 tmax 10 40])

On the Approximation of Delay Models The SISO delay model

0 y (t ) = u(t d )

, t<d , td

(1)

is sometimes replaced by an approximative model. That is done too often since in many cases we may avoid it by proper use of e.g. dde23 , frd etc. ! The delay tf is

G ( s, d ) = exp( d s )
CST offers pade to form a Pade approximation of a desired order. It uses the formula

(2)

ez

c
k =0

zk
(3)

(1)
k =0

ck z

where the

q is the order of the approximation and the coefficients are


(4)

ck =

( 2q k )! q! ( 2q)! k!( q k )!

The coefficients may be generated with gamma function or with pade or using the recursion

ck =

q k +1 ck 1 , c 0 = 1 k ( 2q k + 1)

(5)

The Pade approximation of the delay tf is therefore

exp( d s )

c
k =0

k q

d k ( 1) k s k
(6)
k

c
k =0

d s
k

25

The proper selection of q depends on the relevant frequency range which depends on other sub-models, the purpose of modelling etc.

d , the properties of

Sometimes one may also use Laguerre approximations. The first order one is obtained from the identity

y (t +

d d d ) = u(t ) = u(t + ) 2 2 2

(7)

by linearizing both sides,

& (t ) y (t ) + y

d d d d & (t ) ) u(t ) + u y (t + ) = u(t + 2 2 2 2

From this we decide to use the ODE model

d d & (t ) + y (t ) = & (t ) + u(t ) y u 2 2


to produce an approximation

(8)

y . The tf of the model (8) is

d s +1 d s+2 = G1 ( s, d ) = 2 d d s+2 s +1 2
The fourth order Laguerre approximation may be defended as follows: introduce a block diagram where the total delay d is formed from four identical delays each equal to d / 4 : delay = d/4 delay = d/4 delay = d/4 delay = d/4

(9)

d exp( s ) 4

d exp( s ) 4

d exp( s ) 4

d exp( s ) 4

Then apply the first order approksimation for each block:

G1 ( s ,

d ) 4

G1 ( s ,

d ) 4

G1 ( s ,

d ) 4

G1 ( s ,

d ) 4

The transfer function of this series connection is

G4 ( s , d ) = G1 ( s ,

d d d d d ) G1 ( s , ) G1 ( s , ) G1 ( s , ) = G14 ( s , ) 4 4 4 4 4

In a similar way the delay d may be presented as a series connection of n identical sub-delays each of the magnitude d / n . This yields the n th order Laguerre approximation

ds 1 2n d s n ( 2 n d s ) n d n 2 n = Gn ( s , d ) = G1 ( s , ) = = ds n 2n + d s ( 2n + d s ) n 1 + 2n

(10)

The explicit formulae of the numerator and denominator coefficients may be found using the binomial formula. 26

2.

Matrix Presentations of Time Domain Linear Time-Invariant Models

This chapter shows compact derivations and presentations of some delay-free time domain LTI (Linear TimeInvariant) models, for which Simulink offers blocks and CST (Control System Toolbox) offers nice tools. The topic of Section 2.1 is static LTI systems while dynamical systems are discussed in Section 2.2.

2.1 On Static LTI Models

Example 1. A static LTI SISO model is characterized with a constant gain. A gain model may be used to describe many actual or virtual systems model, e.g. a P (proportional) controller as well as scaling of a function to change the unit of the variable or to have a normalized function with values within a suitable range. A gain block is available in Simulink while ss of CST offers the possibility to create a corresponding model object with its shortest call: a gain model with the numerical gain k is available simply by a command like gainmodel = ss(k)

Example 2. We have derived a linear pre-compensator for a tank with two inflows. Its rough IO block diagram presentation is given below:

u a u b

linear pre compensato r

q h q c

The output deviations depend on the input deviations roughly according to the linear model below where the RHS (right hand side) expressions are weighted sums of input deviations:

q h = k ha u a + k hb u b q c = k ca u a + k cb u b
The elementary block diagram of the model (1) is :

(1a) (1b)

u a

k ha
+

q h

k hb

k ca
+ +

u b

k cb

q c

It is convenient and fruitful to store the coefficients in a two-dimensional array K found from weighted sums of (1ab) by covering the input deviations and the plus signs of additions:

k K = ha k ca

k hb k cb

(1c)

27

Lets introduce a new block diagram presentation based on the array K :

u a u b

k K = ha k ca

k hb k cb

q h q c

Lets next define one-dimensional column arrays for input deviations and output deviations ,

u u := a u b

q q := h qc

(1d)

There are several good reasons for using one-dimensional column arrays instead of one-dimensional row arrays. Now we are ready to introduce further block diagrams:

u u = a ub

k K = ha k ca
q
K

k hb k cb

q q = h qc

Notice that matrix algebra defines a product of a matrix (with possibly several columns) and a column vector so that here we may write

q h k ha q = k c ca
q = K u

k hb u a k cb u b

(1e)

(1f)

In fact, the result above follows from a more general definition of the product of two compatible matrices, which is selected to provide us a good tool for modelling some more complicated systems. In Simulink a column vector may be built from scalars with a Mux block, and the opposite operation is available by the DeMux block. A Matlab name of the array K is Matrix Gain. It can be created to Matlab memory in many ways. Two common ways are shown below: K = [kha,khb kca,kcb] K = [kha,khb;kca,kcb] Comma can also be replaced by a space. A CST model object can be formed with ss and documented with or without set : help ss sys = ss(K) set(sys) % Info about abilities of set set(sys,'InputName',{'dua','dub'}) % No display! sys % Display! sys.OutputName = {'dqh','dqc'} sys = ss(K,'InputName',{'dua','dub'},'OutputName',{'dqh','dqc'}) 28

Object content can be picked with dot operations and get : K_ = sys.d get(sys) % Info about abilities of get

Outputs = get(sys,'OutputName')

Direct derivation of Matrix Gain from the non-linear model Symbolical partial derivatives may be calculated with diff and jacobian of ST. The latter one is convenient for multivariable problems for calculation of gradient vectors of scalar functions of several variables and Jacobian matrices for vector functions of several variables. To repeat these concepts of Differential Calculus consider two general functions of two variables,

f 1 = f 1 ( x1 , x 2 ) f 2 = f 2 ( x1 , x 2 )
Gradient. Linearizing the first function gives (if the deviations are close enough to zero)

(2a) (2b)

f 1

f 1 f x1 + 1 x 2 x1 x 2

(2c)

where the partial derivatives are evaluated at the operating point. This may be present as a inner product

f f 1 1 x1

f 1 x1 x x 2 2 1 2 3
x

(2d)

Here the row vector of partial derivatives,

f f1 := 1 x1

f1 x 2

(2e)

is called the row gradient vector of the function f 1 . In a similar way, linearizing f 2 yields

f 2

f 2 f x1 + 2 x 2 x1 x 2

(2f)

f f 2 2 x1

f 2 x1 x x 2 2 1 2 3
x

(2g)

Here the row vector of partial derivatives,

f f 2 := 2 x1

f 2 x 2

(2h)

is called the row gradient vector of the function f 2 .

29

Jacobian matrix. Models (2c) and (2f) may be combined to a single model of two equations:

f 1

f 1 f x1 + 1 x 2 x1 x 2 f 2 f x1 + 2 x 2 x1 x 2

(2c)

f 2

(2f)

f 1 f 1 f 1 x1 x 2 x1 f f x2 2 2 f 2 1 2 3 x x x 1 2 42 1 43
J

(2i)

Here the rectangular (and here even square) matrix

f1 x J := 1 f 2 x1

f1 x 2 f 2 x 2

(2j)

is called the Jacobian matrix of the column vector function f with respect to the column vector x ,

f f = 1 , f2

x x = 1 x2

(2k)

Note that the first row of the Jacobian

J contains the row gradient f 1 of f1 , while the second row of J is occupied by the row gradient f 2 of f 2 . We may also say, that f 1 is the Jacobian of f 1 while while f 2 is the Jacobian of f 2 . So dont be suprised, that the tool jacobian of
Symbolic Toolbox may be used to obtain the row gradients !

For the precompensator of the tank with two inflows discussed we have

qh = qh (ua , ub ) =
qc = qc (ua , ub ) =

u a ub 1 + ub
ua 1 + ub

Think this as a column vector-to-column vector mapping

u q q : a h ub qc
q : u q (u )
The first order Taylor approximation is

30

qh qc

qh ua ua qc ua ua

+ +

qh ub ub qc ub ub

q h q h q h u u a u b a q c q c q c u b 1 2 3 1 2 3 u a u b 42 q 1 4 43 4 u
J

q J u
where the partial derivatives and so the matrix J should be evaluated at the operating point. This matrix,

q h u J = a q c u a

q h u b q c u b

is the Jacobian of the mapping q with respect to u . It is equal to the Matrix Gain K also obtained by 1st order Taylor expansions.

% MATRIX GAIN THROUGH JACOBIAN WITH SYMBOLIC TOOLBOX % Solve the pre-compensator outputs fromits inputs: q = solve('qh + qc = ua','qh/qc = ub','qh,qc') qh = q.qh qc = q.qc % Define symbolic variables: syms ua ub % Define appropriate column vectors: u = [ua;ub] % input column vector q = [qh;qc] % output column vector % Compute Matrix Gain as a Jacobian Matrix: J = jacobian(q,u) J = simple(J) pretty(J) % Operating point values may be substituted with either subs or limit .

Example 3 . A linear model of a cross-coupling We have seen in both linear process models and linear controller models a coupling structure presented below:

u1

y1

k
u2
+ +

y2

31

Lets derive a MIMO model, first in a traditional way, then in a way convenient for ST users: The outputs are here

y1 = u1 y 2 = u 2 + k u1
Organize and use a bit expansion (use unity and zero multipliers to complement the model if needed)

y1 = 1 u1 + 0 u 2 y 2 = k u1 + 1 u 2
A matrix presentation of this is

y1 1 0 u1 y = k 1 u 2 2
So the system model is a Matrix Gain model with the Gain

M,

1 0 M = k 1
But a ST user may derive this in a very convenient way by noting that vector with respect to the input vector: syms u1 u2 y1 y2 k y1 = u1 y2 = u2 + k*u1 u = [u1;u2] y = [y1;y2] M = jacobian(y,u)

M is the Jacobian of the output

Example 4 . Two P controllers operating within the same control law Two P controllers may be used jointly in control of a TITO system to form two controller outputs from two actuating errors:

e1 e2

K P1 K P2

u1 u2

Here the inputs are the actuating errors , and the outputs will be inputs of the process or a pre-compensated process. The block diagram above may also represent two ideal sensors operating jointly (if K P1 = K P 2 = 1 ) or scalings. Nevertheless, the separate (independent) systems may be presented a joint virtual MIMO model for convenience of Simulink simulation or CST analysis: the block models

u1 ( t ) = K P1 e1 ( t )

u 2 ( t ) = K P 2 e 2 (t )
32

may be appended together and bit-expanded to the form

u1 (t ) = K P1 e1 (t ) + 0 e 2 (t ) u 2 (t ) = 0 e1 (t ) + K P 2 e 2 (t )
which has a convenient matrix presentation

u1 (t ) K P1 u (t ) = 0 2

0 e1 (t ) K P2 e2 (t )

The model is a special Matrix Gain model

u (t ) = K P e (t )
where the matrix K P happens to be a diagonal (diag) matrix,

K K P = P1 0

0 K P2

Note that for two ideal sensors modelled by unity gains alone the diagonal Matrix Gain derived above becomes the identity (eye) matrix of dimension 2 ,

1 0 I= 0 1
CST offers a nice tool, append , for the operation needed. Above we could use the commands KP = diag([KP1,KP2]) , sys = ss(KP)

Alternatively, they may be replaced by the commands sys1 = ss(KP1) , sys2 = ss(KP2) , sys = append(sys1,sys2) The tool append can append even an larger number of joint submodels with a single command. Remarks. We have introduced a static LTI MIMO block diagram with input column vector v , output column vector w and a Matrix Gain M

M v

M
This means that

wi = M ik vk
k

M ik or in Matlab language M(i,k) the row index i is the index of the output while the column index k is that of the input. So all the parameters of the i th output lie on the i th row M(i,:) of the Matrix Gain M while all the multipliers of the k th input lie on the k th column M(:,k) of M .
In the multiplier We may sometimes change the order of inputs and/or outputs which of course may change the content of the Matrix Gain. In Matlab one may use vectors of indices to refer to a set of columns and/or rows. For example, M([1,3],2) picks the first and the third row from the second column etc. Beside that the order of columns (and so that of inputs) may be reversed with fliplr while the order of outputs (and so that of the outputs) may be reversed with flipud. 33

2.2 Introduction to true LTI State-Space Models A set of first order delay-free LTI ODEs may be presented using standard matrix notation. This presentation, the LTI State Space Model, is a fundamental model structure of many control analysis and design procedures and software packages. Concerning Matlab, Control System Toolbox provides us with great many nice easyto-use and professional tools for ss modelling , time domain simulation, frequency response analysis etc. A good introduction to state space models can be found from the course books (Burl , Dorf-Bishop , FranklinPowell-Workman) as well as from several elementary Math books, e.g. Advanced Modern Engineering Mathematics of James. We have learned that many delayless LTI systems (without input, internal and output delays) can be presented an elementary block diagram consisting of realizible SISO gains, integrators , summing elements and subtraction elements. Subtraction may of course be presented implicitly using the gain ( 1) and a summing but for simplicity of block diagrams it is often presented explicitly. We have seen that elementary block diagrams may connect the elements mentioned using etc. series , feedback and parallel connections. A parallel connection of a gain and a LTI system is sometimes needed to describe an immediate effect of an input to a response variable, e.g. but not only in many controller models. Note that no derivative blocks are allowed in elementary block diagrams. Finally, the elementary block diagram defined corresponds to a set of first order ordinary differential equations without reference to derivative functions of the input functions. For a delayless system such a model is a state space model well suited for ode45 simulations and can also be conveniently described using matrix notation. The ODEs of that kind of model express the state derivatives of a time instant as functions of simultaneous values of the states and external inputs.

Example A biproper first order LTI SISO system Phase lead circuit , phase lag circuit , PI controller etc. may be modelled with the first order LTI ODE

& = a1 y + b0 u & + b1 u , b0 0 y
The parameters of this model are constants (not functions of the time). An elementary block diagram without derivative blocks is wanted. The input differentiation can here be avoided with the aid of a single integration, which yields (for a constant b0 ) the integral equation

y = ( a1 y + b1 u ) + b0 u
A straightforward elementary block diagram of this is shown below with x I denoting the integral above:

b0 u b0
+
u

b1

b1 u

+ +

&I x

a1

xI

a1 y

Note that we indeed have here series , feedback and parallel connections. Note especially the fast forward connection (link) with the gain b0 in the upper parallel path. The block diagram above is a good basis for e.g. Simulink implementation of the controller.

34

E.g. ode45 simulations are based on explicit time domain equations which may be used in calculation of first order derivatives of the functions to be solved. CST simulations may be based on certain standard organized presentations of the same equations. Lets derive candidate equations suitable for both tools mentioned. Here the integrator output xI may be chosen to be the state variable (integrator outputs of delay-free elementary block diagrams can always serve as state variables!). The state derivative, i.e. the input of the integrator is

& I = a1 y + b1 u x
On the other hand, elimination of y (which is neither a state nor an input!) through substitution of

y = xI + b0 u
yields

& I = a1 ( xI + b0 u ) + b1 u x
Therefore the state ODE of the ss model may be chosen as

& I = a1 xI + ( a1 b0 + b1 ) u x

Summary. The LTI IO ODE

& = a1 y + b0 u & + b1 u y
has been shown to correspond to a state ODE and an algebraic equation below,

& I = a1 xI + ( a1 b0 + b1 ) u x

y = 1 xI + b0 u
The initial state for an initial time

t0 is obtained from

xI (t0 ) = y (t0 ) b0 u(t0 )

The model above may also be found from a parallel connection block diagram due to polynomial division (deconv) of the transfer function G : Polynomial division of the tf G yields the sum

G( s) =

b + a b b0 s + b1 = b0 + 1 1 0 s a1 s a1

Instead of explicit polynomial division we could get simplifying the difference of the parallel connection block diagram below :

b0 also from b0 = G ( ) and the second term by

G() b0 (ST: syms , limit , simple). Nevertheless, the tf sum above is the tf

b0
+
u

b1 + a1 b0 s a1

35

Here the output of the tf in the lower path is xI modelled above: show that using the IO ODE of the lower path or solve v from IO variables. However, the lower path may also be presented other block diagrams, e.g. that shown below:

b0
+ +

1 s a1

b1 a1 b0

Here w may serve as the state. So the IO ODE of state-space model

w may be exploited as the state ODE. This yields the

& = a1 w + 1 u w

y = ( b1 a1 b0 ) w + b0 u
The initial state needed here is

w( t 0 ) =

y (t0 ) b0 u( t0 ) b1 a1 b0

Compare the two different state models obtained due to a different choice of the state. Here they contain the same symbolic coefficients but so that the coefficients 1 and ( b1 a1 b0 ) are interchanged. Both candidate models may be presented as special cases of the more general single state SISO model

& = a x + bu x
y = c x + d u
Parameters of this parameterization due to the two models obtained are shown in the table below:

model 1 a b c d x ( t0 ) a1 b1 a1 b0 1 b0 y (t0 ) b0 u(t0 )

model 2 a1 1 b1 a1 b0 b0 y (t0 ) b0 u(t0 ) b1 a1 b0

Yet additional parametrizations of the single state model exist due to scalings motivated either by change of the engineering units of the functions or by numerical issues. Substituting in the model above x = p where p is a scaling constant yields a new state-space model

& = a + p 1 u

y = cp x + d u

Here the first and the fourth state space parameters ( a , d ) get their previous values while the second and the third parameter are modified. However, note that the product of the modified parameters is not modified

& (0) which is natural since ( cp ) ( p b) = cb is a property of the IO response, namely the initial slope y of the unit step response for zero initial value of the state.
36

Possibility of scaling alone means that there exists an infinite number of different state-space models for a given IO model. Note also that a first order IO model is sometimes obtained as a simplification due to cancellation of common factors of the numerator and the denominator polynomial of the tf (pole-zero cancellation!) of a higher order IO model, e.g.

s+2 s+2 1 = = s + 3 s + 2 ( s + 1) ( s + 2) s + 1
2

In this example the cancellation is due to having both a tf zero (zero) and a tf pole (pole , pzmap) at the point 2 = 2 + 0 j of the complex plane. The second order tf above may be found infinitely many state space models with e.g. two states (using procedures of DB 3.4 to be discussed later), each model yielding a first order IO response! In the sequel we will often discuss systems with several state variables and even with several inputs and/or outputs. It is tempting to try to extend the time domain equations, block diagrams and ideas discussed above for such systems. In generalized equations and block diagrams inputs, outputs and internal functions are column vectors ; integration , summing and subtraction operate on column vectors vector elementwise according to familiar definitions of Math courses ; Matrix Gain defined earlier is used to present multiplication of a column vector from left with a matrix. So we use e.g. the operations shown below:

v1 w1 v1 w1 M M = M v w v w n n n n v1 dv1 / dt d M = M dt vn dvn / dt

f11 w1 + ... + f1m wm f11 L = M M f w ... f w + + nm m f n1 L n1 1


v1 v1 M= M vn vn

f1m w1 M M f nm wm

We may now write many delay-free LTI State Space models in the form below:

Linear Time Invariant State Space Model = LTI ss model A general ss structure is:

& (t ) = A x (t ) + B u (t ) x y (t ) = C x(t ) + D u (t )

x is column vector of state variables (states), state vector u is column vector of inputs, ie. input vector
&= x dx dx &k = k = x x dt dt

>

x ' = Ax + Bu y = Cx + Du

>

y is column vector of outputs, ie. output vector A , B , C , D are constant matrices (independent of time ; vectors or scalars in special cases) no delays are included in the model!

37

Its block diagram presentation is shown below:

Elementary Block Diagram of LTI State-Space Model.

D
+

B
+

& x

A
x

Ax

The IO variables and the internal variable (state x ) are column vector functions of the time. The parameters A , B , C , D are in general called Matrix Gains. A Matrix Gain multiplies its input (a column vector) from left. Integration and addition of vectors is performed elementwise. Note that series connections, a positive feedback connection and a parallel connection are included in the block diagram given. A non-zero feedforward (matrix) gain D is typical e.g. in many controller models and in several error models, where it explains the immediate response (fast initial reaction) of those systems to an input excitation.

On State Models of First Order SISO systems Below three important special cases of the first order SISO systems are discussed explicitly. Example. SISO integrator Amplified integration of a scalar function u is available by removing (preventing) both the positive feedback with the choice A = 0 and the feedforward effect with the selection D = 0 . From that pure scalar integration is obtained with e.g. B = C = 1 . There also exists other choices of B and C as soon as we have CB = 1 . This observation suggests that a system might have an infinite number of state space models. For e.g. the integrator we usually select C = 1 to get y = x , which allows the initial value of x be that of y . Then we must select B = 1 . So the most typical choice of ss parameters for an integrator is

A = 0 , B = 1 , C = 1 , D = 0 , x(t0 ) = y (t0 )
where

t0 is the initial time, often but not always selected to be zero. This selection yields the ss model

&=u , y= x x
as well as the necessary IO differential equation model

& =u y
or equivalently the necessary integral equation model

y = u
Example. SISO Time Constant Model Some systems with a scalar output y and a scalar input u can be modelled using the LTI ODE 38

& + y = K u Ty
where T is the Time Constant and K is the (dc) Gain of the system (model). The IO ODE is

&= y

1 K y + u T T

This observation encourages us to a subjective convenient choice x = y , after which we are forced to select

C = 1 , D = 0 to get output equation y = x . Here we have the ss parameters

A=

1 K , B= , C =1 , D = 0 T T

The initial value of the state variable implied is conveniently

x(t0 ) = y (t0 )
Again, there exists other parameter sets with different values for A , D and a different (more complicated) initial condition. Example. SISO Proportional Integral (PI) Controller The famous PI controller with integration time TI and proportional gain K P has the output

B , C but with the same values for CB ,

u PI ( t ) = K P ( e( t ) +

1 e dt ) TI

where e is the actuating error , and an appropriate integration constant will be selected to get a desired initial value for uPI (see LAB instructions of the basic course!). The controller output may be written in the form

uPI (t ) = K P e(t ) + K I e dt
where K I is the Integral Gain

KI =

KP TI
as y for u = e according to the controller

The elementary block diagram of ss models can produce uPI equation above e.g. when we select

A = 0 , B = 1 , C = KI , D = KP
In fact, the controller can be presented the block diagram below:

KP
e

x PI

KI

+ +

uPI

Indeed, here

39

& PI = e xPI = e x
Therefore a possible state space model is

& PI = 0 x { e { xPI + 1
A B

uPI = K I x PI + K P e { {
C D

Then the desired initial output

uPI (t0 ) is obtained for the initial state

x PI ( t0 ) =

uPI ( t0 ) K P e( t0 ) KI

This dependence on the initial state on the integral gain K I is not convenient. Moreover, in some practical running conditions a better presentation of the controller output is

uPI (t ) = K P e(t ) + K I e dt
The elementary block diagram of ss models can produce this with the choices

A = 0 , B = KI , C = 1 , D = KP
which shares A ,

D and CB with the former set of ss parameters. In fact, we may present the block diagram
KP
+

KI

x PI 2 +

uPI

The elementary block diagram of ss models can produce uPI as y for u = e according to the controller equation above e.g. when we select the parameters as above. In fact, we have

& PI 2 = K I e xPI 2 = ( K I e) x
Indeed, a state space model thus becomes

& PI 2 = 0 x I e { xPI 2 + K {
A B

uPI = 1 KP e { x PI 2 + {
C D

The desired initial output

uPI (t0 ) is obtained for the initial state

xPI 2 (t0 ) = u(t0 ) K P e(t0 )


which becomes independent of the controller tuning in a typical situation with zero

e( t0 ) .

40

2.3 On Companion State Models of Second and Higher Order SISO systems Mathematics and control theory & engineering books often introduce higher order models (transfer functions and/or their ODE presentations) in modelling (see e.g. DB 3.4) and present then suitable procedures for them. However, it should be noted, that most systems can initially be modelled without using such ODEs, i.e. using just a suitable set of first order ODEs. This observation follows from the following two facts: (1) Basic definitions and laws of physics and chemistry typically bind the first order derivative of a variable to another variable (or reversely, a variable to an ordinary integral of another variable). Example: it is true that acceleration a of an object in linear motion is the second order derivative of the position p of

& = a . However, using more & , which gives the system the second order ODE & the object, i.e. a = & p p elementary concepts of physics we may say, that acceleration a is the first order derivative of velocity & , and that v is the first order derivative of the position p , v = p & . Using now the ODE v, a = v

& = a in modelling avoids the explicit use of the second order derivative! & = v together with the ODE v p

The same observation holds in general, see for e.g. the spring-mass-damper system and the RLC circuit. (2) Higher order ODEs can also be avoided in modelling complex systems consisting of subsystems connected with each other, since the state space model of the whole system may be obtained from the state space models of subsystems as is shown in e.g. DB 3.5. We will return to this topic later. It should also be noted, that the state space models derived in DB 3.4 (of which some are available by tf2ss) and discussed later in this text may be ill-conditioned for numerical computer computations with finite accuracy. Better real-parameter models may sometimes be derived based on partial fraction expansion (see DB 3.5 and a later example) or based on a tf versus ss versus block diagram study in E12 of ACI-20010/6. Below a second order biproper system will be derived two alternate state space presentations of two states:

Example. Consider the SISO tf model

b0 s 2 + b1 s + b2 Y (s) = 2 U (s) s + a1 s + a2
The LTI IO ODE of this is

& & + a1 y & + a2 y = b0 u && + b1 u & + b2 u y


Controllable canonical form. Lets start with a possibly unrealizable block diagram yet suitable for some theoretical studies:

U (s)

1 2 s + a1 s + a2
&& + a1 v & + a2 v = u v

V ( s)

b0 s 2 + b1 s + b2 1 && + b1 v & + b2 v y = b0 v

Y ( s)

Find first a set of first order differential equations for v by letting v and

& be the states, e.g. so that v

& , x2 = v x1 = v && = x &1 and the first order ODEs This definition implies the relationship v & 2 = x1 , x &1 + a1 x1 + a2 x2 = u x

which can be presented in the organized form 41

&1 = a1 x1 a2 x2 + u x & 2 = x1 x
The output of the latter block first becomes

(a) (b)

&1 + b1 x1 + b2 x2 y = b0 x
&1 using (a) we obtain and then by elimination of x

y = b0 ( a1 x1 a2 x2 + u ) + b1 x1 + b2 x2
This may be organized to the form

y = (b1 b0 a1 ) x1 + (b2 b0 a2 ) x2 + b0 u
The Equations (a) , (b) , (c) now form a state space model suitablefor e.g. ode45 simulations. They may also be exploited in creating a Simulink model consisting of integrators , gains , summing and subtraction elements. But for Control System Toolbox and for the State-Space block of Simulink we need to present the ODE model with matrix notation:

(c)

&1 = a1 x1 a2 x2 + u x & 2 = x1 x

(a) (b)

&1 a1 x1 a2 x2 + u x = x x1 &2 &1 a1 x1 a2 x2 u x + 0 = x x1 &2 &1 ( a1 ) x1 + ( a2 ) x2 1 u x + 0 u = x 1 x1 + 0 x2 &2


&1 x x a a2 1 = 1 1 + u x x2 1 0 4 0 &2 1 2 4 244 3 1 3 {
A x B

Equality of vectors:

Separation of responses and input ; vector addition

Bit expansion to have a gain for each function

Separation of parameters and functions ;

matrix-vector products The output should also be expressed as a function of the same vectors:

y = (b1 b0 a1 ) x1 + (b2 b0 a2 ) x2 + b0 u
y=

[b1 b0 a1 b2 b0 a2 ] 14 44 4 24444 3
C

x1 b0 u x + { 2 1 2 3 D
x

We are ready to use the State-Space block of Simulink and the ss tool of Control System Toolbox. The latter one enables e.g. simulation with e.g. lsim , step , impulse etc.

42

Remark. The order of the states in the state vector above may be reverted. This moves elements of the matrices to new positions. Find the modified matrices and compare them with the matrices above. Which order of the states do you prefer? How would you use fliplr and flipud to change between the two presentations? Observable canonical form. Lets now derive another ss model for the same LTI IO model, now presented as

& & = a1 y & a2 y + b0 u && + b1 u & + b2 u y


An integration of the LTI ODE above yields the integro-differential equation

& = b0 u & a1 y + b1 u + ( a2 y + b2 u ) y
Another integration yields the integral equation

y = b0 u + a1 y + b1 u + ( a2 y + b2 u )

An elementary block diagram of this model for e.g. Simulink use is shown below equipped with some reference to a subsequent state-space model:

b2 &2 x x2

b1 &1 x x1

b0
y

a2

a1

Once an elementary block diagram is known we may let the integrator outputs be the states. Then the integrator inputs are state derivatives which the state ODEs express as functions of states and external inputs. The model may first be written in the form

&1 = a1 y + x2 + b1 u x & 2 = a2 y + b2 u x

y = x1 + b0 u
However, here y is (in a general case) neither a state nor an external input. Therefore it must be eliminated from the right hand sides of the ODEs, here by the aid of the algebraic model equation above, to get

&1 = a1 ( x1 + b0 u ) + x2 + b1 u x & 2 = a2 ( x1 + b0 u ) + b2 u x

43

Now the state-space model may be expressed in the form

&1 = a1 x1 + x2 + (b1 a1 b0 ) u x & 2 = a2 x1 + (b2 a2 b0 ) u x y = x1 + b0 u


A matrix presentation of this model is

&1 d x = &2 dt x
Remarks 1. 2.

a1 1 x1 b1 a1 b0 a 0 x + b a b u 2 2 2 0 4 2 1 4 1 2 4 3 4 2 44 3
A B

x y = [1 0] 1 + { b0 u 123 x2
C D

Reversing the order of the states gives again another matrices. In the two companion forms we have a) the same D , b) the matrices A transposes of each other , c) B of a form is obtained by transposing C of the other form and vice versa , d) e.g. the same CB .

3.

b0 = 0 the block diagram would have been quite obvious already from the integro-differential equation obtained with the first integration? Moreover, then C of the controllable canonical form and B of the observable canonical form are prettied to an interesting form
For In the matrices of both the controllable canonical form and the observable canonical form we see parameters associated with the polynomial division (deconv) ,

4.

(b a b ) s + (b2 a2 b0 ) b0 s 2 + b1 s + b2 G( s ) = 2 = b0 + 1 1 2 0 = b0 + Q ( s ) s + a1 s + a2 s + a1 s + a2
This sum represents the tf of the parallel connection shown below:

b0

Q( s ) =

(b1 a1 b0 ) s + (b2 a2 b0 ) s 2 + a1 s + a2

The rational function Q ( s ) of the lower path strictly proper. Note that in both models the feedforward parameter is

D equals to the quotient b0

the state matrix A depends only the denominator parameters of Q ( s ) and G ( s ) one of the matrices B and C depends only on the numerator coefficients of Q ( s ) while another of them is not depending on the model parameters at all. Note also that

b0 = G ( ) and that Q ( s ) can be obtained by simplifying the difference [G ( s ) b0 ] .


44

Generalizations of the above results for higher order biproper and strictly proper models are quite straightforward. Assume a rational tf

G( s) =
where

B( s ) A( s )

B and A are polynomials such that their polynomial degrees satisfy

deg B deg A = n
The controllable canonical form is based on the series connection block diagram below:

U (s)

1 A( s )

V (s)

B( s)

Y (s)

Here the model of both blocks may be written in terms of v and its ( n 1) first derivative functions, which may then be exploited as the state variables. The state vector may be built from the states in various ways, e.g. using a different order of the states in different models. Sometimes the n states x1 , , xn are defined as

xk =

d nk v dt n k xn = v .

which includes as a special case the intermediate response v as the last state, For the tf

G( s ) =

b0 s n + b1 s n 1 + ... + bn , n2 s n + a1 s n 1 + ... + an

the procedure yields the presentation

&1 = ( a1 ) x1 + ... + ( an ) xn + u x & k = x k +1 x


,

2 k n 1

y = (b1 a1 b0 ) x1 + ... + (bn an b0 ) xn + b0 u


where the multipliers in the output equation are again associated with polynomial division. The observable canonical form is based on e.g. an integral equation and the corresponding elementary block diagram obtained with n successive integrations. However, sometimes even a smaller number of integrations may remove all the derivatives of the input function so that the resulting integro-differential equation is a sufficient basis for creation of the elementary block diagram (where a number of successive integrations produce a non-derivative term). Nevertheless, we can form a state-space model, the states of which are the integrator outputs (while integrator inputs provide us with the state derivatives, to which we find equations). Some results are shown in DB 3.4 . The observable canonical form of the tf above includes the equations

& k = ak x1 + xk +1 + (bk ak b0 ) u ; 1 k n 1 x & n = an x1 + (bn an b0 ) u x y = x1 + b0


A ss presentation is available by tf2ss of Matlab, which? Which one is almost obtained with canon if the option companion is used? 45

2.4 Another State Models of SISO systems In DB 3.5 state-space models are derived for some series and parallel connections of some subsystems with numerical coefficients, starting from state-space models of subsystems. In LAB instructions of ACI-20010/6 you may find a similar study for the positive feedback implementation of the PI controller. Lets now study use of series and parallel connection for a few models with symbolic coefficients.

Example. A ss model for a series connection of two first order SISO systems Consider a system with the following series connection block diagram:

y1 G1

u2 G2

y2 & 2 = A2 x 2 + B 2 u 2 x y 2 = C 2 x 2 + D2 u 2

&1 = A1 x1 + B1 u1 x y1 = C1 x1 + D1 u1

This structure may describe open loop control (pre-compensation of process) , post-compensation of sensor , phase-lead-lag circuits , forward path of a feedback control system, dc motor from e.g. voltage to torque to speed , The connection rule is u 2 = y1 . The variable u 2 or y1 is neither a state nor an external input. So it should not appear on RHS of equations but should be eliminated. Elimination means here substituting

u 2 = y1 = C1 x1 + D1 u1
into the latter model. This yields the equations

& 2 = A2 x 2 + B 2 (C1 x1 + D1 u1 ) = B 2 C1 x1 + A2 x 2 + B 2 D1 u1 x y 2 = D 2 C1 x1 + C 2 x 2 + D 2 D1 u1
A state space model of the series connection thus is

&1 = A1 x1 + B1 u1 x & 2 = B 2 C1 x1 + A2 x 2 + B 2 D1 u1 x y 2 = D 2 C1 x1 + C 2 x 2 + D 2 D1 u1
Lets present this in the bit expansion form :

&1 = A1 x1 + 0 x2 + B1 u1 x {
0

(1)

& 2 = B 2 C1 x1 + A2 x 2 + B 2 D1 u1 x y 2 = D 2 C1 x1 + C 2 x 2 + D 2 D1 u1
A subjective and easy choice of the state vector is

(2) (3)

x x := 1 x2
The matrix form of the model (1), (2), (3) then becomes

(4)

46

&1 A1 0 x1 B1 x = + u1 x & 2 B2 C1 A2 x2 B2 D1 { 14 4 244 3 { 1 4 24 3


& x

(5a)

x y 2 = [D2 C1 C 2 ] 1 + D2 D1 u1 14 4 244 3 x 2 123 C D {


x

(5b)

Note that the state matrix A above is a lower triangular matrix. The designer may be more interested in the states of the latter sub-system. Therefore he or she may build the augmented state vector to first include its state. Then a natural choice of the augmented state x is

x x := 2 x1
The state space parameters for this choice may be found by changing the order of equations and the order of states x1 , x 2 in the right hand sides of the equations:

(6)

& 2 = A2 x 2 + B 2 C1 x1 + B 2 D1 u1 x &1 = 1 x2 + A1 x1 + B1 u1 x y 2 = C 2 x 2 + D 2 C1 x1 + D 2 D1 u1
A straightforward matrix presentation of this is

(2) (1) (3)

& 2 A2 B2 C1 x2 B2 D1 x u1 + = x &1 0 A1 x1 B1 { 14 4 244 3 { 1 4 24 3


dx / dt A x B

(7)

x y 2 = [C 2 D2 C1 ] 2 + D2 D1 u1 14 4 244 3 x1 123 C D {
x

(8)

Note that the matrix A above is an upper triangular matrix. Example. A ss model for a second order strictly proper system with real distinct poles Consider a system with input u , output y and tf

G ( s) =

cs +d , ab ( s a ) ( s b)

It has the partial fraction expansion

G ( s) =

ca + d c b + d 1 1 + ab sa ba s b

Matlab offers residue for forming a PFE. A block diagram of this presentation is:

47

u u

1 sa

x1

ca + d ab

y1
+

1 sb

x2

c b + d ba

y2

The most obvious state equations are

&1 = a x1 + u x & 2 = b x2 + u x
The matrix form of this model is is

&1 a 0 x1 1 x = + u x &2 x2 1 0 b { { 123 {


& x

Note the diagonality of A . The output equation

y = y1 + y 2
becomes

y=

cb + d ca + d x1 + x2 + 0 u ab ba

The matrix form of this is

c a + d c b + d x1 y= +0 { u x a b b a 2 1444 4 24444 3 { D
C x

Remark. If the poles are non-real, the model above has non-real coefficients. If that is not tolerated, one can use the option modal of canon. This was discussed in L&E12 of ACI-20010/6. The tf of the state model

&1 = x1 + x2 + 1 u x & 2 = x1 + x2 + 2 u x y = 1 x1 + 2 x2
is

Ga ( s ) =

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

Here the four yet unknown parameters 1 , 2 , 1 , 2 should be selected to adjust the numerator polynomial to that given . There is some freedom which may be exploited in various ways, see ACI-20010/6.

48

2.5 State Models of MIMO systems

Example. The tank with two inflows has been derived the rough linear model

& = k h + k q + k q h 1 2 h 3 c
& = k T + k q + k q T 5 6 h 7 c
Define input vector u , state vector x , output vector y :

q h h u h , x , y T T qc
Here y = x . Define also a vector for the state derivatives and denote it with

& : x

& h & x & T


Lets repeat basic concepts and ideas of Matrix Computation (and Linear Algebra) for this simple example: 1. Present the model as a vector equation / Equality of Vectors

& k1 h + k 2 q h + k 3 qc h & = T k 5 T + k 6 q h + k 7 qc
2. Distinguish between input variables and response variables / Vector Addition :

& k1 h k 2 q h + k 3 qc h & = + k q + k q k T T 5 7 h c 1 4 24 3 16 44 4 24 44 3
reponse terms input terms

3. Present the vectors added as a Product of a Parameter Matrix and Signal Vector

& k1 h + 0 T k 2 q h + k 3 qc h + & = k q h + k 7 qc h + k 5 T 0 4 T 1 42443 16 44 4 2444 3


response terms input terms

( Bit Expansion with 0 and 1 )

& k1 0 h k 2 k 3 q h h & = + T 0 k 5 T k 6 k 7 q c 2 3 1 4 24 3 1 4 24 3 1 2 3 1 2 3 1
& x
A x B u

We obtain the model

& = A x + B u x
k A= 1 0 0 k5
(here a diagonal matrix : diag)

49

k B= 2 k 6

k3 k7

(here a matrix with no special structure)

Note that in Math the vector

& of derivatives is also defined as the derivative of vector x . So x

&= x

d x = x dt

& was expressed as a linear combination of the state vector and the input vector. It is common to Above x express the output as a similar expression, i.e. in the form
y = C x + D u
Here the Output Response may be presented as

h T = 1 2 3
y

response terms

h T 2 1 3

input terms

0 0 {

Use bit expansion, i.e. introduce unity and zero multipliers when needed:

h 1 h + 0 T 0 qh + 0 qc T = 0 T + 1 T + 0 q + 0 q 2 1 44 1 h c 44 1 3 244 3 2443
y response terms input terms

Write using matrix-vector-products:

h 1 0 h 0 0 q h T = 0 1 T + 0 0 q c 1 2 3 123 1 2 3 123 1 2 3
y C x D u

So the matrices

C and D are here:


(an identity matrix: eye)

1 0 C= 0 1 0 0 D= 0 0

(a zero matrix: zeros)

Simulink offers a nice State-Space block where e.g. the model matrices and the initial value of the state may be configured. The familiar CST tool ss may be used to create an appropriate CST object for both simulation and other analysis and design. Setting and getting properties of the model object is available in familiar ways (set , get , dot operation etc.). Try also ssdata.

Example. The tank with a heater has been derived the linear model

& = a 1 (q q ) h in out
& = k T + k P + k q T 2 3 4 in & = T 1 ( P P ) P e e
50

A state-space model excluding the heater has P as an input and is of the form

& 0 0 h h a 1 0 a 1 &= = x + T & 0 k k k 0 T 2 4 3 4 1 4 24 3 123 1 4 4 2 444 3


A x B

qin P q out 1 4 2 4 3
u

qin h 1 0 h 0 0 0 y= = T + 0 0 0 P 0 1 T 1 1 23 1 4243 4 24 3 qout C x D 1 4 24 3


u

Above dashed lines are added in the input vectors to distinguish between control inputs and the disturbance input. Corredponding to that separation dashed lines are added to the matrices B , D to distinguish between columns of control input parameters and the (here) single column of disturbance input parameters. A state-space model including the heater is has Pe as an input and is of the form

& 0 0 h a 1 0 a 1 qin 0 h & & = T x k 3 T + k 4 0 0 Pe = 0 k 2 1 & 0 0 T 1 P P 0 T 0 q e e out 44244 23 1 44 1 1 3 1 4 2 4 3 4 2444 3


A x B u

h 1 0 0 y= = 1 0 T 1 0 4243
C

h qin T + 0 0 0 P 0 0 0 e 4243 1 qout P 23 D 1 1 4 24 3


x u

Dashed lines are again used to classify inputs and separate the columns of their multipliers from each other.

Example . Two SISO PI controllers operating within the same control law Two PI controllers may be used jointly in control of a TITO system:

e1

u1

PI1
e2

PI 2

u2

The inputs are the actuating errors , and the outputs will be inputs of the process or a pre-compensated process. It is often convenient to describe the operation of both controllers using a single virtual MIMO ss model. The model combines the subsystem models,which are here selected to be

u1 (t ) = K P1 e1 (t ) + K I 1 v1 (t ) u 2 (t ) = K P 2 e 2 (t ) + K I 2 v 2 (t )
The individual State Space models are:

, ,

v1 (t ) = e1 (t ) dt v2 (t ) = e2 (t ) dt

&1 (t ) = e1 (t ) , v & 2 (t ) = e 2 (t ) , v

51

PI 1

PI2

&1 (t ) = 0 v1 (t ) + 1 e1 (t ) v u1 (t ) = K I 1 v1 (t ) + K P1 e1 (t )

& 2 (t ) = 0 v 2 (t ) + 1 e 2 (t ) v u 2 (t ) = K I 2 v 2 (t ) + K P 2 e 2 (t )

The equations may be re-arranged and expanded to contain multipliers for all the RHS terms,

&1 = 0 v1 + 0 v 2 + 1 e1 + 0 e 2 v & 2 = 0 v1 + 0 v 2 + 0 e1 + 1 e 2 v

, ,

u1 = K I 1 v1 + 0 v 2 + K P1 e1 + 0 e 2 u 2 = 0 v1 + K I 2 v 2 + 0 e1 + K P 2 e 2

A standard matrix presentation of this model is

&1 0 0 v1 1 0 e1 v v = 0 0 v + 0 1 e 23 2 23 2 1 &2 1
" A" " B"

0 v1 K P1 0 e1 u1 K I 1 u = 0 K v + 0 K P2 e I2 2 2 1 4243 142 4 43 4 2
"C " "D "

The matrix A is here the two-by-two zero (zeros) matrix denoted here simply by O , the B matrix is here the two-by-two identity (eye) matrix denoted here by I , and the controller gains are included in two diagonal (diag) matrices . The model may be written in the form

&(t ) = O v I e(t ) { v(t ) + {


" A" "B "

0 0 O= 0 0

1 0 I= 0 1

u (t ) = K I v(t ) + K P e(t ) { {
"C " "D "

K K I = I1 0

0 KI2

K K P = P1 0

0 K P2

We can use zeros , eye , diag to form the model matrices for Simulink and CST and then apply ss to get the model object for possible CST use. We may also create first ss objects of the individual controllers and get then the final CST model object with append. From that object e.g. get or ssdata may be used to pick the model matrices for Simulink use.

2.6 On State Transformations Linear state transformations are initially discussed in e.g. Burl 2.7 , FPW 4.3.3 and James 6.6 They are used to introduce sparsity or/and to give the model coefficients values which lead to more reliable computations for analysis and design. Sparsity may be exploited to make certain computations more efficient or/and to get a model structure based on which analysis and inventing a controller structure becomes easier. One may e.g. replace the original state-space model with a new state space model where the matrix A is diagonal or almost triangular or has a structure familiar from controllable or observable canonical form. The linear transformation uses a non-singular matrix state vector through linear formulae,

T which relates the original state vector x and a new

x = T = T 1 x
This kind of choices will next be motivated by a simple example: 52

Example. Consider a system of two interconnected tanks illustrated by the figure below:

u1

u2

h1 h2

q
d1 d2

Here u1 , u 2 , q , d 1 , d 2 are volume flowrates and h1 , h2 are the levels of the tanks assuming that zero values of them mean empty tanks. Under certain conditions the levels have the LTI perturbation model

& = h 1 & = h 2

1 h1 + h2 + q1 a1 a1 a1

a2

h1 +

1 h2 + q 2 a2 a2

Can you explain the model? For a special case a 2 = a1 = a the model becomes

& = ( k ) h + k h + a 1 q h 1 1 2 1 & = k h + ( k ) h + a 1 q h 2 1 2 2
The matrices of the state vector ODE are

k = /a

(a) (b)

k A= k

k a 1 0 , B= 1 k 0 a

Now another state space model can be found e.g. for the interesting (?) new state variables

hsum = h1 + h2 , hdiff = h1 h2
The new model is

& = a 1 q + a 1 q + a 1 q h sum 1 1 2
& = ( 2 k ) h + a 1 q + ( a 1 ) q h diff diff 1 2
The matrices of the new state vector ODE are

(a*) (b*)

0 0 A= 0 2k

a 1 a 1 B = 1 a 1 a
53

Here the models (a*) , (b*) are decoupled to MISO models.This is associated with the diagonality of A . However, while the new model has a simpler state matrix A it has a more complicated input matrix B . Notice that we applied here a linear transformation representable in matrix form,

hsum = h1 + h2 hsum 1 1 h1 = h h hdiff = h1 h2 1 1 diff 2


Here the matrix above is

T 1 of the general transformation theory. T implies new state space matrices given below,

In general, a non-singular transformation matrix

Anew = T 1 A T , Bnew = T 1 B , Cnew = C T , Dnew = D

Anew are said to be similar to each other. They have the same eigenvalues. Note that explicit inversion of T may be avoided by appropriate slashing. Moreover, some procedures for forming T will give Anew as already prepared:
The matrices A and Diagonalization? In the example above the A matrix was diagonalized by a linear transformation. Diagonalization is sometimes wanted and is possible for most systems. A system can be diagonalized if and only if the old state matrix A has (can be found) independent eigenvectors (eig). This condition is satisfied e.g. always when all the eigenvalues of A are distinct (i.e. different from each other). It is also satisfied by many systems with some multiple eigenvalues. However, some important system/sub-systems are known not to have this property, e.g. the double integrator system. From SISO transfer function point of view the question is about the existence of the partial fraction expansion in terms of first order transfer functions (residue). When the eigenvectors of A are linearly independent a suitable T is the eigenvector matrix of A (where all the eigenvectors of A are used in different columns of T ), which makes Anew to contain the eigenvalues of A on the main diagonal in the order given by the order of the eigenvectors in T . This will be proved later in Appendix but the procedure will be tested for the tank example above in a PC exercise. Note that even a real-parameters model with even a single complex conjugate eigenvalue pair will here be transformed to a system with some non-real coefficients, which is sometimes regarded as inconvenient but which is not a major problem for Matlab .

Jordan form When the diagonalization discussed above is not possible one can in theory try to form the so called Jordan form of the system (jordan). While the theoretical existence of this form has been regarded as highly interesting for many theorems the form is extremely sensitive for minor changes in the elements of A . Learn about this topic by considering a second order system where the damping factor is around 1 . The Jordan form is suited most often only for studies where the elements of A are symbolic, integer or rational numbers to be processed with infinite precision (without roundings and truncations typical to finite precision computations).

Incomplete triangularization through unitary transformations When the diagonalization discussed above is not possible or not reliable enough or not wanted due to e.g. some non-real eigenvalues (which yield a state-space model with non-real parameters) one may exploit the Hessenberg (hess) or Schur (schur) decomposition of A . This means selecting a unitary transformation matrix

T which makes Anew at least almost triangular. Unitarity means that T 1 equals to the conjugate (conj) transpose (transpose) of T . For a real matrix A the matrix T may be selected to be a real matrix

with the nice orthogonality property

54

T 1 = T T
With this property we have

Anew = T T A T Bnew = T T B

Anew together with T . In the Hessenberg form Anew ( r, c ) is zero for r c + 2 while the elements Anew ( r, r + 1) of the first sub-diagonal may be nonzero. In the (real) Schur form Anew ( r, c ) is zero for r c + 2 but some sub-diagonal elements Anew ( r, r + 1) may also be equal to zero. Note that for a system with a small number of states the matrix Anew formed by hess and schur may contain almost or even precisely as many non-zero numbers as A .
However, both hess and schur are able to provide us with Sometimes

T is selected to have Anew in a companion form where a row or a column contains information

for calculation of eigenvalues of the matrix. This form appeared in our previous discussion of controllable and observable canonical forms and appears in DB 3.4 . Unfortunately, such transformations are not as reliable or as generally applicable as the unitary transformations discussed above. However, they are sometimes used to discuss controllability and observability.

Balanced realizations Good CAD software tools may use yet different state space presentations called balanced realizations , see Burl 11.4 , 2.7 , 2.4.2 , Appendix A3. Matlab provides us with balreal.

Other transformations Sometimes

T is chosen to be the orthogonal factor of the full QR decomposition (qr) of B or C T .

The orthogonal factors of the full singular value decomposition (svd ; Burl 2.4.2 , A3) of B may be used to combine a linear state transformation and a linear input transformation while the corresponding factors of

C T may be used to combine a linear state transformation and a linear output transformation.
Interesting ss tools are: ssbal , canon , ss2ss .

2.7 Repetition & Linearization & Partitioned Presentations In this section some previous results are first re-discussed for a general TITO system with two states. Then the models are presented in terms of partitioned (block) matrices . After that convenient Matlab strategies for getting the block matrices will be presented. Start first with a repetition without too many words: Non-Linear State-Space Model

&1 = f 1 ( x1 , x 2 , u1 , u 2 ) x & 2 = f 2 ( x1 , x 2 , u1 , u 2 ) x y1 = g1 ( x1 , x2 , u1 , u2 ) y 2 = g 2 ( x1 , x2 , u1 , u 2 )

(1a) (1b) (1c) (1d)

55

Steady State or Equilibrium (fix some variables, solve other variables1)


* * * 0 = f 1 ( x1 , x2 , u1* , u 2 ) * * * * 0 = f 2 ( x1 , x2 , u1 , u2 ) * * * * * y1 = g1 ( x1 , x2 , u1 , u2 ) * * * * * y2 = g 2 ( x1 , x2 , u1 , u2 ) *

(2a) (2b) (2c) (2d) referring to an equilibrium value of the variable in question.

with the superscript

Perturbation presentations of original variables vs. Deviations introduced as new variables


* u1 = u1 + u1 * u2 = u2 + u 2

u1 := u1 u1*
* u 2 := u 2 u 2 * x1 := x1 x1 * x 2 := x 2 x 2 * y1 := y1 y1 * y2 := y2 y2

(3a) (3b) (3c) (3d) (3e) (3f)

x1 = x1* + x1
* x2 = x2 + x2 * y1 = y1 + y1 * y2 = y2 + y2

An Approximate Linear Time-Invariant (LTI) State-Space (ss) Model

&1 = x &2 = x

f 1 f f f x1 + 1 x 2 + 1 u1 + 1 u 2 x1 x 2 u1 u 2 f 2 f f f x1 + 2 x 2 + 2 u1 + 2 u 2 x1 x 2 u1 u 2

(5a)

(5b)

y1 = y 2 =

g1 g g g x1 + 1 x2 + 1 u1 + 1 u2 x1 x2 u1 u2 g 2 g g g x1 + 2 x2 + 2 u1 + 2 u2 x1 x2 u1 u2

(5c)

(5d)

with the partial derivatives evaluated for equilibrium values of the inputs , states and outputs.

Remark. Sometimes adaptive or repeated linearization is applied, even on-line. Then the system is linearized around an operating point (OP) which is not an equilibrium point (EP). Then minor modifications appear in the models needed.

Often inputs for fixed states or outputs are needed , sometimes vice versa.

56

Standard LTI State Space Matrix Notation

f1 f1 f1 f1 u u u1 x x x1 &1 x 2 2 + 1 = 1 x f f f f & u x 2 2 2 2 2 2 123 123 1 22 3 u u x x dx / dt x u 1 2 1 2 4 4 1 4 244 3 1 4 244 3


A B

(6a)

g1 g1 g1 g1 u u u1 x1 y1 x1 x2 2 + = 1 x y g g g g u 2 2 2 2 2 2 123 123 1 22 3 u u x x y x u 1 2 1 2 4 4 1 4 244 3 1 4 244 3


C D

(6b)

Lets now make some new observations:

Model Matrices as Jacobians

f1 x A= 1 f 2 x1 f1 u B= 1 f 2 u1 g1 x C= 1 g 2 x1 g1 u D= 1 g 2 u1

f1 &1 x f1 x x2 & with respect to x = 1 = equilibrium Jacobian of f = = = x f 2 &2 x2 f2 x x2 f1 &1 u f1 x u2 & with respect to u = 1 = equilibrium Jacobian of f = = = x f 2 &2 u2 f2 x u2 g1 x1 g1 y1 x2 = equilibrium Jacobian of g = = = y with respect to x = g 2 x2 g 2 y2 x2 g1 u1 g1 y1 u2 = equilibrium Jacobian of g = = = y with respect to u = g 2 u2 g 2 y2 u2

Here equilibrium Jacobian refers to the value of the Jacobian matrix evaluated for equilibrium values of the inputs , states and outputs.

Augmented Form of the State Vector ODE It is sometimes convenient to store a) all the model parameters in a single array and b) all the RHS deviations in a single array, too.

57

A nice presentation due to the model (5) with this property is shown below:
P 6444 4 7 4444 8 f1 f1 f1 f1 x1 & x x2 u1 u2 x2 x = P d & = 1 = 1 x f f f f u & x 2 2 2 2 1 2 x1 x2 u1 u2 u 2 1 4 24 3 1 4 24 3 1 2 3 d A B

(8)

Here the computation of the derivative vector is reduced to a standard matrix-vector -multiplication. The matrix P nicely contains the matrices A and B stored beside each other in the order mentioned. It is common to express such partitioned result with the compact notation

P = [A B ]
The matrix P consisting of blocks is said to be a block matrix or partitioned matrix. Along this we may use the vector partitioning, e.g.

(9)

x1 x x d = 2 = u1 u u2
Augmented State ODE from a single Jacobian matrix The matrix P ,

(10)

f1 x P= 1 f 2 x1

f1 x2 f 2 x2

f1 u1 f 2 u1

f1 u2 = [A B ] f 2 u2

(11)

(with the partial derivatives evaluated in OP) must be the Jacobian Matrix of the model mapping ,

x1 x & f x model : d = 2 1 = 1 u1 x &2 f 2 u2

(12a)

x &= f model : d = x u
Example ST commands are given on next page. Notice that jacobian may also be used to pick the State-Space matrices from a set of linear first order ODEs . This means, for example, that B & with respect to u etc. Exploiting this observation automatizes bit expansion is the Jacobian of x with zero and unity coefficients and puts all the multipliers in appropriate positions!

(12b)

Output Equation. The reader is asked to present the linear algebraic output equation using partitioning with reference to a suitable Jacobian matrix. 58

% Symbolic Toolbox syms a ao g Th Tc syms qh qc h T % constants % variables

hder = (qh + qc - ao*sqrt(2*g*h))/a Tder = (qh*(Th - T) + qc*(Tc - T))/(a*h) % Create input and state vectors u = [qh;qc] x = [h;T] % Stack them into a Block vector d = [x;u] % Derivative vector xder = [hder;Tder] % Find partial derivatives P = jacobian(xder,d) % At this point subs or limit could be used to insert % desired equilibrium values nx = length(x) % number of states A = P(:,1:nx) % all rows, columns 1 to nx B = P(:,nx+1:end)

All parameters in a single array Lets go further with the partitioning. However, for convenience lets abandon the partial derivative notation and drop away the symbol, yet remembering that our model variables may in reality be deviation variables. Start from model equations

&1 = a11 x1 + a12 x 2 + b11 u1 + b12 u 2 x & 2 = a 21 x1 + a 22 x 2 + b21 u1 + b22 u 2 x y1 = c11 x1 + c12 x 2 + d 11 u1 + d 12 u 2 y 2 = c 21 x1 + c 22 x 2 + d 21 u1 + d 22 u 2
We have seen that the ODEs may be written in the form

& a a12 x1 b11 b12 u1 x & = 1 = 11 x + = A x + B u & 2 a 21 a 22 x x 2 b21 b22 u2 { 14 { 24 3 { 1 4 24 3


& x

as well as in the partitioned form,

x1 &1 a11 a12 b11 b21 x 2 x x &= = x = [A B ] = P d 1 2 3 & 2 a 21 a 22 b21 b22 u1 u x P { 144424443 d P u2 {
d

Lets now collect all the equations together and present the result also in a partitioned form which includes a product of a parameter matrix and a function vector , 59

&1 a11 x x & 2 = a 21 y1 c11 y 2 c 21

a12 a 22 c12 c 22

b11 b21 d 11 d 21

b12 x1 b22 x2 d12 u1 d 22 u 2

Introduce now dashed lines for partitioning ,

&1 a11 x x & 2 = a 21 y1 c11 y 2 c 21

a12 a 22 c12 c 22

b11 b21 d 11 d 21

b12 x1 b22 x2 d12 u1 d 22 u 2

It is convenient to observe, that according to some definitions of matrix computations the equation above may be presented using block vectors and a block matrix ,

& A B x x y = C D u
Can you propose a method to obtain the parameter matrix above as a Jacobian matrix of a mapping? We will often exploit similar observations. Often two tricks will be needed: First, a missing scalar v (not appearing in all the equations) may be presented (where it is missed) in the form 0 v , and a missing vector v may be presented as O v , where O is a zero matrix of a suitable dimension. Second, a visible scalar v without a multiplier may be written as 1 v , and a vector v without a matrix multiplier may be written as I v , where I is an identity matrix of a suitable dimension.

2.8 Basic Theory of State-Space Models Basic properties of State-Space models are discussed in e.g. Chapter 6 of James, Chapters 3 , 6.4 , 11 of Dorf-Bishop , Chapters 2-4 and Appendix of Burl as well as in Chapters 2 , 4 of FPW. In this point we are interested only in ... general response formula ... practical stability ... initial value response (natural response, free response) ... impulse response ... step response ... dc gain of a dynamic system described by a State-Space model. The other issues (transfer function matrices, frequency response , zeros, controllability, observability etc.) will be discussed elsewhere with links to a few related topics. Study the next topics from the books mentioned. Below there are some conclusions from and extensions to that. 2.8.1 The general state response of the ss model The state response x (t ) may be expressed as 60

x(t ) = (t ) x( ) + ( ) B u (t ) d 14 4 244 3 1 444 4 24444 3 natural response


forced response

(1)

where the state transition matrix

is the matrix exponential defined by the series expansion


(2)

( t ) = e At := I +

( At ) k k! k =1

The formula (1) is derived in e.g. James. Another derivation is based on a time-variant linear transformation of the state vector, see Burl A6 (and tune the transformation to make the state derivative expression of the ODE independent of the state!) . Key properties of the state transition matrix can be found from Exam Tables , too. See e.g. Burl 2.1 and DB 3.3 , 3.7 , too. For later needs define a new notation for the exponential matrix (expm)

expm( M ) = e M
2.8.2 Practical stability

(3)

It is typically desired, that the state response will finally become independent of the initial value x ( ) . This means that the natural response term ( t ) x ( ) should converge to zero when

t for

any initial value x ( ) . This will happen, if and only if the state transition matrix (t ) will converge to zero matrix. A necessary and sufficient condition for this is that all the eigenvalues of the matrix A have negative real parts , i.e. lie left to the imaginary axis (eig, pole , pzmap ; real). From this condition it also follows, that the forced response represented by a convolution integral is bounded for any bounded input function u . Then we will have Bounded State for Bounded Input. The stability of state also implies stability of the output: when the eigenvalue condition above is satisfied, the output finally becomes independent of x ( ) and is bounded for any bounded input function u . Due to the latter property the system is then said to be Bounded Input Bounded Output (BIBO) stable. Unfortunately, boundedness or convergence of the output does not guarantee similar success for the state. A proof of the statements may be based e.g. on the eigenvalue decomposition (eig) and the Jordan decomposition (jordan) of A . 2.8.3 Practical simulation of the initial value response The response for zero input function is called the free response, unforced response, natural response, autonomous response, initial value response etc. The last name is adopted here along the CST tool initial. The initial value response has the property

x(t ) = e A( t ) x( )
The state transition matrix can be computed in great many different ways. Documentation of expm reveals that expm applies clever scaling , Pade (!) approximation, and compensation of the original scaling . For a square matrix

(1)

M the Pade approximation is

61

q q k k k e ( 1) ck M ck M k =0 k =0 M

(2a)

ck =

q k +1 ck 1 , c0 = 1 k ( 2q k + 1)

(2b)

The Taylor expansions of both sides of (2a) are identical upto a certain power of the variable, which? The computational efficiency can be optimized separately for different values of the order q . The response is often wanted for evenly distributed time instants such that

t k + 1 t k = t
where

(3a)

k 1 is an integer (see diff). Then


(3b)

t k + 1 = t k + t
We now obtain

x(t k +1 ) = expm( A (t k +1 t k )) x(t k )


or equivalently,

(4a)

x(t k +1 ) = expm( A t ) x( t k )
or

(4b)

x(tk + t ) = expm( A t ) x(t k )


This means that only a single call of expm is needed, after which every new sample state vector is obtained by a simple multiplication of a vector from left by a square matrix! In Matlab the sequence of state vectors due to (4c) may be generated using for a loop or the tool ltitr. LTI state-space systems with zero input are sometimes used as function generators

(4c)

2.8.4 The impulse response See Burl 2.1 , DB 5.2 . Denote the scalar unit impulse function of Dirac with

. For the input


(1a)

u(t ) = u (t )
with constant column vector u and zero initial state

x (0) = 0
we obtain the state response

(1b)

x(t ) = e At B u , t 0
But this state impulse response has the property

(2)

62

x( t ) = e At x(0)
x (0 ) = B u

(3a) (3b)

So the impulse response x may be viewed as an initial value response. Therefore it can be computed using the approach of Section 2.8.3 . For evenly spaced time instants we could use e.g. expm and ltitr. However, CST offers the convenient tool impulse . Note that in many studies and runs an element of u has unity value while the other elements are set to zero values. Many input functions are formed as impulse responses of artificial (virtual) function generator systems.

Simulink The unit impulse function can be viewed as the derivative of the unit step function. So the response for the impulsive function u with a constant column vector u is the derivative of a step function with the amplitude vector u . However, this observation should not be directly applied in Simulink to generate an impulse function (why?). It is better to exploit a fact implied by the relationship above: the response to u is the derivative of the response to a step function with amplitude u . This idea is sound for State-Space models in Matlab if the feedforward gain D of the State-Space model is zero, i.e. for the model

& = A x + B u x
y =Cx

(4a) (4b)

& once a step change with amplitude u is applied in Now the impulse response desired is obtained as y the input function u and the initial state is zero. We could exploit the elementary block diagram below:

C
u
+

& y

B
+

& x

A
x

Ax

& which is the response of (4) to Using here a constant u as u and selecting x (0) = 0 gives y & zero Concerning CST simulation notice that y & =Cx & = C ( A x + B u) y & for zero So the output derivative y

u .

D is given by

D has the state-space model


(5a) (5b)

& = A x + B u x
& = (CA) x + (CB ) u y
The step response of this with input amplitude u and zero initial state is the impulse response! Again, in a typical simulation an element of u has unity value while the other elements are zero.

63

2.8.5 Step Response See Burl 2.2 , FPW 4 . By the step response we mean the response for the input function

u (t ) = u , t > 0
The state response may be written in e.g. the following forms:

(1)

x(t ) = e At x(0) + x(t ) = e At x(0) +

t 0 t 0

e A B d u e A d B u

(2a)

(2b)

So the response is of the form

x ( t ) = F ( t ) x (0) + H ( t ) u

(2c) (2d)

F (t ) = e At

H (t ) =

t 0

e A B d =

t 0

e A d B

(2e)

The matrix F is the familiar state transition matrix but now renamed for Matlab convenience. The matrix H is called the state step response matrix. The matrices F , H are very important for digital control if Zero-Order Hold is used, see DB 13 and FPW 3-4. They may be solved in various ways. For a common special case the Matlab solution may be very easy:

Step Response Parameters for a Non-Singular A If the matrix A is non-singular (if the number zero is not an eigenvalue of A ) , the response may be expressed as

x(t ) = e At x(0) + (e At I ) A 1 B u
Every stable system satisfies the non-singularity condition. This result is due to the matrix ODE

(3)

d At e = e At A dt
which can be integrated from zero time to time

(4)

t to get
(5)

e At e A0 =

t 0

e At dt A

from which the integral of the matrix exponential can be solved trivially. One could also postmultiply the two equations above by B . On the other hand, integration of another matrix ODE ,

d At e = A e At dt
yields

(6)

e At e A0 =

t 0

e At dt A

(7)

64

from which we can solve a new presentation for the integral. It implies the step response

x(t ) = e At x(0) + A1 ( e At I ) B u
Notice that actual explicit inversion of A is not needed but the matrix multiplying u may be solved from a linear equation in a better way, e.g. with slash. Step Response Parameters for a Singular A When A is singular , we must use a more complicated approach. One can compute the matrices by solving first order differential equations with e.g. ode45. A matrix presentation of the ODEs and the initial values needed is

(8)

& (t ) = F (t ) A F & (t ) = F (t ) B H

, ,

F ( 0) = I H ( 0) = O

(9) (10)

where I is the identity matrix (eye) of an appropriate dimension while O is the zero matrix (zeros) of an appropriate dimension. Another set of two matrix ODEs is obtained by transposing the equations above. The transpose equations may also be splitted into a set of vector ODEs by reading them column by column. However, c2d uses a simple general Matlab strategy which uses expm for a partitioned matrix:

Theorem (c2d)

A B F ( t ) H ( t ) expm O O t = * ** 2 1
O1 ... zero matrix with dim u rows and dim x columns O2 ... zero matrix with dim u rows and dim u columns

Derivation of the result may be based on e.g. the following steps: The two matrix ODEs may be collected to a block form,

d & [4 F H] = F 24 3 dt 1 X

& = [F A F B ] = [F A + H O F B + H O ] H 1 2

A B = [F H ] 1 4 24 3 O1 O2 X 14 24 3
V

Now we have a single matrix ODE and its initial condition ,

& = X V X
X (0) = [F (0)
The matrix

H (0) ] = [I

O]

X is obviously
65

X ( t ) = X (0) expm (V t )
Assume now a partitioning of the matrix expm (V t ) along that of V ,

T T2 expm(V t ) = 1 T3 T4
Now we have

[F

H ] = X = [I

T T O ] 1 2 = [I T1 + O T3 T3 T4

I T2 + O T4 ] = [T1 T2 ]
F and H beside each other, F as the

In another way, the top block row of expm (V t ) includes left matrix and H as the right matrix.

Another derivation combines the state ODE and the input ODE

& ( t ) = u (t ) , u (0) = 0 u
to a partitioned form

& A B x 0 x u = O O u + u & 1 4 24 3
V

and solves the unit impulse response in a usual way to

x(t ) Vt x(0) Vt 0 u(t ) = e u(0) + e u


Here we get for u (0) = 0 using the partitioning of e
Vt

above the result

x(t ) T1 T2 x(0) T1 T2 0 T1 x(0) + T2 u u(t ) = T T 0 + T T u = T x(0) + T u 4 3 4 3 4 3


which implies the result wanted,

x ( t ) = T1 x (0 ) + T2 u
The tool c2d can still be used with the old command structure [F,H] = c2d(A,B,t) Again for evenly spaced time instants (by e.g. linspace) a single call of c2d is sufficient since e.g. ltitr can then be used for necessary time steps of equal length. CST provides us with the tool step which is able to plot output step responses assuming zero initial state x(0) . In many runs an element of u has unity value while the other elements are zero. So an output curve of an automatic plot shows the behaviour of the output in question in a situation where a single input is subject to a unit step change while the other outputs are kept equal to zero. The variable name of non-zero input is written above the curve. The tool step can also return responses into output and state arrays. Be carefull in picking the arrays returned to correct arrays pay attention to the position of the time array in the call! Problems. 1) Develope a F&H procedure based on diagonalization.

66

2) Develope more efficient F&H procedures for a case with size(B,2) > size(B,1) . Discuss separately the cases with a non-singular vs. singular A as well as the solution of Problem 1. 3) If A is singular one can perhaps exploit series or parallel connection presentations where the singularity is isolated to a sub-system. How could F&H be computed based on this?

2.8.6 On the equilibrium of a LTI state space model vs. bias of Step Response (dcgain) Consider the state space model

& = A x + B u x
y = C x + D u
There may exist an equilibrium where the input u has a constant value u the state x has a constant value x For a constant state x the state derivative

(1a) (1b)

& is equal to zero. Then in the equilibrium we must have x


(2)

0 = A x + B u
If u is known, then the steady state value of x may be solved from the linear equation

A x = B u
without matrix inversion , using e.g. Gaussian elimination . In Matlab we may use the slash operation (\ , slash): x = A\(-B*u) The formal solution of Eq. (3) is, if A is non-singular,

(3)

x = A 1 B u
So the state is proportional to the input,

(4)

x = Kx u
K x = A 1 B
The proportionality matrix

(5) (6)

K x is called the input-to-state dcgain or the state dcgain.

The state dcgain can be solved without matrix inversion from the equation

A K x = B
In Matlab we can do that with the command Kx = A\(-B) If the input and the state are constants mentioned above, then the ouput y has a steady state value

(7)

67

y = C x + D u = C ( A 1 Bu ) + Du = ( D CA 1 B) u
Hence the output is here proportional to the input,

(8)

y = K y u

(9a) (9b)

K y = D CA 1 B
Here the proportionality matrix K y is called the input-to-output dcgain or the output dcgain or the system dcgain, or briefly the dcgain. In Matlab this may be implemented as Ky = D C*(A\B) Note that the output dcgain is a first order function of the state dcgain:

Ky = C Kx + D
Therefore both dcgains are available through the commands Kx = A\(-B) Ky = C*Kx + D A CST user may calculate the output dcgain with the commands: help dcgain sys = ss(A,B,C,D) Ky = dcgain(sys) The state dcgain matrix

(10)

K x is the output dcgain matrix of the model


(11a) (11b)

& = A x + B u x
"Out "

x = { I x+ O { { u
identity matrix zero matrix

Therefore we may get it also through the commands nx = size(A,1) % number of states = number of rows in A I = eye(nx) O = zeros(nx) xsys = ss(A,B,I,O) Kx = dcgain(xsys)

Applications of the dcgain Consider systems, for which the number zero is not an eigenvalue. Assume a constant input u (t ) u for

t > 0 . Then the response is


(12a)

x(t ) = e At x(0) + (e At I ) A 1 B u
This may also be written as

x(t ) = e At ( x(0) + A1B u ) + ( A1B u )


This may be written in terms of the state dc gain,

(12b)

68

x ( t ) = e At x (0) + A1B u + K x u
Here

(12c)

K x u is called the dc component of the response. In a corresponding way, the dc component of the output is K y u .
For a stable system the responses will have a finite final value, since e
At

0 for t :
(13)

stability lim x(t ) A1B u = K x u


t

So the step response of a stable system will converge to its dc component, which is obtained by multiplying the input amplitude from left with the dc gain. In the same way we have

lim y(t ) = K y u
t

(14)

The state and output may converge to finite constant values even when the input functions are not constant functions, if the inputs will converge to finite final values. If this happens, the final values are related through

lim x(t ) = K x lim u (t )


t t

(15a) (15b)

lim y(t ) = K y lim u (t )


t t

Remark. The output of some systems may converge to a constant value even when the state will not converge at all. State and input convergence imply output convergence, but output convergence does not always require convergence of input and state! Remark. The step response formula can also be obtained as follows, if the matrix A is nonsingular: (1) Find a constant solution x of the ODE using the theory above. This constant will be a dc term of the response (for a stable system it is also the final value of the response). Substitute in the ODE x (t ) = x + ~ x (t ) and simplify the ODE to an ODE of Solve

(2) (3) (4)

~ x .

~ x from the resulting ODE ... as a natural response term.

Form the complete solution x (t ) = x + ~ x (t ) .

Perform Steps (1) to (4) :

Problem. Create a step response tool based on expm , ltitr , slash and other basic tools of the pure Matlab.

69

2.9 Series Connection of Matrix Gain Model and Another ss Model Series connections of two subsystems of which at least one is a Matrix Gain system appeared in the initial discussion of decoupling control since we used a LTI Matrix Gain precompensator. There are a few interesting modelling tasks where we should combine such a Matrix Gain model with some other standard model to get a model of a series connection. We sometimes want/should to calculate e.g. 1) the actual dc gain of the series connection of the LTI Matrix Gain precompensator and the LTI process model (of some OP not necessary the design OP) from the Matrix Gain mentioned and process dc gain, or the Matrix Gain of the series connection of SISOP controllers in append configuration and a LTI Matrix Gain precompensator 2) a state space model of the series connection of the Matrix Gain precompensator and the LTI process model to enable e.g. design of the SISO controllers,

3) a state space model of the MIMO controller consisting of the series connection of e.g. SISOPI controllers and the LTI Matrix Gain precompensator, e.g. for implementation of the controller.

The three modelling examples introduced for series connections will be solved below in general terms. More general series connections will be discussed later to enable increasing use of CST. Before that use series without fully understanding its procedure. Note that in Problem 3 appending two SISO P/PI controller models was discussed in Sections 2.1 , 2.5 while for a larger number of SISO P/PI controllers or phase lead/lag controllers the generalization of the idea presented is trivial, yielding appropriate diagonal state-space matrices. When at least a SISO controller is of higher order the modification is slightly more difficult, yet available by a modest effort, and producing block diagonal matrices. For such modifications compact matrix methods will be given in Chapter 4. Before that use append without completely understanding its procedure.

2.9.1 Series Connection of Two Matrix Gains Consider the series connection of two Matrix Gains:

K1

K2

This could describe a MIMO controller consisting of two layers or the equilibrium model of the series connection of the precompensator and the process. Here a presentation of the overall model is

u = K1 w y = K2 u
However, for some reason a model is wanted to just explain the effect of the external input w to the final output y without reference to internal variables. Such a model is found by elimination of the internal connection variable u from the model (1) by

(1a) (1b)

y = K 2 u = K 2 ( K1 w ) = ( K 2 K1 ) w

(2) 70

So we get a Matrix Gain model,

y = K w
with the Matrix Gain

(3a)

K = K 2 K1
The result may be expressed in a block diagram form :

(3b)

K1

K2

K 2 K1

It is important to notice that the order of the two matrices in the product K 2 K1 can not in general be changed. In fact, this fact is true even for a product of two quite sparse matrices, which is demonstrated below with a simple example:
1 1 2 0 1 2 + 1 0 1 0 + 1 3 2 + 0 0 + 3 2 3 0 1 0 3 = 0 2 + 1 0 0 0 + 1 3 = 0 + 0 0 + 3 = 0 3 2 0 1 1 2 1 + 0 0 2 1 + 0 1 2 + 0 2 + 0 2 2 2 3 0 3 0 1 = 0 1 + 3 0 0 1 + 3 1 = 0 + 0 0 + 3 = 0 3 0 3

The reader is encouraged to check the validity of (3ab) for the series connection of two appended P controllers and a Matrix Gain precompensator with two outputs: Find K in two ways, first performing initial modelling and eliminations without using matrices, then by matrix multiplication of (3b). A ST implementation of the check is given below while further study is left to Chapter 3: syms w1 w2 syms Kp1 Kp2 k11 k12 k21 k22 u1 = Kp1*w1 u2 = Kp2*w2 y1 = k11*u1 + k12*u2 y2 = k21*u1 + k22*u2 w = [w1;w2] y = [y1;y2] K = jacobian(y,w) K1 = [Kp1,0 0,Kp2] K2 = [k11,k12 k21,k22] K_ = K2*K1 % K! 71

2.9.2 Series Connection of a Matrix Gain and a Dynamic State Space System Consider the series connection below:

x' = Ax + Bu y = Cx + Du

This could describe precompensation of a process. The step or frequency etc. response of the series connection could then be a basis for design of SISO controllers. On the other hand, this could describe e.g. simple input scaling (with a K being a diagonal matrix due to an append operation for individual scaling factors) or even a more complicated linear transformation of input to create a desired structure for the model. The visible overall model consists of the left system model

u = K w
and the right system model

(1)

& = A x + B u x
y = C x + D u
A single model in a standard form is desired to explain the effect of the external input w to the state and the output of the latter system. Such a model is available by elimination of the interconnection variable u which transforms the model (2) to the form

(2a) (2b)

& = A x + B Kw x
y = C x + D Kw
But this may be presented in a state-space form,

& = A x + (B K ) w x

(3a) (3b)

y = C x + (D K ) w
where we have A , C directly from the model (2) while the two input matrices of the model (2) have been post-multiplied by the Matrix Gain of the pre-system. Notice that u was eliminated since it is neither a part of the state nor an external input. Pay again attention to the position of the pre-system gain K in the matrix products BK and DK ! 2.9.2 Series Connection of a Dynamic State Space System and a Matrix Gain Consider the series connection below:

x' = Ax + Bu y = Cx + Du

This could describe a MIMO controller consisting of two layers of which the left one could represent a collection of SISO controller operating jointly. On the other hand, this could describe e.g. simple output scaling (with a K being a diagonal matrix due to an append operation for individual scaling factors) or 72

even a more complicated linear transformation of ouput to create a desired structure for the model. Nevertheless, the overall model consists of the front (pre, former) model

& = A x + B u x
y = C x + D u
and the back (post, latter) model

(1a) (1b)

w=Ky
A single model in a standard form is desired to explain the effect of the external input w to the state of the former system and the output of the latter system. Such a model is available by elimination of the connection variable y which transforms the model (2) to the form

(2)

w = K (C x + D u )
A state-space model of the series connection is now available by presenting this in a suitable form and joining it with (1a). The model is

& = A x + B u x
w = (K C ) x + (K D) u
where we have A , B directly from the model (1a) while the two output matrices of the model (1b) have been pre-multiplied by the Matrix Gain of the post-system. Pay attention to the position of the post-system gain K in the matrix products KC and KD !

(3a) (3b)

Example. Consider a familiar controller structure:

KPa Gain5 Gain1 K Ia ea Gain6 1 s In te g ra to ra va Sum a dua k1 1 Gain2 k1 2 KPb Gain7 dub Sum b k2 1 Gain3 K Ib eb Gain8 1 vb s In te g ra to rb k2 2 Gain4 Sum 2 dqc dqh

Sum 1

Find first a state space model through scalar operations of scalar equations and present the results then with matrix notation. Then check the results with matrix operations relying on Chapter 2 theory, a ST description of which is given below: syms Kpa Kia syms Kpb Kib Kp = diag([Kpa,Kpb]) 73

Ki = diag([Kia,Kib]) A = zeros(2) B = Ki C = eye(2) D = Kp syms k11 k12 k21 k22 K = [k11,k12 k21,k22] A B C = K*C D = K*D Further results are shown in Chapter 3.

2.10 Getting rid of the Derivative Block Some publications show block diagrams including the derivative block. Using a block called a derivative block often introduces substantial inaccuracies to the result. Note that two competing software for simulation or controller implementation in commercial PLC and DCS systems may implement the algorithm for the derivative in very different ways. To avoid unexpected results it may be wise not to use derivative blocks. The topic was discussed to some extent already in ACI-20010/6 and in a sence above in Sections 2.2 , 2.8.4 . Here the series connection of a derivative block and a dynamic LTI State-Space block will be studied assuming zero feedforward matrix D which is required to obtain practical results for Matlab. In Section 2.8.4 we derived the following useful equivalence for avoiding explicit differentiation:

x' = A x + B u y =Cx

d dt

x' = A x + B u f = CA x + CB u

Consider next the following series connection:

d dt

& w

x' = A x + B u y =Cx

Again, lets try to avoid explicit differentiation. The state of the right system has now an IO Vector ODE

74

& = A x + B w & x
Following the time domain reasoning of Section 2.2 but now for vector integration , vector addition and Matrix Gains we may present this in the form

(1)

& I = A xI + A B w x

(2a) (2b)

x = xI + B w
Now the final output

y is given by

y = C x = C ( xI + B w)
A standard state space model of the series connection consists now of (2a) and the latest equation in a suitable form: the series connection of a derivative operation and a LTI state space model ss(A,B,C,0) has e.g. the state model

& I = A xI + A B w x
y = C x I + (C B ) w
Note that the two series connections have (in theory, not in Matlab !) the same IO response if both systems have zero initial states. So the two models derived, ss(A,B,C*A,C*B) and ss(A,A*B,C,C*B) have the same forced response defined in Section 2.8.1 .

(1) (3)

75

3.

DECOUPLING CONTROL

3.0 Introduction In Chapter 1 we studied decoupling control of the tank with two inflows. The block diagram of the closed loop system is in Figure 1 :

m1

sensor1

r1 r2

- e1
e2

con1

w1 w2

u1

y1

pre compensator

con 2

u2

MIMO process

y2

m2
sensor 2

Figure 1. Multivariable control of a process with two inputs and two outputs. An ideal pre-compensator would decouple the MIMO closed-loop system into two SISO closed-loop systems as illustrated in Figure 2 where process1 and process2 denote virtual SISO processes:

m1 r1
+

sensor1

- e1

controller1

w1

process1

y1

r2

e2 controller 2

w2

process 2

y2

m2
sensor 2

Figure 2. Ideal decoupling for a system described in Figure 1. In case of ideal decoupling the remaining design task would in ideal conditions be the design of the two SISO controllers separately from each other, whenever we are not requested to worry about the behaviour of the actuators which also depends on the precompensator. In many practical cases linear static precompensators are used. Then almost complete decoupling is obtained only around the OP (operating point) of the design. We then use the term nominal decoupling. However, far away from the design OP we are not always satisfied with the performance due to the initial design which assumed zero interactions. In fact, practical closed-loop responses may be very bad, even unstable. This challenges many serious control designers to study Robust Control Theory. Before that adjustment of SISO controller tunings may be needed to obtain acceptable responses. For a P control of a stable or marginally stable process this may mean reduction of the proportional gain, which also may be needed for a PI controller 76

parameterized in terms of an integration time and proportional gain. For this purpose one may e.g. introduce additional gains in front of the nominal SISO controllers to allow fine-tuning. This is illustrated in the block diagram below where the new blocks with the gains 1 , 2 may be used for fine-tuning as well as for simple analysis of degree of stability:

sen1
_ +

1
+

con1 con 2

2
_

pre compensator

MIMO process

sen 2
Figure 3. A closed-loop system with extra gains 1 , 2 for fine-tuning and stability analysis. Next we will study the design of linear MIMO controllers for nominal decoupling of so called square systems assuming a LTI State Space process model. Square means here that the number of the inputs equals to that of the outputs and is denoted by m (a positive integer). The ideas below may be easily extended even for processes with output delays. Matrix notation will be used, and SISO systems of the same nature (controllers , sensors) working jointly parallel each other are presented as virtual MIMO systems formed by an append type operations. Use the notation and the block diagram below:

y = [ y1 L ym ] u = [u1 L um ] r = [r 1 L rm ] z = [z1 L zm ] e = [e1 L em ]

(process outputs) (control inputs) (set points) (measurements) (actuatinc errors)

(1a) (1b) (1c) (1d) (1e) (1f)

w = [w1 L wm ]

(SISO controller outputs , precompensator inputs)

virtual MIMO system

e
_

SISO controllers

MIMO pre compensator

MIMO process

virtual MIMO system

sensors

Figure 4. A closed-loop system presented using vector functions and true and virtual MIMO blocks and vectors. 77

Figure 3 can also be generalized in a similar way. In Figure 5 below the extra SISO blocks of Figure 3 are also represented by an extra virtual MIMO system :
virtual MIMO systems

+ _

SISO

controllers

MIMO pre compensato r

MIMO process

virtual MIMO system

sensors

Figure 5. A MIMO presentation of a closed-loop system presented using vector functions and true and virtual MIMO blocks and vectors. The block represents an adjustment layer for fine-tuning and stability analysis. For fine tuning gains it is a Diagonal Matrix Gain obtained by appending the individual gains . Consider again Figure 4. Assume a LTI static precompensator represented by a Matrix Gain K . Below models of two typical MIMO control laws are presented. If all the SISO controller are P controllers with models given by

wi (t ) = pi ei (t ) + wi ; i = 1 , ... , m
where each

(2a)

wi is a suitable constant, then the joint (append) model of the SISO controllers is
(2b)

w(t ) = diag ( [ p1 ... pm ] ) e(t ) + w


Then the precompensator output is

u(t ) = K w(t ) = K diag ( [ p1 ... pm ] ) e(t ) + K w


i.e. of the form

(3a)

u(t ) = K P e(t ) + u

(3b) (3c)

K P = K diag ( [ p1 ... pm ] )
Pay enough attention to the order of the two matrices in Equation (3c). Equation (3b) with m = 1 represents SISO P control. Because Equation (3b) for m > 1 generalizes the rationale of P control to MIMO case we will say in the sequel that a MIMO control law of the form (3b) is a MIMOP control law and speak about MIMOP controllers. The Matrix Gain of equation is called the MIMOP gain. Remark. In Matlab and in Matrix Gain block of Simulink Equation (2a) may be presented using a special element-by-element multiplication, i.e. in the form

w = p . * e + wline
where

(4)

p is a vector containing the parameters p1 ... pm .

If all the SISO controllers are PI controllers with models given by e.g.

78

wi = pi ei + ki vi
vi = ei

(5a) (5b) (5c)

&i = ei v
then the joint (append) model of the SISO controllers is

w = diag ( [ p1 ... pm ] ) e + diag ( [k1 ... k m ] ) v


v = e
&=e v
The corresponding state space model combines (5f) and (5d) so that (5f) is presented as

(5d) (5e) (5f)

& = Ov + I e v
Then the precompensator output is

(6)

u(t ) = K diag ( [ p1 ... pm ] ) e + K diag ( [k1 ... k m ] ) v


i.e. of the form

(7a)

u(t ) = K I v + K P e

(7b) (7c) (7d)

K I = K diag ( [k1 ... k m ] ) K P = K diag ( [ p1 ... pm ] )


Guess what: e.g. control laws of the form (7b) , (5ef) are called MIMOPI control laws. The Matrix Gains K I , K P are called MIMOI and MIMOP gains, respectively. A state space model of the MIMO controller consists of (6) and (7b). Again, pay attention to the order of the two matrices in both (7c) and (7d).

Remark. Another forms of MIMOPI control laws and selection of the initial conditions will be discussed later. Or do you want to work out those results yourself already now?

3.1 Decoupling Matrix Gain for Square MISO Processes Below we assume a linear square process model of the MISO form

& k = ak yk + bk 1 u1 + ... + bkm um ; k = 1 , ... , m y


The LTI model of the Tank with Two Inflows has this structure for m = 2 . The model above can be presented in the matrix form

(1)

& = A y + B u y

(2a)
T

y = [ y1 L ym ] u = [u1 L um ]

(2b) (2c)

79

A = diag ( [a1 L am ] )
b11 K b1m B= M M bm1 L bmm
Notice that the model structure above may be obtained from a more general state space model of a square process if the matrix A is diagonal and the matrix C is non-singular, by just letting the output to be the new state and performing the linear transformation for this choice. Next we will study the MIMO control approach presented for m = 2 in Figure 1 of Section 3.0 assuming diagonality of A . Derivation of the decoupler is based on the presentation

(2d)

(2e)

& k = ak y k + f k y

; k = 1 , ... , m

(3a) (3b)

f k = bk 1 u1 + ... + bkm um ; k = 1 , ... , m


where the auxiliary variables

f1 , ... , f m are defined as trial inputs of the precompensator, which

are formed by SISO controllers. So (3b) is a trial to specify an inverse model of the precompensator. The equations (3a) are totally decoupled from each other which reduces the design problem into a set of SISO design problems if we are able to create a pre-compensator which creates the control input variables u1 , ... , um from the output variables f1 , ... , f m of SISO controllers. But this is often possible by solving the set of linear equations shown below by standard procedures like Gaussian elimination etc.:

bk 1 u1 + ... + bkm um = f k ; k = 1 , ... , m


Introduce now a column vector f due to (3b) . Eq. (3b) may be presented in the Matrix Gain form

(4)

f = Bu
The equations (4) may therefore be presented in the form

(5)

Bu = f
This equation has (for the square matrix B ) a unique solution if the matrix B is non-singular. Under this condition the equation could be solved using a full slash-type operation on-line. However, there are more efficient ways if the matrix B is not changed during practical control. The most obvious procedure is to compute

(6)

B 1 before start-up and exploit on-line the formula


(7)

u = B 1 f
This means that the precompensator is a LTI Matrix Gain system with the gain matrix

B 1 ,
(8) (9)

u=K f

K = B 1
Another procedure would be to use a procedure, a Matlab description of which is [L,R,P] = lu(B) LRu = P*w % Step 1 for P*B = L*U with L and U triangular % Step 2

80

Ru = L\LRu u = R\Ru

% Step 3 % Step 4

for solving L*Ru = LRu for solving R*u = Ru

Step 1 can be performed before start-up. Step 2 associated with pivoting is for simple and fast ordering of f variables, executed in many cases on-line but possible to be avoided if certain re-indexing is performed before start-up. Steps 3 and 4 are on-line steps where two triangular systems should be solved, which can be made as easy as multiplication f by B . Saving L and U requires the space needed otherwise for saving B. However, you will most likely not need this knowledge in the current context but perhaps elsewhere? Lets now derive the precompensator in a different way to learn more modelling and to get a formula for some analysis of accuracy for non-nominal studies. Let the vector of actuating errors be e . The block diagram below assuming explicitly a matrix gain for the precompensator can be used :
1

MIMO-controller

process

SISO controllers

& k = ak y k + f k y

k = 1 , ... , m

Figure 6. The feedforward path of a feedback control system

Here the precompensator

is selected initially to cancel the Matrix Gain

B to yield f = w , i.e.

f = I w , which is a special Matrix Gain formula with the Matrix Gain equal to the identity matrix (eye) of dimension m . On the other hand, we get by elimination of the connection function u the result f = B u = B ( K w) = ( BK ) w
Note the order of the two matrices in the matrix product ( BK ) representing a series connection of two Matrix Gains: it is opposite to the signal flow direction! So we have an adjustable Matrix Gain ( BK ) , the desired value of which is of dimension m . We must therefore solve the matrix equation (10)

I , the identity matrix


(11)

BK = I
For a known non-singular matrix

B this has a unique solution given in (9) .

The next step is to design the SISO controllers. The k th controller forms

wk = f k from ek . Its yk

structure and tuning are selected based on the process model (3a) , the model of the sensor measuring as well as some design specifications for You have learned many ideas in your basic course?

yk . Different loops may have different SISO controller structures.

Ideas and principles for creating a State-Space model of the MIMO controller for e.g. Simulink use were given in Chapter 2. In addition, the second derivation of the precompensator above included a formula for the series connection of two Matrix Gains which may be used if we select the SISO controllers to be proportional controllers: the two CST commands below should produce the same result. Further discussion of this topic is postponed to Chapter 4 where systematic matrix-based methods of State-Space modelling will be discussed with illustrating examples. However, lets mention already here that the joint use of CST tools ss , append , parallel , series for appropriate Matrix Gain and State-Space models would conveniently provide us with a State-Space model of the overall controller. People using the positive feedback implementation of the SISO PI controller shown in LAB instructions of ACI-20010 or ACI-20016 could use feedback with special care.

81

3.2 Nominal Steady State Decoupling for Square LTI Process There are many LTI State-Space processes for which the combination of SISO controllers and a linear static precompensator can not even yield complete nominal decoupling. The same may be true for many other LTI processes which may include some delay phenomena, too. This means that even around the design OP a process output may react in an undesired way to non-zero changes in the set point(s) of another output(s). However, good enough a precompensator fed by good enough possibly integrating SISO (feedback) controllers may remove the problem in steady state due to converging set points (and disturbances). If we are not going to use many enough integrating SISO feedback controllers or feedback control at all (open loop control is allowed only for a stable process!) we can still search for nominal steady state decoupling in steady state using a certain LTI Matrix Gain as the precompensator while complete transient decoupling is not reached. In fact, the same matrix may perhaps be used even as combined with integrating SISO (feedback) controllers to improve the degree of transient decoupling. Steady state decoupling of open or closed loop control system means, that in possible equilibriums (due to appropriate stability and converging external inputs) each process outputs is independent of the set points of other process outputs. Lets first study this for open loop control assuming a stable LTI ss process without disturbances. Open loop control A rough block diagram of open loop control is given below, where the column vector (of y , column vector of the set points of individual process outputs):

r is the set point vector

open loop controller

stable LTI process

Figure 7. Multivariable open loop control of a stable LTI MIMO process.

Call the steady state values of the control input (the process input) and the process output with respectively. The equilibrium model of the process claims that

u and y ,

y = Ky u
where K y is the dc gain of the process (dcgain). For the model ss(A,B,C,D) it was shown to be

(1)

K y = D CA1B
However, note that in most process models the matrix D is zero matrix, which simplifies the result,

(2)

D = O K y = CA1B
1

(3)

Nevertheless, the existence of the matrix A follows from stability assumed: lack of the inverse can occur if and only if the process has at least an eigenvalue at the origin which is excluded by stability assumed. The steady state model (1) may in many cases be used to solve the steady state control input u from the steady state process output y which is desired to be equal to the set point vector r . The solution relies on the solution of f of Section 3.1 from equation (5) there. So we may e.g. write the solution in the form
1 u = Ky y

(4)

This finally means that the inverse of the process dc gain is used as LTI Matrix Gain precompensator. For open loop control the input of the precompensator is simply the set point vector r :

82

1 Ky

stable LTI process with dc gain K y

Figure 8. Multivariable open loop control using a LTI Matrix Gain compensator

Example. Example unit step responses (responses to unit changes of the set points) are shown below in Figure 9 for a stable LTI process assuming the dc gain K y is estimated precisely and the precompensator gain is computed and implemented accurately: The responses below the header r1 are obtained for zero initial values and set point values r1 = 1 , r2 = 0 . There y1 will most obviously converge to its set point r1 (in upper-left subplot) when t while y 2 initially deviates from its set point r2 (in lower-left subplot for an interaction) but will most obviously return to the set point when t . The responses below the header below the header r2 assume zero initial values and set point values r1 = 0 ,

r2 = 1 . There y2 will most obviously converge to its set point r2 (in lower-right subplot) when t while y1 initially deviates from its set point r1 but will most obviously return to the set point (in upper-right subplot) when t .

Figure 9. Example results due to open loop control. The set point mentioned above the two output responses has unity value while the other set point and initial conditions are zeros. So the transients are not decoupled (and the interaction responses can differ too much from the zero set points) but nominal steady state decoupling is obtained. However, it should be noted that even typical modest roundings of precompensator parameters lead to loss of steady state decoupling! Therefore lets now turn to feedback control:

Feedback Control We have learned many reasons to prefer feedback control to open loop control in many cases. Next a trial MIMO feedback controller is searched. Use below Figure 1 of Section 3.0 to keep yourself in the map while the discussion is not limited to TITO systems.

83

A trial MIMO control law is obtained by selecting the precompensator as above in this section, i.e. to be a Matrix Gain given by the inverse of the process dc gain. However, select the pre-compensator input now to be a column vector w collected from the outputs of SISO controllers so that wi is selected based on the

y i and the set point ri of y i . The design of the SISO controllers may be based on parametric models or experimental responses which explain the effect of w and y as well as
measured value of the process output similar descriptions of the sensors. Elementary knowledge for creating such parametric models has been discussed before while more systematic and compact methods will be studied in Chapter 4. Note that some experimental models from w to y can be derived from e.g. the step responses shown above for open loop control using e.g. techniques discussed in Chapter 1. Interactions between w and y may initially be ignored so that the design of the k th SISO controller for creating and the appropriate sensor for estimation of

wk is first based on the relationship wk and yk

yk .

3.3 Complete Nominal Decoupling For Square Stable Processes with Non-singular B Consider a stable process described by the nominal model

& = A y + B u y
where

(1a)

rank ( B ) = dim y = dim u = m


When A is not a diagonal matrix a MIMO controller consisting of SISO controllers and a static precompensator is not able to decouple the system. However, it will be shown below that for stable processes with a non-singular matrix B we can find a simple integrating controller which decouples the system and yields a nominally stable closed-loop system. The derivation is based on the definition of the system inverse to be defined next in a wider sense than so far:

(1b)

Inverse System A model of the system describes, how the output function of the system depends on the input function of the system. Another model for calculation of the input function from output function is called the inverse of the (original) model :

model

inverse model
u

inverse model

We used the idea within our discussion of the static non-linear pre-compensator (for the tank with two inflows) as well as in previous sections for a LTI Matrix Gain pre-compensator. Now the idea will be extended for dynamic systems, for which the tool inv (help lti/inv) is useful in later studies. The famous scalar integrator (integrator block) can be viewed as an inverse of the not-so-famous differentiator (derivative block). Note that the differentiator is improper , an abstraction which has some theoretical properties without exact practical counterparts. Note also that application of inverse systems may hide instabilities, i.e. to lead to lack of internal stability as was demonstrated already in ACI-20010/6. Nevertheless, command: der = tf('s') 84

help lti/inv inte = inv(der) By this definition of inverse system we may have (if the inputs belong to a suitable domain of the operation):

w y

inverse model

model

w y
I

In control applications the model is a description of the process or an important part of it. The inverse model is a description of a part of an open loop compensator or a feedback controller: the input w will be formed either from the set points alone (in open loop control ) or from both the set points and the measured process outputs, often from actuating errors (in closed loop control). The inverse model for the current process model is

& A y) u = B 1 ( y
Replace y with w to obtain a theoretical initial precompensator with input vector w . An unrealizable block diagram description of (2) is

(2)

d dt

& w
+

( )

A w

B 1

Recall that the block d / dt can not be implemented precisely in real life. Therefore the block diagram above can not be used alone. However, it can be used as a virtual part of the final controller, for which we may find practical implementations. In fact, we can use the (from accuracy point of view) desirable integrator to solve the implementation problem, if we will design a feedback control law. Recall that a similar idea was used for Heated Tank. So let now an integration preceed the inverse model:

d dt

+ _

If this can be found a sound implementation we may select w using SISO controllers. Next move the integrator to both paths of the parallel connection:

d dt

& w

Aw -

B 1

u
85

In the upper path integration will now cancel (eliminate) the undesirable derivative block d / dt (the inverse system!) so that we get the following simplified block diagram suitable e.g. for Simulink:

B 1

Figure 10. A dynamic integrating precompensator for feedback control. This block diagram is sound from implementation point of view and can be used as a precompensator for a stable process within a feedback control law only since the presence of the integrator does not allow open loop control. On the other hand, integration will yield improved accuracy for some running situations. Stability of the process must be assumed to get an internally stable system since this cancellation controller hides the original process dynamics (see the figure below) which would be very dangerous for an unstable or a marginally stable process. So far we have proceeded and gained as shown below:

inverse process

process

Cancellation

w wi

w= y yi

The vector w may be selected using SISO controllers. Since integration is included in the precompensator we may use non-integrating SISO controllers, e.g. P controllers to form w . The remaining task associated with a

y i is to design an e.g. P controller gain pi for a scalar integrator process and an appropriate sensor of y i using basic control engineering knowledge. Example tunings will be discussed later.
single process output The multivariable controller may now be presented as the block diagram shown below in Figure 11:

diag ( [ p1 ... pm
e

])
w

Dp

B 1

Figure 11. A decoupling integrating MIMO controller for a stable process with the nominal & = A y + B u . The elements of the diagonal matrix D p IO ODE y are positive parameters called fine tuning parameters, typically bounded from above. Recall. The controller is designed to cancel - in fact hide - process dynamics. If the process happens to be unstable, the controller would then try to hide an unstable phenomenon. That should never be done for two reasons: First, other response functions (e.g. controller output ) may then behave in an unstable manner, although the process output would be regarded as nominally stable. Second, the process output would not be robustly stable: minor changes in process or controller properties could cause an unstable process output. In fact, you can get a demonstration about this by simulating the system for a large enough a Stop Time: presentation, rounding and truncation errors associated with calculations by a digital computer make 86

cancellation almost always imperfect (imprecise), which means that the phenomenon to be hidden will actually be seen also in the process output (more about this topic in the elementary course ACI-20016 , where Internal Stability was discussed) ! Problem. Adapt the derivation above for a SISO process with Time Constant T and Gain K : what will be integration time of the controller , and what kind of mathematical operations occur in transfer function manipulations?

A more efficient implementation Lets modify the block diagram to a more efficient form with a smaller number of Matrix Gain blocks: start by moving the rightmost block leftwards onto the two paths:

B 1
+

Dp

B 1

Continue by joining two successive Matrix Gains in the lower path:


proportional rough tuning matrix

B 1
e
fine tuning matrix integral rough tuning matrix

Dp

])

B 1 A

diag ( [ p1 ... pm

Then move the fine tuning block onto the two paths:

Dp

B 1

Dp

B 1 A

Next change the order of the Matrix Gain D p and the integration (assuming a constant D p ) :

Dp

B 1

Dp

B 1 A

u
87

Join two successive Matrix Gains in both paths:

B 1 D p
KI
e

B 1 A D p

Change from subtraction into addition with

( K I v) = K I v to get the Figure 12:

KP

B 1 D p
KI
+ +

B 1 A D p

Figure 12. A more efficient alternative to the controller of Figure 11. The controller contains a parallel connection of a MIMOP controller in the upper path and a MIMO controller with amplified integration in the lower path. Guess what: we will call such controllers MIMOPI controllers. Note that the controller of Figure 12 can not typically be presented using a single Matrix Gain precompensator but in general two quite independent Matrix Gains are needed. A systematic discussion of modelling aspects will be postponed to next section. Next something about finetuning, i.e. tuning of a set of SISOP controllers represented by the diagonal matrix D p : On the fine tuning When the MIMOPI controller derived above is used, the forward path system is of the form

ei

pi

yi

( i = 1,..., m )

Stability of the closed loop system depends partly also on the frequency response of the open loop system. This frequency response depends partly on the sensor dynamics. However, independent of the sensors, the fine tuning parameters should be positive,

pi > 0
to yield a relevant frequency response of the open loop system (with the phase curve up enough). Fine-tuning relies mostly upon principles learned in a basic course of control. The following results may be partly familiar, and a result may be suitable for a process output while another results may be suitable for other process outputs.

88

Example 1. Fine tuning assuming an ideal sensor

ri +
_

ei

pi

&i wi = y

yi

& i = wi = pi (ri y i ) y i = wi dt y

() ()

& i = pi yi + pi ri y
This model has a single eigenvalue, the real number (

pi ). This has a negative real part, iff

pi > 0
The corresponding Time Constant is

hi =

1 pi

1 & i + yi = ri y pi

This suggests the fine tuning

pi =

1 hi

where

hi = desired Time Constant of y i

Example 2. Fine tuning assuming a sensor modelled by a Transport Delay

ri +
_

ei

pi

wi

yi

Transport Delay d i
pi = pi = exp(1) di

critical damping for

phase margin

(in radians ) for

/ 2 m
di

m <

Example 3. Fine tuning assuming a sensor modelled by a Time Constant (and unity gain)

ri +
_

ei

pi

wi

yi

Time Constant i
89

critical damping for

pi =

0.25

i
1+ 2 i
,

phase margin

for

pi =

= tan( / 2 m )

3.4 On the State Space Model of the MIMOPI Controller This section presents shortly some useful results for models of MIMOPI controllers in general. Model 1

& e=v
e

KI KP KP e

KI v
+ +

The state variable will be

v = e dt
Then the model becomes

(1a)

&=e v

(1b) (1c)

u = KP e + KI v
The state space presentation is

&=O v I e { v + {
" A" "B "

(2a)

u=K I v + K P e { {
"C " "D "

(2b) zeros(m)

... ...

zero matrix with m rows and m columns :

identity matrix, with m rows and m columns: eye(m)

Often the actuating error e is zero before initial changes in the set points and or disturbances. Denote that initial value with

e(0 ) . Immediately after the input changes e may be totally different due + to a possible discontinuous jump from e(0 ) to some value called e(0 ) . When e(0 ) is zero , the
initial control input () is

u ( 0 ) = K I v (0 )
The initial value

(3a)

v(0 ) needed satisfies the linear equation


(3b)

K I v ( 0 ) = u (0 )

90

This has a unique solution, if K I is non-singular. The solution may then be found with the command v0 = KI\u0 Modification for

e(0 ) 0 is left for the reader!

Model 2

KI
e

& w

+ +

w u

KP

The model equations are here

u = w + KP e
& = KI e w = K I e dt w
The standard state space presentation of this is

(4a) (4b)

&=O w KI e { w+{
" A" "B "

(5a)

u= { I w+ K P e {
"C " "D"

(5b)

... ...

zero matrix with m rows and m columns :

zeros(m)

identity matrix, with m rows and m columns: eye(m)

For the controller illustrated above we obtain

e(0 ) = 0 u (0 ) = w(0 )
Therefore we will select

(6)

w(0 ) = u (0 )
No slashing this time! Modification for

(7)

e(0 ) 0 is again left for the reader!

Summary: Two easy State-Space presentations for a MIMOPI controller together with initial conditions associated with zero initial value of actuating error vector are given in the table below:

91

Matrix A B C D InitialCondition

presentation1 presentation 2 O I KI KP K I \ u (0 ) O KI I KP u (0 )

3.5 MIMOPI controller of Davison-Penttinen-Koivo The rough tuning of the following controller design is based on some propositions by E.J. Davison in 1970s and on another propositions by J. Penttinen and H. N. Koivo (TUT) in 1979. Some fine-tuning suggestions are due to additional TUT undergraduate and post-graduate students lead by Koivo. Below a design of the general MIMOPI controller of Section 3.4 for rough decoupling is discussed. The proposed method is parallel to that of Section 3.2 . Assume a known square stable strictly proper delay-free MIMO process model

& (t ) = A x(t ) + B u (t ) x

(1a) (1b) (1c) (1d)

y (t ) = C x (t )

rank (C B ) = dim( y ) = dim( u ) = m dim( x )

rank (C A1 B ) = m
When the condition (1c) is not satisfied one can exploit the design method of Section 3.2 if the condition (1d) is fulfilled. Delayed models as well as experimental design techniques will be treated later. Below we assume for simplicity ideal measurement of the process output vector. Assume the PI controller model

u (t ) = K P e(t ) + K I v(t )
&(t ) = e(t ) v

(2a) (2b)

v ( t ) = v (0) +

t 0

e(t ) dt

(2c)

where e is the actuating error, i.e. the difference of the set point

r (of y ) and the measured value of y . y (0 ) , u(0 ) , x(0 ) and v(0 )

Below we assume a step change of the set point at zero time and that are zero vectors of appropriate dimensions. In doing so note that zero

x(0 ) is not always implied by zero

y (0 ) . Assume a constant set point vector r for positive times.


The tuning of the proportional and integral parts is based on the following observation: for small positive times the output of the PI controller is mostly due to the proportional part while for large enough times it is mostly coming from the integral part. So the design of the I part should be based mostly on late, even stationary part of the response while the design of the P part should focus mostly on initial transients. However, note that P part should also take special responsibility of closed-loop stability which is threatened to some extent by introduction of the marginally stable I part.

92

Tuning Formulae of the Integral Part Below we will use a familiar gain for the integral controller

K I = ( CA1B ) 1 diag ( [k1 , ... , k m

])

ki > 0

(3)

Here the inverse of the process dc gain pre-multiplies a diagonal matrix, as proposed by Davison who developed the controller of Section 3.2 . Assuming stability of the closed loop system (which also depends on the choice of the proportional gain matrix!) this choice has a few interesting consequences: first, the Integral of Error (IE) of the step response due to a constant set point vector r is (for a stable closed loop system) decoupled ,

IEi :=

ei (t ) dt =

1 ri ki

for i = 1,..., m

(4)

In fact, stability implies here full steady-state accuracy y ( ) = r , which here means that

r = y () = C A1 B u() = C A1 B K I v () = diag ( [k1 , ... , k m


which is equivalent with (4) since v integrates e . Second, the steady state error for a rampwise set point function

] ) v ( )

r (t ) = t
is also decoupled (again for a stable closed loop system) ,

(5a)

ei ( ) =

1 i for i = 1,..., m ki

(5b)

A proof of this will be provided later using a transfer function method. Another proof is based on getting the ramp response of the closed-loop state-space model e.g. through integration of the step response. Both (4) and (5b) can be exploited to guide in the choice of the parameters

ki .

Tuning Formulae of the Proportional Part When complete transient decoupling is not achievable we can try to keep the undesired interaction responses close enough to zero for small values of time to give the integral part of the controller a sufficient time to build appropriate compensation of the interactions. Penttinen and Koivo proposed & (0) would help to reach this goal. The decoupling means that that possibly possible decoupling of y

& i (0) = pi ri y

for i = 1,..., m

(6a)

Here we of course select the parameters of (6a) to be positive,

pi > 0
Appending the requirements (6) gives the vector design specification

(6b)

& (0) = D p r y
D p = diag ( [ p1 ,..., pm

(7a)

])

(7b)

93

& (0) . Lets form the initial output derivative available using Here (7a) specifies the desired value of y both the controller model and the process model:
Controller model. For zero initial values

x(0 ) , v(0 ) , u(0 ) , y (0 ) we first obtain


(8)

e(0) = r y (0) = r y (0 ) = r 0 = r
since the structural slowness of the process keeps y (0) equal to y (0 ) . We also have v (0) equal to zero due to a similar property of the I part of the controller. Therefore the controller output jumps from zero value to the value

u (0) = K P e(0) = K P r
& (0) as Process model. Now we can use the process model to form y

(9)

& (0) = C x & (0) = C {A x (0) + B u(0)} = C {A 0 + B K P r} y


& (0) available is Hence y

& (0) = C B K P r y
Now the initial output derivative of (10) available may be tuned to match the desired value of (7) always when the condition (1c) is satisfied. The matching tuning is then given by

(10)

K P = (CB )1 diag ( [ p1 , ... , pm

])

pi > 0 for i = 1,..., m pi can partially be based on desired initial speed of

(11)

Here the selection of the initial slope parameters

the process outputs and/or on further search for improved decoupling. However, stability requirements as well as constraints of the control inputs must also be taken into account somehow.

On empirical fine-tuning The fine-tuning parameters The desired response from for the reader. One can also select first the numbers

pi , k i may be selected with several different methods of different complexity.

ri to yi may sometimes be characterized in terms of a stable first or second order model with unity gain. For such a model one can find pi and ki to match e.g. (4) and (6a). The details are left
& (0) , e.g. comparable with pi to give the initial response a nice slope y that in the step point of the process. Alternatively, fine-tune first the proportional parameters pi with any

suitable method. After that obtain the unit step responses for proportional control alone with a practical expreiment or computer simulation. Then sketch trial unit step responses for PI control so that for small times the response is close to that of P control (a response not converging to the set point!), while for large times the responses converges to the set points (thanks to integrating control!). Once the assumed responses have been sketched, calculate the numbers IE i from appropriate curves (trapz ?) and select

ki =

ri IEi

for i = 1,..., m

(12)

94

Example process model structure for application of the idea proposed Use of experimental step responses in modelling has been discussed earlier. As a result of such procedure we may have a Gain- Time Constant model of the form presented by the block diagram below:

u1

Gain TimeConstant Gain TimeConstant

K11 T11 K12 T12

y11

y1
+

y12

Gain TimeConstant

K 21 T21

y21
+

u2

Gain TimeConstant

K 22 T22

y22

y2

Model parameters can be presented in a compact way by using a Gain array K and a Time Constant array T defined in the most obvious way,

K K = 11 K 21

K12 K 22

T T T = 11 12 T21 T22

(13)

The ODEs of the blocks are

&11 (t ) = y &12 (t ) = y & 21 (t ) = y & 22 (t ) = y

1 K y11 (t ) + 11 u1 (t ) T11 T11 1 K y12 (t ) + 12 u2 (t ) T12 T12 1 K y21 (t ) + 21 u1 (t ) T21 T21 1 K y22 (t ) + 22 u2 (t ) T22 T22

(14a)

(14b)

(14c)

(14d)

The algebraic equations are

y1 (t ) = y11 (t ) + y12 (t ) y2 (t ) = y21 (t ) + y22 (t )


Here y11 , y12 , y 21 , y 22 are candidate state variables. If they are used as states in the order given the state-space model becomes

(14e) (14f)

95

K11 1 0 0 0 0 T T 11 y 11 &11 y 11 1 K12 0 0 0 0 y & T12 u1 T12 y12 12 = + u K 21 y 1 & 21 y 21 2 2 0 0 0 0 1 3 & T T u 21 21 y y 22 22 1 23 23 K 22 1 1 & x x 0 0 0 0 T22 T22 4 444 1 4 2444 4 3 1 4 24 4 3
A B

(15a)

y11 y1 1 1 0 0 y12 = y 0 0 1 1 y 44 2 21 2 244 3 1 3 1 C y y22 1 23


x

(15b)

Here we proceeded output-by-output, i.e. used the information of the arrays K , T row-by-row. We can also proceed input-by-input , i.e. use the information of the arrays K , T column-by-column. Here this change means simply interchanging the order of y12 and y 21 in the state vector. For the new state and ODE order we obtain the model

&11 (t ) = y & 21 (t ) = y &12 (t ) = y & 22 (t ) = y

1 K y11 (t ) + 11 u1 (t ) T11 T11 1 K y21 (t ) + 21 u1 (t ) T21 T21 1 K y12 (t ) + 12 u2 (t ) T12 T12 1 K y22 (t ) + 22 u2 (t ) T22 T22

(16a)

(16b)

(16c)

(16d)

y1 (t ) = y11 (t ) + y12 (t ) y2 (t ) = y21 (t ) + y22 (t )


A matrix presentation of this is

(16e) (16f)

K11 1 0 0 0 0 T T 11 y 11 &11 y 11 1 K 21 0 0 0 0 y y & 21 T T u1 21 21 = + 21 K12 1 &12 y u2 y 12 2 0 0 0 0 1 3 & T T u 12 12 y22 22 y 1 2 3 1 23 1 K 22 & x x 0 0 0 0 T22 T22 4 444 1 4 2444 4 3 1 4 24 4 3
A B

(17a)

96

y11 y1 1 0 1 0 y12 y = 0 1 0 1 y 44 2 2 21 244 3 1 3 1 C y 22 y 1 2 3


x

(17b)

Nevertheless, both state-space models presented above have the property

( CA B )
1

ij

= K ij

(18a)

(CB ) ij =

K ij Tij
K . / T and C * B .

(18b)

Note that Equation (18b) implies the Matlab equivalence of

97

4. Getting a state-space model from state-space models of sub-systems This chapter starts by discussing some theory for the modelling tools append , parallel , series and feedback to generalize some results of Chapter 2 , DB 3.5 , Burl 4 as well as to train for some results of Burl 4. Each subsystem model is assumed to be a true state-space model with a positive number of states. Recall that modelling of a e.g. series connections of a Matrix Gain model and another Matrix Gain model or a true statespace model and was already discussed in Section 2.9 and Chapter 3. Other modelling problems involving only Matrix Gain models can be handled using the theory to be presented for transfer function matrices in Chapter 6.

4.1 append This tool is for appending (joining , combining) e.g. two possibly MIMO models into a single MIMO model:

&1 = A1 x1 + B1 u1 x y1 = C1 x1 + D1 u1
u1 y1

system 1

u2

system 2
& 2 = A2 x 2 + B2 u 2 x y 2 = C 2 x 2 + D2 u 2

y2

Group / introduce block vectors:

u1 u 2

system 1 system 2

y1 y 2

Recall the use of Mux and DeMux blocks in Simulink The CST command has the structure system = append(system1,system2) The use of this command is not limited for ss models. For ss models we could use the commands system1 = ss(A1,B1,C1,D1) system2 = ss(A2,B2,C2,D2) systems = append(system1,system2) What happens? : Introduce zero matrices ( O1 , O2 , ...) of appropriate row and column dimensions so that the products of matrices and vectors below can be computed and added to appropriate other vectors:

&1 = A1 x1 + O1 x2 + B1 u1 + O2 u2 x & 2 = O5 x1 + A2 x2 + O6 u1 + B2 u2 x

y1 = C1 x1 + O3 x2 + D1 u1 + O4 u2 y2 = O7 x1 + C2 x2 + O8 u1 + D2 u2

Finding the dimensions of the zero matrices is mostly left for the reader but lets show an example: First, the &1 requires that O2 has length(u 2) or size( B 2,2) existence of the term O2 u2 in the equation of x 99

&1 ) . The dimensions of the other zero matrices can be found in a which requires that size(O2 , 1) = length ( x similar way.
Use now partitioned (block) vectors and matrices to get

&1 if and only if columns. Second, O2 u2 can be an additive term of x

&1 ) length(O2 u2 ) = length( x

&1 A1 O1 x1 B1 O2 u1 x = + x &2 O5 A2 x2 O6 B2 u2 { 1 { 4 24 3 { 1 4 24 3
& x A x B u

y1 C1 O3 x1 D1 O4 u1 y = O C x + O D u 7 2 2 8 2 2 2 { { { 1 4 24 3 1 4 24 3
y C x D u

Three state-space models may be joined together in a corresponding way. Alternatively, one can use the result above in a recursive way so that two first models are combined to gether first, after which the model so obtained can be combined with the third model.The idea is illustrated below with a block diagram and commands: systema

u1

system 1

y1

u2

y2

system 2
u3 y3

system 3
systems

systema = append(system1,system2) systems = append(systema,system3) However, CST offers more convenience in a possible command, systems = append(system1,system2,system3)

4.2 parallel Consider the parallel connection below (see BCAT/ATP material for initial motivation for this problem!)

&1 = A1 x1 + B1 u x y1 = C1 x1 + D1 u y1 + G1
+

y2 G2

& 2 = A2 x 2 + B2 u x y 2 = C 2 x 2 + D2 u
100

The final output becomes

y = y1 + y 2 = (C1 x1 + D1 u ) + (C 2 x 2 + D2 u ) = (C1 x1 + C 2 x 2 ) + ( D1 + D2 ) u
The state ODEs may be written in the form

&1 = A1 x1 + x &2 = x

} O1 x 2 + B1 u 14 24 3
zero matrix zero vector

zero matrix

O 2 {

x1 + A2 x 2 + B2 u
Section 4.1. The

where the dimensions of the two zero matrices are selected using the procedure of (partitioned) block matrix form is

& A O1 x1 B1 x & = 1 = 1 x + u & 2 O2 A2 x 2 B2 x { { 1 4 24 3


A x B

x y = [C1 C 2 ] 1 + ( D1 + D2 ) u 1 4 24 3 x2 1 4 24 3 C D {
x

The parallel connection of e.g. three subsystems can be formed along principles and conventions studied in Section 4.1 for append. The solution of the parallel problem colud also be based on the append math. Remark. The matrix A above is block diagonal. There are tools for getting such a presentation from a statespace model initially not in that form. Recall e.g. our discussion of diagonalization and its relationship to partial fraction expansion (residue) of the tf. Problems. Prove using symbolical (not numerical) thinking that the models m1 , m2 formed below for matrices A,B,C,D,K of suitable dimensions have the same IO responses: a) m1 = parallel(ss(D),ss(K)) b) m1 = parallel(ss(A,B,C,D),ss(K)) , , m2 = ss(D+K) m2 = ss(A,B,C,D+K)

4.3 series Consider the series connection below (see BCAT/ATP material for initial motivation for this problem!)

y1

u2

y2

sys1
&1 = A1 x1 + B1 u1 x y1 = C1 x1 + D1 u1
CST accepts the commands

sys 2
& 2 = A2 x 2 + B2 u 2 x y 2 = C 2 x 2 + D2 u 2

sys1 = ss(A1,B1,C1,D1) , sys2 = ss(A2,B2,C2,D2) , sys = series(sys1,sys2) The connection rule is u 2 = y1 . The variable u 2 or y1 is neither a state nor an external input. Therefore it should not appear in RHS of equations. Therefore it should and can be eliminated by substituting 101

u 2 = y1 = C1 x1 + D1 u1
into the latter model to yield the equations

& 2 = A2 x 2 + B2 (C1 x1 + D1 u1 ) = B2 C1 x1 + A2 x 2 + B2 D1 u1 x
y 2 = D2 C1 x1 + C 2 x 2 + D2 D1 u1
A model of the series connection thus is

&1 = A1 x1 + B1 u1 x & 2 = B2 C1 x1 + A2 x 2 + B2 D1 u1 x
y 2 = D2 C1 x1 + C 2 x 2 + D2 D1 u1
Lets present this in the expanded form (where O denotes a zero matrix with a suitable number of rows and a suitable number of columns to enable multiplications and additions needed in the equation):

&1 = A1 x1 + x

} O x 2 + B1 u1 14 24 3
zero matrix zero vector

(1)

& 2 = B2 C1 x1 + A2 x 2 + B2 D1 u1 x

(2) (3)

y 2 = D2 C1 x1 + C 2 x 2 + D2 D1 u1
Define a so called augmented state vector to consist of subsystem state vectors:

x x := 1 x2
The matrix form of the model (1), (2), (3) becomes, using partitioned (block) matrices,

(4)

&1 A1 O x1 B1 x = + u1 x & 2 B2 C1 A2 x 2 B2 D1 { 14 4 244 3 { 1 4 24 3


& x A x B

(5a)

x y 2 = [D2 C1 C 2 ] 1 + D2 D1 u1 14 4 244 3 x 2 123 C D {


x

(5b)

Remarks 1. The matrix A above is of Equation (5a) a block lower triangular matrix. 2. Note the order of multiplication in the matrix D of Equation (5b) :

D = D2 D1
Notice that this kind of a results exists also for Matrix Gains as we saw in Section 2.9!

102

Matlab commands not assuming Control System Toolbox % ss(A1,B1,C1,D1)ss(A2,B2,C2,D2) % ss(A,B,C,D) n1 = size(A1,1) n2 = size(A2,2) O = zeros(n1,n2) A = [A1 , O ; B2*C1 , A2] B = [B1 ; B2*D1] C = [D2*C1 , C2] D = D2*D1 ; ; ; ; ; ; ; % number of rows , dimension of x1 % number of columns , dimension of x2

Another solution by reordering the states The designer is often more interested in the states of the last sub- system. Therefore he or she may build the augmented state vector to first include those states. Then a natural choice of the augmented state x is

x x := 2 x1
The state space parameters for this choice may be found by changing the order of equations and the order of vectors x1 , x 2 in the right hand sides of the equations:

(6)

& 2 = A2 x 2 + B2 C1 x1 + B2 D1 u1 x &1 = O x 2 + A1 x1 + B1 u1 x
y 2 = C 2 x 2 + D2 C1 x1 + D2 D1 u1
A straightforward matrix presentation of this is

(2) (1) (3)

& 2 A2 B2 C1 x 2 B2 D1 x = + u1 x &1 O A1 x1 B1 { 14 4 244 3 { 1 4 24 3


dx / dt A x B

(7)

x y 2 = [C 2 D2 C1 ] 2 + D2 D1 u1 14 4 244 3 x1 123 C D {
x

(8)

Here the matrix

D is that of model (5), D = D2 D1 , whereas the structure of other matrices has changed in a certain way. The matrix A is here an block upper triangular matrix.
Knowing the state vector may be important, if one is going to use initial or lsim . Is the tool series of CST is using (7) & (8) ?

Remark. A linear state transformation by e.g. schur (see Section 2.6 and Burl 2.7) can be used to cast the model into a form which can propose us a block diagram consisting of parallel and series connections of true state-space models This is in a sense related to partial fraction expansion (residue) of the system tf.

103

4.4 feedback Consider the negative feedback connection where the the input of a sub-system is formed by subtraction of the external input and the output of another subs-system:

u1
_

sys1
u2

y1

y2

sys 2

We will study this problem in small steps by looking first some simple yet important special cases:

Example 1. Direct Negative Feedback for a Strictly Proper Forward Path System

& = A x + B u x y =Cx

u
_

sys

y
Lets try to polish the ODE so that it has on its right hand only the state x of sys and the external input r . So we search for a model of the form

& = f ( x, r ) x
y = g ( x, r )
So we must not have u in the final ODE . Therefore eliminate u through the substitution (connection rule) u = r y to get

& = A x + B (r y) x 1 23
u

Now we have y on RHS while we should not. Hence eliminate yields

y by the substitution y = C x which

& = A x + B (r C x) x
The overall model now becomes

& = ( A B C ) x + { x B r 14 24 3 "B "


" A"

y=C {x+ O { r
"C " "D "

The result has nice implications for computation of transfer functions, which will be discussed later. It also provides for many systems the relationship of the open loop system and the closed loop system, which is useful in analysis of stability, robust stability , sensitivity using root locus and frequency responses. 104

Example 2. Static Systems (also for dcgains of dynamic systems)

u1
_

y1 K1 u2

y2

K2

Here we have an algebraic loop which calls for use of special actions. The model of the overall system can be found from an implicit equation :

y1 = K 1 u1 = K 1 (r y 2 ) = K 1 (r K 2 u 2 ) = K 1 (r K 2 y1 ) = K 1 r K 1 K 2 y1
This can be solved as follows:

I y1 + K 1 K 2 y1 = K 1 r

( I + K 1 K 2 ) y1 = K 1 r
This is a linear equation which could be solved with slash ( \ ) . The formal solution has the obvious presentation

y1 = ( I + K 1 K 2 ) 1 K 1 r
This is a Matrix Gain model with the Matrix Gain

K = ( I + K 1 K 2 ) 1 K 1
The use of an explicit matrix inverse can be avoided by solving K from

( I + K 1 K 2 ) K 12 = K 1
with e.g. slash. In Matlab we could use e.g. the commands n1 = size(K1,1) n2 = size(K2,2) I = eye(n1,n2) K12 = (I + K1*K2)\K1

Example 3. Direct Negative Feedback for a Biproper Forward Path System

& = A x + B u x y = C x + D u

u
_

y sys

y
Lets search again for a model of the form

& = f ( x, r ) x

105

y = g ( x, r )
We clearly must eliminate u . Again we have an algebraic loop. We may form an implicit equation for u :

u = r y = r (C x D u ) = r C x D u

This linear implicit equation of u may be presented in the forms

I u + D u = r C x
and

( I + D) u = r C x
If the matrix is then

( I + D) is non-singular, the function u may be solve always uniquely. The formal solution

u = ( I + D) 1 r ( I + D) 1 C x
Substituting this now into the forward path state space model yields the closed loop model

& = ( A B ( I + D) 1 C ) x + B ( I + D) 1 r x 1444 2444 3 14243


" A" "B "

y = (C D ( I + D) 1 C x + D ( I + D) 1 r 1444 2444 3 142 4 43 4


"C " "D "

Check that this will produce the result of Example 1 for D = O !

Example 4. Two strictly proper ss systems

&1 = A1 x1 + B1 u1 x y1 = C1 x1 u1 y1 sys1
_

y2

sys 2

u2

& 2 = A2 x 2 + B2 u 2 x y 2 = C 2 x2
Eliminate from the RHS of equations all other variables than the states and the external input. Eliminate first u1 by taking into account the connection rule u1 = r y 2 . Then get rid of y 2 . Combine these eliminations by substituting

u1 = r C 2 x 2
in the first state equation to get

&1 = A1 x1 + B1 (r C 2 x 2 ) x
106

Substitute now in the second state equation u 2 = y1 = C1 x1 to get

& 2 = A2 x 2 + B2 (C1 x1 ) x
The differential equations may be presented in the form

&1 = A1 x1 B1 C 2 x 2 + B1 r x & 2 = B2 C1 x1 + A2 x 2 + O r x
The output equation may be written as

y1 = C1 x1 + O x 2
The matrix form is shown below,

& A B1 C 2 x1 B1 x & = 1 = 1 + r x & 2 B2 C1 A2 x2 O x { { 144 4 2444 3


A x B

x y1 = [C1 O ] 1 + O r 1 4 2 4 3 x2 { D C {
x

The tool feedback of CST is using (7) & (8) ?

Example 5. Two biproper ss systems

&1 = A1 x1 + B1 u1 x y1 = C1 x1 + D1 u1 u1 y1 sys1
u2

y2

sys 2

& 2 = A2 x 2 + B2 u 2 x y 2 = C 2 x 2 + D2 u 2
Here we combine the ideas of Examples 3 and 4: Find for u1 an implicit equation, where other variables are the states and the external input and work hard to get

& A1 B1 ( M 1 D2 ) C1 x1 B1 M 1 B1 ( M 1 C 2 ) x & = 1 = + x r & 2 B2 ( I D1 ( M 1 D2 )) C1 A2 B2 D1 ( M 1 C 2 ) x 2 B2 ( D1 M 1 ) x 14444444444244444444443 { 1442443


A x B

x y1 = ( I D1 ( M 1 D2 )) C1 D1 ( M 1 C 2 ) 1 + D1 M 1 r 14444444 4 244444444 3 x2 1 4 24 3 C D {
x

107

M = I + D2 D1
Observe that certain products and terms appear above several times ... but need to be computed only once. Note also that matrix inversions may be avoided by using \ or / . Derivation:

u1 = r y 2 = r (C 2 x 2 + Du 2 )
Noting that u 2 = y1 yields

u1 = r C 2 x 2 D2 y1 = r C 2 x 2 D2 (C1 x1 + D1u1 ) = r C 2 x 2 D2 C1 x1 D2 D1u1


Present u1 on the LHS as Iu1 , where I is the identity matrix (of a suitable dimension). Then we may write

Iu1 + D2 D1u1 = D2 C1 x1 C 2 x 2 + r

( I + D2 D1 )u1 = D2 C1 x1 C 2 x 2 + r
Now u1 may be solved provided that the matrix

M = I + D2 D1
is non-singular. In that case we obtain the solution

u1 = ( I + D2 D1 ) 1 ( D2 C1 x1 C 2 x 2 + r )
The standard presentation of this (note the order of the variables) is

u1 = M 1 D2 C1 x1 M 1C 2 x 2 + M 1 r
&1 becomes, after using the equation above in the original ODE, The variable x

&1 = A1 x1 + B1 ( M 1 D2 C1 x1 M 1C 2 x 2 + M 1 r ) x &1 = ( A1 B1 M 1 D2 C1 ) x1 + B1 M 1C 2 x 2 + B1 M 1 r x
The first output becomes, since u 2 = y1 ,

y1 = C1 x1 + D1 M 1 D 2 C1 x1 M 1C 2 x 2 + M 1 r

y1 = (C1 D1 M 1 D2 C1 ) x1 + D1 M 1C 2 x 2 + D1 M 1 r
The second ODE becomes, by elimination of u 2 = y1 ,

& 2 = A2 x 2 + B 2 (C1 D1 M 1 D 2 C1 ) x1 + D1 M 1C 2 x 2 + D1 M 1 r x & 2 = B2 (C1 D1 M 1 D2 C1 ) x1 + A2 B2 D1 M 1C 2 x 2 + B2 D1 M 1 r x


Show yourself now that

108

y 2 = D2 (C1 D1 M 1 D2 C1 ) x1 + C 2 D2 D1 M 1C 2 x 2 + D2 D1 M 1 r
and proceed to the final model of y 2 . Collect the results:

M = I + D2 D1

&1 = ( A1 B1 M 1 D2 C1 ) x1 + B1 M 1C 2 x 2 + B1 M 1 r x & 2 = B2 (C1 D1 M 1 D2 C1 ) x1 + A2 B2 D1 M 1C 2 x 2 + B2 D1 M 1 r x y1 = (C1 D1 M 1 D2 C1 ) x1 + D1 M 1C 2 x 2 + D1 M 1 r y 2 = D2 (C1 D1 M 1 D2 C1 ) x1 + C 2 D2 D1 M 1C 2 x 2 + D2 D1 M 1 r


The hard work above is good training in many respects. However, there are a few tricks which can be used to make practical computations easier. See first how the current (up-to-date) feedback solves the problem using a few other tools. Yet another procedure may be based on a block diagram of y 2 where the series connection of the blocks

sys1 and sys 2 appear as a forward path system, also as the open loop system. Then combining the result for the series connection and the result for direct negative feedback (see Example 1) will yield suitable equations. The details are left for the reader
&1 = A1 x1 + B1 u1 x y1 = C1 x1 + D1 u1 & 2 = A2 x 2 + B2 u 2 x y 2 = C 2 x 2 + D2 u 2
u2 y2

u1
_

y1

sys1

sys 2

Remark. In all the examples with two true state-space systems one can in principle select different block structures for the final state vector. With any version of Matlab new to you and with any other CAD software make some tests to learn which block structure is adopted by that version!

109

5 POLE PLACEMENT / EIGENVALUE ASSIGNMENT / MODAL CONTROL 5.1 Introduction Next we will study, how a linear state feedback control law may be designed to yield desired eigenvalues (see DB 6.4 , 11 and ideal dc gain (equal to the identity matrix) for the closed loop system, when the process satisfies certain assumptions. A dc gain equal to the identity matrix implies for a stable closed loop system, that the response for a constant set point vector r will converge to the finite value I r = r . Note, that here decoupling is not included in the design specifications! Assume the LTI (Linear Time Invariant) process model

& = A x + B u x

(1a) (1b)

y =Cx
where the dimensions (lengths) of the vectors u , x and Consider now the linear state feedback control law

y are nu , n x and n y , respectively.


(2)

u = K x + N r
where r is the set point of the output y , and K as well as N are constant matrices (of appropriate dimensions) free to choice. A block diagram for Equations (1) and (2) is given below:

+ _

& = Ax + Bu x

f K

Remark (DB 6.4) The matrix A is said to have a non-zero eigenvector v (column vector) and a scalar eigenvalue , if and only if A v = v . This definition implies the consequence det( I A) = 0 or det( A I ) = 0 . This consequence, a polynomial equation for , has a theoretical value and can be used in symbolical calculus for low-dimensional matrices but should not necessarily be exploited in numerical computations of the eigenvalues. Note that det( s I A) is the denominator polynomial of the matrix

( sI A) 1 met in DB 3 . This so called characteristic polynomial also becomes the denominator polynomial 1 of the transfer function C ( s I A) B of the model (1) , if there are no pole-zero cancellations, i.e.
cancellations of possible common polynomial factors of the numerator polynomial and denominator polynomial of the transfer function. Any zero of the polynomial det( s I A) is an eigenvalue. Some eigenvalues may be subject to a cancellation due to B and/or C (and will thus be called hidden eigenvalues) , while the other eigenvalues of

A remain visible as poles of the simplified form of C ( s I A) 1 B .

Solution The tuning of the control law will be based on the state space model of the closed loop system between r and y . This ss model will be obtained through the elimination of u , which initially yields

& = A x + B u = A x + B ( K x + r ) x
Therefore a ss model between r and y is 110

& = ( A BK ) x + B r x

(3a) (3b)

y =Cx
Eigenvalues. The eigenvalues (DB 6.4) of the overall system illustrated above are those of the model (3), since the gain N will not affect the eigenvalues, which fact becomes more evident from the model (7) below. The eigenvalues in question are those of the matrix

A1 = A B K
This matrix has n x eigenvalues. Each of them should have a negative real part to achieve stability. A non-real complex eigenvalue complex conjugate number

(4)

= + j (with , real and 0 ) implies, that the * = j is also an eigenvalue, if the matrices A , B , and K

are real valued matrices. Remembering the observations above you can try to find a matrix K to achieve desired eigenvalues. Also remember knowledge on pole locations in DB 2.4 , 5.3 , 5.4 , 6.3, when you select desired locations for the eigenvalues. Finally, for stable processes selecting the closed loop eigenvalues close to process eigenvalues (those of A ) may lead to peaceful control. The matrix K yielding the desired eigenvalues may be searched using Symbolic Toolbox, CST or a set of basic commands of Matlab. Before making such attempts, lets make some remarks: 1. There are some processes, for which no matrix K can assign the eigenvalues in desired positions. This failure occurs, iff (if and only if) the system is not controllable. See DB 11 and Burl 2.8 . 2. For controllable Singel Input systems ( nu = 1 ) there exists a unique matrix

K solving the problem.

For numerical (i.e. non-symbolical) calculations acker is not a good tool. Therefore using the more robust tool place instead of acker is recommended, although place has a certain limitation on the multiplicity of an eigenvalue. 3. For controllable Multiple Input systems ( nu 2 ) there exists infinitely many matrices K solving the problem. For example, even a rank-one product of a random column vector (of dimension nu ) and an adjustable row vector (of dimension n x ) may often be used as K (see placebo). This essentially means controlling with a single control input (re-write the problem for a suitable new input variable to understand this!). For systems with rank ( B ) = nu = n x we may even select all

K is made by place to select a robust1 gain provided that the multiplicity of any eigenvalue is not exceeding nu . For nu = 1 multiple eigenvalues are not found with place, and for nu = 2 no number should apper more than twice in the
the eigenvectors of the matrix A1 , too. A clever choice of set of the eigenvalues. See Matlab Help!

Some documentation of place is given below:

PLACE

Pole placement technique

K = PLACE(A,B,P) computes a state-feedback matrix K such that the eigenvalues of A-B*K are those specified in vector P. No eigenvalue should have a multiplicity greater than the number of inputs.

Check always the eigenvalues of A1 for the controller tuning selected !


1

See Numerical Linear Algebra Techniques for Systems and Control by Patel, Laub, and Van Dooren, IEEE Press 1994 and Modern Control Theory by Brogan, Prentice-Hall 1991.

111

Dc gain. The desired dc gain is obtained by an appropriate selection of the precompensator matrix N . Calculate first the dc gain K of the model (3) either with ss and dcgain or using the formula

K = C A11 B
A1 = A B K
The dc gain of the whole system is obviously K N . This becomes the (ideal) identity matrix , iff

(5a)

N = K 1
The state space model of the whole system is obtained from the model (3) and the equation r = Nr ,

(6)

& = A1 x + BN r x

(7a) (7b)

y =Cx
This model should have the desired eigenvalues and the desired dc gain: check always your design! Observations for convenient CST design Start by selecting the matrix K with place. The documentation of place actually reminds you about the matrix A1 = A BK . Then let the block diagram below advice you to select suitable CST commands: sys2 sys1 xsys

+ _

& = Ax + Bu x x = Ix + Ou
f

Form first xsys , then sys1 , then sys2 , then the dc gain of sys2 , ... Finally, check the eigenvalues , the dc gain and the step responses of the whole system. In a Single Input case ( nu = 1 ) checking of some stability margins (gain margin, phase margin and delay margin) may be easily possible for you from the open loop frequency response (DB 9.1 , 9.3, 9.4 ). In this task you can exploit the block diagram below: open loop system xsys ? +

u = K x

& = Ax + Bu x x = Ix + Ou

K x = u + ...

Kx

112

So the ss model of the open loop system may be easily obtained! The model may also be presented as below: open loop system

& = Ax + Bu x

(for zero set point)

u = Kx + Ou

5.2 Pole placement designs for integrating control A former design method for PI control combined decoupling with selection of some closed loop eigenvalues, while some eigenvalues were those of the process assumed to be stable. Next we will study tuning integrating control laws to assign of all the eigenvalues of the closed loop system. This topic is discussed also in DB 11. Consider again a (strictly proper) process model of the form

& = A x + B u x

(1a) (1b)

y =Cx
Here we assume a set point r for the process output of y , so that the actuating error e is

y . We also assume perfect measurement

e=ry
Consider an integrating control input function of the form

(2a)

u (t ) = K x(t ) + K I e(t ) dt + u c 0 1 4 24 3
v (t )

(2b)

where

u c should be adjusted to yield a suitable initial value for the control input u . Suppose

that we should place the closed loop poles at desired locations of the complex plane. The control problem introduced may perhaps be solved using state feedback theory:

Solution 1 Noting that

& = e = r y = r Cx v
makes it possible to present all the ODE equations as an augmented state space model:

(3)

& = A x + O1 v + B u + O r x

(4a) (4b)

& = C x + O2 v + O3 u + I r v
or

& A O1 x B x v = C O v + O u + 3 & 1 2 4 { { 24 3
A* x* B*

of secondary interest

O I r 3 1 2

(4c)

or 113

&* = A * x * + B * u + ... x
B A O1 and B* = A* = C O2 O3
where O1 , O2 ,

(4d)

(4e)

O3 and O are zero matrices of appropriate dimensions

Here the state dimension (= the number of forward path poles = the number of closed-loop poles) is

dim x* = dim x + dim v = dim x + dim e = dim x + dim y

(5)

The control law (2) requested includes a state feedback term based on the entire state vector of this model:

x u = {K x K I v} + u c = {K x + ( K I ) v} + u c = [K K I ] + u c 1 4 24 3 v K* {
x*

(6a)

or

u = K * x * +u c
where the unknown state feedback gain matrix is

(6b)

K * = [K

KI ]

(6c)

The closed loop model may be written as

&* = ( A * B * K *) x * +... x
The eigenvalues of the closed loop system are thus those of the matrix

(7)

Aclo = A * B * K *
The number of the eigenvalues is dim x * . Under appropriate controllability conditions they may be placed in desired positions by a proper choice of K * ( with e.g. place if ). Remarks 1. After you have obtained 2. The matrix

(8)

K * be careful in picking K I : in Equation (6c) you have ( K I ) !

K * can not be selected to have unity rank placebo is not for this problem, why?

3. The poles of the model (4) are those of the process and the controller integrators. The integrator poles lie at the origin. In search of peaceful enough control input behaviour you could choose certain desired poles close to and left to stable process poles and some poles left to but close to the origin. 4. For systems with C = I ( y =
t

x ) the controller equation becomes


(9)

u (t ) = K y (t ) + K I e(t ) dt + u c
0

This is an implementation of the so called PI controller. The usual implementation and notation is

u (t ) = K P e(t ) + K I e(t ) dt + u c
0

(10)

The pole placement design of controller (10) is similar to the pole placement design of controller (9) as soon 114

as we let K P to correspond to K . In fact, for a zero set point controllers (9) and (10) the become fully equivalent. The procedure for the controller (10) becomes: (1) Design the gains of the controller (9) using the general theory with C = I and dim x* = 2 dim x = 2 dim y desired eigenvalues, (2) set K P K .

Solution 2 Write the controller equation in the non-minimal 8 (and from practice point of view bad!) form

u = K x K I y dt + K I r dt + u c
A block diagram for this equation is given below:

K
-

+ -

& = A x + B u x

x = I x + O u KI

The integrator may be modelled by a state space model, where i is the state vector. Then the state space model of the link u i (before introduction of feedback through K ) obtained by an appropriate series command (? , check for your Matlab version!) from models of the links u y and y i has a state variable

i y x* = = x x
The parameters of the model mentioned are available by ssdata. The controller equation may be written as

i u = K I y dt K x + K I r dt + uc = [K I K ] + uc 1 4 24 3 x K* {
x*

uc being a constant, i.e. as a state-feedback control law (where uc is not affecting the poles). The matrix K * can perhaps be obtained with place. Be careful in picking the matrices K I now from the left part of the matrix K * . The design can then be checked with CST using feedback , series , pole in a simple way?
with Remarks 1. The non-minimal equation and block diagram above are only for design thinking , not for implementations: It is not wise to integrate the set point and the measurement separately to avoid unbounded functions 2. The matrix

K * can not be selected to have unity rank why? So placebo is not applicable here.

115

6. TRANSFER FUNCTION MATRIX (TFM) The TFM of a CT (Continuous-Time) LTI system is based on the LT (Laplace Transform) of certain CT functions. It has some interesting applications, e.g. frequency response studies and applications. However, the TFMs should not be used in every possible calculus procedures

6.1 On Laplace transforms The (one-sided) LT of nice enough a function x is defined as

L{x}:=

x(t ) e st dt =: X ( s )

where s is a complex parameter and 0 is either the ordinary zero or that denoted by 0 in DB. When the function x is associated with (is a typical input function or a response to a typical input function) a LTI system, LT exists for suitable choices of s with large enough a real part. Example, LT of the unit step function u H or Heaviside has a LT U H is s has a positive real part:

1 , t > 0 uH ( t ) = 0 , t < 0

U H ( s ) = L{uH } =

1 , Re{s} > 0 s

Important familiar scalar LT rules are listed below (assuming the existence of the transforms mentioned):

L{ x} = L{x} L{x + w} = L{x} + L{w} &} = s L{x} x (0) L{x L{x (t ) uH (t )} = exp( s ) L{x}

(Gain Rule for a constant (Sum Rule) (Derivative Rule)

(Delay Rule for a constant

Other rules can be derived from the rules given above: For example, Gain Rule and Sum Rule yield

L{ x + u} = L{x} + L{u}
With

(Linearity Rule for constants Difference Rule, (Difference Rule)

=1

= 1 this implies the

L{x u} = L{x} L{u}

Rules for higher order derivatives may be obtained by repeated application of the Derivative Rule. LT of the second derivative is

&} = s 2 L{x} s x (0) x & (0) L{& x


We can define LT even for vector functions of time, a vector of scalar transforms as a result. For example:
x1 ( t ) x x x = 1 L 1 = e st dt = 0 x x2 1 x2 ( t ) 4 22 4 3 transform of a vector

x e st dt x1 e st 0 1 = L{x1} = dt st st L{x2 } x e dt x2 e 2 4 2 4 3 0 1 vector of


transforms

116

as soon as both scalar transforms on the right exist. In a corresponding way we can also define LT even for more general matrix functions of time. Formal application of the LT definition naturally leads to

x u L{x} L{u} v w = L{v} L{w}

as soon as all the scalar transforms on the right exist. The Gain Rule , the Sum Rule , the Derivative Rule as well as the Linearity Rule, Difference Rule and higher order Derivative Rules are valid also for a vector or matrix x and a constant matrix as long as all the objects in the rules are well-defined. The Delay Rule is valid for a matrix x and a constant scalar when the objects in the rule are well-defined. Note that we may even define LTs of block vectors and block matrices in an obvious way and obvious results. Final value theorem A vector function y of non-negative time has a finite final value if and only if the simplified form of the product

s Y ( s)
either has no poles or has all its poles left to the imaginary axis. When this condition is satisfied the limit is

y () = lim [s Y ( s )]
s 0

(under an assumption mentioned above!)

6.2 TFM of a MIMO system Example. Consider the linear perturbation model of the Tank with Two In-Flows:

& = k h + k q + k q h 1 2 h 3 c

(equality of functions) (equality of functions)

(a) (b)

& = k T + k q + k q T 5 6 h 7 c

Lets first apply LT on the first equation only:

& = L{k h + k q + k q } L h 1 2 h 3 c

{ }

(Equal functions have equal transforms)

s L{h} h(0) = L{k1 h} + L{k 2 qh } + L{k3 qc } (Derivative Rule & Sum Rule ) s L{h} h(0) = k1 L{h} + k 2 L{qh } + k3 L{qc } (Gain Rule for constant parameters)
Since T is not appearing here, we can solve the LT of h easily:

s L{h} k1 L{h} = k 2 L{qh } + k3 L{qc } + h(0)


This may be presented as a Polynomial Model, where each LT has a polynomial as its multiplier:

( s k1 ) L{h} = k 2 L{qh }+ k3 L{qc } + h(0)

(polynomial form)

LT of h can now be found a nice form for preparation of a Simulink block diagram ,

117

L{h} =

1 h ( 0 ) [k 2 L{qh } + k3 L{qc }] + s k1 s k1

(c)

Applying similar operations on the temperature model yields

L{T } =

1 T ( 0 ) [k6 L{qh } + k7 L{qc }] + s k5 s k5

(d)

In fact, (d) may be edited from (c) by appropriate substitutions after comparison of (a) and (b) ! A Simulink block diagram of (c) and (d) for
Gain1 [ k2 dqh + k3 dqc ] 1 dqh Gain2 2 dqc [ k6 dqh + k7 dqc ] k6 Gain3 1 s-k5 Transfer Fcn2 deltaT 2 dT k3 k2 1 s-k1 Transfer Fcn1

h(0) = 0 , T (0) = 0 is given below:


deltah 1 dh

k7 Gain4

The LT of h and

T may also be expressed as explicit first order functions of LTs of qh , qc :

L{h} = L{T } =

1 k k2 L{qh } + 3 L{qc } + h ( 0 ) s k1 s k1 s k1 k6 k 1 L{qh } + 7 L{qc } + T ( 0 ) s k5 s k5 s k5

This may be presented using elementary matrix operations:

k3 h ( 0 ) k2 sk { } { } L q L h s k1 s k1 h 1 + = L{q } L{T } ( 0 ) k k T 6 7 c 1 4 24 3 1 4 24 3 s k5 s k 5 s k5 Vector of Vector of 1 4 4 4 2 4 4 4 3 1 4 24 3 Output Transfroms Input Transforms


Matrix of Transfer Functions

Vector of Initial Condition Terms

Due to our earlier definition on LT of a vector function we may present this in the form

k3 k2 qh h s k1 s k1 L = L + k6 k7 qc T 14 24 3 1 4 24 3 s k s k Transform of 5 5 44 1 4 2444 3 Transform of


Output Vector : Y (s) Transfer Function Matrix G ( s ) Input Vector : U (s)

(s)

Initial Condition Term:

h(0) sk 1 ( 0 ) T s k5 4 1 24 3

The results is of the form 118

Output Transform

Y (s) {

Transfer Function ( Matrix )

G (s) {

Input Transform

U ( s) {

Initial Condition Term

(s) {

The Transfer Function Matrix is here

k2 s k 1 G( s ) = k 6 s k5
Remarks

k3 s k1 k7 s k5

1. The TFM is the Jacobian of the Output Vector Transform with respect to the Input Vector Transform ! 2. The fact that some tfs of the TFM above have a common denominator polynomial is interesting. This can be understood by a careful study of the Simulink block diagram above. This topic will be discussed later.

Below find something for a TITO system:

U1
Y1 G11 G12 U 1 Y = G 2 21 G22 U 2
Y1 = G11 U 1 + G12 U 2 Y2 = G 21 U 1 + G 22 U 2 U2 G 21 G11

+ +

Y1

G12

+ +

G22

Y2

6.3 TFM of a ss system (tf) Lets take a look on the TFM of a LTI state-space model. DB 3.3 , 3.7 and Burl 2.3 , 2.5 , 2.6 , 5.1 , 4.3 , discuss this topic. Below pieces of their knowledge is collected for convenience. Lets start with the state ODE :

& = A x + B u x

(equality of time domain functions) (equality of Laplace transforms) (Sum Rule) (Gain Rule for constants A ja B ) (notation for transforms)

&} = L{A x + B u} L{x &} = L{A x} + L{B u} L{x &} = A L{x} + B L{u} L{x &} = A X ( s ) + B U ( s ) L{x

119

s X ( s ) x (0) = A X ( s ) + B U ( s ) s I X ( s ) A X ( s ) = x (0) + B U ( s )

(Derivative Rule) ( I for matrix compatibility !)

( s4 I A) 1 2 4 3
Polynomial Matrix

Response Transform

X ( s) = {
1

Initial Value Term

x (0 ) {

Matrix Input Polynomial Transform


1

B {

U ( s) {

(Polynomial Model )

X ( s ) = (s I A) x (0) + (s I A) B U ( s )
G x ( s ) = (s I A ) B
1

(State Transform) (State TFM) (State dc gain!)

Gx (0) = ( A) B
1

Then process the algebraic equation:

y = C x + Du
L{y} = L{C x + D u}

(Output Function) (Output Transform) (Linearity Rule)

Y ( s) = C X ( s) + D U ( s)
Y ( s ) = C (s I A) x(0) + C (s I A) B + D U ( s )
1 1

(Output Transform) (Output TFM) (dc gain , output dc gain)

G ( s ) = C (s I A ) B + D
1

G (0) = C ( A) B + D
1

Above we observe the matrix

RA ( s ) = (s I A) RA ( s ) = L{e At }

It is called the resolvent of

A and is the LT of the state transition matrix,

In fact, this result can be derived by Laplace transforming the familiar matrix ODE

& ( t ) = A F ( t ) , F (0) = I F
the unique solution of which is the state transition matrix. This means that

e At = L1{RA ( s )}
where

L1 denotes element-by-element Inverse Laplace transforms, e.g.


U L1{X } L1{ U } = 1 1 W L { V} L { W }

X L1 V

See DB 3.3 , 3.7 , 6.4 and James for additional knowledge. Inverse Laplace Transform of the system TFM G( s ) is called the weight function of the system and equals to the impulse response matrix, see Burl 2.1 and the CST tool impulse. 120

We may now use the relationship which binds the adjoint, the inverse and the determinant of a matrix. Find info on minor , cofactor, and the adjoint on your books (Burl, too) and/or from Internet, e.g. Wikipedia. A matrix inverse may be written as

M 1 =

adj ( M ) det( M )

This implies for our resolvent

RA ( s ) =
where

adj ( sI A) P s n 1 + ... + Pn = n 1 det( sI A) s + a1 s n 1 + ... + an

det( sI A) = s n + a1 s n 1 + ... + an adj ( sI A) = P1 s n 1 + ... + Pn


P1 = I
Here the scalar denominator polynomial det( sI matrix

A) is the full characteristic polynomial of the

A and the whole ss model. Its zeros (roots) are the eigenvalues of the state-space model.

The output TFM has the structure

G( s ) =
where the

D s n + ( a1 D + CP1B ) s n 1 + ... + ( an D + CPn B ) s n + a1 s n 1 + ... + an

D implies the numerator order which makes the model either biproper or strictly proper

det( sI A) becomes the full (initial) denominator polynomial of the tf while in some cases we might have pole-zero cancellations which sometimes may hide some important see material of BCAT/ATP and Burl 2.6 , 5.1 .

A classical algorithm for computation of the parameters of the det and the adj is available as a m-function, see resolv. Unfortunately, the algorithm is very ill-conditioned and suits only for models with symbolic, integer or rational parameters if suitable arithmetics is used and otherwise possibly for some well-conditioned models of a few states. If you need the resolvent desperately, get it with RA = tf(ss(A,eye(size(A,1)),eye(size(A,1)),0))

Read about TFM zeros from Burl 2.5 (see zero). Note that for all matrices we may write

rank ( M ) = rank ( MM T ) = rank ( M T M )


and that the rank of a square matrix is full as soon as the determinant of the matrix is non-zero. However, use of det is not always clever in such studies when the elements of the matrix have truncated presentations and computations are performed with finite precision while det is OK for matrices with symbolic, integer or rational parameters. In many practical numerical computations we may exploit the singular values of M (see svd, rank) or the condition number of M (cond). Strict rank deficiency occurs iff there is at least a zero singular value or equivalently an infinite condition number. Practical rank deficiency is said to occurs if the condition 121

number is a large finite number. Note that the hints above may be re-used in studies of controllability and observability. The topics mentioned will be discussed in more details soon.

On the calculus of strictly proper SISO tfs Consider computation of the tf of a strictly proper LTI SISO system. Once it is mastered modification needed to biproper models is very simple. There are many classical algorithms for the job. Unfortunately, many efficient algorithms may fail totally with some systems and produce inaccurate results for some other systems. Below a reasonably good yet not fully precise algorithm is presented since it links ss and tf results to each other in a nice way. It is based on a double study of a feedback system illustrated by the following block diagram:

& = A x + B u x y =Cx

u
_

n( s ) d ( s)

Assue first that the number of states is m where m > 1 . The task is to calculate the polynomials

n( s ) and

d ( s ) . Of them d ( s ) is the characteristic polynomial of the matrix A . The coefficients of d ( s ) may be computed once the eigenvalues 1 , ... , m of the matrix A are known by e.g. eig. Then we have d ( s ) = ( s 1 ) ... ( s m )
After the use of eig , e = eig(A) the coefficients of this polynomial may be obtained by using conv many enough times (recursive use of the tool is needed if m 3 ) or with the convenient command den = poly(e) The closed-loop system has now the state space model (see Chapter 4)

& = ( A B C) x + B r , y = C x x
as well as the full tf (if no cancellations will be performed despite of a possible possibility ; see BCAT )

n( s ) n( s ) d (s) Q( s ) = = n( s ) 1+ 1 d ( s ) + n( s ) d ( s)
Now the denominator polynomial of

Q( s ) above,

d clo ( s ) = d ( s ) + n( s )

( A B C ) . Its coefficients can so be computed from the eigenvalues of ( A B C ) using the procedure presented above for computation of d ( s ) !
is obviously the characteristic polynomial of the matrix 122

After that we may solve the coefficients of n( s ) using the fact

n( s ) = d clo ( s ) d ( s )
Complete Matlab details are left for the reader. Note that the operation available by poly (or by conv only ) is not as numerically robust.

6.4 Responses to typical test functions in terms of the tfm Consider a system with tfm G ( s ) and input function u . The following results may be derived using e.g. the partial fraction expansion of the output transform : 1) Response to is of the form

u (t ) = u y (t ) = G(0) u + ...

if 0 is not a pole of G ( G (0) is dcgain)

2) Response to is of the form

u (t ) = u t y (t ) = G (0) u t + G (0) u + ...

if 0 is not a pole of G . 3) Response to is of the form

u (t ) = u t 2 y (t ) = G (0) u t 2 + 2 G (0) u t + G (0) u + ...

if 0 is not a pole of G 4) Response to is of the form if

u (t ) = u exp( p t ) + ... y (t ) = G ( p) u exp( p t ) + ...

p is not a pole of G
u(t ) = u sin( t ) with real parameters u ,
y (t ) = Re{G ( j )} u sin( t ) + Im{G ( j )} u cos( t ) + ...
(freqresp, frd , nyquist)

5) Response to is of the form

if j is not a pole of G 6) Response to is of the form

u (t ) = u cos( t ) with real parameters u ,


y (t ) = Re{G ( j )} u cos( t ) Im{G ( j )} u sin( t ) + ...
(freqresp, frd , nyquist)

if j is not a pole of G

Above G ( j ) is the frequency response of the system, see Burl 2.4. It is well-defined for stable systems, for which it can be viewed as the one-sided Fourier transform of the impulse response matrix g (discussed for ss models by Burl 2.1). For marginally stable systems (like the integrator, I/PI/PID controllers , motors 123

in position control etc.) and unstable systems (like the double integrator) the use of the fr concept and G ( j ) suffers from some lack of mathematical rigor but can provide practical results with true conclusions. CST or some other toolboxes of Matlab provide us with the tools ltifr , freqresp , frd , nyquist , bode , bodemag , Lets explain the core ideas: The state fr (frequency response) is

Gx ( j ) = ( j I A)1 B
It can be computed without actual inversion from

( j I A) Gx ( j ) = B
by e.g. slash. Linear state transformations by eig (or canon/modal) , schur or hess (see Section 2.6) are useful for fr computations if the system has many enough states. Notice that for a diagonal (by eig) or quasi-triangular (by hess or schur) matrix Anew the matrix ( j I Anew ) has the same sparse structure for all frequencies which can be exploited in a sparse slash-type operation. The tool ltifr promises high speed Note that the state dc gain is obtained from Gx ( j ) for

=0

equation from left with the complex conjugate (conj) of ( j I A) to get

The real (real) and imaginary (imag) parts of Gx ( j ) may be found nice equations: Multiply the previous

( j I A) ( j I A) Gx ( j ) = ( j I A) B
Simplifying this gives

( 2 I + A2 ) Gx ( j ) = AB j B
An augmented presentation of this is

( 2 I + A2 ) [Re{Gx ( j )} Im{Gx ( j )}] = [ AB B ]


This can be solved with slash. Again, matrix factors needed for a new frequency can be computed rapidly from those of the first or previous frequency . The IO fr is naturally available as

G ( j ) = C G x ( j ) + D
Sometimes we may need the explicit formulae below:

Gx ( j ) = ( 2 I + A2 ) 1 AB j ( 2 I + A2 ) 1 B G ( j ) = D + C ( j I A) 1 B = D C ( 2 I + A2 ) 1 ( A B ) + j ( ) C ( 2 I + A2 ) 1 B = D (C A) ( 2 I + A2 ) 1 B + j ( ) C ( 2 I + A2 ) 1 B
Show that ss and tf or ss2ft can be used to find the explicit dependence of the real and the imaginary part of the fr on the frequency! 124

6.5 Joining TFM models The topic of this section is forming a TFM (and so FR and so a DCGAIN) model of a system from those of the subsystems. 6.5.1 append Two sensors, controllers, filters etc. or even two multivariable systems operating beside each other:

U1 G1 G2

Y1 U 1 U 2 Y2 G Y1 Y 2

U2

The rationale behind the operation and documentation of append is basd on the model

Y1 = G1 U 1 = G1 U 1 + O U 2 Y2 = G2 U 2 = O U 1 + G2 U 2
The joint model may be presented as

( O a zero matrix with appropriate dimensions ) ( O a zero matrix with appropriate dimensions )

Y1 G1 Y = O 2

O U 1 G2 U 2

Therefore we obtain:

U 1 U 2

G1 O

O G2

Y1 Y 2

The tfm is here

G G= 1 O

O G2

append works even for a larger number of subsystems, for which we also could apply recursive operations:

U1 G1 U2 G2

Y1 Y2

U3 G3

Y3

125

6.5.2 parallel The parallel connection may be modelled as follows:

U
G1 U G2

Y1 = G1 U
+ +

G1 + G 2

U
Indeed,

Y2 = G2 U

Y = Y1 + Y2 = G1 U + G 2 U = (G1 + G 2 ) U
where the TFM is

G = G1 + G 2
6.5.3 series The left system below should be presented in a form used in the right system below:

G1

G1 U

G2

Z
Elimination of the connection transform Z yields

Y = G 2 (G1 U ) = (G 2 G1 ) U
So the series connection above has the tfm

G = G 2 G1
Here the order of the two matrices in the product is in many many cases critical .

6.5.4 feedback The left system below should be presented in a form used in the right system below:

+ _

G1

R
TY

Z
G2

A possible formula of TY is (note the plus sign!) 126

TY = ( I + G1 G2 ) 1 G1

(plus!)

This may be derived from the implicit presentation of Y :

Y = G1 ( R G2 Y )

(minus!) (minus!) (note I for compatibility and the sign change due to a move!) (plus!)

Y = G1 R G1 G2 Y

I Y + G1 G2 Y = G1 R

( I + G1 G2 ) Y = G1 R

Y = ( I + G1 G2 ) 1 G1 R

(plus!)

Another presentation of TY may be found by starting from e.g. an implicit presentations of E :

E = R G2 G1 E

(minus!) (plus!) (plus!) (plus!)

E = ( I + G2 G1 ) 1 R Y = G1 E = G1 ( I + G2 G1 )1 R TY = G1 ( I + G2 G1 ) 1

Find the equivalence of the two presentations of TY from an appendix of Burl! Yet another presentation of TY is obtained from an implicit equation of Z :

Z = G2 G1 ( R Z )

(minus!) (plus!)

Z = ( I + G2 G1 ) 1 G2 G1 R E = R Z = (I ( I + G2 G1 ) 1 G2 G1 ) R Y = G1 E = G1 I ( I + G2 G1 ) 1 G2 G1 R TY = G1 G1 ( I + G2 G1 ) 1 G2 G1
See Matrix Inversion Lemma explained in an appendix of FPW!

Yet-yet another presentation of TY is obtained if G1 is a non-singular square matrix:

TY1 = G11 (( I + G1 G2 ) 1 ) = G11 ( I + G1 G2 ) = G11 + G2


1

TY = (G11 + G2 ) 1
This observation may even be exploited (under the condition mentioned) for calculation of a state space model of TY from those of G2 and a G1 with a non-singular D1 with using inv and parallel !

127

Here even both E and Z may be derived several different presentations. Note that for internal stability both e and z should be bounded for bounded external input functions. See Burl 2.6 , 5.1 .

6.6 On the nominal stability of the closed-loop system A nice block diagram for stability considerations is that of the measurements represented by a vector z : open loop system L = HGF

+ _

F
controller

G
process

H
meas. sys.

Assume, that there are no pole-zero cancellations (see Burl 2.6 , 5.1!)

6.6.1 The Characteristic Equation Yes, see Burl 2.6 , 5.1 to be cautious enough! The Laplace Transform Z of z satisfies the implicit equation

Z = L (R Z )
where R is the Laplace Transform of r and L is the transfer function matrix from e to z ,

L = HGF
(Do you agree with the order of multiplication?). Equation of Z can be presented in the form

( I + L) Z = L R
For poles of the closed loop system the matrix ( I + L) is singular, which means that

det( I + L) = 0
This condition called the characteristic equation, defines the poles of the system. Singularity of ( I + L) also means that there exists a vector v 0 such that

( I + L) v = 0
But this may be written in an interesting eigenvalue form,

L v = (1) v
So for a pole (or eigenvalue) s of the closed loop system The number ( 1 ) is an eigenvalue of the matrix Let

L( s )

an [Q ]

denote an eigenvalue of the matrix

Q . The eigenvalue condition may now be written as

an [L( s)] = 1

128

6.6.2 Marginal stability Lets now study marginal (critical) stability. Repeat first DB 6.1 , 9.1, 9.3 , 9.4. Marginal stability implies that the eigenvalue condition above is satisfied at least on a point s = j of the imaginary axis but on no points right to the imaginary axis (Caution: Note that even some unstable systems may have poles on the imaginary axis!). If the system has real parameters the condition for 0 is also satisfied on the complex conjugate point s = j . The condition for s = j becomes

an [L( j )] = an [H ( j ) G ( j ) F ( j )] = 1
Then linear combinations of the elementary functions sin(t ) and cos(t ) may be found from typical responses. The period of oscillation of these linear combinations is

T =

In analysis of the eigenvalue condition use e.g. freqresp, frd, series, frdata , sort , angle, unwrap, abs , eig. Sorting may be needed, since it may sometimes be difficult to position an eigenvalue to the appropriate curve. Cures for this problem will be presented in the session.

6.6.3 On Degree of Stability Below a scalar gain margin and a delay margin will be defined by modest extension of the definitions familiar from SISO control. Note, that for multivariable systems a few other more advanced definitions may be possible and relevant. It will be assumed, that the process is either stable or marginally stable. Let the nominal model of the open loop system be the closed loop system is stable, if Upper Gain Margin open loop system

Ln . Assume a stable or marginally stable process and that

L = Ln .

g m is defined to be the smallest number p above unity , p > 1 , for which an actual

L = p Ln
yields a marginally stable closed loop system. Compare this definition with that of DB 9.4!). The number g m will be found by performing the analysis of DB to the Nyquist curves of all the eigenvalues of

Ln ( j ) : each curve may give a candidate value of g m , and the smallest of these candidate values is g m .
In fact, if you know the points of the negative real axis where the curves intersect the axis, select the rightmost point ( < 0 ) and obtain the gain margin as g m = 1 / .

Remark. Ability to calculate the gain margin means ability to obtain critical value of a controller gain ?

Delay margin system

d m is defined to be the smallest positive (additional) delay d , for which an actual open loop

L( s ) = exp(d s) Ln ( s)
yields a marginally stable closed loop system. The delay margin the course ACI-20016.

d m is the smallest of the candidate delay margins found for the Nyquist curves of the eigenvalues of Ln ( j ) . A procedure has been explained in

129

6.7. Inverse models revisited Inverses of models or sub-models are used as parts of different compensators. Lets therefore make some new remarks for both tf and ss models. Consider any square system represented by the block diagram below:

U (s)
G (s)

Y ( s)

Here the TFM G is square and is assumed below both to exist on infinitely many points of the complex plane with large enough real parts and to be non-singular at most such points. The inverse system is then defined through the block diagram below:

Y ( s)

G ( s)

U (s)

The CST tool inv (help lti/inv) may sometimes be used for inversion of tf and ss models. The newest version may introduce a model structure beyond the scope of this course. We will exploit the possibility without understanding the details. Below some limited theory will be given. Lets first show that the inverse of a ss model may be a ss model:

Inversion of a Square Biproper ss Model with a Non-singular Feed-Through Matrix The state space model

& = A x + B u x

(1a) (1b)

y = C x + D u
with

dim( y ) = dim(u )
det D 0
has the inverse ss model

(1c) (1d)

& = ( A BD 1C ) x + BD 1 y x

(2a) (2b)

u = D 1C x + D 1 y

Proof. Get (2b) from (1b). Obtain (2a) by substituting the info of (2b) into (1a). Unfortunately. The model (2a) may be unstable and so unsuitable as a part of a compensator. Remark. If the condition (1d) is not satisfied an inverse model can sometimes be found for if p is large enough a positive integer. See Section 2.8 for hints!

d p y / dt p

130

The result above has a nice corollary for many studies of identification, estimation and control (see appendices of Burl and FPW!)

Matrix Inversion Lemma / Woodbury formula The dc gain matrices of the models (1) and (2) are naturally inverses of each other. Therefore we obtain

( D C A 1 B ) 1 = D 1 ( D 1 C ) ( A B D 1 C ) 1 B D 1
Substitute C = E ,

A 1 = F to get a very useful formula

( D + E F B) 1 = D 1 D 1 E ( F 1 + B D 1 E ) 1 B D 1

The Remark made above has the TFM interpretation

G 1 ( s ) = s p s p G ( s )

A generalization of the tfm trick above is

G 1 ( s ) = DR ( s ) [ DL ( s ) G ( s ) DR ( s )
where DR and DL may be e.g. computations possible or easier.

]1 DL ( s)
tf or ss

diagonal polynomial matrices introduced to make some

6.8 On poles and zeros (Burl 2.5) The claim about complex conjugate poles (and zeros) assumes that the coefficients of the model are reals. The poles and zeros of a state space system are related to e.g. to the response of an exponential input function of the form

u(t ) = u e pt
Call u the amplitude of the input. For this input the state and output output responses of most systems contain an additive term (component) with a similar structure with amplitudes x , y ,

x(t ) = x e pt y (t ) = y e pt
In fact, substituting the presentations (specific trial solutions) above into the ss model gives

x e pt p = A x e pt + B u e pt y e pt = C x e pt + D u e pt
Here we can remove the non-zero exponential function by a division allowed for a non-zero. After that the equation can be modified to the form

pI x = A x + B u

131

y = C x + Du
Lets try to solve the response amplitudes be written as

x and y from the input amplitude u . The first equation may

( pI A) x = B u
If the matrix

( pI A) is non-singular we get the formal solution

x = ( pI A)1 B u = Gx ( p ) u
which implies

y = C ( pI A) 1 B + D u = G ( p ) u
When the condition (2.29) is satisfied, there exists non-zero input amplitudes u for which y becomes zero which eliminates the exponential variation from the output. This is sometimes exploited in to filtering away unwanted components of some functions. Notice that the result above for smoothed differentiation?

p = 0 gives the dc gain which is natural since step functions are related to exponential function obtained for p = 0 . Then filtering means removal of a dc component with

( pI A) is singular , then p is an eigenvalue of A and a pole of the uncancelled tf. te pt . The response then includes e.g. a resonance term of the form u
If the matrix On zeros. The amplitude equations may then be written in the form

( pI A) x + ( B ) u = 0

C x + Du = y
This is equivalent to

pI A B x 0 = C D u y
This has a non-zero solution for zero

y (meaning elimination of the exponential) when the matrix

pI A B M = M ( p) = D C
with

nx + n y rows and nx + nu columns is rank-deficient, i.e.

rank ( M ) < min(nx + n y , nx + nu ) = nx + min(n y , nu )


For a square system this is equivalent to the condition (2.30), otherwise use the result

rank ( M ) = rank ( M T M ) = rank ( M M T )


to get a determinant condition: for while for

n y > nu a reduced rank is obtained iff M T M has zero determinant

n y < nu zero determinant occurs iff the matrix M M T is zero. Note that this trick may be used
132

in studies of e.g. controllability and observability, too.

The result above for p = 0 may be used for some steady-state calculations when we e.g. want to compute initial values for states of some sub-systems. It is needed e.g. for integrating processes where e.g. a trial call of dcgain leads to a problem. For a square system we then try to solve the equilibrium values from

A B x 0 = C D u y
or from the equivalent equality

A B x 0 C D u = y
Amplitude formulae like

y = G( p ) u
for LTI systems are not requiring that the system obeys a state space model but they can also be obtained from appropriate Laplace Transforms by exploiting either the convolution integral transform formula or partial fraction expansion procedure. If the procedures above produce zero y we call p a zero of the system. Then the exponential function is somehow eliminated or filtered away by the system as was proposed above. Note that a single zero at the origin filters a constant function a double zero at the origin filters a ramp function complex conjugate zeros

j , j filter the sinusoidal functions a sin(t ) , b cos(t )

This discussion is related to controllability , observability , minimum realizations (due to possible cancellations) etc. which are related together. Later PC exercise will demonstrate this. To be practical, the mathematical concepts rank and det are quite nave tools for computations where the coefficients are not integer, rational or symbol. See first rank of Matlab and svd called by it. Then look at cond associated with svd. From practical point of view large enough a condition number indicates practical rank-deficiency. Did the transfer function matrices appear here?

133

7.0 A background for norms , weighted norms and their squares in general The norms and weighted norms of Burl 4.5 and CT performance indices used in Burl 4.5 , 6.2 as well as the DT performance indices of FPW 9 can be motivated in several ways. Below a motivation will be explained while another approach will be explained in a later session. Note that the story can even be used for deterministic and stochastic identification, estimation etc. studies. We will start with unweighted vector norms for real vectors. Then weighting will be introduced. Note that in system theory we often introduce expectations, summings and integrations to that kind of objects. In some studies we even integrate sums of expected values ! On vector norms for real vectors Lets study things initially for a real vector of two elements. An engineer may at a time t (not shown

explicitly in formulae for a while) want to have both y1 and

y2 , the elements of the column vector

y y = 1 y2
equal to zero or at least close enough to zero. However, there are some constraints due to resources and other issues which may make reaching the goal exactly impossible or at least hard, time-consuming etc. How can success be measured when the goal has not yet been reached or can not at all be reached? Quite often she/he initially modifies the problem into a problem where she/he attempts to make positive numbers if not equal to zero. If both

y1

y2 small enough

y1

and

y2

are far from zero she/he is sad while success

with one of the variables together with failure with another variable makes her/him to hesitate if the job is well done. To resolve that confusion she/he initially introduces a non-negative scalar performance measure (index) like Sum-of-Absolute-Values ,

J 1 = y1 + y2
to measure success. This is called the L1 (Lebesque) norm of the column vector y and denoted by

= y1 + y2

In Matlab this is available with norm(y,1) . For good job the value of J 1 is small with the ideal value equal to zero while for failure the value is large. For confusing situations J 1 has medium values. Note that

y1 J 1 ,

y2 J 1 J 1 would quarantee success for both y1 and y2 . So she/he

which shows that small enough a value of

might try to minimize J 1 to reach the goals as well as possible. Another performance index, even a more popular one, used to measure closeness to zero of

y1

and

y2

is Sum-of-Squares
2 = y12 + y2 = [ y1

J 2 = y1

+ y2

y y2 ] 1 = y T y = y y2

2 2

where

denotes the Euclidean or L2 (Lebesque) norm of the real column vector y ,

134

= yT y

Note that

y1 J 2 ,

y2 J 2

which encourages to make J 2 small enough by (at least rough) minimization to reach the design goal. Note also that

= J2

= J1

The sum-of-squares above is expressed in terms of an inner product. There exists a convenient outer product providing the individual squares and so also access to the sum-of-squares as many readers have seen in statistics? In fact, for a column vector y the symmetric rank-one matrix

Y = y yT
contains the squareed elements of

y on its main diagonal. For a vector with to elements we e.g. obtain


y1 y2 y12 = y2 y2 y1 y2 y1 y2 = YT 2 y2

y Y = y yT = 1 [ y1 y2

y y y2 ] = 1 1 y2 y1

The sum of the main diagonal elements in defined as


2 tr (Y ) = yk k

Y , i.e. the trace of the matrix Y is denoted by tr (Y ) and

So for our example we have


2 tr (Y ) = y12 + y2 = J2

Even more generally we have


2 yk = y yT

k ,k

2 2

= yk2 = tr ( y yT ) = yT y
k

A more general formula for the so called inner product of the column vectors x and

y is

< x, y > := xk yk = xT y = yT x = tr ( y xT ) = tr ( x yT )
k

In Matlab the Euclidean norm is available with norm(y,2) or by the default choice norm(y) . Note that on a real plane

equals to the shortest distance between the points

(0 , 0) and ( y1 , y2 ) , and it is also

equal to the absolute value (abs) of the complex number ( y1 + i y 2 ) ,

135

y1 + i y2 =

y1 y 2

The benefits and disadvantages of the two norms will be discused in more details later for general column vectors but lets here state that the Euclidean norm leads to easier (yet difficult enough) theory and less demanding computations. Weighting However, in many applications

y1

and

y2 should not be compared with each other directly due to y1


and

scaling matters and possibly different importance (price , utility) of the

y2 in the business. Some

people apply poor scaling or do not at all scale there variables which calls for many problems, even illconditioned matrices with large condition numbers (cond) etc. Note for example that in simultaneous control of e.g. the level and the pressure of a head-box of a paper machine the unit of the pressure, bar and Pa as typical alternatives, may strongly affect to conclusions about success or failure when level values are compared with pressure values since the ratio bar/Pa is so large (how large?). To resolve this problem apply one of the norms defined above for weighted values 1 y1 , 2 y2 where the weights 1 , 2 take care of both scaling and relative importance of y1 and y2 . Lets elaborate this below for only the Euclidean norm used in this course. In fact, to get rid of the complicating square root lets use the squared Euclidean norm. The squared norm of the weighted response is given by

f y = ( 1 y1 ) 2 + ( 2 y2 ) 2
This should be given small enough a value for success. A classical standard presentation of this will first be derived: Computing the squares above yields
2 2 f y = 12 y12 + 2 y2

which is of the form


2 f y = w1 y12 + w1 y2

where w1 , w2 weighting squared function values are the squares of the original weights,
2 w1 = 12 0 , w2 = 2 0

The index

f y to be minimized may be presented several matrix presentations. One of them is given below:
w y y2 ] 1 1 w2 y2

Start by an inner product presentation,

f y = y1 w1 y1 + y2 w2 y2 = [ y1

Here the row vector is the transpose of y while the column vector is y scaled componentwise which (as we have seen in early sessions!) can be modeled using a diagonal scaling matrix to multiply y from left,

f y

y w y + 0 y2 y1 w1 = 1 1 1 = y2 0 y1 + w2 y2 y2 0
T T

0 y1 w2 y2

But this is a quadratic form of the form

f y = y T W y
136

where the weighting matrix W

is

w W = 1 0

0 w2

See Burl 4.5.1 where quadratic forms are related to weighted norms! Here we have a diagonal weighting matrix with non-negative weights on the main diagonal. Another presentation of the weighted performance index is based on the weighted response vector

1 y1 2 y2

The number f y may now be represented as

f y =

2 2

= T = tr ( T )

The weighted response vector may also be presented as a linear function of the original vector,

1 0

0 y1 2 y2

This is of the form

= y
where

M is a diagonal matrix of response weights, here


0 2

M = 1 0

Now all the following presentations are possible:

f y = My

2 2

= yT M T M = tr ( MyyT M T ) = tr ( yyT M T M ) = tr ( M T MyyT )

Here some trace formulae of a Burl appendix were used. This also proposes that

W = MTM
In some studies we may know a real square matrix W for which we should find a real square matrix M such that the equation above is satisfied. In all the cases W is not diagonal. Matlab tools sqrtm and chol can perhaps be applied. Here sqrtm will provide the result if is W a symmetric matrix and has non-negative eigenvalues. The tool chol assumes symmetry and positive eigenvalues for W . For a diagonal W one can get the result in a more evident way?

Reduction of freedom in weighting Notice that the number scalar (while a negative

f y above is minimized by the same design as f y / as soon as is a positive

= w1

would replace minimization by maximization!) . Assuming w1 > 0 and selecting

yields the normalized performance index 137

f y / = 1 y12 +

w2 2 y2 w1

where we have only a single positive parameter ( w2 / w1 ) to be adjusted to yield a good design. Assuming

w2 > 0 and selecting = w2 yields in a corresponding way a presentation with a single positive weighting

parameter,

f y / =

w1 2 2 y1 + 1 y 2 w2

There still exists an interesting choice for normalization: for

= w1 + w2 > 0

we obtain

f y / =

w1 w2 w1 2 2 y12 + y2 = y12 + (1 ) y2 , 0 = 1 w1 + w2 w1 + w2 w1 + w2

where proper adjustment of

on the closed range may lead us to success.

Before generalization lets us apply the results above for SISO control and make some practical comments, too:

Application to SISO control In SISO control with zero set point we wish to have the process output close enough to zero but without excessive control actions, which means that we want to keep the controller output close to zero, too. We may try to reach this goal by applying the ideas and the math above so that y1 above is the process output y (do not confuse with the previous vector y ) while y 2 above is the controller output u . Then , using the standard notation, we typically have for each interesting time instant of a time range the quadratic performance index

J = q y 2 + r u 2 with q > 0 , r > 0


This is in some studies written in the matrix form

y q 0 y J = u 0 r u
The cost may be replaced (according the observations above) by a scaled performance index to reduce the number of weighting paramters by one. There are several suitable scaled costs for the purpose, e.g. all the single-parameter costs below:

Jq =

J r r = 1 y 2 + u 2 , 0 < < q q q

Jr = J qr =

J q 2 q = y + 1 u 2 , 0 < < r r r J q r q = y2 + u 2 = y 2 + (1 ) u 2 , 0 < = <1 q+r q+r q+r q+r J q . However, many practitioners (engineers,

Of these many writers use cost function structures resembling process operators etc.) regard the tuning parameter stable plants increasing the ratio

r / q as inconvenient since for typical stable and marginally

r / q typically implies a modified optimal design which yields to slower


138

control which is against intuition of the operator. This problem can be avoided by minimizing J r where reoptimization with a larger the tuning parameter transient. The advantage is also shared by

q / r typically yields a modified design which speeds up the

a design with a smaller . Here it is also nice to have the tuning parameter bounded from both below and from above. The smallness of the unity upper bound is convenient from numerics point of view. However, there are enough numbers on the range from zero to the unity value, and on some subranges minor changes of may change the design in a considerable way.

J qr where designs for larger values of typically yield more speed

Generalization for several variables with application to TITO control If we must have more than two variables close enough to zero we can generalize the ideas and the math presented above for a larger set of variables in an obvious way. Lets study this with a practical motivation for a typical control cost of a TITO system using typical notation: In TITO control with zero set points we wish to have the two process outputs close enough to zero but without excessive control actions, which means that we want to keep the two controller outputs close to zero, too. At a time instant we may try to reach this goal by limiting a control cost of the form
2 2 J = q1 y12 + q2 y2 + r1 u12 + r2 u2

where all the the weights are at least non-negative. In flexible (high order) enough CT control of especially delayless systems positive input weights are typically used to prevent the optimization from producing designs which makes a control input or even several control inputs unbounded. The local cost may be written e.g. in the form

J = y1 q1 y1 + y2 q2 y2 + u1 r1 u1 + u2 r2 u2 = [ y1

y2

u1

q1 y1 q y u2 ] 2 2 r1 u1 r2 u2

This implies the quadratic form

y1 q1 0 y 0 q 2 J = 2 u1 0 0 u2 0 0

0 0 r1

0 y1 0 y2 0 u1 0 r2 u2

However, it is more common to separate between the process response and controller output terms. For the current example this means using twice the formulae derived for two variables. This yields the expression

y q 0 y1 u1 r1 0 u1 J = 1 1 + y2 0 q2 y2 u2 0 r2 u2
which can be formed from both of the two latest equations. This is of a more general structure

J = y T Qy y + u T R u
with two quadratic forms in which

Q y and R are diagonal matrices with non-negative diagonal entries.

Concerning scaling of the cost to remove an adjustable parameter we could use e.g. the normalized cost

139

J q1 2 q2 2 r 2 = y1 + y2 + 1 u12 + 2 u2 r1 r1 r1 r1
with three free positive weighting parameters.

Non-diagonal weighting matrices may arise! Suppose that

y is a linear function of another vector , say vector x ,

y =Cx
Now we have

yT = xT C T
Putting this into the latest quadratic form of

y yields

J y = y T Q y y = x T C T Q y Cx
This is a quadratic form of the form

J y = xT Q x
where we have the weighting matrix

Q = C T Qy C

Q is not diagonal but it is always symmetric. This can be shown in many ways, e.g. by T T T T T T showing that Q = Q by repeated use of ( KL) = L K and the facts Q y = Q y , ( M ) = M :
In general the matrix
T T T T Q T = ((C T Q y ) C )T = C T (C T Q y )T = C T Q T y (C ) = C Q y C = Q

Using this we obtain the local cost the presentation

J = x T Q x + u T Ru
Remark. Recall the possibility to use the trace function, e.g.

J y = xT Q x = tr (Q xxT ) = tr ( xxT Q)
Remark. Sometimes quadratic forms like x Q x appear with a non-symmetrix matrix be a problem for a particular software to be used. In that case one can exploit the equality
T

Q which might

xT Q x = xT

Q + QT x 2

where the new weighting matrix on the right is symmetric. In fact, many subroutines use statements like Q = (Q + Q')/2 (here Q' gives the transpose for a real matrix only!) to force desired symmetry (proposed by theory) the existence of which is threatened by input from the user or inaccuracies of numerical computations. Note that this 140

observation is also applied when the Hessian matrix of a function of several variables is defined to be symmetric which is not forced by theory.

On definity All the eigenvalues of each symmetric (and so square) matrix eigenvalues of

Q are real numbers. Above the

Q are also non-negative due to the obvious non-negativeness of the quadratic form implied T by its original definition as weighted squares with non-negative weights. The minimum of x Qx for a vector x not equal to the zero vector is then either zero or positive. It is positive iff all the eigenvalues of Q are positive; then we say that Q is positive definite. The minimum is zero if 0 is an eigenvalue of Q then we say that Q is semipositive definite. It is wise to check that the eigenvalues of Q are satisfactory
Performance Over Time A study described above is often needed for several time instants between an initial time and an end time. We can form a local quadratic performance index for each time! In e.g. a control design problem an obvious problem is to decide how all the quadratic forms are taken into account to judge goodness of control. Well, lets reuse the idea of the story above, i.e. lets define from all the quadratic forms from different times a nonnegative scalar performance index with or without weighting in the time direction. In DT control (see FPW 9.4) this means summing the desired quadratic form over sampling instants. Here we are interested on a CT study where we might want to have a quadratic form for any time instant on the interesting range. The number of such times is infinite even for a finite time range. Therefore the summing over times must be represented in terms of integration over time. Burl 4.5.1 and 4.5.2 introduce for such integrals suitable structures with optional time weighting. Burl 6.2 seems at the first sight to use pure integration of the quadratic form without time-weighting but adds a terminal cost term which is a quadratic form of the Stop Time value y ( t f ) . This terminal cost could in principle be taken into account inside the integral if the unit impulse function is exploited to create an appropriate term there (see Burl 2.1 , too!). So the cost in essence uses time-weighting. Moreover, the theory for time-variant model parameters and time-variant weighting matrices is not much more complicated. The integral of a non-negative quadratic form has a nice interpretation since the integral of any non-negative scalar function over a time range also is the area of the region below the curve inside the time range , above the the time axis and right to the vertical axis: in the figure below you see the plot of a quadratic form with the area as shaded:

The quadratic form is desired to be close to zero. A nice measure of the closeness is the value of the area? Yes, rapid enough a decay of the quadratic form and so rapid decay of the original variables towards zero is obtained when the area is small while a large area indicates problems in convergence due to either excessive overdamping or excessive underdamping. Flipud this page by a rotation of 180 over the horizontal direction to justify terms like Rise Time and Settling Time of DB 5.3 in this discussion and to use ISE figures of DB 5.7 of 11th edition or DB 5.9 of 10th edition.
o

141

7.1 Introduction to Integral of Squared Error and related Math Responses of CT control systems are sometimes analyzed and designed based on quadratic performance indices. They are often applied in formulating a control design problem to a parametric optimization problem. However, the same and similar performance indices are used even for other tasks. For example, modelling errors in identification and model reduction problems as well as estimation errors are frequently characterized in terms of these indices or their modifications and extensions. Consider next a situation where two response functions, y1 and y2 , should converge from non-zero initial values to zero within an infinite time range or to values close enough to zero within short enough a finite time range. Success or lack of succes is sometimes measured in terms of suitable non-negative numbers associated with the responses. Sometimes absolute values

y1 and y2 at many enough time instants are


2 2

relevant and selected for this study. However, for responses of LTI systems squares y1 and y2 are more convenient than the absolute values, since there are many more theoretical results as well as symbolical and numerical algorithms developed for the squares. Moreover, for the squares the time range may easily be extended to infinity without considerable additional difficulty or even to make the evaluation of the indices easier! In addition, squares emphasize and thus reveal errors far from zero (error) in a better way than the absolute values. Unfortunately, the squares tend to almost hide errors close enough to zero. In the figure below example responses y1 , y 2 and their squares and regions below the squares are shaded:
2 4 3 y2 1 2 1 -1 0
2 y12 , y2 are plotted for a finite time range,

1 y1 0 0

0.5

1.5

2.5

0.5

1.5

2.5

60

0 y2 y2 2 -5

40

20

-10

0.5

1.5

2.5

0.5

1.5

2.5

The end (stop) time of the time range is called the horizon. Above it is equal to 3 . The areas of the shaded regions below (the non-negative) squares , right to the vertical axis and above the time axis are used as measures of success. Convergence towards zero (within the time range selected) is regarded as efficient, if the area is close enough to zero note that ideal error response would be the zero function, for which the corresponding area would equal to zero, the theoretical lower bound of a non-negative area below the curve of a non-negative function! Convergence is regarded as inefficient (poor), if such an area is too large but finite. If there were no convergence at all , the area for the infinite horizon would be unbounded (infinite). Large areas below squared errors may follow for both very slow monotone decay to zero (excessive overdamping) and for very oscillatory responses (excessive underdamping). Small areas are typically obtained for responses which are lightly underdamped, critically damped or lightly overdamped. The area below the squared response
2 yk for the horizon h may be presented the integral formula

ISE [ yk ] =

h 0

2 yk (t ) dt

(1)

142

where ISE abbreviates Integral-of-Squared-Error. The square root of ISE is called the L2 -norm of y k , the letter L due to Lebesque . General results for squares are discussed below: Squares of elements of a vector and their integrals In system theory squares of variables are often needed for modelling , estimation , control etc. errors as well as for transients of several other functions (transients or derivatives of controller outputs etc.). We may be interested in only the squares or integrals , sums or expected values of squares or even expected values of sums of integrals etc. ! If the variables in question are elements of the same column vector x , the squares are available conveniently by a square symmetric matrix, namely the outer product

V = x xT = V T

(outer product)

Indeed, the squares of elements of x are the (main) diagonal elements of V ,


2 xk = x xT

kk

(on the main diagonal, row k , column k )

Let x be a function of continous time. Then V is a function of continous time, too. The integrals of these quantities over the time range (0, h) are (see Burl appendix A1.1)

X = V (t ) dt = x(t ) xT (t ) dt
0 0
2 J k = xk (t ) dt = 0 h h 0

[x(t ) x (t )]
T

k ,k

h dt = x(t ) xT (t ) = X k , k 0 k ,k

The results are illustrated for dimension 3 of x below :

x1 T x x = x2 [x1 x3

x2

x1 x1 x3 ] = x2 x1 x3 x1
x1 x2 x x2 x3
2 2

x1 x2 x2 x2 x3 x2

x1 x3 x12 x2 x3 = x1 x2 x3 x3 x1 x3
1 2

x1 x2 x x2 x3
1 3 2 2

x1 x3 x2 x3 2 x3

x12 x xT dt = x1 x2 x1 x3

2 x1 x3 x1 x2 x3 = ( x1 x2 ) 2 x3 ( x1 x3 )

(x x ) (x x ) x ( x x ) (x x ) x
2 2 2 3 2 3 2 3

Here the main diagonal elements are interesting! In many studies we also have another vector of y may be evaluated using V :
2 y = C x yk = y yT

y , which is a linear function of x . The squares of the elements

kk

2 = yk = C x xT C T

kk

= C V CT

kk

where we used the important transpose of product formula

( M N )T = N T M T

V is at least positive semidefinite (has non-negative eigenvalues ; symmetric real T matrices always have real eigenvalues). The matrix CVC is symmetric and at least positive semidefinite, too. 2 In fact, lack of positive definiteness would claim a non-negative y k to be negative for some choices of C !
The symmetric matrix

143

7.2 State-space computation of the ISE numbers The theorems below present some ISE formulae for the natural response of a LTI system. The claims are partly based on the response math, the formulae above, partly to a later derivation and on the result

( e At )T = e A t , too.
T

THEOREM 1. If

y =Cx
& = A x x
then the ISE numbers of the the outputs and the states for the horizon h are given by (2a)

ISE [ yk ] =

h 0

2 yk (t ) dt = C X C T

kk

ISE [xk ] =
where

h 0

2 xk (t ) dt = X kk

(2b)

X is the symmetric and positive definite or semidefinite matrix


h 0

X =

x(t ) x T (t ) dt =

h 0

e At x(0) x T (0) e A t dt
T

(2c)

which satisfies the symmetric algebraic Lyapunov equation

A X + X AT = x( h ) x T ( h ) x(0) x T (0) x( h ) = e Ah x(0)


from which the matrix

X can be solved uniquely if all the eigenvalues m of A satisfy the inequalities

m r
for both

r m and r = m (the latter requiring that A has no zero eigenvalues).

Remarks The existence of eigenvalue conditions can be guessed by trial use of the theorem above for a system with a diagonal A (due to e.g. diagonalization by e.g. canon or eig). The same condition also exists for non-diagonalizable systems. When the condition is not satisfied use the matrix ODE derived below. The Lyapunov matrix X contains n elements where n is the dimension of x . However, due to symmetry it suffices to solve the n main diagonal elements and the n( n 1) / 2 elements
2

n( n 1) / 2 elements below the main diagonal with the rule X ( r, c ) = X ( c, r ) for r > c . Therefore there are only n( n + 1) / 2 unknown elements in X .
above the main diagonal and use then symmetry to specify For an internally stable system the algebraic Lyapunov equation of the matrix horizon h = will be simplified (!) to

X for an infinite

A X + X AT = x(0) x T (0)
144

due to the convergence of

x( h ) to zero. The eigenvalue condition above is satisfied by stability!

The L2 (Lebesque) norm of the unit impulse response of a SISO system is called the H 2 norm of the system. It is used to measure the strength of the system. See: help lti/norm Note that the ISE number associated with an unstable state ODE may be finite for pathological choices of the initial state. This topic will be further discussed later. Recall the possibility to view the natural response above as a virtual unit impulse response of the single input system ss( A, B, C ,0) with B = x (0) and vice versa. This means that the ISE

y with a strictly proper Laplace transform Y ( s ) can be found by regarding Y ( s ) as a virtual tf due to a state-space model, the B of which is used to replace x(0)
number of a scalar function in the theory above. This convention will be adopted below every now and then. The algebraic Lyapunov equation may be solved with lyap if the eigenvalue condition is satisfied. The tool lyap2 may be used for diagonalizable systems. The tool lyapchol suits for e.g. the computation of the infinite horizon ISE associated with a stable system. On the derivation and usability of the Lyapunov formulae A derivation of Theorem 1 is based on integrating both sides of a matrix ODE of the outer product

V = x xT
over the interesting time range. The ODE is

d &=x & xT + x ( xT ) = Ax x + x ( x & )T = AV + x xT AT = AV + VAT V dt


This derivation is parallel to that in Appendix A7 of Burl. However, we need other also other related matrix integrals, and in some cases we need alternate algorithms for practical computations. Accept therefore the following: Algebraic and differential equations of Lyapunov are special cases to those of Sylvester associated with Sylvester integrals of the form

S (t ) =

t
0

e Tr W e Mr dr =

t
0

eT ( t r ) W e M ( t r ) dr

The two forms in the double equation above are related to each other through change of integration variable. The matrix X is obviously S ( h ) for T = A , M = A . W = x (0) x (0) .
T T

Differentiate the double equation above with respect to t from very left to very right using Exam Tables. The crucial key formula is
b ( t ) f (t , r ) d b (t ) db(t ) da(t ) f t r dr = f t b t f t a t + ( , ) ( , ( )) ( , ( )) a (t ) t dr dt dt a ( t ) dt

which implies for the current problem the simpler yet sufficient variant

d dt

t 0

f (t , r ) dr = f (t , t ) +

t 0

f (t , r ) dr t

Use this and a few other formulae to get the double equation

145

& (t ) = eTt W e Mt = eT ( t t ) W e M ( t t ) + S

t 0

{ eT ( t r ) W e M ( t r ) } dr t

= eT ( 0 ) W e M ( 0 ) +

t 0

M (t r ) T (t r) e W e M ( t r ) + eT ( t r ) W e dr t t

Inside the integral use different (!) derivative formulae for the two exponential matrices to get

& (t ) = eTt W e Mt = I W I + S

t 0

(T e

T (t r )

W e M ( t r ) + eT ( t r ) W e M ( t r ) M ) dr

The integral may now be splitted into a linear combination of two integrals,

& (t ) = eTt W e Mt = W + T t eT ( t r ) W e M ( t r ) dr + t eT ( t r ) W e M ( t r ) dr M S
0 0

In fact, we find here S ( t ) in two positions and can thus write our double equation in the form

& (t ) = eTt W e Mt = W + T S (t ) + S (t ) M S
This contains both the algebraic linear matrix equation

T S (t ) + S (t ) M = e Mt W e Mt W
called algebraic Sylvester equation (see lyap) and the linear matrix ODE , Sylvester differential equation

& (t ) = T S (t ) + S (t ) M + W S
S (0) = O
Conditions for solvability of the algebraic Sylvester equation can be guessed by trial solution of S for diagonal matrices T and M . The condition for their diagonal elements is obviously the condition for the eigenvalues of more general matrices T and M . Failure occurs iff there exists at least an eigenvalue of T and at least an eigenvalue of M the sum of which is zero. In the Lyapunov case we have T = M which makes the eigenvalues of T to be those of M , which together with the eigenvalue condition of the Sylvester equation implies the condition of Theorem 3. When the eigenvalue condition is not satisfied use the ODE . However, be then careful with the accuracy settings of the ODE solver. Note also that a lot of computation may be needed for a large horizon and that the result for the infinite horizon must be estimated using a truncated finite-horizon one.
T

The algebraic Sylvester equation can also be derived in many other ways. Some procedures use integration by parts while some procedures first form the ODE of the integrand which is then integrated side-by-side. Both types of procedures also exploit the two different (!) matrix ODEs of the exponential matrix. In some of the procedures one collides to the inverse of either T or M which makes one to wonder if the Sylvester equation is useful for a singular T or for a singular M . Some other derivations/proofs starting with integration by parts of TS or SM are not revealing this possible problem as clearly.

Example. Lets verify the Lyapunov formulae for a scalar function

y such that

y (t ) = b e at , t > 0
where a is a real parameter. Its ISE for a finite positive horizon h is

ISE [ y ] = (b e at ) 2 dt = b2 e 2 at dt
h h 0 0

146

b2 b2 2 ah + e 2a 2a ISE [ y ] = b2 h

, ,

a0 a=0

Consider now the limit of this for an infinite horizon, h = . If b 0 , i.e. if the function y is not the zero function, the result for h = is infinite for both a = 0 and a < 0 . This happens because y is of exponential form but not decaying to zero. For a > 0 we obtain a finite result

ISE [ y ] =

b2 for a > 0 , h = 2a

due to zero final value of

e 2 ah after an exponential decay. y is

Try now to get the result above using the Lyapunov theory: the strictly proper Laplace transform of

Y (s) =

b s+a

This has a single pole, the number ( a ) . This has a negative real part implying a finite value of the infinite horizon ISE iff a > 0 . Regard now Y ( s ) as a virtual tf. The parameters of the corresponding state-space model are the scalars

A = a , B = b , C = 1
The Lyapunov equation becomes, since for scalars

A and B we obtain AT = a and B T = b ,

a X + X ( a ) = b b
Here the two scalar-valued products on the left happen to be equal to each other yielding

2a X = b b
The solution of this scalar Lyapunov equation is

X=

b2 2a
for a > 0

So we obtain

b2 ISE [ y ] = 1 X 1 = X = 2a

while ISE [ y ] is infinite for a 0 . The correct result!

Example. Consider a function

y with the minimal transform

Y (s) =

b1 s + b2 s + a1 s + a2
2

Minimality means here that the possible zero of the transform differs from both poles so that no pole-zero cancellation can not be performed. The stability condition necessary to get a finite infinite horizon ISE 147

is here a1 > 0 & a 2 > 0 (DB 6.2). Regard space matrices of the virtual system is

Y ( s ) as the tf of a virtual system. A suitable set of state-

a A= 1 a 2

1 b1 , B = , C = [1 0] 0 b2

This follows from a procedure of DB 3.4. See Appendix, too. Moreover, it follows from the result used by tf2ss and application of duality discussed soon. The symmetric Lyapunov matrix is now of the form

X X = X T = 11 X 12

X 12 X 22

The ISE number is here

ISE [ y ] = C X C T = X 11
The Lyapunov equation now becomes

a1 a 2

1 X 11 0 X 12

X 12 X 11 + X 22 X 12

X 12 a1 X 22 1

a2 b = 1 [b1 0 b2

b2 ]

Performing the matrix multiplications yields

a1 X 11 + 1 X 12 a X + 0 X 12 2 11

a1 X 12 + 1 X 22 X 11 a1 + X 12 + a2 X 12 + 0 X 22 X 12 a1 + X 22

X 11 a2 b b b b = 1 1 1 2 X 12 a2 b2 b1 b2 b2

Note that the second matrix on the left is the transpose of the first matrix on the left! Summing them yields

a1 X 11 + X 12 X 11 a1 + X 12 a X X a + X 2 11 12 1 22
and

a1 X 12 + X 22 X 11 a 2 b12 = a 2 X 12 X 12 a 2 b1 b2

b1 b2 2 b2

2 a1 X 11 + 2 X 12 a X + X X a 22 11 2 1 12

a1 X 12 + X 22 X 11 a 2 b12 = 2 a 2 X 12 b1 b2

b1 b2 2 b2

Here we have a symmetric matrix on both sides Comparison on row 2 , column 2 gives the identity and the result

2 a 2 X 12 = b X 12
2 2

2 b2 = 2 a2

This is well-defined for a stable system with a 2 > 0 . Comparison on row 1 , column 1 yields

2 a1 X 11 + 2 X 12 = b X 11
2 1

2 X 12 + b12 = 2 a1
X 12 solved above it becomes

This number, ISE [ y ] , is well-defined for a stable system with a1 > 0 . For

148

X 11 =
Now

2 2 + a2 b12 1 b2 b2 2 + = 2 b 1 2 a1 2 a1 a2 2 a2

if a1 > 0 & a 2 > 0

1 ISE [ y ] = [1 0] X = X 11 0
Therefore, if

y is not the zero function ,


, a1 > 0 & a2 > 0 otherwise

2 b2 + a2 b12 2a a 1 2 ISE [ y ] =

7.3 Frequency Domain Computation of ISE The infinite horizon ISE number associated with a strictly proper Laplace transform may also be given a frequency-domain presentation (under the stability assumption) . This fact is based on the so called Parseval formula associated with the Inverse Fourier transform formula or the Inverse Laplace transform formula of Mellin (DB 2.4 , 8.1). The result is applied for empirical data e.g. when all the models needed are not known in a parametric form. It is also needed for some complicated time-delay systems. The original integrals in question are line integrals on the complex plane. However, they can be transformed to integrals of a real variable by an appropriate change of the integration variable. This yields

ISE [ y ] =

1 Y ( j ) Y ( j ) d 2

(5c)

Here the integrand Y ( j ) Y ( j ) is an even function of

and the range of integration is symmetric

with respect to = 0 . This symmetry means that the whole integral is obatined by multiplying that for 0 < by two. Hence we obtain

ISE [ y ] =

Y ( j ) Y ( j ) d
0

But here Y ( j ) and Y ( j ) are complex conjugates of each other: regard Y again as a virtual tf and think the symmetry of the Nyquist diagram of this tf over

= 0 ! The conjugacy implies here the result

Y ( j ) Y ( j ) = Y ( j )

Therefore we may write ISE as

ISE [ y ] =
Example

Y ( j ) d
2

Try now to re-derive the first-order result of Section 7.2 result using the Parseval theory which assumes exponential convergence of y to zero, i.e. here the condition a > 0 . Here

149

Y ( j )

b = j + a

2 2

j + a

1 b b2 a = 2 = = + a2 2 a 2 +1 +1 a2 a
2

b2 a2

The Parseval integral now becomes

ISE [ y ] =

1 1 b2 b2 a = lim d a a 2 +1 a

arctan a

1 b2 a

0 lim arctan arctan a a

For a > 0 we obtain


2 1 b2 b for a > 0 ISE [ y ] = 0 = a 2 2a

which is the correct result. Recall that the Parseval formula is here not relevant for a 0 . The theory of this section is often used to estimate ISE roughly by performing truncated integration with a suitable numerical integration algorithm. Then the upper bound of the integration is replaced by large enough a positive number. 7.4 ISE for a scalar function with a non-rational Laplace Transform In feedback system with a single open loop delay we often have an interesting error function, the Laplace transform of which is the form

V ( s) =
where

B( s ) + exp( h s ) D( s ) A( s ) + exp( h s ) C ( s )

A , B , C and D are polynomials such that their polynomial degrees satisfy the inequalities

deg B < deg A


deg D < deg C
and all the poles of V have negative real parts typically due to the stability of the closed-loop system (most often demonstrated using the open loop frequency response) . Then the ISE function is of the form

v 2 (t ) dt =
m

G ( z m ) B( z m ) + D( z m ) exp( h z m ) F ( z m ) A( z m ) + C ( z m ) exp( h z m )

where F and G are polynomials given by the formulae

F ( s ) = A( s ) A( s ) C ( s ) C ( s ) G ( s ) = A( s ) B( s ) C ( s ) D( s )

150

and the numbers z m are the zeros (roots) of the polynomial

F.

Hence, elementary polynomial operations are needed and sufficient to get ISE which is quite easy in Matlab (conv , polyder, roots, ). This nice result is picked from the book J. E. Marshall, H. Gorecki, K. Walton, A. Korytowski: Time-Delay Systems. Stability and performance criteria with applications, Ellis Horwood 1992 which also includes some time domain methods. The last chapter of this book discusses optimal PID control of delayed systems.

Example. In BCAT we saw the Laplace transform

V ( s) =

1 s + k exp( s )

(1)

in a study of critical damping. For that application we later found the stability condition

0 < k < /2
using the open loop frequency response. This is also the sufficient and necessary condition for v to converge to zero and to have a finite ISE . The theory above may be used to get the formula

ISE =

cos( k ) 2 k (1 sin( k ) )

0 < k < /2

This is minimized at k 0.739 which was found in a Voluntary Extra PC session with two methods. 7.5 Duality (Burl 2.1 , 4.5.4 , ) The ISE results and related results may be presented duals , i.e. dual results. This fact is based on the fact that the impulse response matrices of the state-space models

ss( A, B, C , D )
and

ss( AT , C T , B T , DT )
are transposes of each other: that of ss( A, B, C , D ) is

g (t ) = C e At B + D (t )
while that of ss( A , C , B , D ) is
T T T T

(6a)

B T e A t C T + DT (t ) = B T ( e At )T C T + DT (t ) = C e At B + (D (t ) ) = g T (t )
T

(6b)

This also means that the transfer function matrix of


T T T T

ss( A, B, C , D ) is the transpose to

that of ss( A , C , B , D ) which can also be shown using formulae of Exam Tables. The state space models

ss( A, B, C , D ) and ss( AT , C T , B T , DT ) are called the duals of each other.

CST allows transposing the model object as if it were an ordinary matrix. How? Consider now this duality for a stable strictly proper SISO system for which g
T

equals to

g.
151

For the model ss( A, B, C ,0) Section 7.2 gives the ISE number

J =

g 2 (t ) dt

the presentation

J = C X CT A X + X AT = B B T
For the equivalent SISO model ss( A , C , B , D ) the corresponding result is
T T T T

(7a) (7b)

J = BT X d B AT X d + X d A = C T C
The formulae (8) are equivalent to to the formulae (9) (not only in the current context but) always when A is a square matrix with n rows, B is a column vector with n rows and C is a row vector with n columns. The symmetric matrix X is called the controllability grammian (gram) of the SISO system ss( A, B, C ,0) while X d is the observability grammian (gram) of ss( A, B, C ,0) . The system is controllable iff X is positive definite and observable iff X d is positive definite.

(8a) (8b)

The symmetric matrix X is also the observability grammian of the SISO system ss( A , C , B ,0)

X d is the controllability grammian of ss( AT , C T , B T ,0) . The system is observable iff X is positive definite and controllable iff X d is positive definite. Grammians of MIMO systems
while are discussed in Burl 4.5.4 . The number

J is the H 2 norm of the system (help lti/norm). Norms are discussed in Burl 4.5 .

Duality can be applied in many many studies. Lets pick one actual example: The finite horizon ISE

ISE [ y ] =

h
0

y 2 (t ) dt

(2b)

for a scalar function y due to

& = A x x

y =Cx
has been found the expression

ISE [ y ] = C X C T A X + X AT = x ( h ) x T ( h ) x (0) x T (0) x( h ) = e Ah x (0)


The matrix X may be presented in the form

152

X = X0 Xh
where (be careful with the signs!)

(9a)

A X h + X h AT = x ( h ) x T ( h ) A X 0 + X 0 AT = x (0) x T (0)
This implies

(9b) (9c)

ISE [ y ] = C X C T = C ( X 0 X h ) C T = C X 0 C T C X h C T
Both terms of the RHS may be presented using the solution X d of the dual Lyapunov equation above: for the first termof (9c) let B to correspond to x (0) and for the second term let B to correspond to

(9d)

x( h ) . This yields ISE [ y ] = x T (0) X d x (0) x T ( h ) X d x ( h )


2

(9e)

Recall that this ISE is the area below the curve of y on the range 0 < t < h . In a stable case the first termis the infinite horizon ISE while the term subtracted is the area below y
2

on the range h < t < .

7.6 On Time-Weighting See DB 5.x where x = 9 for Ed. 10 while x = 7 for Ed. 11. Minimization of ISE type performance indices sometimes leads to poor damping. Better damping may be available by a modified design based on minimization of another performance index that addresses more emphasis on errors occurring at larger values of time. Minimization of that kind of index should then force the response to converge to its final value more efficiently. An example trial index for that purpose is

ISTSE =

[t v(t )] dt

(1)

This index sometimes also called ISTE is actually the ISE number of the weighted error

w(t ) = t v(t )
For a Laplace transform V ( s ) the Laplace transform needed for its evaluation is

(2)

L[t v (t )] =
In fact:

dV ( s ) ds

(3)

L{t v(t )} =

[t v(t )] exp( s t ) dt

= v(t ) [t exp( s t )] dt

d = v(t ) [ exp( s t )] dt 0 ds

differentiate to check!

153

d = [v(t ) exp( s t )] dt 0 ds

= =

d v(t ) exp( s t ) dt ds 0 d V (s) ds

For a rational error transform the transform of the weighted error is a rational function:
polynomial 64444 4 744444 8 polynomial polynomial 64 4 744 8 64 4 744 8 polynomial polynomial 6 7 8 6 7 8 polynomial dN ( s ) dD( s ) } N ( s) D( s) N ( s) dV ds ds V ( s) = = 2 D s ds ( ) D ( s ) { 1 2 3 polynomial polynomial

(4)

This is a ratio of two polynomials hence it is a rational function. The polynomial products may be calculated using conv (Section 2.10). However, a convenient tool is available: polyder.

State-space consideration of weighted performances like ITSE , ISTSE (or ISTE) may lead us to weighted Sylvester integrals of the form

Sm =

h
0

t m e At W e Tt dt
m

(5) is here interpreted as 1 , which then gives S 0

With m = 0 the expression t the Sylvester equation

= S , i.e. S 0 satisfies

A S 0 + S 0 T = e Ah W e Th W
Recall, that the matrices T and A are often transposes of each other, and the matrix W is often (in that case) a symmetric matrix. Then the matrix S m is also symmetric. The name Sylvester is then replaced by the name Lyapunov. To evaluate the integral S k for positive integers k consider the matrix function

(6)

Qk (t ) = t k e At W e Tt ; k = 1, 2 , 3 , ...
For constant matrices A , W and T the derivative matrix of this matrix becomes, according to some Exam Formulae ,

(7)

& (t ) = kt k 1 e At W e Tt + t k Ae At W e Tt + t k e At W e Tt T ; k = 1, 2 , 3 , ... Q k
This result may be written as a matrix ODE,

(8)

& (t ) = k Q (t ) + A Q (t ) + Q (t ) T ; k = 1, 2 , 3 , ... Q k k 1 k k
The initial value of the matrix Qk is

(9)

154

Qk (0) = O

k = 1, 2 , 3 , ...

(10)

It follows from the differential equation for constant matrices A and T , that

& (t ) dt = k Q k

Qk 1 (t ) dt + A

Qk (t ) dt +

Qk (t ) dt T

(11)

This result may be written as

Qk (h) Qk (0) = k S k 1 + A S k + S k T ; k = 1, 2 , 3 , ...


Note now the initial value (10). The matrix S k satisfies the Sylvester equation

(12)

A S k + S k T = h k e Ah W e Th k S k 1 ; k = 1, 2 , 3 , ...
To calculate the matrix S m first solve S 0 . Then solve S k for integer values k 1 upto k = m . Typical case. In the most typical case we have Re i

(13)

[ ]

+ Re j

[ ]

< 0 , h = and m = 1 or

m = 2 . Then we are supposed to solve the Sylvester equations

A S 0 + S 0 T = W A S 1 + S1 T = S 0
A S 2 + S 2 T = 2 S1
(for m = 2 only)

(14) (15) (16)

If you solve e.g. S 0 , S1 or S 0 , S1 , S 2 with lyap or lyap2, you will actually performance a lot of computation twice or three times, i.e. re-compute a schur or eig decomposition already formed. As an exercise problem modify the algorithm applied in lyap2 to get an algorithm, where computations associated with the eigenvector matrix are performed only once! This is of course associated with diagonalization of the state-space model in question. Below another method is used to obtain equations for e.g. Sylvester integral S1 : Consider the matrix integral

S ( p) =
where

h
0

e pt e At W e Tt dt

(17)

p is a real valued parameter. The matrix S ( p) may be used to get e.g. S1 , since (let S denote the derivative of S with respect to p )
S (0) =
h

t e At W e Tt dt = S1

(18)

The calculation of this derivative is based on the Sylvester integral

S ( p) =

e ( A+ pI )t W e Tt dt

(19)

and the corresponding Sylvester equation

( A + pI ) S ( p ) + S ( p) T = e ph e Ah W e Th W
Differentiating both sides with respect to

(20)

p yields

155

I S ( p) + ( A + pI ) S ( p) + S ( p ) T = he ph e Ah W e Th
which may be written as a Sylvester equation,

(21)

( A + pI ) S ( p ) + S ( p) T = he ph e Ah W e Th S ( p)
Substituting now

(22)

p = 0 yields the Sylvester equation


(23)

A S (0) + S (0) T = h e Ah W e Th S (0)


which becomes, using our older notation,

A S1 + S1 T = h e Ah W e Th S 0
But this is the same as Equation (13) for k = 1 ! Derive Sylvester equations for S 2 = S (0) Evaluation of the performance index

(24)

Ja =

h
0

[e

at

v(t )

dt

can be based on application of the ISE theory and procedures for the Laplace Transform

L{ e at v (t ) }= V ( s a )

156

8.

On LQ problems

8.1 Some comments on the lqr theory Consider next theory behind the CST tools lqr , lqry as well as results needed to analyze the optimal design and its competitors. The text is related to Burl 4.5.1 , 4.5.2, 4.5.4, 6.2 , 6.3 ; to optimization sections of DB 5 , 11 ; to PC1 instructions and previous text on ISE numbers etc. Consider a process with m inputs and

p outputs. Assume the LTI process model

& = A x + B u x

y =Cx
Lets study LTI state-feedback control,

u = K x
The closed-loop ODE is

& = ( A BK ) x = Ac x x
where

Ac = A B K
Assume internal stability of the closed loop system, i.e. that all the eigenvalues of the matrix Ac lie left to the Im axis. Then the state response,

x(t ) = expm( Ac t ) x(0)


decays to zero in an exponential way for any possible value of x (0) . This implies similar decay for both y and u , too. Introduce the infinite horizon cost (performance index)

J =

m p 2 2 q y ( t ) r u ( t ) + k k k k dt k 1 1 = = k

with non-negative output weights and positive input weights,

qk 0 rk > 0

, ,

k = 1 , ... , p k = 1 , ... , m

The cost J is obviously non-negative and finite. Note that here we have no terminal cost for the (here infinite) Stop Time since stability implies zero final value of the state which makes a candidate terminal cost equal to zero and so not necessary. Note also that the convenience multiplier (1 / 2) of Burl is not used here. Below se wish to find a constant controller gain K which minimizes the cost matrix form of the cost. Such a presentation is

J . Lets first adopt again a

J =
where

y T Q y + uT R u ) dt

Q and R are diagonal matrices, the main diagonal elements of which are
157

q Qik = i 0

, i=k , ik

r , i = k Rik = i 0 , i k

The optimal gain K for minimization of J is conveniently available by lqry , the theory of which is related to that of Burl 6.2-3. However, note that lqry is able to minimize a more general cost which includes a bilinear term, too. Since

y = C x y T = (C x )T = x T C T
we may also write

J =

(x

Q x + u T R u ) dt

Q = CT Q C
Here J has a presentation accepted by lqr. However, note that lqr is able to minimize a more general cost which includes a bilinear term, too. According to Burl 6.2 , 6.3 the optimal gain K is given by

K = R 1 B T P
where P is a symmetric matrix satisfying the algebraic Riccati equation (are , care)

P A + AT P P B R 1 B T P + Q = O
The same result can also be derived using the partial derivatives of J with respect to the elements of K . BTW, a convenient presentation of the partial derivatives relies on just two dual Lyapunov equations. The non-linear quadratic Riccati equation may have several solutions, of which some may yield instability while a solution yields a stable closed loop system. Lets have an example Example. For a pure integrator process algebraic Riccati equation

ss(0 , 1 , 1 , 0) and weights Q = R = 1 we get the

P2 + 1 = 0
which has two solutions, both P = +1 and P = 1 . The positive solution gives K = +1 which implies Acl = 1 which gives a stable closed-loop system, for which J is finite for any initial state. On the contrary, the negative solution P = 1 gives K = 1 which implies Acl = +1 which implies instability which implies an infinite J as soon as the initial state is non-zero. So we must clearly here select the positive solution of Riccati.

More generally, we should pick a solution with positive (or perhaps only non-negative) eigenvalues. So the solution wanted is either positive definite or semi-positive definite (see chol , eig). This is implied by e.g. the fact the the smallest value J min of J must be non-negative for any non-zero initial state since our original definition of J quarantees the non-negativity of J . The smallest value is

J min = x T (0) P x (0)


An expression of this quadratic form (note again that the convenience multiplier used by Burl is not used here) is non-negative iff the definitiveness condition mentioned is satisfied. Taking the condition into account is important if tools like fsolve are used to solve a Riccati equation. Finding a positive definite solution with fsolve becomes possible by replacing P above with a so called UD factorization where the diagonal 158

elements of the diagonal factor are expressed in terms of exponentials of unknown parameters. For a system with two states the matrix would have the presentation

0 1 U 12 1 U 12 exp( d1 ) P= exp( d 2 ) 0 1 0 0 1

where fsolve could be used to find U 12 , d1 and d 2 . Note that computation of the products PA and PB are not requiring explicit computation of P during the solution procedure. The Riccati solution procedure of Burl 6.3.1 based on the Hamiltonian model is will be studies in a <Own Time> problem. The Hamiltonian model typically has nx stable eigenvalues which then are closed loop poles, too. Since for a controllable single input systems the pole placement problem can be solved uniquely we may here solve the optimal gain also with pole placement method used in PC1 session. So compute the Hamiltonian eigenvalues and feed them to place (or acker if place happens to fail) together with the parameters of the state ODE. Burl 6.3 intoduces a nice study of robust stability. In this course we will refer just that for single-input systems. The result is illustrated using Figure 6.11 and promises a phase margin of at least 60 . The unit circle centered at the Nyquist-Barkhausen point ( 1 + 0 j ) and the unit circle centered at the origin (0 + 0 j ) intersect each other at the points 0.5 j 0.5 3 , which really lies arctan 3 = 60 degrees below the negative real axis (see DB 9.4, Burl 5.3 for picking the phase margin from the open loop Nyquist plot).
0

( )

8.2 The lqr cost as a a function of a stabilizing gain Sometimes the performance index J is wanted for a non-optimal yet stabilizing gain K . Sometimes should be minimized without a Riccati solver using e.g. a general purpose optimization software like fminsearch. Then J may be computed through a Lyapunov equation since

J = x T (0) Z x ( 0)
where

Z is a symmetric and positive or semi-positive definite matrix satisfying the Lyapunov equation

T Ac Z + Z Ac = Q + K T R K

Derivation: We have

J = J =

(x

Q x + u T R u dt with u = K x

x T ( Q + K T R K ) x dt with x(t ) = expm( Ac t ) x(0)


T T

Because x ( t ) = x (0) expm( Ac t )

]T

T = x T (0) expm( Ac t ) we obtain J above with

Z=

T expm( Ac t ) ( Q + K T R K ) expm( Ac t ) dt

which obviously satisfies the Lyapunov equation given, see Section 7.2.

159

In literature quadratic forms like that for J above as well as more general inner products are sometimes represented by a trace (trace ; the sum of the main diagonal elements of the matrix) expression, see e.g. Burl 4.5 , A2.2. In fact, for two column vectors w and v of equal dimensions (lengths) we obtain

wT v = tr ( w v T )
This may be applied e.g. for the quadratic form x Qx , which as a scalar is the trace of itself: we get
T

x T (Q x ) = tr ( x (Q x )T ) = tr ( x x T Q T ) = tr ( x x T Q )
due to e.g. symmetry of Q . Integration yields for a constant Q , since the order of integration and traceing may be interchanged,

( x T Q x ) dt = tr

( x x T ) dt Q

where we see an integral familiar from Section 7.2. Using the same for the total control input cost and combining all the costs with tr ( M + N ) = tr ( M ) + tr ( N ) yields now a new presentation of J ,

J = tr ( X (Q + K T R K ))
T Ac X + X Ac = x (0) x T (0)

Here X may be solved with lyapchol . Availability of X enables getting the ISE numbers of the process states and outputs as well as the controller outputs:

ISE [xk ] = X kk ISE [ yk ] = C X C T ISE [uk ] = K X K T

kk

kk

Concerning the ISE numbers note that the original cost of this section ,

J =

m p 2 2 q y ( t ) r u ( t ) + k k k k dt 1 1 k k = =

is a linear combination of ISE numbers of process outputs and controller outputs,

J = qk
k =1

2 yk (t ) dt + rk k =1

2 uk (t ) dt

Some people regard this as a more original cost because they think first in terms of individual response functions before thinking compromising between different functions (see the Performance Indices section of DB 5). If we want to evaluate process output costs and controller output costs from each other we may use the formulae

q
k k =1

2 yk (t ) dt = tr ( X Q )

r
k k =1

2 uk (t ) dt = tr ( X K T R K )

160

8.3 On trace and duality of Sylvester (and so Lyapunov) equations

Burl A2.2 discusses the trace. A simpler quite obvious formula for the sum of two matrices (of common dimensions) not mentioned there is:

tr ( A + B ) = tr ( A) + tr ( B )
In fact,

(T1)

tr ( A + B) = ( A + B ) kk = ( Akk + Bkk ) = Akk + Bkk = tr ( A) + tr ( B)


k k k k

Recursive application of the sum formula above gives

tr ( M k ) = tr ( M k )
k k

(T2)

In a similar way derive the difference formula

tr ( A B ) = tr ( A) tr ( B )
Another simple formula for a scalar

(T3)

is (T4)

tr ( A) = tr ( A)
This and (T1) imply the formula

tr ( A + B ) = tr ( A) + tr ( B )
This also gives the difference formula with

(T5) ,

=1

= 1 .
size( B,1) and size( B,2) = size( A,1)
(T6)

For the matrices A and B with both size( A,2) = a key formula derived in Appendix A2.2 of Burl is

tr ( A B ) = tr ( B A)
Another important trace formula for matrices

A and B with both size( A,2) = size( B,1) and

size( A,1) = size( B,2) is


tr ( AT B T ) = tr ( A B )
This can be derived as follows: (T7)

tr ( AT B T ) = tr (( B A) T ) = tr ( B A)

since

AT B T = ( BA)T

since transposition maintains the diagonal elements as proved in Burl

= tr ( A B)

Trace of a square matrix is also the sum of the eigenvalues. In Matlab dialect we may say that trace(A) equals to sum(eig(a)) . Test the results above in Matlab!

161

In some studies of optimal control and estimation we may need the following duality result: The scalar

J = tr ( S R)
associated with the Sylvester equation

(1)

A S + S D = N
with square matrices

(2)

A , D also has the presentation


(3) (4)

J = tr ( P N )

D P + P A = R
The Sylvester equations of the matrices

P and S are called duals of each other.

Proof.

J = tr ( S R) = tr ( S ( DP PA)) = tr ( SDP SPA) = tr ( SD P ) tr ( S PA)


(T 6 )

(1)

( 4)

(T 5)

= tr ( P SD ) tr ( PA S ) = tr ( P SD P AS ) = tr ( P ( SD AS ))
(3!)

(T 5)

J = tr ( P N )
T

( 2)

This result is most often used with A = D . The result can help to use LQ optimal control software and theorems for variance calculus including that needed in Kalman filtering and vice versa. It is also extremely useful if we need partial derivatives of a performance index with respect to the design parameters like controller gains etc. Then for any number of parameters only two Lyapunov equations duals to each other are needed, and after solving one of them solving the other is much easier than when one starts from scratch (because the schur , hess, and eig decompositions of A and A typically used by Lyapunov solvers are closely related to each other).
T

162

8.4 Exponential Time Weighting To Improve Convergence The process model is again assumed to be

& = A x + B u x

(1a) (1b)

y =Cx
The control law is again

u = K x
But a new performance index is chosen to affect settling/convergence of the response
2 J ( p) = d1 e 2 pt y12 (t ) dt + ... + d k e 2 pt y k (t ) dt 0 0 2 + r1 e 2 pt u12 (t ) dt + ... + rm e 2 pt u m (t ) dt , p 0 0 0

(2)

(3)

This may be written as

J ( p ) = e 2 pt x T (t ) Q x (t )
0

uT (t ) R u(t ) dt

(4)

Q = C T diag (d1 L d k ) C R = diag (r1 L rm )

Theorem 1. The optimal gain K is equal to that of the lqr formulation Model: Control: Cost:

& = (A + p I) x + B u x
u = K x

(5a) (5b) (5c)

J = (x T Q x + u T R u )
0

In case of success the closed loop eigenvalues satisfy the inequality Re s < p

[]

Proof. Cost: Since

e 2 pt = e pt + pt = e pt e pt
we get

e 2 pt x T Qx = e pt x T Q e pt x = (e pt x) T Q (e pt x) = x T Q x

with

x = e pt x

163

In a similar way

e 2 pt u T Ru = u T R u
Control:

with

u = e pt u

u = K x e pt u = e pt ( K x) = K (e pt x) u = K x
Model:
pt & = d (e x) = ( pe pt ) x + e pt x & = p (e pt x) + e pt ( A x + B u ) x dt

= p x + e pt A x + e pt B u = p x + A e pt x + B e pt u

= p I x + A x + B u = (A + p I) x + B u
Observe! If you will solve the problem with lqr , it is able to provide you with the eigenvalues of the matrix

M p = ( A + pI ) BK = ( A BK ) + pI = M + pI
Hence it will not give you eigenvalues of the matrix M , i.e. the eigenvalues of the closed loop system! Here the eigenvalues of the matrices mentioned are related to each other in a simple way:

[M p ] = [M ] + p [M ] = [M p ] p
The eigenvalues of M p should have negative real parts in case of success. Then the eigenvalues of the eigenvalues of the closed loop system, satisfy the inequality Re s < p . See DB 6.3 !

[]

M ,

Theorem 2. The performance indices of the individual response functions are

0 0 0

2 e 2 pt y k (t ) dt = C X C T

kk

(6a)

2 e 2 pt u k (t ) dt = K X K T

kk

(6b)

e 2 pt x k2 (t ) dt = X kk

(6c)

where the matrix X can be solved from the Lyapunov equation


T Mp X + X MT p = x (0) x (0)

(6d) (6e)

M p = ( A + pI ) BK = ( A BK ) + pI
Proof. Your proof ... see Sections 7.2 and 7.6 !

164

8.5 A useful normalization of the input function In some optimal control studies the symmetric input weighting matrix R causes some extra pain. Next a variable change is introduced to remove most of this pain assuming that R is a positive definite matrix. We may present the matrix

R in the product form

R T R is a diagonal matrix we may (but are not forced to) where is a non-singular square matrix. If choose to be a diagonal matrix with e.g. positive diagonal elements ,

R Rrc = rr 0

rc = rr , cr 0 , c=r

, c=r , cr

If R is not a diagonal matrix we may use either chol , sqrtm , eig , schur or svd to get from R . Of these alternatives chol with = chol ( R ) is here perhaps the most convenient. The user of sqrtm (which would also work for a semi-positive definite R of another study) should notice that for a symmetric matrix R the command = sqrtm( R ) produces a symmetric so that the structure of the help documentation is equivalent to needed here. Nevertheless, after this decomposition step we may write the local control input cost in the form
T

u T R u = u T ( T ) u = ( u T T ) ( u ) = ( u )T ( u ) = u T I u
where we intoduced the variable change

u = u
Now we have " R" = I which simplifies some computations in some procedures. The cost is now

J =

(x

s Q x + u T u ) dt

The variable change must now be taken into account in the process model as well as in the controller model. The state model of the process may be written as

& = A x + B u = A x + ( B 1 ) (u ) x
and so as

& = A x + B u x
where the new input matrix introduced is

B = B 1
This matrix is computed before the Riccati ODE or the algebraic Riccati equation is solved. For example, the ODE to be solved with e.g. ode45 now has the simple presentation

& = ( M A) + ( M A)T ( M B ) ( M B )T + Q M
From the solution of this ODE or the corresponding algebraic equation we can get the gain normalized control law

of the

u = K x
165

Then we can form the actual control law with

u = 1 u = 1 ( K x ) = ( 1 K ) x = K x
where

K = 1 K
The matrix K can be obtained without matrix inversion by solving the equation

K = K
In Matlab one may use slash or perhaps even more effective procedures. Outside Matlab the upper triangular structure of by chol makes solution easy. Notice that the equation above may be read columnwise,

K (: , c ) = K (: , c )
8.6 Removing the bilinear cost term

The problem solved by lqr has the structure: Process model: Control Law: Cost: Here the local cost is

& = Ax + Bu x

u = K x
J =
0

(x

Q x + uT R u + 2 x T N u ) dt

J t = x T Qx + uT Ru + 2 x T Nu
Note first that the third term has also another presentation,

2 x T Nu = x T Nu + u T N T x
This term is a bilinear term. Such terms are obtained in some studies due to squared Euclidean norms of the form

Lx x + Lu u
2

which also yields two quadratic forms,

Lx x + Lu u

= ( Lx x + Lu u )T ( Lx x + Lu u )
T T T T T T = x T LT x Lx x + x Lx Lu u + u Lu Lx x + u Lu Lu u

Reverse thinking advices to try a change of e.g. the control input variable,

+ L x u=u
so that a proper selection of L removes the bilinear term of the local cost. Substituting this variable presentation into the cost yields after some standard manipulation

T Ru + x T 2 LT R + 2 N u J t = x T Q + LT RL + 2 NL x + u
The bilinear term is eliminated away if

166

LT R = N
Transposing this and using symmetry of R yields

RL = N T
For a positive definite R we obtain L as

L = R 1 N T
The local cost may now be presented in the form

T R u J t = x T (Q + N L ) x + u
Making the variable change in the process model yields

& = ( A + B L ) x + Bu x
The two latest equations above may be fed to lqr to solve the gain of the control law

= K x u
After this remembering the variable change

+ L x u=u
proposes the control law

u = ( K L) x
Therefore the call [K,P] = lqr(A,B,Q,R,N) may perhaps be replaced by the commands: L = -R\(N.') An = A + B*L Qn = Q + N*L Qn = (Qn + Qn.')/2 [Kn,Pn] = lqr(An,B,Qn,R) K = Kn - L % force symmetry!

167

9. State Observability and Controllability Consider the state-space model

& = A x + B u x

y = C x + Du dim( x ) = n
Below observability and controllability of this system will be discussed again. The topic is related for e.g. pole-zero cancellations of transfer functions or other similar simplifications, where the tf is not revealing all the phenomena. Recall that we learned both in BCAT and in this course that some systems may have hidden modes which can not be observed in/from the measurement function. Before continuing , run the commands of ctrbobsvdemo.m

9.1 State Observability Assume zero input function u but non-zero initial state x (0) . Can we conclude x (0) from the time history of y known for the finite time range 0 < t h < ? If we can, we say that the initial state is observable. Later values of the state can then be computed by simulation, which allows us to say that the state function is observable as soon as the initial state is observable. The measurement function is here

y (t ) = C e At x(0)
Lets search the initial state by minimizing the non-negative CT Least Squares performance index

J=

T 1 h y (t ) C e At x(0) y (t ) C e At x(0) dt 2 0

] [

by adjustment of The gradient of


h
T

x(0) . The value of J is actually zero for the actual initial state!

J with respect to x(0) should be zero for the actual initial state. The gradient is

J = e A t C T Ce At x(0) y (t ) dt
0

This becomes zero iff

h 0

e A t C T Ce At dt x (0) =
T

h 0

e A t C T y (t ) dt
T

The actual initial state can be solved from this, if the Lyapunov integral

Po = e A t C T C e At dt
T

called the observability grammian (Gram matrix, gram) is non-singular (a sufficient condition!). Because this matrix is by structure symmetric and at least positive semi definite, it is non-singular if and only if it is positive definite. In many but not all cases the observability grammian may be solved from the Lyapunov equation (lyap)

AT Po + Po A = e A h C T C e Ah C T C
T

168

This is possible for any stable system while for some (but not at all all) unstable systems we must use another methods, e.g. the matrix ODE technique. If the state ODE is correct , y really is equal to Cx , and the grammian is non-singular, then the correct initial state is found correctly with the theory above.

Naive study The observability condition on Po may in theory be studied with rank , determinant , eigenvalues, Cholesky decomposition, singular values or condition number. In fact, the following observability conditions are equivalent with infinite precision both in modelling and analysis computations: (1) (2) (3) (4)

rank ( Po ) = n det( Po ) 0
All the eigenvalues of Po are positive.

Po may be presented in the Cholesky form

Po = RT R
where R is a real upper triangular matrix square matrix with non-zero diagonal elements. (5) (6) All the singular values of Po are positive. The condition number (ratio of the largest and the smallest singular value) of Po is finite.

Some of the conditions may be used as such for symbolic studies or studies where the coefficients are integers or rational numbers. Other situations are discussed below:

A practical study For studies where inexact numerical values arise due to imprecise modelling as well as later roundings and truncations in storing values and subsequent computations we should select an appropriate procedure modified in an appropriate way. Modification is needed e.g. since the inaccuracies mentioned may mislead us to regard a strictly unobservable system as observable. Moreover, a nominal system may be observable but minor changes in some parameters may cause loss of observability, or even modest amount of noise may hide some essential parts of the response. The procedure should also be insensitive enough for state and output units and scalings. A practical modified procedure is based on the singular values of Po : The system is observable in a practical way, if the smallest singular value of Po is large enough a positive number. The condition above restricts amplification of possible measurement noise in the estimate of the state x and linear functions d x of the state, which can be shown using stochastic theory from Burl 2.4 , 3 and A3. If the output measurement function contains an additive term due to stationary white noise function with spectral density (called noise intensity by e.g. covar)
T

2I

, then the estimate of the initial state for an observable

system can be shown to contain a zero mean error term the variance of which is the command

2 Po

. This may written in

terms of the singular values of Po and the left unitary matrix U of the singular value decomposition of Po :

169

[U,S] = svd(Po) gives U and a diagonal singular value matrix S such that the state estimation error has the variance matrix

W = 2 U S 1 U T
while the estimation error for d x has the variance
T

12
S11

+ ... +

n2
S nn

=UT d
A very small singular value S kk (recall that here S nn is the smallest one) tends to increase W in some sense as well as make

large especially for some values d . Note that letting d be the kth column of the identity
T

matrix makes d x to be xk

and

to be the kth column of U

which has unity norm. If d is

proportional to the last column of large

U T then becomes inverse proportional to S mm which means a very

for a very small S nn .

It is difficult if not impossible to give a general positive lower bound for the smallest singular value. In the current context the singular vectors of Po also have modest effect to the interesting variances of the state estimation error. The tool of rank of Matlab selects a positive tolerance of zero, but that threshold value of the procedure is not selected with observability in mind. Despite of this the test can sometimes warn about weak observability or reveal lack of observability in a case where the naive test fails to do that. Another practical using the condition number of Po is less sensitive to e.g. output scaling: The system is observable in a practical way, if the condition number of Po is small enough. Again, it is difficult to define here the concept small enough.

Another test matrix Denote the characteristic polynomial

det( sI A) with ( s ) . It may be written in the form

( s ) = ( s ) + (0) 1
where ( s ) is a polynomial which combines terms for orders (degrees) 1 , ... , n while order term. The Cayley-Hamilton Theorem claims that

(0)

is the 0th

( A) + (0) I = O
, An + 2 , An + 3 , ... can be presented as finite order matrix polynomials of A with scalar coefficients. The order is at most ( n 1) . This also means, that state transition
This result implies that all the powers A , A
n n +1

matrix (the matrix exponential defined using a Taylor polynomial of infinite order) may be expressed as a matrix polynomial of order ( n 1) or smaller where scalar multipliers of matrix powers may depend on time. Through this observation it has been shown that the matrix Po is positive definite iff the observability matrix discussed in DB and available by obsv has rank equal to n . Denote this simple matrix by Wo . Its block structure for different values of n is illustrated below: 170

0 ,1

Wo

C C CA CA CA2

4 C CA CA2 3 CA

n5 C CA M n 1 CA

The test matrix may be formed with the commands: Wo = C ; nx = size(A,1) ; for k = 1:(nx-1), Wo = [C; Wo*A] ; end However, obsv works faster, because it doesnt use an array of variable dimension during the looping. The system is observable iff

rank (Wo ) = n
For a single output system the condition may be expressed as

det(Wo ) 0 , if dim( y ) = 1
For multiple-output systems a convenent condition is

det(WoT Wo ) 0
This is associated with the rank formula

rank (Wo ) = rank (WoT Wo )


However, critical observations made for tests of

Po may be referred here, too. Therefore a practical study of observability is again based on singular values or the condition number of Wo :
The system is observable in practice , if the smallest singular value of

Wo is large enough a positive number.

if the condition number of

Wo is small enough .

Remark. The observability may most often be studied and (for an observable system) initial state may also be estimated using DT (Discrete-Time) methods available in FPW assuming that observability is not lost due to sampling which may occur for some pathological systems if the sampling time is selected in a bad way. The DT theory resembles a lot the CT (Continuos-Time) theory above! See c2d , d2c , obsv , gram , dlyap , obsvf , balreal , minreal , modred , canon etc.

9.2 State Controllability Definition. The model

& = A x + B u x
is said to be state controllable, if and only if there exists an input function u , which may drive the state x from an arbitrary initial value x(0) to an arbitrary end value x ( h ) = f at an arbitrary positive finite end time h . If this is not possible, the system is uncontrollable (DB 11). 171

A sufficient and necessary condition for controllability is the non-singularity of the matrix

Pc = e At B B T e A t dt
T

Because this matrix called the controllability grammian (Gram matrix, gram) is symmetric and by structure either positive semidefinite or definite, requesting non-singularity means that Pc must be positive definite. In many example cases the matrix

Pc may be solved from the Lyapunov equation (lyap)

A Pc + Pc AT = e Ah B e Ah B

][

B BT

This is possible for any stable system while for some (but not at all all) unstable systems we must use another methods, e.g. the matrix ODE technique.

For a controllable system there are infinitely many control input functions u capable to yield The input function u which minimizes the control input cost

x( h ) = f .

J =

h
0

uT (t ) u(t ) dt

is given by

u(t ) = B T e A

(ht )

Pc1 d

d = f e Ah x(0)
The optimized value of
h

J is

J = u T (t ) u (t ) dt = d T Pc1 d
0

This may written in terms of the singular values of decomposition: the command [U,S] = svd(Pc)

Pc and the left unitary matrix U of the singular value

gives U and a diagonal singular value matrix S such that the optimal (minimal)

J is

J=

12
S11

+ ... +

n2
S nn

=UT d
If at least a singular value is very small, the optimized

J contains a large term for some f , which makes J large, which means some difficulties in reaching the goal x( h ) = f ? So lets say that: Pc is large enough.

The system is controllable in practice if the smallest singular value of The condition number of need of lot of energy.

Pc may also be used: large condition number may mean problems in control, e.g.

172

Another controllability test matrix The Cayley-Hamilton Theorem can again be used to provide a simple test matrix denoted by

Wc :

nx = 1 Wc = [B ] nx = 2 Wc = [B nx = 3 Wc = B nx = 4 Wc = B AB ] AB A1B A2 B

]
A3 B

A2 B

] ]

nx = n 5 Wc = B

A1B

A 2 B L A n 1B

In Matlab we could use the following recursive commands to create the test matrix: Wc = B ; nx = size(A,1) ; for k = 1:(nx-1), Wc = [B,A*Wc] ; end However, ctrb works faster, because it doesnt use an array of variable dimension during the looping. The system is state controllable, if and only if

rank (Wc ) = nx
(i.e. iff the rows of the matrix

Wc are linearly independent). An equivalent more convenient condition is

det(Wc WcT ) 0
In the Single Input case the condition may be simplified :

nu = 1 det( Pc ) 0
Det tests are again fine only for studies with symbolic parameters or integer and rational numbers. Otherwise use singular values: The system is controllable in practice if the smallest singular value of The condition number of

Wc is large enough.

Wc may also be used: large condition number may mean problems in control.

Remarks. Controllability may most often be studied and (for a controllable system) a desired state can be reached using DT (Discrete-Time) methods available in FPW assuming that controllability is not lost due to sampling which may occur for some pathological systems if the sampling time is selected in a bad way. The DT theory resembles a lot the CT (Continuos-Time) theory above! See c2d , d2c , ctrb , gram , dlyap , ctrbf , balreal , minreal , modred , canon etc. Duality results exist, e.g. ctrb(ss(A,B,C,D)) obsv(ss(A,B,C,D)) gram(ss(A,B,C,D),'c') gram(ss(A,B,C,D),'o') equals to equals to equals to equals to obsv(ss(A.',C.',B.',D.')).' ctrb(ss(A.',C.',B.',D.')).' gram(ss(A.',C.',B.',D.'),'o') gram(ss(A.',C.',B.',D.'),'c')

173

Example Consider a system with the second order strictly proper tf

G(s) =

cs + d ( s a ) ( s b)

The characteristic polynomial of this is

( s ) = ( s a ) ( s b)
The zeros of are a and b . They are the poles of G and the system. For a b we may present a partial fraction expansion (residue)

G( s) =

k1 k + 2 , if a b sa sb cb + d ca + d , k2 = ab ba

k1 =

A parallel connection block diagram presentation of the partial fraction expansion is below:

u u

1 sa
eigenvalue = a

x1

k1

y1
+

1 sb
eigenvalue = b

x2

k2

y2

This can be assigned a state-space model,

&1 = a x1 + u x & 2 = b x2 + u x
y = k1 x1 + k 2 x 2
The matrix form of the model is

&1 a 0 x1 1 x = + u x &2 x2 1 0 b { { 123 {


& x A x B

x y = [k1 k 2 ] 1 + 0 u 1 4 2 4 3 x2 C {
x

The state matrix is

174

a 0 A= 0 b
Note that the matrix A is here diagonal (see canon!). The eigenvalues of (roots) of the characteristic polynomial .

A are a and b , i.e. the zeros

Here x1 can not be observed from y if k1 = 0 , which occurs for ( c a + d ) = 0 , i.e. iff the pole a is a zero of the numerator polynomial ( c s + d ) . For k1 = 0 the tf can be simplified to the first order tf.

G( s ) =

k2 sb

The only pole of this is b , one of the two eigenvalues of the system. So for k1 = 0 the eigenvalue a is hidden while the eigenvalue b is visible. The unobservability of x1 would be fatal, if x1 is not behaving in a stable way. An unbounded x1 is obtained e.g. for zero u if a > 0 and x1 (0) 0 . Tell yourself about possible unobservability of x2 in a way used above! Lets next verify that the obsv matrix can warn about possible problems: here we have

C = [k1 k 2 ]
Now the simpler observability test matrix is

C k1 k 2 Wo = = C A k1a k 2b
Lack of observability occurs if this (here) square matrix has a zero determinant. The det is

det(Wo ) = k1 ( k 2b) k 2 ( k1a ) = k 2 k1 (b a )


This is zero, since here a b , iff k1 = 0 or k 2 = 0 . The condition k1 = 0 was found above in a different way while finding the condition k 2 = 0 was left to the reader!

Another block diagram presentation of the partial fraction expansion is below:

u k1 u

1 sa
eigenvalue = a

z1
+

y
+

k2

1 sb
eigenvalue = b

z2

This can be presented a state-space model

175

&1 = a z1 + k1 u z &2 = b z2 + k 2 u z
y = 1 z1 + 1 z 2
The matrix form of the model is

&1 a 0 z1 k1 z + u = z &2 z 2 k 2 0 b { 123 { {


& x
A x B

z y = [1 1] 1 + 0 u 1 2 3 z2
C

Note that the matrix A above is diagonal (see canon!). The eigenvalues of A are a and b , i.e. the zeros of the characteristic polynomial . Here z1 is unaffected by control, i.e. uncontrollable, if k1 = 0 . This is fatal if a > 0 and z1 (0) 0 . You are asked to study what this means for the tf. Also study what happens for k 2 = 0 . Lets now look, if the ctrb matrix can warn about possible problems. Here the simpler controllability matrix is

Wc = [B

k AB ] = 1 k 2

ak1 bk 2

Lack of controllability occurs if this (here) square matrix has a zero determinant. The det is

det(Wc ) = k1 (bk 2 ) k 2 ( ak1 ) = k1 k 2 (b a )


This is zero, since here a b , iff k1 = 0 or k 2 = 0 . The condition k1 = 0 was found above in a different way while finding the condition k 2 = 0 was left to the reader!

Problem. Consider the SISO state-space model

&1 = a1 x1 + k1 u x & 2 = a2 x2 + k 2 u x

&3 = a3 x3 + k3 u x
& 4 = a4 x4 + k 4 u x

y = p1 x1 + p2 x2 + p3 x3 + p4 x4
Find conditions for having a controllable & observable state , a controllable & unobservable state , an uncontrollable & observable state and an uncontrollable & unobservable state. Illustrate your result with a block diagram and obtain the tf of the model. Discuss possible dangers in the situation.

176

You might also like