You are on page 1of 5

183 THE INTERNATIONAL JOURNAL OF ENGINEERING AND INFORMATION TECHNOLOGY (IJEIT), VOL.6, NO.

2,2020

A Guide to Implement a Two Wheeled Robot


Using Pole-Placement on Arduino
Ausama Hadi Ahmed Othman E. Aburas
Electrical and computer dept. Electrical and computer dept.
Elmergib University, College of Engineering Elmergib University, College of Engineering
El-Khoms, Libya El-Khoms, Libya
ausama.ahmed@gmail.com/ahahmed@elmergib.edu.ly

Abstract— Practical experiments are a must for students to companies world-wide. However, looking to the current
understand the different components of the control systems. financial situation of our country, Libya, many
The financial situation in our country does not make universities cannot afford getting such experimental
teaching practical control easy. In this paper a two wheeled setups. For instance, a Ball and Beam experiment costs
robot, is built, modelled, and controlled. The two wheeled
around 1,260US$ [6], while a basic Two Wheeled Robot
robot is a slightly modified version of the well-known
inverted pendulum experiment. A dc motor with gears is (Segway) costs a little over 150 US$ [7], without the
used to balance and move the robot, the motor is derived ability to see or draw its response. Only a two wheels
with the use of an H-bridge. An accelerometer and a mounted on a chassis will cost around 50US$[8].
gyroscope are the sensors used to balance the robot. All the A number of papers show how to control a two
components are connected to an Arduino board which can wheeled robot using different controllers[9][10][11], but
be programmed to serve either as a controller (the control is very few used pole placement technique [12]. The pole
on-board) or as a wireless data acquisition card (the control placement controller is chosen specifically because it can
is off board on a nearby host PC) with the help of a be used to place the poles of the system as desired without
Bluetooth module. This system is similar to systems that use
increasing the order of the system.
forces at one end such as rockets. The parameters of the
mathematical model are obtained experimentally. Balancing Building and controlling a low cost two wheeled robot
the robot is successfully achieved via PD controller is demonstrated in this paper where, section II presents the
programmed onto the Arduino board. An integrator is not different components of the robot and how they are
used as the PD controller can be used to place the roots at connected, section III presents the mathematical model of
any position as desired, which is proved in this paper. This the robot, and experimentally determining its parameters,
robot is aimed to be a platform for students to learn while section IV presents the used pole placement
concepts in the field of modern, robust and optimal control. controller, and the results are presented along with the
model verification in section V.
Index Terms: two wheels robot; balancing; PD controller;
Arduino
II. ROBOT BUILDING
I. INTRODUCTION The robot uses an Arduino board (as the brain) to
control the various parts of the robot. To make the robot
C onnecting theory with application is very important
to teach proper engineering materials to students.
Applying the theory can be accomplished either as a
compact, one of the smallest Arduino board variant is
used, i.e. Arduino Mini Pro. Either a serial port or a USB
simulation, an experimental setup, or both. It will be more to serial converter is needed to program the board. MPU
beneficial if students build an experiment and apply the 6050 sensor is used to measure the inclination and the
theory to that experiment which will expose them to the speed of rotation of the robot’s body as well as the linear
real engineering problems that arise from building a acceleration. The Arduino board communicates with the
project or product. sensor using the I2C protocol on pins 4 and 5.
In control systems, many classical experiments, such The robot moves using a DC motor connected to the
as the ball and beam [1], [2], magnetic levitation [1], [2], wheels via a gearbox. The gearbox is used to increase the
spring mass damper system [3], and inverted pendulum torque of the motor. Because it is not easy to find a
[3]–[5] and its variation, i.e. Segway [5], are available for gearbox in the local market, both the motor and the
students to learn different control concepts. Such gearbox were taken from a car toy, see Figure 1. The DC
experiments can be easily bought from different motor is operated by the use of an H-bridge which is
connected to the Arduino board through pins 10 and 11.
‫ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Received 25 Apr, 2020; revised 22 May, 2020; accepted 8 June,
2020.

Available online 15 June, 2020.

www.ijeit.misuratau.edu.ly ISSN 2410-4256 Paper ID: EN121


Ausama Hadi Ahmed and Othman E. Aburas/ A Guide to Implement a Two Wheeled Robot Using Pole-Placement on Arduino 184

Let the distance between the center of mass ( ) and


