Self Balancing With Pid Control
Self Balancing With Pid Control
Abstract—In this paper modeling and control of a two wheeled and rotate according to signals sent. The prototype used in this
balancing autonomous robot is reported. The main focus is on work relies on a dead-reckoning multi-sensor system, which will
developing efficient control algorithms required to enable the robot consist of i) two optical incremental encoders mounted on the
to perceive and act in real time for a dynamically changing world. motor shafts, to sense the relative angular positions and angular
The prototype relies on a multi-sensor system consisting of i) two velocities of the wheels and ii) a 3-Axis accelerometer tilt sensor
optical incremental encoders and ii) a three axis accelerometer
to measure the inclination and angular velocity. The code is
which is used as a tilt sensor. The information from the sensory
system is provided to the robot controller. The performance and written in C and compiled for the Atmel AT89C52
reliability of controller is then simulated in MATLAB® as a microcontroller, which is interfaced with the sensors and
platform. Finally, the solution is verified on a real physical model motors. The main goal of the microcontroller is to fuse the
controlled by means of a single chip AT89C52 microcontroller. wheel encoder and accelerometer sensors to estimate the
behaviour of the platform and then to use this information to
Keywords— Simulation, dynamics, inverted pendulum mobile drive the wheel in the direction to maintain an upright and
robot, state space control balanced position.
B. Chassis Modelling
Chassis modelling parameters is shown in Fig 4. Sum of
forces perpendicular to the chassis or pendulum,
∑ Fperpendicular =M rc ɺɺ
xcosθ rc
..
δ rc =
M rcgl
δ+
M rcl
x−
ɺɺ
(Cr+Cl )
J rc + M rcl J rc + M rcl
2
2 2
J rc + M rcl
Fig.4 Inverted pendulum free body diagram M rc l .. ( Cr +Cl )
x=
ɺɺ δ + (20)
Sum of moments around the centre mass of the pendulum
2 M wh +
2 J wh + M rc r 2 M wh + 2 J wh + M rc
.. 2
∑ M=Jα where α=θ rc r 2
r
(13)
-( P +P )lsinθ -( H +H )lcosθ -( C C )=J θ.. The state space equation is obtained as below after substituting
r l rc r l rc r+ l rc rc
equation (19) into (18) and equation (20) into (17) in the form
Rearranging equation (13), of:
( ) ( ) ..
(
- Pr +Pl lsinθ rc - H r +H l lcosθ rc =J rcθ rc + C r+ Cl (14) )
Multiplying equation (11) by –ell,
Fig.5 Balancing robot control system As shown in the Fig 6, the tilt sensor and encoders measured
The robot parameters are as tabulated in Table 2. four variables. All the variables is feedback to the controller.
The controller computes the state space variables and produces
TABLE 2 the control inputs to stabilize the robot. Thus the controller
PARAMETER OF ROBOT computes the voltage which is then decoupled and modified to
Symbol Parameter Value [unit] the actual voltage to be applied to the right and left wheels [4].
0 0 0 Stop
0 1 1 Forward
1 0 1 Backward
1 1 1 Stop
B. Accelerometer
The Hitachi H48C Tri-Axis Accelerometer is an integrated
module that can sense gravitational (g) force of ±3g on three
axes (X, Y, and Z). The module contains an onboard regulator to
provide 3.3-volt power to the H48C, analog signal conditioning,
and an MCP3204 (four channel, 12-bit) analog-to-digital
converter to read the H48C voltage outputs. All components are
mounted on a 0.7 by 0.8 inch module. Acquiring measurements
from the module is simplified through a synchronous serial
interface. With the BASIC Stamp® series, for example, this is
Fig.12 Impulse response of the robot position with PID control easily handled with the SHIFTOUT and SHIFTIN commands.
Features: Measure ±3 g on any axis Uses MEMS (Micro
Electro-Mechanical System) technology Onboard regulator and
high-resolution ADC for simple connection to microcontroller
host SPI communications compatible with BASIC Stamp 2
series SHIFTOUT and SHIFTIN commands Free-fall output
indicates simultaneous 0g an all axes Small, breadboard-friendly
package Key Specifications: Power Requirements: 5 VDC
Communication: Serial SPI Dimensions: 0.7 x 0.8 x .45 in (17.8
x 20.3 x 11.4 mm) Operating Temperature: -13 to +167 °F (-25
to +75 °C) [12].
The accelerometer board is shown in Fig. 14.
Fig.13 Root Locus sketch with PID control k=100, kd=80, ki=45
V. HARDWARE DESIGN
Fig. 14 Accelerometer Board
The hardware of the robot consists of motor interface board,
accelerometer and microcontroller board
itself properly. The implementation of the robots hardware was
easily achieved providing the system integration and
functionality. Being based on low cost components, the project
is an ideal demonstration of control theory for a classroom.
ACKNOWLEDGMENT
The author wish to acknowledge the assistance of Mr. Umar
Farooq on the development and the implementation of control
theory of this project.
REFERENCES
[1] Mr Peter Miler, “Buliding a Two Wheeled Balancing Robot”, University
of Southern Queensland, October, 2008.
[2] Soumit Kumar Biswal, “Development of Self Balanced Robot and its
Controller”, National Institute of Technology, Rourkela, 2009.
[3] Ho-Khoon Chye Randel, “Balancing Wheel Robot”, University of
Southern Queensland, October 2005.
[4] M.H. Knudsen, “Experimental modeling of dynamic systems: An
educational approach”, IEEE Trans. Educ., vol. 41, pp. 146-158, May
1998.
[5] R. Kelly and J. Moreno, “Learning PID structures in an introductory
courses of automatic control”, IEEE Trans. Educ., vol. 44, pp. 373-376,
Nov. 2001.
[6] J.C. Basilio and S.R. Matos, “Design of PI and PID controllers with
transient performance specification”, IEEE Tans. Educ., vol. 45, pp. 364-
370, Nov. 2002.
[7] R.C. Dorf and R.H. Bishop, “Modern Control Systems”, 10th ed.
Englewood Cliffs, NJ: Prentice-Hall, 2005.
[8] B.C. Kuo and F. Golnaraghi, “Automatic control System”, 8th ed. New
York: Wiley, 2003.
[9] G.F. franklin, J. D. Powell, and A. Emami-Naeini, “Feedback Control of
Dynamic Systems”, 4th ed. Englewood Cliffs, NJ: Prentice-Hall, 2002.
[10] Shui-Chun Lin and Ching-Chih Tsai, “Development of a self-balancing
human transportation vehicle for the teaching of feedback control”, IEEE
Fig. 15 Motor interface circuit Trans. Educ, vol. 52, No. 1, February 2009.
[11] Nawawi S. W, Ahmad. M. N, Osman J.H.S, Husain A. R and Abdollah
A.F, “Controller design for two-wheels inverted pendulum mobile robot
using PISMC", 4th Student Conference on Research and Development
(SCOReD 2006), Shah Alam, Selangor, Malaysia 27-28 June, 2006.
[12] [Online] visit: Toptronic (PTY) Ltd T A AP ELECTRONICS - HITACHI
H48C TRI-AXIS ACCELEROMETER MODULE.
VI. CONCLUSION
In this paper, an effective and pragmatic approach to the
modeling and control of two wheeled balancing robot using low
cost components is presented. Sensory system of the robot
consists of accelerometer and encoders which gives the tilt and
the displacement information respectively. A linear PID
controller has been developed that helps the robot to balance