Chapter03.Modeling in The Time Domain
Chapter03.Modeling in The Time Domain
3.1 Introduction
State space (modern or time-domain) approach:
• Nonlinear system (backlash, saturation, dead zone, …)
• System with nonzero initial conditions
• Time-varying system: missiles with varying fuel levels, lift in aircraft flying
• MIMO (multiple-input, multiple-output) system
• System simulation with digital computer
-1-
3.2 Some Observations
di 1
L dt + Ri + C ∫ i dt =v(t )
dq di d 2 q
=with i (t ) =and = 2
, ∫ idt q
dt dt dt
d 2q dq 1
→ L 2
+R + q= v(t )
vL (t ) q dt dt C
di 1
L + Ri + ∫ i dt =
v(t )
dt C
di 1 dq
L − q (t ) − Ri (t ) + v(t )
= =i
dt C dt
1 → →
vL (t ) = − q (t ) − Ri (t ) + v(t )
C di 1 R 1 di 1 R 1
=
− q − i + v(t ) =
− q − i + v(t )
dt LC L L dt LC L L
-2-
Ex: Determine linearly independent or linearly dependent.
- Two vectors:
= x1 (1,1),
= x2 (2, 2)
1. Linear combination:
S = K n xn + K n −1 xn −1 + + K1 x1
2. Linear independence:
S=0 only if every Ki=0 and no xi=0.
A is invertible (det( A) ≠ 0). It implies that the equation (A) has only the trivial solution K1 =
K2 = 0.
K3 =
→ Therefore, this set of vectors is linearly independent.
Example 2:
1 0 0 −1 1 0
Consider the set of vectors , , on the vector space M 22 .
0 1 0 0 0 0 OR
K1 + K 3 =0 1 0 1 K1 0
Determine if this set is linearly independent or linearly dependent.
− K 2 = 0 → 0 −1 0 K 2 = 0
K1 = 0 1 0 0 K 0
0
K1 + K 3 = 3
1 0 0 −1 1 0 K1 + K 3 −K2 1 0 1
K1 + K2 + K3 =0→ = 0 ⇒ −K2 = 0
0 1 0 0 0 0 0 K1
K1 = 0
→ det 0 −1 0 =
1 (≠ 0)
1 0 0
→ K1 = K 2 = K 3 = 0 → Therefore, this set of vectors is linearly independent.
-4-
3.4 Applying the State-Space Representation
diL
vL = L
dt
dvC dvC
iC = C
dt C dt = iC
L diL = v
dt L
vC dv dvC v dvC 1 1
iL = iR + iC = +C C ( KCL) C − C + iL
= =
− vC + iL
R dt dt R dt RC C
⇒ ⇒
di di diL 1 1
v(t ) = vL + vC = L L + vC ( KVL) L L =−vC + v(t ) − vC + v
=
dt dt dt L L
−1 1
RC 0
vC C vC
= + 1 v(t )
iL −1 i
0 L L
⇒
L
VC 1 v
iR
= = ( 0) C
R R iL
-5-
Example 3.2: Representing an electrical network
Find the state and output equations if the output is y = [vR 2
iR2 ]T .
i
x = L
vC
di dv diL
dvC L,
L L v=
= C C iC dt
C
dt dt dt ⇒ x =
dvC
State variables
= : x1 iL=
, x2 vC
dt
vR2 =−vC + vL
vL dvC
i
R= + iL + C
1 dt iR2= iC + 4vL
dvC vR2
C = − 4 v =
vL − vC
− 4 v =
(1 − 4 R2 ) v − 1 v
dt R2
L
R2
L
R2
L
R2
C
State variables :
= , x2 vC
x1 iL=
(v=
L vC + vR2 )
diL diL
vL = L =
iL
x = , x
dt
dt
vC dvC
dt
Ci − iL
↓
1 C
C − VC − VC − C (i − iL ) L dVC i −i
diL R2 R2 + R2iL − VC − R2i C
= =
L
R1
dt = 1
dt L L(1 − 4 R2 ) L L ∆ L(1 − 4 R2 ) diL − VC
C C[ − − ] C − R2
R1 R2 R1 R2 dt
L(1 − 4 R2 )
C −
R2
1
(1 − 4 R2 )iL + VC − (1 − 4 R2 )i
dVC R1 R
= , where ∆ = − (1 − 4 R2 ) + 2
dt C ∆ R1
vR2 −vC + vL
The output equation is: ⇒=y =
iR iC + 4vL
2
vR2 R2 / ∆ −(1 + 1 / ∆ ) iL − R2 / ∆
⇒ + i (t )
i
R2 1 / ∆ (1 − 4 R1 ) / ( ∆R ) v
1 C −1 / ∆
-7-
Example 3.3: Representing a translational mechanical system Stiffness k x(t)
d 2 x(t )
Inertia M = M v(t )
dt
x Ax + Bu
=
• State variables: x1 , v1
x2 , v2
dx
1
= v1
x1 = v1 dt
dx
k D k 2
= v2
M v = k ( x2 − x1 ) − Dv1 ⇒ v1 =
− x1 − v1 + x2 dt
1 1 M1 M1 M1
x2 = v2
k k 1
M 2 v2 =f − k ( x2 − x1 ) ⇒ v2 = x1 − x2 + f x Ax + Bu
=
M 2 M 2 M 2 y Cx + Du
=
x1 0 1 0 0 x1 0 x1
⇒ v1 − K / M1 − D / M1 K / M1 0 v1 0
+ f (t ), v1
x2 = (0 0 1 0)
x2 0 0 0 1 x2 0 x
2
v
K / M2 0 −K / M 2 0 v2 1 / M 2 2
v2
-8-
3.5 Converting a Transfer Function to State Space
x1
• Consider differential equation:
x
xn x2 x1 x= 2
xn n
d y n −1
d y dy
+ a n −1 + + a1 + a0 y =
b0 u xn
dt n dt n −1 dt x Ax + Bu
=
dy d2y d n −1 y
Choose state variables ⇒ = , x2
x1 y= , x3
= , =
, xn
dt dt 2 dt n −1
State eq. ⇒ x1 =x2 , x2 =x3 , , xn −1 =xn , xn =− a0 x1 − a1 x2 − − an −1 xn + b0u
x1 0 1 0 0 0 0 0 x1 0 x1
x2 0 0 1 0 0 0 0 x2 0 x2
x3 0 0 0 1 0 0 0 x3 0 x3
+ u , y = (1 0 0 0 )
x 0 0 0 0 0 0 1 xn −1 0 x
n −1 n −1
xn − a0 − a1 − a2 − a3 − a4 − a5 − an −1
n b0
x xn
-9-
Example 3.4: Converting a transfer function with constant term in numerator
Find the state-space representation in phase-variable form equations.
x Ax + Bu
=
C (s) 24 y Cx + Du
=
= 3 → ( s3 + 9s 2 =
+ 26 s + 24)C ( s ) 24 R( s )
R( s ) s + 9 s 2 + 26 s + 24
• D.E. by taking the inverse Laplace transform with zero initial conditions:
D.E.:
c + 9c + 26c + 24c = 24r differential equation
x1 = x2
x = x x1 0 1 0 x1 0
2
3
⇒ x2 = 0 0 1 x2 + 0 r
x3 = −24 x1 − 26 x2 − 9 x3 + 24r x − 24 − 26 − 9 x 24
3 3
y = c = x
x1
y = (1 0 0 ) x2
state-space representation
x3
-10-
Example 3.4: (Continued)
x 0 1 0 x1 0 x1
1
x2 = 0
0 1 x2 + 0 r , y = (1 0 0 ) x2 x Ax + Bu
=
x − 24 − 26 − 9 x 24 x
3 3 3 y Cx + Du
=
state-space representation
-11-
• Appendix B: Matlab Codes & Outputs '(ch3p3)'
A=[0 1 0;
0 0 1;
-24 -26 -9];
B=[0 0 24]’;
'(ch3p1)’ %B=[0;0;24];
% (ch3p2)
A=[0 1 0; 0 0 1; -9 -8 -7] C=[1 0 0];
C=[2 3 4]
B=[7 8 9]' D=0;
% or
% B=[7; 8; 9]
A1=[0 1 0 F=ss(A, B, C, D)
0 0 1
-9 -8 -7] F =
C = A =
A = x1 x2 x3
2 3 4 x1 0 1 0
0 1 0 x2 0 0 1
0 0 1 x3 -24 -26 -9
-9 -8 -7 B =
B =
7 u1
A1 = 8 x1 0
9 x2 0
0 1 0 x3 24
0 0 1
-9 -8 -7 C =
x1 x2 x3
y1 1 0 0
− state-space model
D =
x1 0 1 0 x1 0
u1
= x2 0 0 1 x2 + 0 r
x −24 −26 −9 x 24 y1 0
3 3
x1 Continuous-time state-space model.
y = (1 0 0 ) x2
x
3
-12-
• Appendix B: Matlab Codes & Outputs
'Example 3.4'
num=24;
'Example 3.4’ den=[1 9 26 24];
[A, B, C, D]=tf2ss(num, den);
num=24;
den=[1 9 26 24]; % To 'Phase-variable form'
C (s) 24 [A, B, C, D]=tf2ss(num, den) P=[0 0 1; 0 1 0; 1 0 0];
= 3 2
R( s ) s + 9 s + 26 s + 24 Ap=inv(P)*A*P
Bp=inv(P)*B
• State-Space Representation A = Cp=C*P
-9 -26 -24 Dp=D
1 0 0
x Ax + Bu
= 0 1 0 Ap =
y Cx + Du
= 0 1 0
B = 0 0 1
1 -24 -26 -9
x1 0 1 0 x1 0 0
0
x2 = 0 0 1 x2 + 0 r , Bp =
x − 24 − 26 − 9 x 24 0
3 3 C = 0
0 0 24 1
x1
=y (1 0 0 ) x2 + 0 ⋅ r D = Cp =
x 0 24 0 0
3
⇓ Dp =
Controller Canonical Form 0
⇓
Phase-variable Form
-13-
• Decomposing a transfer function
b2
If a3 = 1, +
b1 y
+ +
b0
+ x3 x3 x2 x1
r (t ) 1 ∫ ∫ ∫
− x1 x1 x1
x2
a2
a1
a0
x1 = x2
x2 = x3 x1 0 1 0 x1 0 x1
⇒ x 0 1 x2 =+ 0 r , y b2 ] x2
x3 =
− a0 x1 − a1 x2 − a2 x3 + r
= 2 0 [b0 b1
x3 −a0 −a1 −a2 x3 1 x3
y = b0 x1 + b1 x2 + b2 x3
-14-
Example 3.5: Converting a transfer function with polynomial in numerator
Find the state-space representation of the transfer function.
C ( s ) = (b2 s 2 + b1s + b0 ) X 1 ( s ) = ( s 2 + 7 s + 2) X 1 ( s )
c(t ) =
x1 (t ) + 7 x1 (t ) + 2 x1 (t ) y = c(t ) = b2 x3 + b1 x2 + b0 x1
x1 = x1 =x3 + 7 x2 + 2 x1
x1 = x2
state-space representation = x1 x1
x
2 x
y [b= b1 b2 ] x2 [ 2 7 1 ] x2
3
= 0
x1 0 1 0 x1 0
x
2
0
0 1 x2 + 0 r x3 x3
x3 −24 −26 −9 x3 1
x1
y = [ 2 7 1 ] x2
x3
-15-
Example 3.5: (Continued)
(b)
Figure 3.12
a. Transfer function;
b. decomposed transfer function;
c. equivalent block diagram.
Note: y(t) = c(t)
-16-
C (s) s2 + 7s + 2
* Controller Canonical Form (page 219) G
= (s) = 3
R ( s ) s + 9 s 2 + 26 s + 24
• Phase-variable Form:
x1 0 1 0 x1 0 x1
x 0 x + = r, y
= 2 0 1 2 0 [ 2 7 1] x2
x3 −24 −26 −9 x3 1 x3
x3 x3 0 1 0 x3 0 x3
x 0 x + = r, y
x = x2 = 2 0 1
2 0 [ 2 7 1] x2
x1
x1 −24 −26 −9 x1 1 x1
x p AP xP + BP r
= xC AC xC + BC r
=
y = C P xP y = CC xC
xC AC xC + BC r
=
y = CC xC
0 0 1
xC= P ⋅ x p
xC =
0 1 0 xP =
P ⋅ xp →
1 0 0 xC= P ⋅ x p
AC PxP + BC r ,
Px p = y=
CC PxP
x p =P −1 AC PxP + P −1 BC r , y =CC PxP
AP BP CP
AP = P −1 AC P
x p AP xP + BP r
=
BP = P −1 BC
y = CP xP CP = CC P
-18-
• Appendix B: Matlab Code for ch3p4 (Example 3.4)
C (s) 24
= 3 2 'Example 3.4' >> T=tf(num, den)
R( s ) s + 9 s + 26 s + 24
num=24;
numerator den=[1 9 26 24]; T =
= 24
denominator -----------------------
% Controller Canonical Form s^3 + 9 s^2 + 26 s + 24
[A, B, C, D]=tf2ss(num, den);
x1 0 1 0 x1 0
Continuous-time transfer function.
x2 0 0 1 x2 + 0 r % To 'Phase-variable form'
x
3
−24 −26 −9 x 24
3 P=[0 0 1; 0 1 0; 1 0 0];
Ap=inv(P)*A*P
x1 Bp=inv(P)*B AP = P −1 AC P >> [N1, D1]=ss2tf(A,B,C,D)
y = (1 0 0 ) x2 Cp=C*P BP = P −1 BC
x Dp=D N1 =
3 CP = CC P
0 0 0 24
DP = D
D1 =
Controller Canonical Form Phase-variable Form
1.0000 9.0000 26.0000 24.0000
A = Ap =
-9 -26 -24 0 1 0
1 0 0 0 0 1
0 1 0 -24 -26 -9 >> [N2, D2]=ss2tf(Ap,Bp,Cp,Dp)
B = Bp = N2 =
1 0
0 0 0 0 0 24
0 1
D2 =
C = Cp =
0 0 24 24 0 0 1.0000 9.0000 26.0000 24.0000
D = Dp =
0 0
-19-
3.6 Converting from State Space to a Transfer function
-20-
Example 3.6: State-space representation to transfer function
Find the transfer function, T(s)=Y(s)/U(s).
0 1 0 10
Y ( s)
x = 0 0 1 x + 0 u , y = (1 0 0 ) x ⇒ T ( s) = = C ( sI − A) −1 B + D ?
0 U ( s)
−1 − 2 − 3
s 0 0 0 1 0 s −1 0
( sI − A) = 0 s 0 − 0 0 1 = 0 s −1
0 0 s −1 − 2 − 3 1 2 s + 3
s 2 + 3s + 2 s+3 1
−1 s ( s + 3) s
2
adj( sI − A ) − s − ( 2 s + 1) s
( sI − A) −1 = = 3 2
det( sI − A) s + 3s + 2 s + 1
Y (s)
T (s) = = C ( sI − A) −1 B + D
U (s)
10
−1 10( s 2 + 3s + 2)
= (1 0 0 )(sI − A ) 0 + 0 = 3 ⇐ The final result!
0 s + 3s 2 + 2 s + 1
-21-
• Using Matlab to convert a state-space representation to a transfer function
num =
0 10.0000 30.0000 20.0000
den =
A=[0 1 0;0 0 1;-1 -2 -3]; 1.0000 3.0000 2.0000 1.0000
B=[10; 0; 0];
C=[1 0 0];
D=0; a =
x1 x2 x3
x1 0 1 0
[num,den]=ss2tf(A,B,C,D,1) x2 0 0 1
%G(s)=num/den, x3 -1 -2 -3
b =
Tss=ss(A,B,C,D) u1
x1 10
x2 0
'Polynomial form, Ttf(s)' ans = Polynomial form, Ttf(s)
x3 0
Ttf=tf(Tss) Transfer function: c =
10 s^2 + 30 s + 20 x1 x2 x3
'Factored form, Tzpk(s)' --------------------- y1 1 0 0
Tzpk=zpk(Tss) s^3 + 3 s^2 + 2 s + 1
10 (s+2) (s+1)
Continuous-time model.
-----------------------------------
(s+2.325) (s^2 + 0.6753s + 0.4302)
-22-
• Using Matlab’s Symbolic Math Toolbox to convert a state-space
representation to a transfer function
ans =
(ch3sp1) Example 3.6
ans =
T(s)
2
s + 3 s + 2
10 -------------------
3 2
s + 3 s + 2 s + 1
>>
-23-
Walking robots (Hannibal): explore hostile
3.7 Linearization environments and rough terrain
d 2θ MgL
J 2 + sin θ = T x1 = x2
dt 2
⇒ MgL T
dθ x
2 = − sin x +
Let x1 = θ , x2 = 2J
1
J
dt
d 2θ MgL T
2
=
− sin θ +
dt 2J J
-24-
• We need to linearize the equation about equilibrium point. dθ
x1 = θ , x2 =
dt
dθ
• The equilibrium point is: x1 = 0, x2 = 0 → θ = 0, =0
dt
x θ
⇒ 1 = = 0
x2 e θ e
x1= 0 + δ x1 x1 0 δ x1
⇒ = +
x2= 0 + δ x2 2 0 δ x2
x
df ( x1 ) ( x1 − x0 ) d sin( x1 )
f ( x=
1) sin( x1 ) ≈ f ( x0 ) + + ≈ sin(0) + 0) δ x1
( x1 −=
dx x = x0 1! dx1 x1 = 0
-25-