You are on page 1of 7

Available online at www.sciencedirect.

com

Procedia Engineering 48 (2012) 629 – 635

MMaMS 2012

State-Space model of a mechanical system in MATLAB/Simulink


Peter Siváka*, Darina Hroncováa
a
Technical University of Košice, Faculty of Mechanical Engineering, Letná 9, 042 00 Košice, 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, Lagrange‘s equations and
the Hamilton‘s equations.
© 2012 The Authors. Published by Elsevier Ltd.
© 2012 Published by Elsevier Ltd.Selection and/or peer-review under responsibility of the Branch Office of Slovak Metallurgical Society at
Selection
Faculty of and/or peer-review
Metallurgy under
and Faculty responsibility
of Mechanical of the Branch
Engineering, Office
Technical of Slovak
University Metallurgical
of Košice Society
Open access underatCC
Faculty of Metallurgy
BY-NC-ND license. and
Faculty of Mechanical Engineering, Technical University of Košice.

Keywords: State Space, Transfer Function, kinetic energy, potential energy, Matlab, Simulink.

Nomenclature
m 1, m 2 masses
k1, k2 stiffness of the springs
b 1, b 2 coefficients of viscous damping
H Hamilton’s function
Ek kinetic energy
Ep potential energy
D Rayleigh’s dissipative function
pi 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.

1877-7058 © 2012 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 Košice Open access under CC BY-NC-ND license.
doi:10.1016/j.proeng.2012.09.563
630 Peter Sivák 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. Newton’s 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).

[ W Y W
  [ W Y W
 
) W
N N
E E
P P

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 m1 and m2 connected with springs with stiffnesses k1 and k2 and dampers with linear damping coefficients b1 and b2
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) = F0sin(Ȧt) is used for the model excitation. The
respective members perform linear forced oscillating motion. Equations of the motion:

m1 x1 = − Fr1 − Fd 1 + Fr 2 + Fd 2 + F (t ) , (1)


m2 x2 = − Fr 2 − Fd 2 , (2)
reaction forces in the springs
Fr1 = k1. x1 , Fr2 = k 2 . (x2 − x1 ) , (3)
damping forces
Fd1 = b1 . x1 , Fd 2 = b2 . (x2 − x1 ) . (4)

