Dynamic Model Analysis of A DC Motor in MATLAB
Dynamic Model Analysis of A DC Motor in MATLAB
State-space Modeling
2 . 1 . S t at e - s p a ce C o nc e p t
2 . 1 . 1 . I nt r o d u ct i o n
1
State vector. A vector which determines uniquely the system state
x(t) for any t ≥ t 0 , once the input u(t) for t ≥ t 0 , is specified.
2
x1 0 1 0 0 0
x 0 0 1 0 0
2
x = , A = , B =
0 0 0 0 1 0
xn −an −an −1 −an − 2 −a1 1
The output equation becomes
x1
x
2
y = [1 0 0 0]
xn
or y = Cx (2.3)
Where C = [1 0 0 0]
Eq. (2.2) is the State Equation, and Eq. (2.3) is the Output Equation.
E x a m p l es :
a.1. Convert the differential equation model
Solution:
The equation is manipulated to the form
From equations (1) and (2) and from substituting equations (1), (2)
and (4) to equation (0) we get
3
When these equations are written in matrix form and the output
equation (1) is included with them, we get the state-space model:
Solution:
Let us choose the state variables as
x1 = y
x 2 = y
x3 = y
Then we obtain
x1 = x 2
x 2 = x3
x 3 = −6 x1 − 11x 2 − 6 x3 + 6u
The last of these three equations was obtained by solving the original
differential equation for the highest derivative term y and then
substituting y = x1 , y = x 2 , y = x3 into the resulting equation. By
use of vector-matrix notation, these three first-order differential
equations can be combined into one as follows:
x1 0 1 0 x1 0
x = 0 0 1 x 2 + 0[u ] (5)
2
x 3 − 6 − 11 − 6 x3 6
4
The output equation is given by
x1
y = [1 0 0] x 2 (6)
x3
Equations (5) and (6) can be put in a standard form as
x = Ax + Bu
(7)
y = Cx
where
0 1 0 0
A= 0 0 1 , B = 0 , C = [1 0 0]
− 6 − 11 − 6 6
The main problem in defining the state variables for this case lies in
the derivative terms on the right-hand side of the last of the preceding
5
n equations. The state variables must be such that they will eliminate
the derivatives of u in the state equation.
It is a well-known fact in modern control theory that if we define the
following n variables as a set of n state variables,
x1= y − β 0u
x2 =y − β 0u − β1u =x1 − β1u
(2.6)
x3 =y − β 0u − β1u − β 2u =x2 − β 2u
( n −1) ( n −1)
xn = y − β 0 u − − β n − 2u − β n −1u = xn −1 − β n −1u
where β 0 , β1 , , β n are determined from
β 0 = b0
β1= b1 − a1β 0
β2 = b2 − a1β1 − a2 β 0 (2.7)
β3 = b3 − a1β 2 − a2 β1 − a3 β 0
βn =
bn − a1β n −1 − − an −1β1 − an β 0
then the existence and uniqueness of the solution of the state equation
is guaranteed. With the present choice of state variables, we obtain
the following state and output equations for the system of Eq. (2.4):
x1 0 1 0 0 x1 β1
x 0 0 1 0 x2 β 2
2
+ [u ]
xn −1 0 0 0 1 xn −1 β n −1
xn −an −an −1 −an − 2 −a1 xn β n
x1
x
=y [1 0 0] 2 + β 0u
xn
=
x Ax + Bu
or (2.8)
=y Cx + Du
6
c). Nonuniqueness of the set of state variables.
It has been stated that a set of state variables is not unique for a given
system. Suppose that x1 , x 2 , , x n are a set of variables. Then we
may take as another set of state variables any set of functions,
x1 = X 1 ( x1 , x 2 , , x n )
x 2 = X 2 ( x1 , x 2 , , x n )
x n = X n ( x1 , x 2 , , x n )
provided that, for every set of values x1 , x 2 , , x n , there
corresponds a unique set of values x1 , x 2 , , x n and vice versa.
Thus, if x is a state vector, then x where
x = Px (2.9)
is also a state vector, provided the matrix P is non-singular. Different
state vectors convey the same information about the system behavior.
Example
c.1. Consider the same system as discussed in Example a.2. We shall
show that Eq. (7) is not the only state equation possible for the
system. Suppose we define a set of new state variables z1 , z 2 , z 3 by
the transformation
x1 1 1 1 z1
x = − 1 − 2 − 3 z
2 2
x3 1 4 9 z 3
or x = Pz (2.10)
where
1 1 1
P = − 1 − 2 − 3 (2.11)
1 4 9
Then by substituting Eq. (2.10) into Eq. (7), we obtain
Pz = APz + Bu
7
By premultiplying both sides of this last equation by P −1 , we get
z = P −1 APz + P −1 Bu (2.12)
or
8
Example:
d.1. Consider the following matrix A:
0 1 0
A= 0 0 1
− 6 − 11 − 6
The characteristic equation is
λ −1 0
λI − A = 0 λ −1
6 11 λ + 6
= λ3 + 6λ2 + 11λ + 6
= (λ + 1)(λ + 2 )(λ + 3) = 0
The eigenvalues of A are the roots of the charcateristic equation, or
-1, -2, and -3.
9
Thus we have proved that the eigenvalues of A are invariant under a
linear transformation.
P = λ1 λ 2 λ3 λ n
2 2 2 2
(2.17)
λ1n λn2 λ3n λnn
λ1 , λ 2 ,, λn = n distinct eigenvalues of A will transform P −1 AP into
the diagonal matrix, or
λ1 0
λ2
P −1 AP = (2.18)
0 λ n
If matrix A defined by Eq. (2.16) involves multiple eigenvalues then
diagonalization is impossible. For example, if the 3x3 matrix A
where
0 1 0
A= 0 0 1
− a3 − a 2 − a1
10
has the eigenvalues λ1 , λ 2 , λ3 then the transformation x=Sz where
1 0 1
S = λ1 1 λ3
λ1 2λ1 λ32
2
will yield
λ1 1 0
S AS = 0 λ1 0
−1
0 0 λ3
Such a form is called the Jordan canonical form.
(2.19)
has full row rank, the system is controllable.
Example:
1. Consider the system given by
x1 1 1 x1 0
x = 0 − 1 x + 1[u ]
2 2
1 1
Since [B AB ] = = singular, the system is not completely
0 0
state controllable.
11
2. Consider the system given by
x1 1 1 x1 0
x = 2 − 1 x + 1[u ]
2 2
[B AB] =
0 1
For this case = non-singular, the system is
1 − 1
therefore completely state controllable.
Example:
1. Consider the system given by
x1 1 1 x1 0
x = − 2 − 1 x + 1[u ]
2 2
x
y = [1 0] 1
x2
1 1
Since [C AC ] =
T
has rank=2, or the determinant is not
0 1
equal zero. Hence the system is completely observable.
12
Note that the control function u does not affect the complete
observability of the system. In order to examine complete
observability, we may simply set u=0. For this system, we have
4 −6 6
[C AC ]
A C = 5
2
−7 5
1 −1 − 1
Note that
4 −6 6
5 − 7 5 = 0 , the rank of the matrix is less than three.
1 −1 1
Therefore, the system is not completely observable.
13
Note that the zero-input response (the response with the input set to
zero) is x ( t ) = x ( 0 ) e at . Because x(t) must be a solution of
x ( t ) = ax ( t ) , it is apparent that the solution embodies a
transcendental function that yields the desired mathematical property.
An algebraic representation of the exponential function exists only as
an infinite series with
1 1
e at =1 + at + ( at ) + ( at ) +
2 3
(2.25)
2! 3!
and differentiation of the series confirms that the derivative of e at is
ae at . This result, in turn, confirms that x ( t ) = Keat is a solution of
x ( t ) = ax ( t ) .
14
If the input is zero, the system model is x ( t ) = Ax ( t ) and the
solution is x ( t ) = Φ ( t ) x ( 0 ) . Thus, the first derivative of Φ ( t )
must be equal to AΦ ( t ) and Φ ( 0 ) must be equal to I. In other
words, the transition matrix must exhibit a property that is very
similar to the property that is ascribed to the exponential function
when applied to a scalar solution. The concept of a vector matrix
exponential function is introduced with Φ ( t ) =
e At , and the required
mathematical properties are attained if e At is defined such that
1 1
e At =I + At + ( At ) + ( At ) +
2 3
(2.29)
2! 3!
Note that the first derivative of e At is Ae At . Revising Equation
(2.28) to utilize the exponential notation produces
t
x ( t ) e At x ( 0 ) + ∫ e BU ( λ ) d λ
A( t − λ )
= (2.30)
0
The exponential representation of the transition matrix yields a time
domain expression of the solution, and the series representation of
the matrix exponential introduces an effective programming option
when considering the utilization of a discrete time algorithm to
simulate the system model.
Note:
Φ (t ) =
e At is transition matrix
Eq. (2.30) is a McLaurin (Taylor) series.
Example:
Obtain the state transition matrix Φ (t ) of the following system;
x1 0 1 x1
x = − 2 − 3 x
2 2
Solution:
For this system,
15
0 1
A=
− 2 − 3
The state transition matrix is given by Φ (t ) = e At = L−1 [sI − A]−1 .
s 0 0 1 s − 1
Since sI − A = − =
0 s − 2 − 3 2 s + 3
The inverse of (sI-A) is given by
s + 3 1
(sI − A)−1 = 1
(s + 1)(s + 2) − 2 s
s+3 1
(s + 1)(s + 2 ) (s + 1)(s + 2 )
=
−2 s
(s + 1)(s + 2 ) (s + 1)(s + 2 )
Hence Φ (t ) = e At = L−1 [sI − A]−1
2e − t − e −2t e − t − e −2t
= −t − 2t
− 2e + 2e − e − t + 2e − 2 t
16
We assume x(0 ) = 0 of Eq. (2.34), and by substituting
X (s ) = (sI − A) BU (s )
−1
Example:
Obtain the transfer function of the system,
x1 − 5 − 1 x1 2
x = 3 − 1 x + 5[u ]
2 2
x
y = [1 2] 1
x2
The transfer function for the system is then
G (s ) = C (sI − A) B
−1
−1
s + 5 1 2
= [1 2]
− 3 s + 1 5
s +1 −1
(s + 2 )(s + 4 ) (s + 2 )(s + 4 ) 2
= [1 2]
3 s+5 5
(s + 2 )(s + 4 ) (s + 2 )(s + 4 )
12 s + 59
=
(s + 2)(s + 4)
2.3.3. Stability Criteria as Applied to Linear State Models
The roots of the characteristic equation are, of course, the poles of the
transfer function, and the poles of transfer function determine the
character of the natural response. Thus, if all the roots of the
characteristic equation are located in the LHP, all of the terms of the
natural response will decay asymptotically to zero.
17
Another definition of stability is described as bounded-input,
bounded-output (BIBO) stability. BIBO stability is obtained if the
output is bounded in response to all bounded inputs. Clearly, if a
linear system display asymptotic stability, it will also display BIBO
stability.
If a LTI system is described using a state model, the system model is
=x ( t ) Ax ( t ) + Bu ( t ) (2.38)
and the system is asymptotically stable if all of the terms of the state
transition matrix approach zero as time approach infinity. Hence, a
system exhibits asymptotic stability if
lim Φ ( t ) =
0 (2.39)
→∞
Example:
From the above example, we know that the characteristic equation of
the system is,
det ( sI − A ) =
0
(s + 2)(s + 4) = 0 ,
Hence the roots of the characteristic equation are -2 and -4, located in
the LHP. It means the system is stable.
18
2.4. Control Analysis using MatLab
jω + 1
10
The open-loop function is described; thus, the gain and phase
margins are also calculated. Bode plots showing both gain (in
decibels) and phase versus frequency on semilog plots can be
obtained using function bode as follows:
%Bode plots (gain and phase) with automatic scaling and labels
n=[0 0 0 200]; % specify the numerator
d=[1 20 100 0]; % specify the denominator
bode(n,d) % plot gain and phase
19
[gm, pm]=margin(n,d1) % calculate gain and phase margins
figure(1)
semilogx(w, db1, w, db2), grid % plot gain
axis([.1 100 -40 20]) % specify plot ranges (optional)
xlabel(‘Freq (r/s)’), ylabel(‘Gain (dB)’) % label axes
pause % press any key to proceed to next plot
figure(2)
semilogx(w, p1, w, p2), grid % plot phase
axis([.1 100 -270 0]) % specify ranges (optional)
set(gca,’ytick’, [-270:30:0]) % specify y scale (optional)
xlabel(‘Freq (r/s)’), ylabel(‘Phase (dB)’) % label axes
For example,
n=[0 0 0 1 2]; % numerator of P(s)
d=[1 3 4 2 0]; % denominator of P(s)
rlocus(n,d) % root locus calculation and plot
[k,poles]=rlocfind(n,d) % specific information request
20
vertically from -5g to +5g. It saved as script M-file, the program can
be applied to a variety of applications with very little modification.
-o0o-
21