Professional Documents
Culture Documents
AUTHORS:
ADRIÁN BUESTÁN
KEVIN CARPIO
LUIS ERRAEZ
LEANDRO ILLESCAS
PEDRO MONCAYO
Objectives
General objective
Simulate an inverted pendulum controller with the Matlab program for a segway
putting into practice the topics learned in the lecture.
Specific objectives
Understand the behavior of an inverted pendulum system and translate it into simulation
Obtain a mathematical modeling that allows us to know the behavior of the inverted pendulum
Use Matlab as a simulation program to check the mathematical analysis carried out.
Obtain the different graces through simulation to verify their behavior
Obtaining a
Study of the behavior Use Matlab as a Obtaining the
mathematical
of an inverted simulation program different graphics
modeling that allows
pendulum system to check the through simulation
us to know the
and translate it into mathematical to verify their
behavior of the
simulation analysis performed. behavior
inverted pendulum
Matching equations.
𝑥𝑑2 𝑀𝑑2 𝑥
= ൫𝑥1𝑠𝑖𝑛ሺ𝜃ሻ൯= 𝜇 − 2
𝑑𝑡 2 𝑑𝑡
𝑑2 𝑀𝑑2 𝑥
𝑚 ∗ sin(𝜃) ሺ1 cosሺ𝜃 ሻሻ = 𝜇cos(𝜃) − 2 cos(𝜃) − 𝑚𝑔sin(𝜃)
𝑑𝑡 𝑑𝑡
𝑚𝑑2 𝑀𝑑2 𝑥
ሺ𝑥 + 1 sinሺ𝜃ሻሻ = 𝜇 −
𝑑𝑡 2 𝑑𝑡
𝑑2 𝑀𝑑2 𝑥
𝑚 ∗ sin(𝜃) 2 ሺ1 cosሺ𝜃ሻሻ= 𝜇cos(𝜃) − cos(𝜃) − 𝑚𝑔sin(𝜃)
𝑑𝑡 𝑑𝑡
BY DERIVING WE GET.
𝑚𝑥ሷ− m1 sinሺθሻθ2ሶ+ m1 cosሺθሻθሷ= 𝜇 − 𝑀𝑥ሷ
𝑚1𝑠𝑖𝑛ሺ𝜃ሻθ2ሶ− 𝑚𝑔𝑠𝑖𝑛ሺ𝜃ሻcosሺ𝜃 ሻ+ 𝜇
𝑥ሷ=
𝑀 + 𝑚𝑠𝑖𝑛2 (𝜃)
𝑥1 = 𝑥 𝑥1ሶ= 𝑥ሶ
𝑥2 = 𝑥ሶ 𝑥2ሶ= 𝑥ሷ
𝑥3 = 𝜃 𝑥3ሶ= 𝜃ሶ
𝑥4 = 𝜃ሶ 𝑥4ሶ= 𝜃ሷ
THEN WE GET
𝑥1ሶ= 𝑥2
𝑚1𝑠𝑖𝑛ሺ𝑥3 ሻ𝑥4 2 − 𝑚𝑔𝑠𝑖𝑛ሺ𝑥3 ሻcosሺ𝑥3 ሻ+ 𝜇
𝑥2ሶ=
𝑀 + 𝑚𝑠𝑖𝑛2 (𝑥3 )
𝑥3ሶ= 𝑥4
−𝜇 cosሺ𝑥3 ሻ+ ሺ𝑚 + 𝑀ሻ𝑔𝑠𝑖𝑛ሺ𝑥3 ሻ− 𝑚1 sinሺ𝑥3 ሻcos(𝑥3 )𝑥4 2
𝑥4ሶ=
𝑀1 + 𝑚1𝑠𝑖𝑛2 (𝑥3 )
Approximation when the value is
very small.
𝑋1ሶ 0 1 0 0 𝑋1 0
ሶ 0 0 −𝑚𝑔/𝑀 0 𝑋2 1/𝑀ې ۍ
൦𝑋2൪ = ൦ ൪= ൦ ൪+ 0 ێµ ۑ
𝑋3ሶ 0 0 0 1 𝑋3 ێ1 ۑ
𝑋4ሶ 0 0 ሺ𝑀 + 𝑚ሻ𝑔/𝑀 0 𝑋4 −ے 𝑀𝐿ۏ
Replace X1 = 0, X2 = 0, X3 = 0, X4 = 0, because
we are going to work at the equilibrium point.
X3 ≈ sin (X3) when x3 0
𝑋1
𝑥 1 0 0 0 𝑋2
ቂ ቃ= ቂ ቃ= ൦ ൪
0 0 1 0 𝑋3
𝑋4
After the investigation carried out, on the inverted pendulum, it was possible to establish the different equations of
motion, both of the base, and thus be able to determine the angle of inclination that the pendulum will obtain.
Therefore, the simulation is carried out in Matlab, establishing the initial parameters previously established and the
data that will be used in this exercise.
Once you have established the limits for the simulation, such as the mass of the pendulum, the mass of the base,
the length of the pendulum and the inertia on the wheels, the different state matrices can be established for the
respective simulation.
As can be seen in the graph, the dynamics of the System has been improved since better control is obtained.
For the next one, we proceed to carry out the analysis on the locus of the roots
For a better analysis, the initiative is taken to make the comparison of the three images that
we visualize, on the response of the different state variables for open loop and closed loop,
and in the same way with the response of the transfer function, where the axes to be
compared are between the angle of the pendulum and the position of the base.
In the part of the simulation and Simulink, the procedure carried out previously where the transfer function is used to
obtain the Angle and the position of the system is reduced, also with the help of the PID control to obtain the 2 graphs.
Here we have the total structure, the joint of revolution that gives us the
angle of inclination provided by the rotary joint, also the force in the
prismatic joint that will be provided by input and the movement will be
carried out automatically.
Here we have the structure of the chassis made up of 3 parts that are part
of the chassis and the 4 supports in the corners of our segway, these are
joined with rigid joints since it allows us to put the location of each piece
and with which it is going to be joined.
In the image we have both the left and right rim and that is joined with a rigid joint and our axis that allows
it to rotate.
In the image we see our animation finished with rigid structures and each one fixed in its
position, if we want to change colors we must enter in each part and we can do both the
colors and the location
In the following image we can see the auto-adjustment option in our animation, we can
establish the desirable attributes of our response and auto tune will generate the appropriate
pid gains that gives us more control of the segway and it would be a balanced one.
• The angle of inclination had to be limited, because at the time of carrying out the
mathematical modeling of the system the equations were linearized, which means
that the angle of inclination had to be done, it always approaches zero, therefore
this Angle must always be zero.
• We conclude that the most direct application of the inverted pendulum is a segway
since it shares the principle of operation exactly, for which we go to simulate and
perform the corresponding calculations of operation of the segway.
• It was demonstrated that the application of a method that is based on principles
for optimizing the gain values of a PID controller makes it possible to present a new
form of unconventional solution to control problems; in addition to finding a
variety of optimal values for these parameters, giving the option of choosing the
one that best suits your design requirements.
• It is recommended that the system have the least number of oscillations, if the
system has many oscillations when trying to stabilize the segway, it may not be
achieved and the system falls into instability
• In order to work with sensors, it is recommended to work with their
characteristic curves and take experimental data, which will help us to have
accurate calculations, and thus obtain an angle of inclination on which the
balance of the vehicle depends.