the axial of the wheel be denoted by [13]. Let the mass
of the robot to be , with a moment of inertia , the tilting
angle of the robot’s body to be , and the distance
between the center of mass and the wheels’ axis of
rotation to be . The free body diagram is shown in
Figure 3.
Assume the gravity to be acting along the negative y-
axis. Two forces, along the x ( ) and y axes ( , are
Figure 1. The Toy Car with a Pen in Comparison
acting on the robot at the center of the wheel.
All of the components are connected together using a
perf board which serves as the body of the robot.
Mounting the gearbox on the perf board is done using
glue. The robot is powered using 5V voltage source
through two pins on the perf board. The robot with its
components is shown in Figure 2.

Figure 3. Free Body Diagram of the Robot

The moment at the center of mass is

Figure 2. The Two Wheeled Robot  


The robot costs 170 L.D. with the individual cost of : the horizontal force acting on the robot
the different components are shown in Table 1. due to acceleration
Table 1. Bill of Materials the horizontal force acting on the robot
Description Price Notes due to acceleration
Arduino Mini Pro 25 The horizontal acceleration is a combination of
H-bridge 10 the acceleration due to the wheels, named , and the
change in the horizontal distance between the center of
MPU 6050 37 mass and the wheels’ axis of rotation
USB to Serial converter 20 Only used for programming

Toy car 30 (2)


Perf board 15 Only one fourth is used.
The vertical acceleration is a combination of the
Bluetooth Module 33 gravitational acceleration, , and the change in the
Total cost 170 vertical distance between the center of mass and the
wheels’ axis of rotation

III. ROBOT MODELLING  

A. Mathematical Model The moment about the center of mass is


The mathematical model of the two wheeled robot is
similar to the well-known inverted pendulum on a moving  
cart. Where, it is desired to keep the pendulum, in this
case the body of the robot, at 0o angle with the vertical
axis, i.e. 90o with the horizon.

www.ijeit.misuratau.edu.ly ISSN 2410-4256 Paper ID: EN121


185 THE INTERNATIONAL JOURNAL OF ENGINEERING AND INFORMATION TECHNOLOGY (IJEIT), VOL.6, NO.2,2020

For a small value of , then the model can be where is the radius of gyration, in our case it is equal to
linearized by setting , and . . The inertia has a value of . With
The model, i.e. (1), is reduced to these values, the state space of the robot given by (6) can
be written as
(5)

The two states of the system are the inclination angle (8)
and the angular acceleration . The input for this system
is assumed to be the acceleration, , and the output, i.e.
the inclination angle, is the first state . The system can IV. CONTROLLER
be put into a state-space form as follows
This system can be controlled using different
controllers. The controller chosen to be used is the pole
(6)placement. It allows placing the roots at any desired
location without increasing the order of the system. It can
with be used only if the system is completely controllable [2, 3,
5]. The controller is a state regulator, as it is desire to keep
the robot at zero inclination and zero angular velocity.
For a system given by (6), a state feedback gain matrix
can be used to place the roots of the system as desired.
Which is true only if the system is completely
B. Identification of model parameters controllable, i.e. the rank of the controllability matrix
The mathematical model derived in the previous is of full rank [2, 3, 5]. of the system is found to be:
section has three unknowns namely, the distance between
the center of mass and the axis of the wheel , the mass
, and the moment of inertia . (9)
The distance between the center of mass and the axis
of the wheel is found by hanging the robot, using a thread,
twice. Each time the robot is hung at a different location, the system is completely controllable because, the rank of
and a line parallel to the gravity, at the hanging point, is is of full rank, .
drawn. The two locations were chosen to be along the
wheels’ axis of rotation. The first is near the left wheel A. Controller Structure and Design
and the second is near the right wheel. In Figure 4-a the The pole placement controller feeds the states back to
robot is hung at the axis of the wheels and the extension the input through a gain matrix K. The values of the
line is drawn in dashed line with blue color. The elements of the K matrix can be calculated using a
intersection of the two extended lines, drawn in black is number of methods, see [2], [3]; if the system is of order
shown in Figure 4-b, which represents the center of mass , then calculating the K matrix by hand is simple using
the direct substitution method, otherwise Ackerman’s
formula or the transformation matrix T are used. In this
work Ackerman’s formula is used to calculate the K
matrix using MATLAB; note that MATLAB has two
commands to calculate the K matrix, namely place() and
acker(). The first does not provide a solution if the poles
are at the same location.
This robot has two states, namely inclination angle
and angular velocity, with each are fed back through gains
and respectively. The state equation of the system
with the gain matrix is

(10)
of the robot.
Figure 4. Determining the Radius of Gration. (a) the Robot is Hung at a
The roots of the system with the controller are the
Point. (b) the Radius of Giration is in Dashed red Line. eigenvalues of the matrix. The roots of the
system must be relatively fast, as slow roots lead to a
The intersection point is found to be 3.8cm from the system with slow response; which is not desirable,
wheels’ axis of rotation, i.e. , see the dashed because a slow response will make the system to go
line in red color in Figure 4-b. The mass of the robot was outside the range of linearity. The roots of the system are
simply found by weighting the robot, which found to be chosen, randomly, to be at and . For this system
64 grams. Since the model depends only on the inertia the values of the gain matrix K are calculated using the
about one axis, i.e. the wheels’ axis, then the inertia of the command acker() on MATLAB to be
robot can be calculated using the following equation [14]. .

(7)

www.ijeit.misuratau.edu.ly ISSN 2410-4256 Paper ID: EN121


Ausama Hadi Ahmed and Othman E. Aburas/ A Guide to Implement a Two Wheeled Robot Using Pole-Placement on Arduino 186

B. Controller Implementation
The Block diagram for the overall control system is Calculate the offset using the first 200
shown in Figure 5. readings

The body inclination angle of the robot, is found by


Read the angular velocity from the sensor.
integrating the z-axis angular velocity as follows


Apply a median filter to smooth the sensor
reading
where, and are the current inclination angle and the
angular velocity respectively, is the previous
inclination angle and is the sample time of the system. Get the sample time

Voltage Using
SS MPU 6050
H-Bridge Motor
equations Integrate and find the body inclination .
Movement

Mechanical
part Multiply by and by to produce the
error signal.
K
1

- State
States feedback
-
control Feed the error, with negative sign, to the
K
2

algorithm input (H-bridge).

Figure 5. The Overall Control System of the Robot

The sensor is found to have an offset that slightly


changes almost every time it is used, from that raised the Figure 6. Flowchart of the Arduino Code
need to calculate the offset at the beginning of each run.
The first 200 readings are averaged right before the start V. RESULTS
of the control algorithm. Averaging 200 readings requires The robot can balance itself using the implemented
a lot of memory if reading the 200 angular velocity is controller which runs at a frequency of 204 Hz. The robot
done first and then summed and divided by 200, which can balance itself when non-zero initial conditions.
the used Arduino board does not have. Instead, the Recovering the balance is shown in Figure 7-a. The initial
following equation which uses only two memory condition of the robot was set by instantaneously tilting
locations is used the robot by hand. The response is shown in Figure 7-b.
From time zero to approximately 0.7 s, the robot is put
into an initial condition by hand, and the transition took
(12)
approximately 0.15 s to return to zero position.
This control system shows a good performance in the
where is the iteration number, has values from 1 to 200, transition phase, however, it has a steady state error.
is the current averaged angular velocity, and That’s noticeable as the robot, sometimes, does not stand
is the previous averaged angular velocity. still, but rather moves without falling.
A flowchart summarizes the flow of the code used to
control the robot is shown in Figure 6.

www.ijeit.misuratau.edu.ly ISSN 2410-4256 Paper ID: EN121


187 THE INTERNATIONAL JOURNAL OF ENGINEERING AND INFORMATION TECHNOLOGY (IJEIT), VOL.6, NO.2,2020

REFERENCES
[1] N. Nise, Control Systems Engineering, Sixth edit. Wiley.
[2] R. Dorf and R. Bishop, Modern Control Systems, 12th ed. New
Jresey: Prentice Hall, 2011.
[3] K. Ogata, Modern Control, Fifth. Prentice Hall, 2010.
(a) [4] H. Khalil, Nonlinear Systems, Third edit. Michigan: Prentice Hall.
[5] K. Astrom and R. Murray, Feedback Systems An Introduction for
Scientists and Engineers. Princeton University Press, 2012.
[6] “ACROME my CONTROL Bal and Beam Kit.” [Online].
Available: https://www.robotshop.com/en/acrome-mycontrol-ball-
beam-kit.html. [Accessed: 09-Jan-2018].
[7] R. UK, “Microduino.” .
[8] Banggood, “Self balancing robot.” .
[9] O. Jamil, M. Jamil, Y. Ayaz, and K. Ahmad, “Modeling, control
of a two-wheeled self-balancing robot,” in 2014 International
Conference on Robotics and Emerging Allied Technologies in
Engineering (iCREATE), 2014, pp. 191–199.
[10] S. M. Boskovich, “A two wheeled robot control system,” in
(b) Proceedings of WESCON’95, p. 750.
[11] Z. Zhang, li Wang, and L. Li, “Design and implementation of
Figure 7. The Robot Recovering from an Initial Non-Zero Angle. (a)
two-wheeled mobile robot by variable structure Sliding Mode
Snapshots Showing the Recovery Process. (b) The Response with
Control,” in 2016 35th Chinese Control Conference (CCC), 2016,
Time.
pp. 5869–5873.
[12] Y. Amano, “Stability Control for Two-Wheeled Mobile Robot
VI. CONCLUSION Using Robust Pole-Placement Method,” Springer, Cham, 2014,
pp. 259–268.
The system worked as expected using the pole
[13] F. Grasser, A. D. Arrigo, S. Colombi, A. C. Rufer, and S.
placement technique implemented on Arduino board. The Member, “JOE : A Mobile , Inverted Pendulum,” IEEE Trans.
budget to build this platform is 170 L.D., which is very Ind. Electron., vol. 49, no. 1, pp. 107–114, 2002.
low budget platform. It can be used as an experiment to [14] R. C. Hibbeler, Dynamics, Twelfth ed. Prentice Hall, 2010.
teach students practical control systems.
To improve the performance of the robot, i.e. get rid
of the steady state error, an integrator with the pole
placement in the feed-forward could be added to the
system [3].
Other controllers in classical control such as the
Proportional + Integral + Derivative controller (PID) with
its variants, in optimal control such as Linear Quadratic
Regulators (LQR), and in robust control can be applied to
this system. The system is non-linear in nature, for
relatively large inclination angles, which can be used to
show/apply non-linear characteristics/controllers. Since
the sensor used is noisy, Kalman filter can also be used to
smooth the sensor readings.

www.ijeit.misuratau.edu.ly ISSN 2410-4256 Paper ID: EN121

You might also like