Provided by UTHM Institutional Repository
Provided by UTHM Institutional Repository
JUNE, 2013
vii
ABSTRACT
This thesis presents a development self-balancing platform mobile robot using PID
controller. The platform has been designed using mobile robot kits including IMU
and two servos, and controlled by an open source microcontroller with PID. An
Arduino microcontroller, hobby grade servos, and a two-degree of freedom (axis)
accelerometer and gyroscope have been used to create the controlled platform. The
controller has been designed to maintain the platform at an initially selected angle
when the support structure orientation changes. By using Matlab, the value of PID
parameters i.e , Kp, Ki and Kd have been obtained and applied to the arduino. The
software has been written with logic to convert the digital data from the
accelerometer to an acceleration magnitude vector. The magnitude is then compared
to a predetermined mathematical function to infer the angle of tilt of the platform.
The angle of tilt is then converted to angle of rotation for the servos to act on.
Experiment shows that the platform performed as expected. Overall, the platform
design is validated based on the positional accuracy of the platform given the
relatively low quality components used to create it.
viii
ABSTRAK
TABLE OF CONTENT
SUPERVISOR’S CONFIRMATION ii
DEDICATION iii
ACKNOWLEDGMENT iv
ABSTRACT vii
ABSTRAK viii
TABLE OF CONTENTS ix
LIST OF FIGURES xv
I INTRODUCTION
II LITERATURE REVIEW
2.3.1 Gyroscope 7
2.3.2 Accelerometer 7
2.6 Conclusion 10
xi
3.7 Conclusion 33
4.3.1 Gyrometer 42
4.3.2 Accelerometer 43
4.4.1 Integration 47
4.7 Conclusion 62
xiii
5.1 Discussion 64
5.2 Conclusion 65
REFERENCES 67
APPENDIX A 70
APPENDIX B 72
APPENDIX C 76
xiv
LIST OF TABLES
pitch axis. 60
xv
LIST OF FIGURES
LIST OF SYMBOL
G - Gravity
θ - Angle
t - Time
J - Moment of Inertia
e(t) - Back Electromotive Force
τ - Torque
I - Current
R - Electric Resistance
L - Electric inductance
Ke - Back electromotive Force Co-efficient
B - Damping Ratio Of The Mechanical System
V - Voltage
ms - Millisecond
xviii
LIST OF ABBREVIATIONS
LIST OF APPENDICES
APPENDIX TITLE
CHAPTER 1
INTRODUCTION
Designing a mobile robot with special capabilities has become a trend these days for a
variety of universal human consumption. It also fits well with the needs and nature of
the human lifestyle. Different forms and uses, mobile robots have been designed and
are now in the market worldwide.
A mobile robot comprises of three main parts including sensors, logical
processing unit and actuator. In this project, a robot that can maintain an upright and
balanced position on a platform is designed and developed. The robot consists of
Inertial Measurement Units (IMU) sensors, microprocessor and motors. The design is
designed with Matlab and the resulting parameters are used and burned into Arduino
UNO controller. The main purpose of the controller is to fuse the wheel encoder,
gyroscope and accelerometer sensors to estimate the attitude of the platform and then
to use this information to drive there action wheel in the direction to maintain an
upright and balanced position platform.
If the platform system itself is not balanced, which means it keeps falling off
away from the vertical axis, then a gyro chip is needed to provide the angle position of
the inverted pendulum or robot base and input into the controller, which the program
itself is a balancing algorithm. The PID controller will then provide a type of feedback
signal through PWM control to turn the motor servo clockwise or anticlockwise, thus
balancing the platform. These two measurements are summed and fed-back to the
actuator which produces the counter torque required to balance the platform robot.
2
In this project, the PID will be used because it is relatively easy to implement
yet practical. Besides that, PID controller has only three adjustable parameters that can
be determined from several techniques. Previous research has shown that PID
controller has shown good results in terms of response time and accuracy when the
parameters i.e, Kp , Ki and Kd, are properly tuned.
Control systems are often designed to improve stability, speed of response, steady-
state error, or prevent oscillations. Many researchers wants to produce a mathematical
equation that is able to determine the position of a very accurate motor position, thus
the steady state error should be zero. DC motor systems have played an important role
in the improvement and development of the industrial revolution. Therefore, the
development of a more efficient control strategy that can be used for the control of a
DC servomotor system and a well defined mathematical model that can be used for off
line simulation are essential for this type of systems. Servomotor systems are known to
have nonlinear parameters and dynamic factors, so to make the systems easy to
control, conventional control methods such as PID controllers are very convenient.
Also, the dynamics of the servomotor and outside factors add more complexity to the
analysis of the system, for example when the load attached to the control system
changes.
Due to these parameters and factors, this study will apply the PID controller to
make the steady-state error, due to continuous disturbance, to be zero. Accordingly
this project will review the principles of PID that is used to control the servo
movement that depends on the angle captured by the IMU. This project uses the PID
to compensate the robot body inclination to stabilize the platform. Among other
performance requirements are to reach the final position of the motor position very
quickly without excessive overshoot. In this case, focusing on systems that have a
finish time of 10 ms and the overshoot is smaller than 25%.
.
3
The aim of this project is to implement PID controller to a mobile robot to maintain its
flatness on a moving platform. The objectives of this project are as follows:
a) To design and develop a mobile robot and a flat platform.
b) To design a PID controller to maintain the robot flatness
c) To simulate the controller using Matlab and analyse its performance.
d) To integrate the controller into the mobile robot.
Chapter 4 discusses about the result and analysis. It also includes the design of a
mobile robot with a flat platform.
Chapter 5 concludes the project and gives suggestions for future work.
5
CHAPTER 2
LITERATURE REVIEW
Masakazu et al. (2005) proposed a tuning method for PID controller that
considers changes in system characteristics. It is about the concept of using the
optimization of PID controller tuning, depending on the obstacles on the control
input derivatives and considering model uncertainties caused by changes in the
system dynamics. Partial model matching method was used to evaluate
performance and control while the reference referred to interference and
repression compared to the tracking properties.
Arpit et al. (2012) proposed a performance comparison of PID and Fuzzy
logic controller using different defuzzification techniques for positioning control
of dc motors. The result of the fine-tuned PID controller gives relatively less
overshoot and settling time with no steady state error. The fuzzy logic controller
with different defuzzification techniques gives zero % overshoot and lesser
settling time.
In a paper titled ‘Attitude Estimation Using Low Cost Accelerometer and
Gyroscope’ written by Young Soo Suh (2003), it shows two different sensors
which are the accelerometer and gyroscope that exhibit poor results when used
separately to determine the attitude which is referred as the pitch angle or roll
angle. However, the gyroscope can combine with accelerometer to determine the
pitch or roll angle with much better result with the use of Kalman filter.
Tomislav et al (2012) proposed self-balancing mobile robot tilter. It
provides a summary of work done in the field of electronic, mechanical design,
software design, system characterization and control theory. Robotic system
model and simulation results of various control methods required for the
stabilization of the system were studied. Dynamic effects become increasingly
important in assessing performance limits in robotic. The processes where the
project was carried out including design and production of certain parts of the
integration section, electronic, mechanical and software.
Hany Ferdinando et al. (2001) proposed a paper titled Developing
Mathematical Model of DC Servo Motor Using Bond Graph. Bond graph can
serve as a tool in the modeling of some plants. The plant was DC servo motor
with all parameter is unity. Simulink and 20-Sim was used for the simulation
procedure.
7
The use of plant transfer function had several performances, such as using a step
response and unit impulse function, the parameters change, how to control the
torque and speed using the input voltage and current.
This project concerns the development of a mobile robot with a platform, which
can be levelled using PID controller. The main objective is to control the flatness
of the platform efficiently with a low cost hardware without limiting the strength
and performance of the whole system. There are various stages that have been
used to stabilize the platform such as modelling the system, obtaining the data
from sensors and determining how the control algorithms will be implemented.
V.J. Van Doren (2009) suggested a two wheeled robot to perform the balancing
and control of mobile robots. In this project the Proportional, Integral,
Derivative (PID) has been implemented to control the flatness of a mobile robot
platform. PID has proven to be popular among the control engineering
community.
As stated by the author of article Vance J. VanDoren (2009), “For more
than 60 years after the introduction of Proportional-Integral-Derivative
controllers, remain the workhorse of industrial process control”.
PID controller will be extensively discussed in Chapter 3.
2.3.1 Gyroscope
A gyroscope is a device that measures angular rate around an axis. Tilt angle can
be obtained by integrating angular rate over sampled time. The gyroscope
modifies a servo control signal by an amount proportional to its measure of
angular velocity. An estimate of angular displacement is obtained by integrating
the velocity signal over time. The Inclinometer outputs an analogue signal,
8
2.3.2 Accelerometer
As stated by A. Warnasch, and A. Killen (2002), the tool that measures the
inertial force in the opposite direction of free fall acceleration vector in terms of
g-force is acceleration. So, gravity acceleration shows 0g power during free fall
down constantly at 1g. It will be supported by the ground with a force equivalent
of 1g, when the accelerometer is at rest on the surface of the earth. Because of
that, it will show a constant downward force perpendicular to the ground 1g rest.
To obtain the tilt angle using the Pythagorean Theorem can also use these
features. Readers are referred to Chapter 3 for more on accelerometer.
The controlled platform is a popular university level project, where many teams
from various colleges and institutions as well as independent parties (tinkerers)
complete designs for credit. A web search of the terms “controlled platform” or
9
2.6 Conclusion
In this chapter, an overview of the previous research on robot control has been
done, including the IMU sensors and mathematical modelling. In addition, a
brief discussion on PID controller has been put forward. It is found that the
research on self-levelling platform is a popular topic. As such, a number of
research on the topic have been performed and published their findings. This
chapter has summarised some of them in Table 2.1.
11
CHAPTER 3
RESEARCH METHODOLOGY
This project is done in three phases. The first phase is to understand and design
the mobile robot as well as to implement the theories in the real hardware. The
second phase is to understand the PID controller and its characteristic and to
design and implement the controller into the robot. The last phase is to analyse
the controller performance using M-file in Matlab and compare it with the
response of the real hardware.
Figure 3.1 shows a general procedure of the project implementation
during PS1 while Figure 3.2 illustrates the procedure during PS2.
Start PS1
PS2
PS2
Test
End
DC Motor
Driver
Left
ire
Stacked
Right
IMU
Sensor
Stabilized
Platform
Stacked
Arduino
UNO
Power
Supply
Voltage
Regulator
Battery
However, the servos used for this board require more power than the Arduino
board can supply from the 5V power pin. Because of this, the servos are
powered using an external power source, a 9V battery.
According to the MMG 995 servo data , the servos are rated to 6V max,
so the 9 volts from the battery are converted to 5 volts via a 5V, 1A power
regulator. The regulator has enough power capacity to drive both servos at
once with low load.
15
The servomotor used to manually control the platform are supplied with
5V from the Arduino board. It is the reduction in voltage supply to the analog
pins which signals the board to send an angle signal to the servos. The
accelerometer is powered by the Arduino board’s on-board 3.3V power. The
ADXL325 accelerometer will send different signals through the analog pins
depending on the supply voltage.
Young (2003) states that the factor that contributes to the deviation of
the desired result of the gyroscope is the drift term. Since the drift increases
with time error in output data will also increase.
16
a) Sensor Gyroscope
Gyroscope can measure the rate at which the rotation is taking place and the
rotation angle for a given time interval is governed by:
where G(t) is the gyroscope reading with respect to the rotation direction.
When the time interval is small, the gyroscope reading can be treated as a
constant and can be approximated as a above equation:
Figure 3.6 : Gyro Axes (θ ) Relative to PCB Axes ( θ) with Orientation Errors
(θ and Φ)
Orientation
Figure 3.7 shows the orientation of the axes of sensitivity and the polarity of
rotation.
b) Sensor accelerometer
The values measured for X0g and Y0g correspond to the x- and y-axis
offset, and compensation is done by subtracting those values from the output of
the accelerometer to obtain the actual acceleration:
Mobile robots that are used in this project is ready made. It features two gear
motors with 65mm wheels and a rear caster. The chassis plates are cut from
acrylic with a wide variety of mounting holes for sensors, controllers, power,
etc. Simply bolt the two pre-cut platforms together, attach the motors and
caster and robotics controller. It includes all of the parts needed to assemble the
chassis as well as a 4xAA battery holder with barrel jack termination.
The 3-wheel mobile robot has two rear wheels and an independently rotating
front wheel. The robot can change direction by varying the relative rate of
rotation of two separately driven rear wheels. If both wheels are driven in the
same direction and speed, the robot will go straight.
The rotation center can fall anywhere in the line joining two wheels.
The center of gravity in this type of robot has been put in the triangle formed
by the wheel. If too heavy mass attached to the free side of the spinning wheel,
the robot will tip over.
The main controller for this project is Arduino Uno which uses Atmel Atmega
328 microcontroller as it combines 32KB ISP flash memory with read-while-
write capabilities, 1KB EEPROM, 2KB SRAM, 23 general purpose I/O lines,
32 general purpose working registers, three flexible timer/counters with
compare modes, internal and external interrupts, serial programmable USART,
a byte-oriented 2-wire serial interface, SPI serial port, 6-channel 10-bit A/D
converter (8-channels in TQFP and QFN/MLF packages), programmable
watchdog timer with internal oscillator, and five software selectable power
saving modes.
21
The device operates between 1.8-5.5 volts. The overview of the device
as shown in figure 3.9 and figure 3.10. (Arduino.cc, 2012).
3.3.4 DC ServoMotor
The servos supporting and controlling the top platform are arranged in
order to control the pitch and roll. Note that pitch and roll are only subjective
directions and are used to describe the motion. Since the platform has no
“front” or “back” the terms pitch and roll are meaningless descriptions of the
rotations about the X and Y axis. A close up view of the servo arrangement
and axis’ is illustrated in Figure 3.14.
This servo arrangement is a more efficient use of space and limits the
amount of slop compared to linkages and hinges as seen in other designs. The
Y axis servo is controlled by the Y axis data stream from the accelerometer and
vice versa for the X axis. Note that the X axis servo motion is in-plane with the
photo while the Y axis would rotate out of plane.
The servos are installed into aluminum brackets illustrated in
Figure 3.15. These brackets allow the servo to be installed onto the
bottom and top platforms. The servo “C” brackets (
Figure 3.16) are then used to attach the servo bodies, via the body
brackets, to themselves and the platforms. The “C” brackets attach to the body
and to the rotating servo horn.
The combination of these two brackets allows the platforms to rotate
independently in two axis.
24
A dual axis accelerometer was the chosen to measure the tilt of the
lower platform in two axes. The data is read from two different channels and
processed in the same manner regardless of direction. The two analog data
streams provide the Arduino logic with the necessary information to maintain
the top board level to the chosen plane.
67
REFERENCES
[4] Arpit Goel., et al. (2012) Performance Comparison Of PID And Fuzzy Logic
Controller Using Different Defuzzification Techniques For Positioning
Control Of DC Motors. Journal of Information Systems and Communication
ISSN: 0976-8742 & E-ISSN: 0976-8750, Volume 3, Issue 1, pp.-235-238.
[5] Young Soo Suh.(2003) .Attitude Estimation Using Low Cost Accelerometer
And Gyroscope.Proceedings KORUS 2003. The 7th Korea-Russia
International Symposium on Volume: 2 Page(s): 423 - 427 vol.2
[8] V.J. VanDoren, “PID: Still The One,” Control Engineering, October 2003.
Retrieved
[9] D. Simon, Kalman Filtering With State Constraints: A Survey Of Linear And
Nonlinear Algorithms, IET Proceediings in Control Theory & Applications,
vol. 4, no. 8, pp. 1303-1318, 2010.
[15] Nise, Norman S.. Control Systems Engineering. Fifth edition 2008.
[16] MATLAB/Simulink User’s Guide, 1998, The Math Works Inc, Natick,
MA,
[18] Arduino.cc. (2012), Arduino Uno Rev 3. Retrieved on Jan 15, 2013,
http://arduino.cc/en/Main/ArduinoBoardUno
[24] ECE572SelfLevelingPlatform
http://www.youtube.com/watch?v=CuN_ZkLK0gM&NR=1