Uploaded by Franky Deemba

State space equations, the important stuf

advertisement
State space equations, the important stuff
W.S. Harwin
Cybernetics, University of Reading
Created Jan 2008, updated Oct 2017
I n t ro d u c t i o n
Both continuous and sampled time systems are considered in state space. The continuous time state space equations
are usually given in the general form as
ẋ
y
= A(x) + B(u)
= C(x) + D(x)
(The sampled time variant should become obvious!). In the following we will consider only linear systems where A,B and
C are matrices, and only strictly proper systems where D = 0. (That is a system where all the gain of the system tends to
zero as the frequency approaches infinity). We will only consider SISO systems so that y and u are scalars and the length
of the vector x is the order of the system. Thus the equation will be of the form
ẋ
y
=
=
Ax + Bu
Cx
The general solution to the first of the above equations is
Z t
x(t) = eAt x(0) +
eA(t−τ ) Bu(τ )dτ
(1)
0
Likewise in the sampled time domain we can describe systems as functions of the sample number n so they are in the
form
xn+1
yn
=
=
As xn + Bs un
Cxn
Put into the s domain to get
sx − x(0)
y
Note: in most cases x, y, z, etc
are implied from context as either x(t) (continuous time), xn
(sampled time), x(s) (Laplace domain), x(z) (z domain). Check
the TEX source for confirmation.
= Ax + Bu
= Cx
and z domain we get
zx − x(0)
= As x + Bs u
y = Cx
We will consider some of the following continuous SISO (single input single output) transfer functions.
First order
Second order
Third order
y
K
=
u
s+a
(2)
y
K
= 2
u
s + as + b
y
K(s + r)
= 3
u
s + as2 + bs + c
(3)
y
K
=
(4)
u
(s + p1 )(s + p2 )
y
K(s2 + rs + q)
= 3
u
s + as2 + bs + c
or defined with poles as
Second order with zero
y
K(s + r)
= 2
u
s + as + b
K
y
=
u
(s + p1 )(s + p2 )(s + p2 )
(5)
(6)
(7)
(8)
etc
S tat e s pac e
We can put the above transfer functions into state space form. Trivially for first order ( eq 2) that is
ẋ =[−a]x + Ku
y =x
(9)
(10)
C o n t ro l l a b l e c a n o n i c a l f o r m
For second and higher orders we can arrange the states in several ways, the first is the controllable canonical form.
1
The all pole second order system of eq 3 is thus
expressed in controllable canonical form as
0
1
0
ẋ =
x+
u
−b
−a
K
y = 1 0 x
(11)
Third order Controlable canonical form


 
0
1
0
0
0
1 x +  0 u
ẋ =  0
K
−c −b −a
y = 1 0 0 x
The single zero given in system 5 changes the
output equation to
y= 1 r x
The single zero shown in system 6 changes the
output equation to
y= 1 r 0 x
(12)
O b s e rva b l e c a n o n i c a l f o r m
Two examples of observable canonical form are
Second order (system 3)
0 −b
K
ẋ =
x+
u
1
−a
0
y = 0 1 x
Third order (system 7)


 
0 0 −c
K
ẋ = 1 0 −b x + Kru
0 1 −a
Kq
y = 0 1 x
D i ag o n a l f o r m
This is based on pole zero form equations.
system 4
−p1
0
K
ẋ =
x+
u
0
−p2
K
y = p1 − r −p2 + r x
We can write system 6,7 or 8 in the form
c1
c1
c1
y
=
+
+
u
(s + p1 ) (s + p1 ) (s + p1 )
We can then put it into diagonal form as


