You are on page 1of 14

Computer Control

Ball and Beam System

Jorge Alejandro Porras Cuevas

A01361608

Yair Prez Ramrez

A01181363

Roberto Castaeda Asencio

A01182814

Eber Ibsan Torres Len

A01184046

Introduction
There has been a great evolution in the robotics field these days, however most of
the research specially in the control of those robots is focused on production and
manufacturing robots, but there are some other types of robots, for example the
underactuated robots, which contain a greater number of DOFs than the strictly
necessary, as they have less actuators they are smaller, lighter and have better
energy consuption than the regular ones, the problem here is that the control of
these systems is much more complex, and it has been less studied.
One of the biggest problems in this kind of systems, and the one that this work will
focus on, is how to control one of the degrees of freedom that does not have an
actuator (Indirect way), the ball and beam is going to be used to explain this
process.
The ball and beam system is one of the most popular and important laboratory
models for teaching control systems in engineering. Throughout this paper we
present the development of this control system, we will be talking about the
theoretical framework, the mathematical background and model, and the different
steps that were developed to achieve it.
The ball and beam system is classified as an underactuated system, because even
though it has two degrees of freedom, it uses only one actuator. The main purpose
of the system is to balance a steel ball on a beam and take it to a desired position.

Different versions of the ball and beam


There are basically two common versions of this ball and beam system, the first
one is a steel ball rolling free on a a beam, the beam is connected to some gears,
this is going to be the actuator, to control the position of the ball, it is used a sensor
to specify the actual position of the ball, and send in this way the error signal to the
system.

Fig.1 Example of
ball and beam with
gear arrangement.

The other type of ball and beam that is commonly found on the labs is one that
uses an actuator attached just to the middle of the bar.

Fig 2. Ball and Beam


system with actuator in
the middle.

As we have mentioned before, a subactuated system has certain characteristics


that make them very interesting, for example the savings that in can produce in
space, money required to be built, and energy consuption, however if all of this
does not seem enough to study them, lets consider an actuated system where one
of its actuators stop working, then we will have to apply one of the methods
described here to control it.

Objectives.
Main objetive
The main objective in this work is to model and simulate prototype of the
previously discussed system, ball and beam.
Specific objectives
To design from scracth a mathematical model for the system.
To understand the mathematical processes, required to program the
mathematical models.
To implement control algorithms to the system, so we can achieve a desired
position.
To create a complete virtual model on the system, considering as much
variables as posible.

Problem Statement
As mentioned in the introduction above, it is needed an efficient control system, for
underactuated mechanisms, it is required to find a way to control the position of an
element by controlling a non direct actuator.

Hipothesis and solution proposed.


The solution proposed here implements a mathematical model of the system, this
will be approached through Euler-Lagrange equations, later this mathematical
model is linearized, so we can apply a control method, and simulate all the results
in a virtual reality environment.

Mathematical Model.
The mathematical model of a system, is its representation with some equations,
genarally, diferential equations, obtained through the laws of the physics that
applies to the system, in order to simulate those conditions, and being capable of
studying them and controlling them.
In this paper we are going to be using the Euler-Lagrange method, this method is
used to model dynamic systems by means of the potential and Kinetic energies of
those systems.
The Lagrangian is represented by:
L = K V (1)
Where K is the kinetic energy and V is the potential energy of the system, the
lagrangian is going to be used in the Euler-Lagrange method as follows:

d L L
= (2)
dt q q

Where:
q is the generalized coordinate vector.
L is the lagrangian
is the vector of any momentum applied the system .

The first step in this process is to determine the independent variables in the
system, in this case we will consider two, the first one is the position of the bar with
the x axis, this is given by an angle, we will call this variable q 2, the second variable
is the position of the ball throughout the bar, we will call this variable q 1, this is
shown in the next figure.

Fig 3. Variables used to


model the DOF in the
ball and beam system

Now that we have determined the variables, we will find the kinetic and potential
energies of the system. The Kinetic energy of a system is given by the next
expression:

K=
i =1

1
2
IiV i
2

(3)

In the previous expression n represents the amount of generalized coordnates, I is


the inertial moment and V is the lineal velocity. Using this formula we can see that
the kinetic energy of the ball and the energy of the bar are given as follows.

K ball =
i=1

1
I b V 2b
2

(4)

= 1 I m V 2m
i=1 2
K

(5)

It is important to mention here, that the ball has angular velocity and lineal velocity,
this happens because the ball moves up and down with bar, and at the same time
it moves through the beam. The new kinetic energy can be expressed as:

1
2 1
2
K ball = I b q 2 + m V b
2
2

(6)

Finally the total kinetic energy can be expressed as the kinetic energy of the ball
and the beam combined.
1
1
1
K ball = I b q 22 + m V 2b + I m q 22
2
2
2

(7)

1
1
( I b + I m ) q 22 + m V 2b
2
2

2
We still need to find the velocity of the ball ( V b ), to do so, we need the position
vector of the ball, this is obtained with some trigonometry as shown below:

Fig 4. Obtaining the


position vector of the ball.
2
cos q 2 , sin q

Rm =q1
The
velocity
is
the
derivative of the position, therefore, to obtain the vector of the position we find:
d

