2015 Stab - Attitude Control Statbilization of TWSBR
2015 Stab - Attitude Control Statbilization of TWSBR
net/publication/283659634
CITATIONS READS
19 3,397
3 authors, including:
All content following this page was uploaded by Omer Saleem on 03 February 2020.
Abstract: The paper demonstrates development of attitude control and stabilization technique of a self-
balancing robot. The main aim is to ensure its vertical stability, even in the presence of an external
bounded impulsive force. By electronically programming a hard-coded vertical reference position, the
proposed robotic system can be balanced at the desired set-point angle. The orientation and the extent of
inclination of the robot body in either direction are measured with inertial-sensor based feedback. The
proposed system uses a combination of first-order spatial filters in order to remove the noise and to merge
the analog sensor readings. Comparative performance analysis is also done between a simple PID
controller and an auto-tuned PID controller for the optimization of attitude control and stabilization of the
self-balancing platform.
Keywords: Attitude control, auto-tuned PID, inertial sensors, filters, PID, self-balancing robot.
where,
1. INTRODUCTION M = moment arm (perpendicular distance between center of
Two-wheeled balancing robots have immense significance in mass and distance from pivot)
g = acceleration due to gravity
the area of robotics and control systems engineering. They
θ = inclination (angle with the vertical)
offer to develop an intricate control system that is capable of
maintaining stability of an otherwise unstable system. This
balancing robotic system imitates the behavior of an inverted
pendulum and in effect works on the same principle as the
Pole and Cart theory. Hence, these principles are taken into
account while designing a robot that is capable of balancing
upright on its two wheels that are aligned on the same axle.
The two wheels are situated below the base and allow the
robot chassis to maintain an upright position by moving in
the direction of tilt, either forward or backward, in an attempt
to keep the centre of the mass above the wheel axles. These
robots are highly non-linear and under-actuated. Since they
are able to balance themselves on only two co-axial
motorized wheels, it is very easy for them to maneuver on
various terrains. Without active control, these systems
become unstable and collapse. Apart from balancing the
posture in a stable upright fashion, they are also able to Fig. 1. Conceptual view of the robot.
regain their posture and stand erect, even when a bounded When θ = 0 degree, the robot is in balanced position and no
external force is applied to them. This force acts as a balancing torque in needed. With θ> 0 or θ< 0, the balancing
disturbance to the system. These robots sense their inclination torque moves the robot in the direction against falling torque.
(rotational pitch angle) continuously, compare it with the set- In this way, the robot tries to retain its balanced position.
point reference provided by the user and correct their Development of a flexible self-balancing robotic platform
orientation by keeping it at the desired pitch angle. The comprises of several essential units. These units include a
system also keeps track of the maximum recovery pitch angle reliable systems model, sensors, signal processors, a stable
(the threshold angular displacement of the robot from the control scheme and actuators. These units have been properly
vertical before it collapses). Inverted pendulum being an discussed by (Nawawi et al., 2007). In the past, the
inherently unstable system tends to fall in either direction. A researchers have extensively used MATLAB toolbox to
conceptual view of the proposed robotic system is shown in efficiently model and control a self-balancing robot (Araghi,
Fig. 1. The balancing torque is given by (1). et al., 2011).Interactive software tools and virtual prototyping
T Mgsin θ (1) techniques, such as ADAMS, can be used to build and
CONTROL ENGINEERING AND APPLIED INFORMATICS 99
simulate a stable mechanical system model (Qian Hao et al., regarding the robot’s orientation. Using the basic
2007). Several non-linear control schemes have been trigonometric relations, this acceleration is used to compute
proposed and their performance has been verified by rigorous angular displacement (θ) of the robot body along with the
experimentation. Neural network controllers have been used direction of tilt, as shown in Fig.3. If one axis (x-axis) is used
in mobile inverted pendulum experiments to control the to calculate the tilted angle of the accelerometer, the
pendulum angle and the position of the cart (S. Jung et al., trigonometry relationship of (2) is used (Analog Devices (a),
2007). Simulation results with PID backstepping control n.d.).
algorithms have proven that with three control loops, this
algorithm can offer a quicker response to balance the two- θ sin (2)
wheeled platform (Nguyen Gia Minh Thao et al., 2010).
where,
State-feedback controllers and Linear Quadratic Regulators Vout= Accelerometer Output (Volt)
(LQR) have also been experimentally validated to provide Voffset= Accelerometer Offset = 1650 mV
robustness for the balance control of a self-balancing robot S = Accelerometer Sensitivity = 800 mV/g
(Solis and Takanishi, 2010; Junfeng and Wanyang, 2011). θ = Angle of Tilt (radians)
2. EXPERIMENTAL SETUP
The voltage signal is the input and the rotational pitch angle
serves as the output. The high level block diagram of the
robot is shown in the Fig.2.
Fig. 3. Single Axis used for Tilt Sensing (Analog Devices (b),
n.d.).
These filtered values are then combined together via a first The mathematical relationship of PID is shown in (4).
order digital complimentary filter, represented by (3).
u t K e t K e t dt K e t (4)
f a y 1 a x (3)
where,
where,
a = τ / (τ + dt), KP = Proportional Gain
y = gyroscope reading, KI = Integral Gain
x = accelerometer reading, KD = Derivative Gain
f = filtered-output The output of the PID controller is checked continuously, so
A properly implemented filter would combine the raw angle that it may stay between a minimum and maximum value.
with the gravity angle, as shown in Fig.4. It fixes the inherent This helps in avoiding the wind-up state. The tuning of KP,
problems of sensor noise, drift and horizontal acceleration KD, KI constants is usually done with the aid of simulations
dependency. It helps rejecting all the short-term fluctuations. and rigorous experimentation. Now, the variation of the PID
The time interval between successive program loops is control output magnitude between these bounds helps in
known as the Sample Period, dt. The time constant, τ, is the deciding the variation in the duty cycle of the Pulse-Width-
time interval on which it operates on a given signal. So the Modulated (PWM) signal. The resultant PWM signal helps
signals that have time period smaller than this time constant controlling the speed and direction of rotation of the DC
are filtered out, while the longer signals stay unaltered. To geared motors, via an H-Bridge motor driver circuit. This
reduce the gyroscopic drift, a lower time constant should be way, if the robot body tilts in a given direction, the motors
implemented. But on the other hand, this leads to a lot of respond immediately by moving in the direction of
horizontal acceleration noise. Hence a compromise is made inclination at an appropriate speed, in order to bring the
by experimentally tweaking its value and adopting the best wheels exactly below the centre of mass of the robot body.
one for the application. The 'Derivative' term amplifies higher frequency noise that is
generated by the sensors. Thus, the higher values of the
2.3 Closed Loop Control derivatives lead to large changes in the output of the PID
controller. A practical solution that has been adopted to
This digital value is used henceforth for the purpose of remove these high frequency components of noise is by
comparison and correction of robots orientation and attitude putting a first order low pass filter programmatically on the
to put it in its stable upright posture. The filtered output of the derivative term. Consequently, the poles of the derivative
sensors, when the robot body is exactly in stable upright term are tuned such that the noise does not affect the output.
position, is taken as the equilibrium reference or equilibrium
set-point by the control scheme. Once the robot is set into 2.4 Motor Control
action, it continuously checks and compares its current state
with the equilibrium set-point. The difference of these two The motor control is probably the simplest of all the tasks.
entities generates the error signal, e(t). The sign of this error For driving the motor, L298 based dual H-Bridge motor
signal denotes whether the robot is leaning forward (if e(t) > driver circuit is used as shown in Fig.6. It can fully control
0) or backward (if e(t) < 0). The magnitude of the e(t) and drive two motors simultaneously. Also the motors require
specifies the extent to which it has fallen. These error signals, a unique PWM signal. This signal is fed to the motor driver
once computed, are stored. The current error is fed to the P circuit in order to control the speed of the motor rotation. The
controller after being multiplied with KP. The I controller pulse length can be varied to change the speed of the motor.
takes the sum of recent errors. Hence the ten recent errors are Generally, the PWM frequency is about 1000 Hertz, with a
added over the time interval (between successive error period cycle of 1.0 msec.
readings) and sent to the I controller, where they are
2.5 Power Source
multiplied with KI. The rate of change/difference between
two recent errors is subjected to the D controller where they To provide DC power to all the electronic devices explained
are multiplied with KD. Eventually all these three terms are earlier, a DC battery has been utilized.
added and the output u(t) of PID control scheme is obtained,
as illustrated in Fig.5.
A MAX MIN (5) overshoot is calculated by using (8). The rise time (TR),
settling time (TS), percentage overshoot (%OS) and steady-
Table 1. PID parameters for the Auto-tuner (Arduino PID
state error (eSS) of the two responses are summarized in Table
Auto-tune Library, 2012)
2.
Control KP KI KD
P 0.5KU - -
PI 0.4KU 0.48KU/TU -
PID 0.6KU 1.2KU/TU 0.075KU/TU
The period TU is found by detecting two zero-crossings and
computing the time between them. For this purpose, the
number of samples between the two zero-crossings is found
and using (6), TU is calculated.
T n T (6)
where,
TS = sampling time Fig. 13. Experimental Setup.
n = number of samples
%OS 100 (8)
Once these KU and TU are found, we next compute the KU via
(7). The PID coefficients are found using the mathematical where,
relations given in Table 1. θMax = Highest peak value of the response in the graph
θSS = Steady-state value of response in the graph
K (7)
π
where,
D = Amplitude of relay output step response
A = peak-to-peak signal value of the input
4. RESULTS
The microcontroller communicates the robot body’s tilt
(pitch) angle with LABVIEW over serial link. The setup used
for testing and recording the simulations results is shown in
Fig. 13. The sampling time used in the application is 10
msec.
Fig. 14. Response with simple PID controller.
Two tests are commenced on the robot to control its attitude
and stabilize it in the upright position. The first test is done
by using a manually-tuned PID controller. The KP, KD and KI
co-efficient are found experimentally to be equal to12.05,
1.075and 0.355respectively. They are hard-coded in the PID
software routine. The step-response of the system is shown in
Fig. 14. The graph is plotted with robot body’s tilt angle
(degrees) and the time (seconds) along the x-axis.
The second test is done by using the automatically tuned PID
controller. The KP, KD and KI co-efficient are found using the
relay method. These coefficients are adjusted automatically.
The step-response of the system is shown in Fig. 15. The
graph is plotted with robot body’s tilt angle (degrees) and the Fig. 15. Response with auto-tuned PID controller.
time (seconds) along the x-axis. It can be clearly seen from Table 2. Summary of robot’s body angle response
the response(s) in Fig. 14 and Fig. 15, that the system
energizes the motors of the robot to oscillate it back and Control Type TR (sec) TS(sec) %OS eSS
forth. Once the robot has gained sufficient energy, the PID 0.30 3.10 13.89% ±6o
balance control scheme(s) implemented via the PID Auto-PID 0.25 1.45 25.10% ±1o
controller and its auto-tuning variant, tend to keep it erect.
5. CONCLUSION
The rise time is experimentally found by looking at the time
required by the response to reach from 10% to 90% of its step The auto-tuning feature saves the trouble of going through
height in Fig. 14 and Fig. 15. Similarly, the settling time is the problematic and redundant task of manually tuning all the
found by observing the time taken by the response to fall PID coefficients, but a comparative analysis of the responses
within ±2% of the steady state value. Finally the percentage in Fig. 14 and Fig. 15, reveals that the overshoot in the
104 CONTROL ENGINEERING AND APPLIED INFORMATICS
system with auto-tuned PID is quite large. However, unlike Dew, ‘Discrete-time PID Controller Implementation,’ 4 May
the manually-tuned PID controllers, the auto-tuned system 2014. [Online]. Available:
shows a smaller steady state error and smaller rise time and http://controlsystemslab.com/category/articles/control-
settling time. The steady state error is reduced by 5o, whereas engineering/pid/. [Accessed May 2014].
the rise time (TR) and settling time (TS) are reduced by 0.05 http://brettbeauregard.com/, ‘Arduino PID Autotune Library,’
sec and 1.65 sec respectively. 28 January 2012. [Online]. Available:
http://brettbeauregard.com/blog/2012/01/arduino-pid-
It is shown in this paper, that application of auto-tuned PID
autotune-library/. [Accessed May 2014].
controllers tend to balance the two-wheeled self-balancing
MicroChip, ‘PIC18FXX2 DataSheet,’ 2006. [Online].
robots in a much more effective manner that the manually-
Available:
tuned PID controllers. Scientifically speaking; with the
http://ww1.microchip.com/downloads/en/DeviceDoc/395
application of the auto-tuned algorithm, the steady state error,
64c.pdf. [Accessed May 2014].
rise time and the settling time of the dynamic system has
Microchip, n.d. ‘Software PID Control of an Inverted
improved. The comparison and hence the improvement in the
Pendulum Using the PIC16F684’. [Online] Available at:
transient as well as the steady state analysis of the system
http://ww1.microchip.com/downloads/en/AppNotes/009
with manually tuned and the auto-tuned controller, also
64A.pdf [Accessed May 2014].
validates the proposed technique. This also manifests that the
Nawawi, S.W., Ahmad, M.N., Osman, J.H.S.
auto-tuned PID controllers can adapt to changes in the
(2007),‘Development of a Two-
physical properties of the robot. That is to say, if the robot’s
Wheeled Inverted Pendulum Mobile Robot,’ IEEE
battery drains over time, the robot will update its PID
Conference Publications, 5th Student Conference
coefficients and would try to cope with the effect of battery
on Research and Development (SCOReD), pp. 1 – 5.
loss to some extent. However in the case of ordinary PID
Nguyen Gia Minh Thao, Duong HoaiNghi, Nguyen HuuPhuc
controller, since the coefficients are hard-coded, the robot
(2010),‘A PID Back-stepping controller for two-wheeled
would get unstable and collapse under such circumstances.
self-balancing robot,’IEEE Conference Publications,
Similarly if the mass of the robot is changed during
International Forum on Strategic Technology (IFOST),
operation, the PID coefficients of system would adjust
pp. 76 – 81.
themselves automatically in order to continue stabilizing. The
Qian Hao, Liping Chen, WeiweiQiao, Peng Li, Songling
relay method for auto-tuning provides us with the ease of
Yang, Qifang Liu (2011),‘Controlling Simulation Study
implementation and great flexibility in usage. It gives us
On Two-Wheeled Self-Balancing Electrical Motorcycle
fairly good values of KP, KD and KI to balance and control the
Based on ADAMS And MATLAB,’IEEE Conference
attitude of our robotic system. Thus, we are able to balance a
Publications, Cross Strait Quad-Regional Radio
two-wheeled platform in a very effective and an innovative
Science and Wireless Technology Conference
way. However, in exchange, some performance sacrifices are
(CSQRWC), pp. 1704 – 1707.
made such as excessive overshoot.
Seul Jung, H. T. Cho, T. C. Hsia (2007), ‘Neural network
There is still a lot of room for further research and control for position tracking of a two-axis inverted
enhancements that can improve the performance of this pendulum system: Experimental studies,’IEEE
platform. Instead of using the manually-tuned PID and the Transaction on Neural Networks, vol. 18, no.4, pp. 1042-
auto-tuned PID controllers, adaptive fuzzy PID controller can 1048.
be used to tune the KP, KD and KI co-efficient in real time. Solis, J., Takanishi, A. (2010),‘Development of a Wheeled
Although the adaptive fuzzy PID control technique would be Inverted Pendulum Robot and a Pilot Experiment with
computationally expensive and slow. But being more Master Students,’IEEE Conference Publications, 7th
sensitive to the changes it would yield a much better dynamic International Symposium on Mechatronics and its
performance for the stability and balance control of the two- Applications (ISMA), pp. 1 – 6.
wheeled self-balancing robot. STMicroElectronics, ‘LPR550AL,’ [Online]. Available:
http://www.starlino.com/wp-
REFERENCES content/uploads/data/acc_gyro/LPR550AL.pdf.
Analog Devices (a), ‘AN-1057 Application Note,’ [Online]. [Accessed June 2014]
Available: www.analog.com/static/imported- Thomas Bräunl, Embedded Robotics: Mobile Robot Design
files/application_notes/AN-1057.pdf. [Accessed May and Applications with Embedded Systems, Springer, 3rd
2014]. ed., 2008
Analog Devices (b), ‘Small, Low Power, 3-Axis ±3 g Wu Junfeng, Zhang Wanying (2011),‘Research on Control
Accelerometer ADXL335,’ [Online]. Available: Method of Two-wheeled Self-
www.analog.com/static/imported- balancing Robot,’IEEEConference Publications,
files/data_sheets/ADXL335.pdf. [Accessed May 2014]. Intelligent Computation Technology And Automation
Araghi, M.H., Kermani, M.R. (2011), ‘Computer-Aided (ICICTA), pp. 476 – 479.
System Design for Educational Purposes: An
Autonomous Self-Balancing Two-Wheeled Inverted
Pendulum Robot,’ IEEE Conference Publications, 24th
Canadian Conference on Electrical and Computer
Engineering (CCECE), pp. 001357- 001360.