moving; Controlling two-wheeled self-balancing robot moving on inclined

 Abstract —This research not only describes the design and implementation of two - wheeled self balancing robot, but also shows how to simulate the platform in Simulink Matlab using Proportional– Integral–Derivative (PID) cascade control rule, then compares it with reality platform. A Kalman filter is used for state reconstruction in the final implementation. A cascaded PID control algorithm was proposed to combine the balancing and movement. The movement of the robot is controlled by using a distance controller that use rotary encoder sensor to measure its traveled distance. Besides the robot is able to move forward, backward, turning and reach the desired angle position by calculating the body's tilt angle. The experiment shows that the robot is likely to climb up slope with upon 25 degrees. Last but not least, this research also shows how to control the robot by using smartphone and C# form on



Abstract-This research not only describes the design and implementation of two -wheeled selfbalancing robot, but also shows how to simulate the platform in Simulink Matlab using Proportional-Integral-Derivative (PID) cascade control rule, then compares it with reality platform. A Kalman filter is used for state reconstruction in the final implementation. A cascaded PID control algorithm was proposed to combine the balancing and movement. The movement of the robot is controlled by using a distance controller that use rotary encoder sensor to measure its traveled distance. Besides the robot is able to move forward, backward, turning and reach the desired angle position by calculating the body's tilt angle. The experiment shows that the robot is likely to climb up slope with upon 25 degrees. Last but not least, this research also shows how to control the robot by using smartphone and C# form on laptop.

INTRODUCTION
he two-wheeled self-balancing robot has the characteristics of flexible and simple structure, working well in a small space, especially in the poor working conditions and complexity task places, such as exploration and dangerous field. Therefore, the robot not only has become an essential and classical experiment facility but also is a good platform for researchers to prove various kinds of control theory and control method. The research on two wheels balancing robot is based on inverted pendulum model. Thus, two wheels balancing robot needs a good controller to control itself in upright position without the forces from outside.
Contrary to this existing research, this study aims to make the robot platform with a cheaper budget, better results and providing feedback with all the angles and position values in detail for evaluation and comparison. After that, the platform can be used in lab rooms at HCM City University of Technology.
The structure of this paper is as follows: Section 2, an overview of the proposed method is presented to explain the whole procedure. This section also discusses each step of the proposed algorithm in detail. Design and construction of experimental models of the robot show in Section 3. Experimental results of the proposed system are presented in Section 4. Finally, Section 5 concludes the paper with suggestions for future research. The block diagram of the proposed algorithm is shown in Fig. 1 The experimental results in Section 4 will visualize clearer each step of the proposed processes achieved in this method.

Read Sensor
Established the I2C communication to start and read angle from the MPU6050 sensor.
At the point of the robot's balancing, the angle was read and set it into Control Angle.
The Gyroscope bias drifted so it had to be calibrated. First, when robot was keep standing still, the gyro values were read and set into GyroCalib.
After reading and calibrating the angle, the rest of this part concerns calculating the Angle. Accelerometer Angle: The final Angle calculated by using Gyro Angle subtract to GyroCalib. After calculating the Gyro and Accelerometer Angle, the filter was used to combine it to compute the real and exact angle.

Complementary filter:
The complementary filtering is needed because the accelerometer is accurate in long term not short term. The gyroscope is just the reverse. Therefore, it's necessary to combine and filter the output of MPU6050 sensor.
The complementary filter is the combined low pass filter and high pass filter.
This filter combines accelerometer and gyroscope value to have final angle following this formula: T value is the boundaries of trust about gyro and accelerometer, so the recommend for value of A is 0.98 to have the suitable T.

Kalman filter:
The Kalman filter is an algorithm which uses a series of measurements observed over time; in this context, it uses an accelerometer and a gyroscope. These measurements will contain noise that will contribute to the error of the measurement. The Kalman filter will then try to estimate the state of the system, based on the current and previous states, that tend to be more precise that than the measurements alone. It is a good way to deal with the accelerometer and gyroscope noise.
The Kalman filter includes two main steps: Time Update and Measurement Update