V b= ( R
) (9)
dt m
q1 q 2 sin ( q 2) + q 1 cos ( q 2 ) ,q 1 q2 cos ( q 2) + q 1 sin ( q2 )

Now that we have obtained the velocity, we just need to square it, the results are
shown below:

2
2
2
2 2
2
2
2

V b=q1 q2 sen q 22 q1 q2 sen q2 q 1 cos q 2+ q1 q 2 cos q2 +2 q 1 q 2 cos q2 q 1 sin q2 + q 1 sin q 2(10)

As we know that

sin x+cos x =1 we see that (10) can be reduced to:

V 2b= q 21 +q 21 q2

(11)

And finally substituting in (5) and (7):

1
2 1
2
2
K Total = ( I b+ I m ) q 2+ m ( q 1 +q 1 q2) (12)
2
2

The next step is to find the potential energy, the potential energy goes as follows:
V =mgh

(13)

If we pay attention to the previous figures we find that:


h=q1 sin(q 2)

(14)

Then the total potential energy is:


V =mg q 1 sin( q2 )

(15)

We have found the energies, the next step is to find the lagrangian, however, we
have to consider the inertial forces, so we are going to calculate the inertial forces
first.
The balls moment of inertia is given by the formula:

2
2
I b= m R
5

where R is the balls radius.

The bars moment of inertia is calculated as:


I m=

1
ml 2
12

(16)

Now that we have all of the elements we can calculate the lagrangian, we will find:

d L
L

=0
dt q 1 q 1

( )

d L
L

=
dt q 2 q 2

( )

Solving for q1:


L
=mq 1 q22mgsin (q 2)
q1
d L
=m q 1
dt q 1

( )

m q1m q1 q 22 +mgsin ( q2 ) =0

(17)

Solving in a similar way for q2 we obtain:


I T q 2 +m q21 q 2 +2 mq 1 q 1 qq +mg q1 cos q 2=
Where:
q1 is the position along the beam (x position).
q2 is the velocity in function of (angle).
Therefore we have the following equations:
mmx 2+ mgsin ( )=0

I T + m x 2 +2 mx +mgxcos=
And we obtain:

[ ][]

x
x1
x
x ( t )= x 2 =

x3
x4

y (t )=x (t )

(18)

The State-Space representation of the nonlinear equations are:


x ( t )=f ( x , u ,t )
y (t )=g ( x , u , t)

[ ][

x 2(t)
x g sin
x ( t )= =
x 4(t )
x 3(t)
cos
2 mx x mgx

x 4 (t)
IT +m x 2
x1(t )
)
x 2(t

y (t )=x 1(t)
The next step is to find the values of A, B, C and D in the Linear State Ecuations,
and we obtain:

[ ]
[]

0
0
A= 0
mg
IT
0
0
B= 0
1
IT

1 0 0
0 g 0
0 0 1
0

C=[ 1 0 0 0 ] ;
D=0 ;

Finally, the representation of the Ball and Beam incremental linear system is given
by a system of linear first-order differential equations in matrix form:

[ ][

0
x1
0
x2
=
0
x3
mg
x4
IT

][ ] [ ]

1 0 0
0
x 1
0 g 0
0
x2 +
0 0 1
0 u,
x3
1
0 0 0 x4
IT

[ ]

x1
y=[ 1 0 0 0 ] x 2
x3
x4

Due to the complexity of the system, Simulink toolbox in Mathlab is used to solve
both systems and a script is run as first step to declare de variables and values of
those as shown below.

Matlab Script

Block Diagram of Non-Linear System

With the block representations finished the last step is to simulate both systems
and analyze the outputs comparing the similarities os the systems with the graphs,
each axis correspond to the space state variables: linear position, linear velocity,
angular position and angular velocity in that order.

Matching the outputs, the conclusion is that the lineal system apporximates with
quite good results. The angular velocity shows a quicker disparity with the nonlinear system but after the first stage where the analysis is focusing. The amount of
error between both responses is appropiate with the ranges first declare.

Designing the Controller


To design the controller of the ball and beam it is very important to have in mind
our four state variables, and to remember that the main objective of the controller is
to stabilize the system around the equilibrium point, which in this case is going to
be x=0.
In this case we are going to be using MATLAB to obtain the coefficients of the
constants that are going to be used.
It is a really simple process, once we have our matrixes, we simply have to create
a vector with the poles of our system, we can define these however we want, but
we have to make sure that they are all negative.
After that we define a vector where will save our constants, the command is called
place, and the syntax is the following:
K = place(A,B,p);

The basic idea of the controller now, will be to multiply our state variables by these
k constants and add them together, the sum will be the input of our previous non
lineal model. The block diagram of this step is shown below.

The results of this controller are shown below, as we can see in the graphs, the
main idea of the system is to get it
stabilized in zero, this zero will be the
position where we want the ball to
stand still, or as we defined above
the equilibrium point.

The last step in the process is to


create a digital model of the system,
and animate it, the idea is to simulate
the reality as much as possible.

Conclusions
In this phase of the project we were able to finish the controlling part, we have
studied one of the most important control methods, and we have seen that in the
end, it is not such a difficult thing to do, the important thing here, is the model, once
we obtain a good mathematical model, we are ready to design a controller, and this
is actually the most simple part of the process, we believe that all of the objectives
were achieved.

You might also like