−p1
0
0
K
−p2
0 x +
ẋ =  0
u
K
0
0
−p
3
y = c1 c2 c3 x
Where there are multiple repeated poles then a more general variant known as Jordan Canonical form is used.
Conversion to Sampled time system
We can use a zero order hold to find the equivalent sampled data system to a particular state space continuous time
system.
Broadly the method uses the solution to ẋ = Ax which is x(t) = eAt x(0) (ignoring input for the moment) by setting
x(0) to xn and using a sampling time of ∆ we can calculate xn+1 = eA∆ xn and hence see that G = eAt . The more general
F∆
conversion is via the equation
in the
form P = e
A B
A Bs
Where F =
and P = s
0 0
0
0
The expansion of these equations leads to the individual solutions
As = eA∆
and
Bs = A−1 eA∆ − I B
So the inverse solutions are
A=
1
loge As
∆
and
B = (As − I)
−1
ABs
We will use the obvious approximation for matrix exponent where ex = I + x + x2 /2! + x3 /3!.... Alternatively a Padé
approximation might be considered. But any matrix exponent approximations need to keep the matrix norm small to
avoid calculation errors (See Moler and Van Loan 2003).
For this theapproximation is ex = I + x sothe digital
system becomes very simple
e−∆P1
0
e−P1 K
Since As =
and Bs = ∆K −P2 K
0
e−∆P2
e
2
S o l u t i o n s t o c o n t i n u o u s t i m e s tat e s pac e e q u at i o n s
Given the linear state space equations in the form
ẋ
= Ax + Bu
y
= Cx + Du
The continuous solution can be written in the Laplace domain as
Y = C(sI − A)−1 (Bu + x(0))
which in the time domain becomes
t
Z
Φ(t − τ )Bu(τ )dτ
x(t) = Φ(t)x(0) +
0
for time invariance
Φ(t) = eAt
so the response to an arbitrary input can be calculated.
C h a n g i n g t h e s tat e s
Let J be any square invertable matrix. We can use J to change the states around (scaling, mixing and swapping). let
x = Jx0 so Jẋ0 = AJx0 + Bu, y = CJx0 . The equivalent state space equation is then ẋ = J−1 AJx + J −1 Bu, y = CJx.
Now if we know the Eigenvectors and values (D,diag(λn ) and V ) for A we can use J=V (provided V is invertable and
A is diagonisable) to transform the system into ẋ = diag(λi )x + V −1 u, y = CV x.
E i g e n va l u e s a n d v e c t o r s
Recall that Eigenvalues and Eigenvectors for any matrix A are those vectors for which the equation λv = Av is true.
λ1 0
This can be written in matrix form as AV = V D e.g. for a 2x2 matrix this would be A v1 v2 = [ v1 v2
0 λ2
−p ∆
e 1
0
From which it is obvious that the poles are
0
e−p2 ∆
General solution
given state space solution
ẋ = A(t)x(t) + B(t)u(t)
The general solution is of the form
Z
t
Φ(t, t0 )B(t0 )u(t0 )dt0
x = Φ(t, t0 )x(t0 ) +
t0
Which simplifies for LTI systems to (see eq 1)
x = eA(t−t0 ) x(t0 ) +
Z
t
0
eA(t−t ) B(t0 )u(t0 )dt0
t0
Computing matrix exponentials is a bit tricky but if we assume that the system has independent Eigenvalues we can
use the relationship
S −1 AS = D
where S is a matrix of Eigenvectors, and D is diagonal. The matrix exponent of a diagonal matrix is then just the exponent
of the diagonal members.
So the impulse response of a system is then
x(t) = SeAt S −1 B
provided it has non repeated Eigenvectors (a biproduct is that this enables S −1 to be computed) and the initial conditions
are all zero.
C o n c at e n at i o n o f s y s t e m s
Given two state space systems in series it is relatively easy to show that the state space of the combined system is
ẋ2
A2 B2 C1 x2
0
=
+
u
(13)
ẋ1
0
A1
x1
B1 1
x2
y2 = C2 0
(14)
x1
3
Other techniques
Still to come - perhaps, controlability, observability, state feedback controllers. Non-linear state space. Awesome
picture of controlability structure (Statespace Notes 24 Oct 2017)
C o n t ro l l a b i l i t y t e s t
A statespace system is controllable if the rank of the controllability matrix M is equal to the number of states.
M = B AB A2 B ... An−1 B
Example
Newtons law in control canonical form is
ẋ =
Clearly the controllability matrix M =
0
1
m
1
m
0
0
0
1
x+ 1 u
0
m
0
is rank 2. Hence is controllable.
Examples
A m a s s s p r i n g da m p e r s y s t e m
Two forms are discussed, the first is typified by a piano string in that a force (e.g. from a hammer, drumstick, bow, finger
) is used to impart a force (often impulse like) to the system. This is shown in figure 1, but note that the force shown is
the force the system imparts on the world! In this category are highly oscillatory systems such as any musical instrument
that can be hit, plucked, tooted or bowed; as well as damped systems such as thermal heat dissipation.
Figure 1: mass-spring-damper (Piano string)
The second is the shock absorber where a displacement at one end of the system (ie the road) results in displacement
at the other (ie the driver and passengers), and is shown in figure 2.
State space of a 2nd order system
For the piano string model, the upward forces on mass m are −Kspring xa − Bdamp ẋa + f so from Newton we get
−Kspring xa − Bdamp ẋa + f = mẍ
This we can put into CCF by writing ẋ2 = ẍa ie x2 = ẋa thus emphasising the vector nature of x
0
1
0
ẋ1
x1
=
+ 1 f
Bdamp
K
ẋ2
x
−
− spring
2
m
m
m ẋ1
y = [1 0]
ẋ2
or by substituting
r
Kspring
m
Bdamp
ς=
2mω
ω=
we can see it is equivalent to ??
4
Figure 2: mass-spring-damper (Shock absorber)
ẋ
0
−ωn2
=
1
−2ςωn
x+
0
ωn2
u
For the shock absorber model, the upward forces on mass m are Kspring (xb − xa ) + Bdamp (ẋb − x˙a ) so from Newton
we get
Kspring (xb − xa ) + Bdamp (ẋb − ẋa ) = mẍ
Hence the state space equations are
ẋ1
ẋ2
0
x1
+
B
Bdamp f
K
x2
− damp
− spring
m
m
m
ẋ1
= 1 Kspring /Bdamp
ẋ2
0
=
y
1
state space of a 2nd order system (B)
ẋ
=
y
=
0
−ωn2
1
−2ςωn
x+
0
ωn2
u
[1 0]x + [0]u
r
ω=
r
ς=
K
M
B2
4KM
NTS: Specify this as a sampled system
Φ = eA4
T h e H a r r i s a n d Wo l p e rt H u m a n m o d e l 1 9 9 8
The transfer function used by Harris and Wolpert is probably of the form 1/s(Js + b)(sT1 + 1)(sT2 + 1) In state space this
would be
0
 0
A=
 0

0
1
0
0
0
1
0
− J T1b T2
−


B=

C=
1
0
0
1
b (T1+T2)
+1
J
− Jb −
T1 T2

0
0
0
1
J T1 T2
0
5
0



0
T1+T2
T1 T2




Or in diagonal form

0
 0
N ewA = 
 0
0



N ewB = 

N ewC =
0
1
− T1
0
0

0
0 

0 
− Jb
0
0
1
− T2
0
1
b
1
− T1 (T1−T2)
(J−T1 b)
1
T2 (T1−T2) (J−T2 b)
b2
J (J 2 −J T1 b−J T2 b+T1 T2 b2 )
1
−T13
−T23
3
− Jb3





Putting the control canonical form into state space with a two term expansion gives.


1
∆
0
0
0

1
∆
0


A = 0

0
∆

1

1+b(T
+T
)
b
−∆
1
2
2
0 − T1∆b
−∆(1 + TT11+T
T2 J
T1 T2
J
T2 + J )


B=

∆ + (1 +

0
0
0
T1 +T2
T1 T2
(15)
+
b
2
J )∆



(16)
H and W give the following values for the arm J = .25Kgm2 b = .2N msrad−1 T 1 = 0.04s T2 = 0.03s
F ly f i s h i n g ro d
As can be seen from Figure 3 we can string mass spring damper systems together. We can form the state vector as
T
x = x1 . . . xn ẋ1 . . . ẋn . The general equation then becomes ẍi = (ki xi−1 + bi ẋi−1 − (ki + ki+1 )xi − (bi +
bi+1 )ẋi +ki + 1xi+1 + bi+1 ẋi+1 )/mi and so an example of a 4 node system would be

0
0
0

0
A=
−(Kspring
+
Kspring 2 )/m1
1

Kspring /m
2
0
0
2
0
0
0
0
Kspring 2 /m1
−(Kspring 2 + Kspring 3 )/m2
Kspring 3 /m3
0
0
0
0
0
0
Kspring 3 /m2
−(Kspring 3 + Kspring 4 )/m3
Kspring 4 /m4
0
0
0
0
0
0
Kspring 4 /m3
−Kspring 4 /m4
1
0
0
0
−(Bdamp1 + Bdamp2 )/m1
Bdamp2 /m2
0
0
0
1
0
0
Bdamp2 /m1
−(Bdamp2 + Bdam
Bdamp3 /m3
0
Figure 3: mass-spring-damper: Fly fishing rod
While casting we can ignore gravity!
We can use Matlab or octave to generate graphics of frequency response, step response etc.
The end
Available on the Internet as URL= http://www.reading.ac.uk/~shshawin/dnb. Comments and corrections to
W.S. Harwin, (pick up the address or email from the web page). You are free to make as many copies as needed and use
this material in any way you see fit as long as it is not illegal, immoral, or likely to endanger life or property. Notes are
currently used in mechatronics and state space modules of the U.Reading Engineering degree.
6
References
K. Ogata ”Modern Control Engineering” 9 Prentice-Hall , isbn 0-13-598731-8 pp. 712-719 (1990)
C.B. Moler and C. F. Van Loan ”Nineteen dubious ways to compute the exponential of a matrix, Twenty-Five Years
Later” SIAM REVIEW Society for Industrial and Applied Mathematics 45 (1 ) pp. 3-000 (2003)
W. Harwin ”notebook 196” pp. 198-199 (22 April 2004)
C. M. Harris and D. M. Wolpert ”Signal-dependent noise determines motor planning” Nature pp. 780-784 (1998)
W.S.Harwin Digital Notebook c October 2006 - 25th October 2017
7
Download