Proportional-Integral-Derivative (PID)
Control System PID control method has been widely used in the feedback control system. It is a very typical way of control strategy in industry [1]. PID is composed of three parts [2]: The proportional part which is used in the purpose of error elimination, the integral part is used to average past error, the derivative part is to predict the further error through past error variation. The final control value can be calculated by simply adding these three terms together.
Three PID controller loops are used to make the robot stand still and move [3]. The first PID was used to let the error between Angle and Angle control down to zero.
If the robot still moved forward and backward in balancing mode, the second PID controller was used to deal with this problem. It keeps the speed of robot to reach the speed control. The output of this speed PID is angle and became the input of the first PID Angle.
Unfortunately, if the hardware is not perfect, the speed of two motors was not the same so the third PID was applied [3]. The output of these PID controllers will bonus with the first two PID above to have the final output to motors. The Fig.  2 will show it.

Feedback for evaluation and comparison
After using PID, all of the PID parameters and result values display and setup through C form. Therefore, we can more easily to find the suitable PID parameter and control the response. The Fig.  3 has shown the method.

Control robot
The robot was not only controlled by using form load C# Fig. 4 but also by android app. When clicked the button, the "character" will be sent to the microcontroller and the robot will operate in suitable mode depending on the character it received.
Transmission and reception of signal between laptop or smartphone with robot via Bluetooth. So we can control it in a short distance about 10 meters radius.
Solve the system of equations (6) we obtain:

Hardware architecture of robot
Hardware includes modules [4,5]: read encoder of two DC servo motors, PWM and DIR to control two DC servo motors, read angle value of the sensor -MPU6050, communicate with Bluetooth HC-05, source... to connect peripheral devices.

Mechanical design
In this model, the structure of a self-balancing robot is expressed. Mechanical parts of the car are designed by AutoCAD software and simulated 3D by SketchUp software.

Complementary file and Kalman filter
The Fig. 9 and Fig. 10 show the angle output after Kalman filter. In general, the angle output is stable and good.
The Fig. 11 shows the Complementary filter is not as accurate as the Kalman filter once when the Angle began changing continuously.

PID cascade
The Fig. 12 and Fig. 13 show the response of robot when we use PID speed and PID Angle.
In the first experiment, it is verified how the robot behaves given zero target velocity. It is seen that velocity and tilt of the robot slightly oscillate in control methods. The robot cannot be absolutely immobile since its state is never statically stable.  When we use two PID controllers at the same time the robot will become stable at the balance point. On one hand, the robot still remains stable after being pushed. On the other hands, if only use PID Angle is used, the robot cannot stay stable almost immediately after being push.

Robot moving on plane
Fig. 14 and Fig. 15 show the robot's response when it was moving forward, backward.
Besides that, it also shows the position of the robot when it moves. The robot still keeps balance while it was moving.
Because of three PID controller loops, the robot will move straight to forward and backward. This is the different compare with when we are not use PID Angle rotate. The robot will turn left or right when it moves for a long distance.
The robot meets installation parameters well. Travelled distance moves forward steadily. The robot's rotation on two wheels always remain stable (delta Pulse towards 0); on the other hand, the robot's angle is stable too. The robot is able to stabilize itself and managed to reject disturbances such as gentle pushes. Fig. 16 and Fig. 17 show the robot's response when it was pushed by external factors.  Fig. 19 show the robot's response when it was rotated.

Robot moving on inclined plane
The Fig. 20 and Fig. 21 shows that angle of robot is greater than angle of slope when moving up slope. The robot tilted back to reduce speed when moving down slope and when robot switched from plane to inclined plane or from inclined plane to plane, it has time of transition.

CONCLUSION AND FUTURE WORK
This project has successfully presented that two wheeled selfbalancing robot can move on plane, inclined plane and preset orbit. The robot can itself balance when it was changed gravity by force from outside. It also can be controlled from smartphone or laptop.
However, there are still some shortcomings. Although the robot can move forward and backward on inclined plane, it cannot turn left or turn right on inclined plane. Although robot can move follow some preset orbit such as square, triangular orbit with edge which can change by people or orbit of number eight…The orbit can only observe directly by eye, cannot draw it on computer.
This is a very challenging problem that should be studied more in the future research. It is also necessary to control exactly the position of the robot so that it can be controlled to move to narrow places where people cannot move.
Furthermore, the proposed straightening algorithm is built on a small platform with affordable and quality material, so that group students can afford to have a project to apply their knowledge.

Duc To-NGUYEN was born in Quang Ngai
Province, Vietnam in 1994. He received the degree in Control Engineering and Automation from Ho Chi Minh City University of Technology, VNU-HCM in 2017.
From 2012 to 2017, he was a student at Ho Chi Minh City University of Technology, VNU-HCM. His research interests include Advanced Control Theory, Intelligent Control, Control Systems.