The aim is to determine the response of the oscillating system - displacements x1=x1(t), x2=x2(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. Lagrange‘s equations

Next we determine the equations of motion of the above mentioned system using Lagrange’s 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 q1 = x1 , q2 = x2 , and the generalized velocities as q1 = x1 , q 2 = x 2 , the
kinetic energy of the system is:
1 1
Ek = m1 x12 + m2 x 22 , (5)
2 2
potential energy
1 1
E p = k1 x12 + k 2 ( x2 − x1 )2 , (6)
2 2
Rayleigh’s dissipative function
1 1
D = b1 x12 + b2 (x 2 − x1 )2 , (7)
2 2
generalized forces
Qb1 = F (t ), Qb2 = 0 . (8)
Peter Sivák and Darina Hroncová / Procedia Engineering 48 (2012) 629 – 635 631

Substituting the generalized coordinates the potential energy of the system:

1 1
Ep = k1 x12 + k 2 ( x2 − x1 )2 = 1 k1 x12 + 1 k 2 x22 − k 2 x1 x2 + 1 k 2 x12 , (9)
2 2 2 2 2

Rayleigh‘s dissipative function


1 1 1 1 1
D= b1 x12 + b2 (x 2 − x1 )2 = b1 x12 + b2 x 22 − b2 x1 x 2 + b2 x12 . (10)
2 2 2 2 2

Lagrange’s equations of the second kind for the mechanical system (Fig. 2) are:

d § ∂ Ek · ∂ Ek ∂ Ep ∂D
¨¨ ¸¸ − =− − + Qb1 , (11)
dt © ∂ x1 ¹ ∂ x1 ∂ x1 ∂ x1

d § ∂ Ek · ∂ Ek ∂ Ep ∂D
¨¨ ¸¸ − =− − + Qb2 . (12)
dt © ∂ x 2 ¹ ∂ x2 ∂ x2 ∂ x 2

After substitution of the partial derivations we obtain equations of motion in the form:

b1 b k k 1
x1 = − x1 + 2 ( x 2 − x1 ) − 1 x1 + 2 (x2 − x1 ) + F (t ) , (13)
m1 m1 m1 m1 m1

b2
x2 = − (x2 − x1 ) − k2 (x2 − x1 ) , (14)
m2 m2

where x1 , x 2 are velocities and x1 , x2 are accelerations of the masses m1 and m2. These equations are linear differential
equations of second order with constant coefficients.

4. Hamilton‘s equations

The Hamilton’s 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:

H = Ek + E p , (15)

1 1 1 1 1
H= m1 x12 + m2 x 22 + k1 x12 + k 2 x22 − k 2 x1 x2 + k 2 x12 . (16)
2 2 2 2 2

Then Hamilton's equations:


∂xi ∂H
= , (17)
∂t ∂pi

∂pi ∂H
=− + Qi + Qbi . (18)
∂t ∂xi

State variables of the mechanical system from Fig. 1 are the displacements x1, x2 and momentum p1, p2. The kinetic
energy expressed by the momentum is:
2
1 1 §p · p2
Ek i = mi x 2i = mi ¨¨ i ¸¸ = i , (19)
2 2 © mi ¹ 2mi
potential energy
632 Peter Sivák and Darina Hroncová / Procedia Engineering 48 (2012) 629 – 635

1
Ep = ki xi2 , (20)
2
Rayleigh‘s dissipative function
1
D= bi xi2 . (21)
2

Generalized linear force for viscous damping is expressed by Rayleigh's dissipative function relationship:

∂D
Qi = − , i=1,2 , (22)
∂ xi
generalized forces
Qb1 = F (t ) , Qb2 = 0 . (23)

Equations of the mechanical system are obtained in the form:

d x1 (t ) ∂ H
= , (24)
dt ∂ p1

d x2 (t ) ∂ H
= , (25)
dt ∂ p2

d p1 (t ) ∂H
=− + Q1 + Qb1 , (26)
dt ∂ x1

d p2 (t ) ∂H
=− + Q2 + Qb2 . (27)
dt ∂ x2
In matrix form:
ª d x1 (t ) º
« dt »
« »
« d x2 (t ) » ª x1 (t ) º
« dt » « »
x (t )
« » = A . « 1 » + B . ª F (t )º , (28)
« d p1 (t ) » « p1 (t )» « 0 »
¬ ¼
« » « »
« d t » p (
¬« 1 ¼»t )
« d p2 (t ) »
« »
¬ dt ¼
state vector is
X = [x1 (t ), x2 (t ), p1 (t ), p2 (t )]T . (29)

Equations of the mechanical system in matrix form for pi(t)=mi.vi(t) , i=1,2 are:

ª d x1 (t ) º
« dt »
« »
« d x2 (t ) » ª x1 (t ) º
« » « »
« d t » = A.« x2 (t )» + B . ª F (t )º (30)
« d v1 (t ) » «v1 (t ) » «0 »
¬ ¼
« » « »
« dt » ¬«v2 (t )¼»
« d v2 (t ) »
« »
¬« d t ¼»
Peter Sivák and Darina Hroncová / Procedia Engineering 48 (2012) 629 – 635 633

and state vector


X = [x1 (t ) , x2 (t ), v1 (t ), v2 (t )]T . (31)

We have determined the equations of state of a mechanical system with two degrees of freedom for the state variables x1,
x2 and v1, v2 of respective objects with masses m1, m2.

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):

