Report For Mathwork Fileexchange PDF
Report For Mathwork Fileexchange PDF
Report For Mathwork Fileexchange PDF
Pendulum
Analysis and Simulation
IIEE Visionaries
Document Version 1.0
Contents
TECHNICAL ADVISORS……………………………………………………………………………………………………………………..…ii
PREFACE……………………………………………………………………………………………………………………………………………iii
1
ABOUT THE AUTHOR
This document “Mobile inverted
pendulum Analysis and Simulation” is
the collection of MATLAB simulation
(scripts and SIMULINK model) and its
result useful for analyzing the
behavior of mobile inverted
pendulum.
E-MAIL:
mirtahaali@iiee.edu.pk
MAILING ADDRESS:
MIR TAHA ALI,
C/o Institute of Industrial Electronics
Engineering (IIEE), PCSIR. ST-22/C,
Block 6, Gulshan-e-Iqbal, Karachi -
75300, Pakistan.
i
Technical advisors
Engr. Ashab Mirza
Associate Professor at IIEE
Postgraduate Course & Research
Work, PNEC, NUST.
MS (Aerospace Engr.) ENSAE,
Toulouse, France
BE (Electronics) NEDUET, Karachi
Email: ashab@iiee.edu.pk
ii
PREFACE
This document “Mobile inverted pendulum Analysis and Simulation” is the collection of
MATLAB simulation (scripts and SIMULINK model) and its result useful for analyzing the
behavior of mobile inverted pendulum.
This report was developed as a part of final year project design report for the B.E program
of INSTITUTE OF INDUSTRIAL ELECTRONICS ENGINEERING, KARACHI, PAKISTAN.
The challenge of balancing an inverted pendulum has drawn an interest on researchers all
around the world due to its uniqueness. And now inverted pendulum alike behavior
systems are developed for different uses and applications.
CONTENTS OVERVIEW
This report comprises of sections
iii
1 APPLICATIONS OF MOBILE
INVERTED PENDULUM
The self-balancing robot is a system similar to the classical mechanical system of an inverted
pendulum on a cart. It is an interesting system to control since it is relatively simple, yet
non-linear and unstable. Following are the main points that define the need of the project
are:
The system of two wheel balancing robot is a good platform for researchers to
investigate the efficiency of various controllers in control system. [1]
Conventional vehicles are based on three or four wheels, which has more parts and
less degree of freedom. The idea of TWBR can be applied to this problem. For
example, a motorized wheelchair utilizing this technology would give the operator
greater maneuverability and thus access to places most able bodied people take
granted. [2]
The idea of TWBR can be applied to various problems, such as designing walking
humanoid robot, robotic wheelchairs and personal transport systems.
The main advantages of making a two wheeled vehicles is that it have less parts than
conventional three or four wheeled vehicles, and due to less parts it has less weight
and due to less weight, its fuel consumption is less and it is considered to be fuel
efficient and eco-friendly vehicle. The two-wheeled robot is the combination of
wheeled mobile robot and inverted pendulum system. It also brings the concept of
creating a transporter for human. [3]
1
2 MATHEMATICAL MODEL
(1)
i = Current through motor coil
kM = motor torque constant
= motor torque
The back electromagnetic force produced by the coils can be given as
̇ (2)
Ve = Back EMF
Ke = Back EMF constant
According to Kirchhoff’s law, the sum of voltages in the circuit must be zero. Hence the
voltages present in the circuit are due to resistance of coil, inductance of coil and back EMF.
(3)
Va = Applied Voltage
L = Inductance of motor coil
R = Resistance of motor coil
To make the equation simpler, we have neglected the inductance of motor. Equation (3) can
be rewritten as,
̇ (4)
2
Newton’s law of motion states that the sum of all toques produces on the shaft is linearly
related to the acceleration of the shaft by the inertial load of armature IR. Hence the
statement can be written as,
∑ ̇ (5)
= Motor Torque
= Applied Torque
= Rotor inertia or Wheel inertia
Torque due to friction of motor shaft is neglected in equation (5).
̇ (6)
Substituting equation (4) into equation (6) and rearranging, we get the equation for torque,
(7)
( ̇ )
Let, = TR
TR = Applied torque on right wheel.
Figure (3) showing the free body diagram of right wheel. Free body diagram of the left
wheel will be similar to right wheel.
The force (Fy) on the wheel in the horizontal direction can be given as:-
∑ ̈ (8)
3
Fy = Force on wheel in horizontal direction
Mw = Mass of wheel
Y = Linear displacement in horizontal direction
̈
∑ ̈ (10)
̈ (13)
( ̇ )
̈
( ̇ ) (14)
Equation (14) is substituted into (9) to get the equation for the left and right wheels
4
̈ (16)
̈ ( ̇ )
Because the linear motion is acting on the center of the wheel, the angular rotation can be
transformed into linear motion by simple transformation [4],
̇ ̇
̇
̇
For the left wheel,
̈
̈ ( ̇)
(17)
[ ] ̈ ( ̇) (19)
Consider Figures (1) which represent the free body diagrams of the IB. Applying the
Newton’s second law of motion in the Y direction yields
∑ ̈ (20)
∑ ̇ ̈ (21)
5
L = Length of frame
HR,HL = Horizontal reaction forces between the IB and wheel axle
Considering the sum of the applied forces in a direction perpendicular to the rod gives,
∑F↑ = Horizontal reaction forces + vertical reaction forces + force due to linear
acceleration
̈ (22)
G = Gravitational force
PR, PL = Vertical reaction forces between the IB and wheel axle
Finally, equating the sum of the applied moments yields,
∑ ̈ (23)
̈ (24)
Torque due to each motor is:
( ̇ ̇)
(25)
Putting (25) in (24), we get,
( ̇ ̇ ) (26)
Adding equation (26) with (22) to remove HR, HL, PR and PL,
( ) ̈
( ̇) (27)
Putting the value of (HR+ HL) from equation (21) into (19), we get,
6
̈
( ̇) ̇
(28)
Rearranging equations (27) and (28) gives the non-linear equations of motion of the system,
( ) ̈ ( ̇)
(29)
̈
[ ] ̈ ( ̇)
(30)
̈ ̇
The above two equations (29) and (30) can be linearized by assuming θ =π+ , where
represents a small angle from the vertical upward direction. Since, we do not want the
pendulum to get tilted at angle greater than 15 degrees.
( )
( ) ̈ ( ̇) ̈ (31)
[ ] ̈ ̇ ̈ (32)
In order to get the state space representation of the system, equations (31) and (32) are
rearranged,
7
̈
̈ ( ̇)
( ) ( )
(33)
( ) ( )
̈ ( ̇)
[ ] [ ]
(34)
̈
[ ]
By substituting equation (33) into equation (31), substituting equation (34) into equation
(31) and after a series of algebraic manipulation the state space equation for the system is
obtained [5].
̇
̈ ̇
[ ] [ ]
̇
̈ ̇
[ ]
[ ]
Where
[ ] [ ]
In the model above, it is assumed that the wheels of the vehicle will always stay in contact
with the ground and that there is no slip at the wheels. Cornering forces are also considered
negligible.
8
3 ANALYSIS AND SYSTEM
COMPENSATION DESIGN
The system response can be observed by its impulse response that is applying impulse input
to the system.
Because the system is inherently unstable, an impulse input applied to the open loop
system will cause the tilt angle and position of the robot to rise unboundedly. This results in
the robot falling. As shown in figure-4. [6]
In order to find the problem, we must observe the system poles location.
Plotting the Pole-Zero Map of the system verifies that the system is unstable as shown in
figure-5 as there is a pole on the right-hand plane of the plot. Ideally, all poles should be on
the left-hand plane of the plot for the system to be stable.
The poles of the system are located at 0, -0.006, 13.519, -13.521.
9
Figure- 3: Pole/Zero Plot of Uncompensated System
3.2.1 RLTOOL
RLTOOL is a tool in MATLAB, which provides a GUI for performing Root Locus analysis on
Single Input Single Output (SISO) systems, which are the class of systems we cover in E105.
RLTOOL is a component of the broader SISO Design Tool in MATLAB, which can also do Bode
and Nyquist analysis.
RLTOOL provides a fast, easy, and useful way to design compensators, and see their
influence on the root locus drawn in the complex plane. With RLTOOL, we can quickly add,
remove, and move compensator poles and zeros, or change proportional gains, and see the
result on the location of the closed loop poles of the system. In addition, RLTOOL can bring
10
up plots of system responses to reference or disturbance inputs, so we can verify the
performance of our compensator-plant system.
RLTOOL can be called with a variety of command arguments. Type ‘help rltool’ at the MATLAB
command prompt to see the options available. Typically, we’ll create a plant transfer function ’G’ in
MATLAB first, and then import it to RLTOOL with the command [7]:
>> rltool (G)
Steps for compensation design:
Type rltool(G) in MATLAB command window
Control and Estimation Tools Manager window and corresponding SISO design window
appears.
The root locus of uncompensated system is given in figure-7:
From the graph, it is observed that the there is always a pole exists on right have plane.
Hence the system will be unstable at any value of compensated gain. So in order to make
the system stable we have design the root locus such that all pole must exists on left hand
side.
Since because there is a zero exists at origin the loci goes to infinity. So to remove zero at
origin, we add pole at origin.
Go to Compensator Editor Tab in Control and Estimation Tools Manager window.
Right Click Pole/Zero Dynamics area>Add Pole/Zero>Integrator. Figure-7
The root locus is then shown in figure-8.
The loci going to infinity on right half plane as in figure-8. The system is still unstable at
all the value of compensation gain.
11
Figure- 4: Root locus of uncompensated system
12
Figure- 6: Root locus after adding an integrator
Since loci goes to infinity in right half plane, we have to add zero on left hand side, which
will attract loci toward it. Adding zero at -10.
Right click Pole/Zero Dynamics area>Add Pole/Zero>Real Zero. Figure-9
Adding another zero at -10, figure-10, in order to get a part of locus where all the roots are
at left hand side.
This is the root locus of compensated system. As shown there is a part of root locus where
all the roots are on left hand side of plane. So in order to find the root where system
response is best, we have to find the compensation gain where the system response is best.
The system response is best when damping ration is considered to be approx. 0.7.
13
Figure- 8: Root Locus after adding zero at -10
14
Figure- 9: : Compensation gain selection
(35)
Gain: 1.15e+04
Pole: 11.4+11i
Damping factor: 0.726
Natural Frequency(rad/s):15.8
Overshoot(%):3.62
15
Figure- 10: Minimum Compensation Gain
Gain: 3.97e+03
Pole: 0.981i
Damping factor: -0.000737
Natural Frequency(rad/s):9.98
Overshoot(%):inf
(36)
16
4 SIMULINK MODEL AND
SIMULATION
4.4 OBSERVATION:
As shown in figure-14, a step input of one-tenth of meter is applied, the system remain
stable and bounded.
The displacement reaches 0.1 meter in about 0.1 seconds and steady state error remain less
than 1%.
The tilt angle reaches 0 degree in 0.15 seconds and the steady state error remains less than
1%.
There is no such effect of disturbance of 10N observe red on system response.
Steady State Error of displacement = 0.1%
17
Percentage Overshoot of displacement = 1%
For large value of displacement, it was observed that system gets unstable for large step
input. So we have to observe the response by giving ramp input because it varies the input
slowly. The Response is shown in figure -15. It was observed that system remain stable and
bounded for giving ramp input.
18
Figure- 12: System response to step input
19
Steady State Error of displacement = 0.01%
20
5 CONCLUSION
21
6 Bibliography
[1] Khaled M K Goher and M O Tokhi, "MODELLING, SIMULATION AND BALANCE CONTROL OF A
TWOWHEELED," Department of Automatic Control and Systems Engineering, The University of
Sheffield, Sheffield, ISBN/ISSN,.
[2] M. O. Tokhi and N. H. Siddique, K. M. Goher, "Dynamic modeling and control of a two wheeled
robotic vehicle with a virtual payload," ARPN Journal of Engineering and Applied Sciences, vol. VI,
pp. 7-8, March 2011.
[3] Wei An and Yangmin Li, "Simulation and Control of a Two-Wheeled Self-Balancing Robot,"
International Conference in Robotics and Biomimetic (ROBIO), pp. 456-458, 2013.
[4] M. O. Tokhi and N. H. Siddique K. M. Goher, "DYNAMIC MODELING AND CONTROL OF A TWO
WHEELED," ARPN Journal of Engineering and Applied Sciences, vol. VI, pp. 37-39, March 2011.
[5] Rich Chi Ooi, "Balancing a Two-Wheeled," Faculty of Engineering and Mathematical Sciences, The
University of Western Australia, 2003.
[6] Rich Chi Ooi, "Balancing a Two-Wheeled," Engineering and Mathematical Sciences, The University
of Western Australia, 2003.
[8] M. O. Tokhi and N. H. Siddique K. M. Goher, "Dynamic modeling and control of a two wheeled
robotic vehicle with a virtual payload," ARPN Journal of Engineering and Applied Sciences, vol. VI,
pp. 7-9, March 2011.
[9] Araki M, "PID control," Control systems, robotics, and automation, vol. II, pp. 1-5.
22
7 APPENDIX
23
plot(T,U)
title('Impulse Input to the system')
ylabel('Amplitude')
xlabel('Time[s]')
axis([-1 2 0 1.2])
figure(2)
[Y,X] = lsim(A,B,C,D,U,T);
plot(T,Y);
title('Open loop impulse response of the system')
ylabel('Position[m], Angle[rad]')
xlabel('Time[s]')
legend('Vehicle position','Tilt angle')
axis([-1 2 0 100])
%==============================================
%pole/zero plot
figure (3)
s = tf('s')
pzmap(Qtf)
%rltool rootlocus plot
rltool(Qtf)
24