You are on page 1of 7

Procedia Engineering 48 ( 2012 ) 629 635

1877-7058 2012 Published by Elsevier Ltd.Selection and/or peer-review under responsibility of the Branch Ofce of Slovak Metallurgical Society at
Faculty of Metallurgy and Faculty of Mechanical Engineering, Technical University of Koice
doi: 10.1016/j.proeng.2012.09.563
MMaMS 2012
State-Space model of a mechanical system in MATLAB/Simulink
Peter Sivk
a
*, Darina Hroncov
a
a
Technical University of Koice, Faculty of Mechanical Engineering, Letn 9, 042 00 Koice, Slovak republic
Abstract
This paper describes solution of the equations of motion of the mechanical system by using State-Space blocks in MATLAB/Simulink. It
deals with the mechanical system with two degrees of freedom. State-Space block solution is compared with solution made by an
alternative approach, using so called Transfer Fcn block. Equations are also derived by Newton's second law, Lagranges equations and
the Hamiltons equations.
2012 The Authors. Published by Elsevier Ltd.
Selection and/or peer-review under responsibility of the Branch Office of Slovak Metallurgical Society at Faculty of Metallurgy and
Faculty of Mechanical Engineering, Technical University of Koice.
Keywords: State Space, Transfer Function, kinetic energy, potential energy, Matlab, Simulink.
Nomenclature
m
1
, m
2
masses
k
1
, k
2
stiffness of the springs
b
1
, b
2
coefficients of viscous damping
H Hamiltons function
E
k
kinetic energy
E
p
potential energy
D Rayleighs dissipative function
p
i
momentum of the i-th member
x state vector
y output vector
u input vector
A state matrix
B input matrix
C output matrix
D feedforward matrix
1. Introduction
In the first part we derived the equations of motion of the mechanical system with two degrees of freedom using the
* Corresponding author. Tel.: +421556022466.
E-mail address: peter.sivak@tuke.sk.
Available online at www.sciencedirect.com
2012 Published by Elsevier Ltd.Selection and/or peer-review under responsibility of the Branch Ofce of Slovak Metallurgical Society at
Faculty of Metallurgy and Faculty of Mechanical Engineering, Technical University of Koice
630 Peter Sivk and Darina Hroncov / Procedia Engineering 48 ( 2012 ) 629 635
second Newton's law. Next the these equations are derived by Lagrange's equations of the second kind. Finally we
determine the state equations by using Hamilton's equations [2]. The aim is to describe the use of State-Space blocks and
Transfer Fcn of the dynamic system in Matlab/Simulink. The obtained results are compared with direct solution in Matlab.
The results are presented in graphical form.
2. Newtons Equations
In this section we describe the compilation of equations of motion of the mechanical system with two degrees of freedom
with Lagrange equations of the second kind and the Hamilton equations. These equations are then solved in Matlab with
Runge-Kutta method. The results provide information about displacement, velocity and acceleration of individual members
of the mechanical system as a function of time. A harmonically variable force F(t) is used for the model excitation (Fig. 1).
k
b
m
k
b
m
(L)
x (L), v (L)
1 1
x (L), v (L)
z z
1
1
1
z
z
z
Fig. 1. Damped mass-spring system with two degrees of freedom.
We consider a mechanical system with two degrees of freedom of movement (Fig. 1), which consists of bodies with
masses m
1
and m
2
connected with springs with stiffnesses k
1
and k
2
and dampers with linear damping coefficients b
1
and b
2
connected to a rigid frame [5-10]. The system performs linear motion in direction of springs and dampers axes. The weights
of the springs are not considered. A harmonically variable force F(t) = F
0
sin(t) is used for the model excitation. The
respective members perform linear forced oscillating motion. Equations of the motion:
( ) t F F F F F x m
d r d r
+ + + =
2 2 1 1 1 1
, (1)
2 2 2 2 d r
F F x m = , (2)
reaction forces in the springs
( )
1 2 2 1 1
. , .
2 1
x x k F x k F
r r
= = , (3)
damping forces
( )
1 2 2 1 1
. , .
2 1
x x b F x b F
d d
= = . (4)
The aim is to determine the response of the oscillating system - displacements x
1
=x
1
(t), x
2
=x
2
(t). This, however, requires
to solve a system of differential equations. For a mechanical system with two degrees of freedom it is a nonhomogeneous
system of 2nd order linear differential equations with constant coefficients.
3. Lagranges equations
Next we determine the equations of motion of the above mentioned system using Lagranges equations of the second
kind. For this we need to determine kinetic and potential energy of the system and the Rayleigh dissipative function.
If we define the generalized coordinates as
2 2 1 1
, x q x q = = , and the generalized velocities as
2 2 1 1
, x q x q = = , the
kinetic energy of the system is:
,
2
1
2
1
2
2 2
2
1 1
x m x m E
k
+ = (5)
potential energy
( ) ,
2
1
2
1
2
1 2 2
2
1 1
x x k x k E
p
+ = (6)
Rayleighs dissipative function
( ) ,
2
1
2
1
2
1 2 2
2
1 1
x x b x b D + = (7)
generalized forces
0 ), (
2 1
= =
b b
Q t F Q . (8)
631 Peter Sivk and Darina Hroncov / Procedia Engineering 48 ( 2012 ) 629 635
Substituting the generalized coordinates the potential energy of the system:
( ) ,
2
1
2
1
2
1
2
1
2
1
2
1 2 2 1 2
2
2 2
2
1 1
2
1 2 2
2
1 1
x k x x k x k x k x x k x k E
p
+ + = + = (9)
Rayleighs dissipative function
( ) .
2
1
2
1
2
1
2
1
2
1
2
1 2 2 1 2
2
2 2
2
1 1
2
1 2 2
2
1 1
x b x x b x b x b x x b x b D + + = + = (10)
Lagranges equations of the second kind for the mechanical system (Fig. 2) are:
,
1
1 1 1 1
b
p
k k
Q
x
D
x
E
x
E
x
E
dt
d
+


(11)
2
2 2 2 2
b
p
k k
Q
x
D
x
E
x
E
x
E
dt
d
+


. (12)
After substitution of the partial derivations we obtain equations of motion in the form:
( ) ( ) ( ) ,
1
1
1 2
1
2
1
1
1
1 2
1
2
1
1
1
1
t F
m
x x
m
k
x
m
k
x x
m
b
x
m
b
x + + + = (13)
( ) ( )
1 2
2
2
1 2
2
2
2
x x
m
k
x x
m
b
x = , (14)
where
2 1
, x x are velocities and
2 1
, x x are accelerations of the masses m
1
and m
2
. These equations are linear differential
equations of second order with constant coefficients.
4. Hamiltons equations
The Hamiltons function H = H (q, p), which is the sum of kinetic and potential energies can be used to determine the
equations of motion of the mechanical system with two degrees of freedom. It has a form:
,
p k
E E H + = (15)
.
2
1
2
1
2
1
2
1
2
1
2
1 2 2 1 2
2
2 2
2
1 1
2
2 2
2
1 1
x k x x k x k x k x m x m H + + + + = (16)
Then Hamilton's equations:
,
i
i
p
H
t
x

(17)
i
b i
i
i
Q Q
x
H
t
p
+ +

. (18)
State variables of the mechanical system from Fig. 1 are the displacements x
1
, x
2
and momentum p
1
, p
2
. The kinetic
energy expressed by the momentum is:
i
i
i
i
i i k
m
p
m
p
m x m E
i
i
2 2
1
2
1
2
2
2
=

= = , (19)
potential energy
632 Peter Sivk and Darina Hroncov / Procedia Engineering 48 ( 2012 ) 629 635
2
2
1
i i p
x k E = , (20)
Rayleighs dissipative function
2
2
1
i i
x b D = . (21)
Generalized linear force for viscous damping is expressed by Rayleigh's dissipative function relationship:
,
i
i
x
D
Q

= i=1,2 , (22)
generalized forces
( ) 0 ,
2 1
= =
b b
Q t F Q . (23)
Equations of the mechanical system are obtained in the form:
1
1
) (
p
H
t d
t x d

= , (24)
2
2
) (
p
H
t d
t x d

= , (25)
( )
1
1
1
1
b
Q Q
x
H
t d
t p d
+ +

= , (26)
( )
2
2
2
2
b
Q Q
x
H
t d
t p d
+ +

= . (27)
In matrix form:
( )
( )
( )
( )
( )
( )
( )
( )
( )

0
. .
1
1
1
1
2
1
2
1
t F
t p
t p
t x
t x
t d
t p d
t d
t p d
t d
t x d
t d
t x d
B A
, (28)
state vector is
( ) ( ) ( ) ( ) [ ]
T
t p t p t x t x
2 1 2 1
, , , = X . (29)
Equations of the mechanical system in matrix form for p
i
(t)=m
i
.v
i
(t) , i=1,2 are:
( )
( )
( )
( )
( )
( )
( )
( )
( )

0
. .
2
1
2
1
2
1
2
1
t F
t v
t v
t x
t x
t d
t v d
t d
t v d
t d
t x d
t d
t x d
B A
(30)
633 Peter Sivk and Darina Hroncov / Procedia Engineering 48 ( 2012 ) 629 635
and state vector
( ) ( ) ( ) ( ) [ ]
T
t v t v t x t x
2 1 2 1
, , , = X . (31)
We have determined the equations of state of a mechanical system with two degrees of freedom for the state variables x
1
,
x
2
and v
1
, v
2
of respective objects with masses m
1
, m
2
.
5. State Space equation in MATLAB/Simulink
Solution of the nonhomogenous system of differential equations of a mechanical system with two degrees of freedom is
first done in Matlab/Simulink using State-Space and Transfer Fcn blocks [7], [2].
In control engineering, a state space representation is a mathematical model of a physical system as a set of input, output
and state variables related by first-order differential equations. To abstract from the number of inputs, outputs and states, the
variables are expressed as vectors. Additionally, if the dynamical system is linear and time invariant, the differential and
algebraic equations may be written in matrix form. The state space representation (also known as the "time-domain
approach") provides a convenient and compact way to model and analyze systems with multiple inputs and outputs. Unlike
the frequency domain approach, the use of the state space representation is not limited to systems with linear components
and zero initial conditions. "State space" refers to the space whose axes are the state variables. The state of the system can
be represented as a vector within that space.
The most general state-space representation of a linear system with u inputs, y outputs and n state variables is written in
the following form (Fig. 2):
[W
\W XW
LQSXW RXWSXW
LQWHUQDOVWDWH

&
$
%
'
[W

Fig. 2. Block diagram representation of the state space equations.


For State-Space equations in form [7]:
( ) ( ) ( ) t t t u B x A x . . + = , (32)
( ) ( ) ( ) t t t u D x C y . . + = . (33)
We obtain:

0
. .
2
1
2
1
2
1
2
1
F
v
v
x
x
v
v
x
x
B A

, (34)

=
0
. .
2
1
2
1
F
v
v
x
x
y D C . (35)
A, B, C, D are the respective matrices of the mechanical system defined as follows:
634 Peter Sivk and Darina Hroncov / Procedia Engineering 48 ( 2012 ) 629 635
( ) ( )
,
1 0 0 0
0 1 0 0
2
2
2
2
2
2
2
2
1
2
1
2 1
1
2
1
2 1

+
=
m
b
m
b
m
k
m
k
m
b
m
b b
m
k
m
k k
A ,
1
0
0
1
0 0
0 0
2
1

=
m
m
B ,
0 0 1 0
0 0 0 1

= C

=
0 0
0 0
D . (36)
The input u(t) is represented by the excitation forces:
( )
( )

=
0
t F
t u . (37)
And the output y(t) is represented by the displacements x
1
(t) and x
2
(t):
( )
( )
( )
( )
( )

=
t v
t v
t x
t x
t
2
1
2
1
.
0 0 1 0
0 0 0 1
y . (38)
Parameters used in the process of solution (Fig. 3) of the mechanical system were: m
1
=70 kg, m
2
=140 kg, k
1
=500 N/m,
k
2
=250 N/m, b
1
=10 N/(m.s
-1
), b
2
=50 N/(m.s
-1
), F
0
=100 N, =2 rad.s
-1
, initial conditions x(0) = 0 m, v(0) = 0 m/s, [1-4].
Fig. 3 The block diagram in Simulink
Output in Scope block - displacements x
1
, x
2
and velocities v
1
, v
2
are shown in Fig. 4 .
(a)
0 2 4 6 8 10
-0.25
-0.2
-0.15
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
Displacement x1 a x2 of the member 1 and 2
t [s]
x
1

[
m
]
,
x
2

[
m
]
x1=x1(t)
x2=x2(t)
(b)
0 2 4 6 8 10
-0.5
-0.4
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
Velocity v1 and v2 of the member 1 a 2
t [s]
v
1

[
m
/
s
]
,

v
2

[
m
/
s
]
v1=v1(t)
v2=v2(t)
Fig. 4. Simulation resuts in Simulink for (a) displacement x
1
(t), x
2
(t) and (b) velocity v
1
(t), v
2
(t).
6. Transfer Fcn model
The obtained State-Space representation of the mechanical system can be in the Matlab easily transformed to an
equivalent Transfer Fcn model (Fig. 5) by ss2tf function. The syntax of this command in Matlab is:
635 Peter Sivk and Darina Hroncov / Procedia Engineering 48 ( 2012 ) 629 635
>> [num, den]=ss2tf(A,B,C,D,1)
Fig. 5 The block diagram Transfer Fcn
Solving the mechanical system by using State-Space equations and the Transfer Function (Fig. 6) gave the same results,
as we anticipated.
0 2 4 6 8 10
-0.25
-0.2
-0.15
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25
Displacement x1 a x2 with Transfer Fcn
t [s]
x
1

[
m
]
,
x
2

[
m
]
x1=x1(t)
x2=x2(t)
Fig. 6 Simulation results in Simulink with Transfer Fcn
7. Conclusion
The paper describes the compilation of the equations of motion of a mechanical system with two degrees of freedom in
Matlab/Simulink by using State - Space and Transfer function.
Results are shown graphically. The calculation is done for a model with force excitation in Matlab and Simulink, to
illustrate the methodology.
The contribution of this work is primarily educational, especially in the field of Applied Mechanics and Mechatronics.
The above procedure presents the possibility of practical implementation of this solution to simple equations of motion of a
mechanical system in Matlab/Simulink.
Acknowledgement
This contribution is the result of the project implementation: Center for research of control of technical, environmental
and human risks for permanent development of production and products in mechanical engineering (ITMS: 26220120060)
supported by the Research & Development Operational Program funded by the ERDF. This work was also supported in part
by the Ministry of Education of the Slovakia Foundation under Grant VEGA 1/1205/12 and Grant VEGA 1/0289/11.
References
[1] Vavrinkov, V., Hroncov, D., 2008. Modelovanie kmitania v prostred Simulink. Acta Mechanica Slovaca, Koice, Slovakia. s. 869-876. ISSN
1335-2393.
[2] Gmiterko, A., 2004. Mechatronics. Emilenia, Koice, Slovakia.
[3] Karban, P., 2006. Vpoty a simulace v programech Matlab a Simulink. Computer Press, Brno, esko. ISBN 80-251-1301-9.
[4] Kozk, ., Kajan, S., 2006. Matlab Simulink I. STU Bratislava, Bratislava, Slovensko.
[5] Ogatha, K., 1978. System Dynamics. Prentice Hall, Inc., Englewood Cliffs, New Jersey.
[6] Stradiot, J., Michalek, M., Mudrk, J., Slavkovsk, J., 1991. Dynamika strojov. Alfa, Bratislava. Slovakia. ISBN 80-05-00756-6.
[7] Horek, P., 1999. Systems and models. Nakladatelstv VUT, Praha, esko.
[8] Sega, ., Sega, J., 2011. Modelling and Optimization of Vehicle suspension with Magnetorheological Dampers, In: 7th International Conference
Dynamics of Rigid and Deformable Bodies 2011, st nad Labem , 2011. ISBN 978-80-7414-376-2.
[9] Hroncov, D., 2012. Studies of compatible software tools for abstract and concrete design of mechatronic systems and linking them for the purpose of
logical and physical modeling, Dissertation thesis, Koice.
[10] Volek, J., Sega, ., Soukup, J., 2007. Analytick vpoet vertiklnch posuv trolejbusu koda 21 Tr pi pejezdu soustavy pekek dle SN ve
stanovench bodech. Vzkumn zprva . 05/07, FVTM UJEP v st nad Labem. esko.

You might also like