' LQWHUQDOVWDWH
X W \ W

 [ W [ W  
% œ &
LQSXW  RXWSXW

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

For State-Space equations in form [7]:


x (t ) = A. x (t ) + B. u (t ) , (32)

y (t ) = C. x (t ) + D. u (t ) . (33)
We obtain:
ª x1 º ª x1 º
« » « »
» + B . ª« º» ,
F
« x 2 » = A . « x2 (34)
«v1 » «v1 » ¬ 0 ¼
« » « »
«¬v2 »¼ «¬v2 »¼

ª x1 º
« »
x
y = C .« 2 » + D. ª F º .
«v1 » « 0» (35)
¬ ¼
« »
¬«v2 ¼»

A, B, C, D are the respective matrices of the mechanical system defined as follows:


634 Peter Sivák and Darina Hroncová / Procedia Engineering 48 (2012) 629 – 635

ª 0 0 1 º
0 ª0 0 º
« » «0
« 0 0 0 1
» « 0 »»
« (k + k ) k 2 (b + b ) b2 » «1 » ª1 0 0 0º ª0 0 º
A = «− 1 2 − 1 2 », B=« 0» , C = « » , D =« » . (36)
« m 1 m 1 m1 m1 » « m1 » ¬ 0 1 0 0 ¼ ¬0 0 ¼
« k2 k b2 b » « 1 »
« − 2 − 2» «0 »
¬ m2 m 2 m 2 m2 ¼ ¬ m2 ¼

The input u(t) is represented by the excitation forces:

ª F (t )º
u (t ) = « » . (37)
¬ 0 ¼

And the output y(t) is represented by the displacements x1(t) and x2(t):

ª x1 (t ) º
« »
ª1 0 0 0º « x2 (t )»
y (t ) = « » . . (38)
¬0 1 0 0¼ «v1 (t ) »
« »
«¬v2 (t )»¼

Parameters used in the process of solution (Fig. 3) of the mechanical system were: m1=70 kg, m2=140 kg, k1=500 N/m,
k2=250 N/m, b1=10 N/(m.s-1), b2=50 N/(m.s-1), F0=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 x1, x2 and velocities v1, v2 are shown in Fig. 4 .

Displacement x1 a x2 of the member 1 and 2 Velocity v1 and v2 of the member 1 a 2


0.25 0.4
x1=x1(t) v1=v1(t)
0.2 0.3
x2=x2(t) v2=v2(t)
0.15
0.2
0.1
0.1
v1 [m/s], v2 [m/s]
x1 [m],x2 [m]

0.05
0
0
-0.1
-0.05
-0.2
-0.1

-0.15 -0.3

-0.2 -0.4

-0.25 -0.5
0 2 4 6 8 10 0 2 4 6 8 10
(a) t [s]
(b) t [s]

Fig. 4. Simulation resuts in Simulink for (a) displacement x1(t), x2(t) and (b) velocity v1(t), v2(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:
Peter Sivák and Darina Hroncová / Procedia Engineering 48 (2012) 629 – 635 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.
Displacement x1 a x2 with Transfer Fcn
0.25
x1=x1(t)
0.2
x2=x2(t)
0.15

0.1
x1 [m],x2 [m]

0.05

-0.05

-0.1

-0.15

-0.2

-0.25
0 2 4 6 8 10
t [s]

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] Vavrinþíková, V., Hroncová, D., 2008. Modelovanie kmitania v prostredí Simulink. Acta Mechanica Slovaca, Košice, Slovakia. s. 869-876. ISSN
1335-2393.
[2] Gmiterko, A., 2004. Mechatronics. Emilenia, Košice, Slovakia.
[3] Karban, P., 2006. Výpoþty a simulace v programech Matlab a Simulink. Computer Press, Brno, ýesko. ISBN 80-251-1301-9.
[4] Kozák, Š., 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., Michalíþek, M., Mudrík, J., Slavkovský, J., 1991. Dynamika strojov. Alfa, Bratislava. Slovakia. ISBN 80-05-00756-6.
[7] Horáþek, P., 1999. Systems and models. Nakladatelství ýVUT, Praha, ýesko.
[8] SegĐa, Š., SegĐa, 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, Košice.
[10] Volek, J., SegĐa, Š., Soukup, J., 2007. Analytický výpoþet vertikálních posuvĤ trolejbusu Škoda 21 Tr pĜi pĜejezdu soustavy pĜekážek dle ýSN ve
stanovených bodech. Výzkumná zpráva þ. 05/07, FVTM UJEP v Ústí nad Labem. ýesko.

You might also like