Wall Following Control System with PID Control and Ultrasonic Sensor for KRAI 2018 Robot

The Indonesian Robot Contest (KRI) was held by the Directorate General of Higher Education (DIKTI) in 2018, the KRAI division with the theme “Throw the Blessing Ball” [1]. In KRAI in 2018, there are two robots that may consist of one manual robot and an automatic robot, or both are automatic, but only one automatic robot can throw a ball of blessing. Both robots must be able to navigate and carry out missions according to Abu Robocon's regulations [2]. During the game, many robots have problems with their navigation system. As a result of these problems, many robots hit the wall in the race area [3]. ARTICLE INFO ABSTRACT


Introduction
The Indonesian Robot Contest (KRI) was held by the Directorate General of Higher Education (DIKTI) in 2018, the KRAI division with the theme "Throw the Blessing Ball" [1]. In KRAI in 2018, there are two robots that may consist of one manual robot and an automatic robot, or both are automatic, but only one automatic robot can throw a ball of blessing. Both robots must be able to navigate and carry out missions according to Abu Robocon's regulations [2]. During the game, many robots have problems with their navigation system. As a result of these problems, many robots hit the wall in the race area [3]. The wall following system is applied to the robot so that it can navigate within walls. Based on the wall following principle, it follows an object, namely a wall. Wall following has grown rapidly in the world of robotics so that it can be used as an algorithm in a robot [4]. The robot uses the SRF-05 ultrasonic sensor as a wall following system. This system will continue to oscillate because the distance reading is always changing [5]. The ultrasonic sensor is a PINGtype sensor that emits ultrasonic waves to measure distances. The robot is paired to navigate the wall following. the robot's drive is an Omni wheel that can move in all directions [6].
This PID control design uses tuning with the trial and error method to determine the appropriate proportional, integral, and derivative values [7]. The wall following system that is carried out is to determine the input to the microcontroller in the form of a distance value that has been determined by the set point to the sensor reading when it detects an object or wall. The data is processed using a microcontroller to generate a signal in order to control the robot so that the wall following system on the robot can work as expected [8]. The error feedback from the difference in the ultrasonic sensor distance reading is processed so that the wall following system can work on the robot. The PID control value that has been obtained is then entered so that the wall following system works as expected [9].

KRAI Robot
The robot is equipped with sensors as the main component for detecting conditions around the robot, including using ultrasonic sensors to detect wall contours in the competition area. This robot system uses the Arduino Mega as a controller for overall behavior and a 24-volt DC motor as the driving force for the robot when maneuvering in the arena. The Arduino Mega is used as much as one board.

Robot Design
The robot is made with the necessary components such as sensors, batteries, motor drivers, and motors by considering the placement of the components so that it can lower the center of gravity of the robot so that it does not experience significant disturbances when walking along the playing field or trial track and of course the robot will be more stable. For data acquisition and control, the robot is equipped with a microcontroller in the form of an Arduino Mega as the main control (mainboard). The robot's power source is supplied by two 12-volt Li-Po batteries to the motor and one 12-volt Li-Po battery to power the microcontroller, sensors, motor drivers, and DC motors. Then to drive the robot using a 24-volt DC motor as many as four units, each controlled by an EMS 43 A driver and using an Omni wheel so that the robot can move freely (holonomic).

PID Tuning
The motor PID control aims to obtain the constant values of KP, KI, and KD, which are used for PID control in order to have the right rise time and also low oscillations. Proportional PID control functions to speed up the response to error signals and speed up reaching the set point. The integral PID control functions to keep the error signal fixed at the setpoint and the derivative will work effectively in the transient area. PID control uses a feedback error from the reading of the distance value from the ultrasonic sensor. The reading value is to determine the accuracy of the wall following the system so that it can be adjusted as expected. The effect of PID control on the wall following system is expected so that the motor that is controlled by PID can maintain its rotation speed without being affected by the oscillation of the reading from the ultrasonic sensor. The PID program in this test is one loop. The error generated by the sensor will be updated so that the robot can adjust the distance to the wall when the sensor emits ultrasonic waves [10].

Closed-Loop Control System
The closed-loop control system or Feedback Control System (FCS) is the output signal that has a direct effect on the control process. The closed-loop control system is also known as the feedback control system because the feedback action that occurs can minimize the errors of the system. The system behavior is observed using a sensing device to obtain the error value, which is the difference between the achieved value and the setpoint value. Then to find out how well the behavior of the system has achieved the expected performance, namely by feedback the error value to the input side [11]. Fig. 1 is a closed-loop control system diagram.

Kinematic Robot
Robot kinematics is the study of analyzing the movement of a robot's wheel or leg against a system of reference coordinate frames that is stationary or moving without regard to the force that causes the movement. The kinematic model represents the end effector relationship in three-dimensional space. Kinematics in robotics is a form of a statement that contains a mathematical description of the geometry of a robot structure [12]. The robot will run more accurately at its maximum speed, and the robot will be more agile because it can slow down faster when its target changes while walking.
The robot design will be built using four DC motors where the position between the four motors is made in such a way as to take into account the angle between the motors so that the robot can move freely (holonomic) so that the robot runs more optimally. The rectangular configuration also provides overall stability. Robot kinematics can be seen in Fig. 2. Parameters X and Y are the Cartesian Coordinate system. Parameters Lx and Ly are wheel velocity to X and Y axes. Parameter Vi (1,2,3,4) is the rotation vector of each Omni wheel. Parameters C1, C2 are the angle of movement of the robot. The rectangular configuration also provides overall stability. When the robot moves forward or backward, i.e., in the Y direction, wheels two (V2) and four (V4) are temporarily active when the robot moves to the right or left side, i.e., the X direction, wheels one (V1) and three (V3) does not provide torque/force. If the robot goes to x-direction or rotates, all wheels are active and apply torque/force.
The kinematic analysis of a mechanical system can determine the position and velocity of the various mechanical elements that make up the mechanism under consideration. In robot motion kinematics, by combining the position and velocity of an element over a certain time span. Refers to the state of the kinematics calculation element, such as (position, orientation, and rate of change) in a given axial axis motion is a straightforward kinematics problem [12]. In order to fully understand the operation of the three omnidirectional drives, the kinematics behind each drive system must be known. The equation used in the robot control system is as follows, The variables V1, V2, V3, and V4 represent the motor speeds 1, 2, 3, and 4, respectively. When the robot moves towards the X or Y axis in the horizontal plane, only the motor in a certain axis must be turned on. For example, if the robot needs to move on the X-axis, only motors 1 and 3 have to operate at the same speed. The same concept applies to the Y-axis motion. Negative velocity means the robot is moving in the opposite direction. This is equivalent to a holonomic drive system configured with normal squares [13].

Wall Following Robot
Wall following navigation system or wall tracking is a robot action to follow the wall and not far from the wall [13]. In different cases, consider using a wall following navigation controller so that the robot can follow the wall. Defined by and D, is the angular deviation relative to the wall line and D is the distance of the robot from the imaginary line of desired distance from the wall. Two ultrasonic sensors are installed on the left side of the robot and are named S1 and S2. The variable D is calculated through the following equation: Two ultrasonic sensors are installed on the left side of the robot and are named S1 and S2.
Placement and examples of the wall following systems can be seen in Fig. 3.

Robot Work Process
Robot design begins with collecting the theoretical basis for each component. In robot design, it can be seen in the block diagram shown in Fig. 4. In the block diagram of an automatic robot in Fig. 4, the robot gets input from a 12-volt battery so that the robot can function. The 12volt voltage from the battery is reduced by the regulator circuit to 5 volts to supply the microcontroller. The driver is an EMS 30A which functions when the incoming current will be filtered to continue the current to the motor. Ultrasonic sensors are used as wall-following systems in robots. All components are connected to each other so that the robot system can function properly and can be analyzed the output of each integrated component.

Method
The KRAI robot motion system uses PID control based on ultrasonic sensors. The KRAI robot motion system uses two ultrasonic sensors to assist in the wall following in order to navigate and regulate the speed of the DC motor. This robot uses an Arduino Mega 2560 microcontroller as a Microprocessor Processing Unit. The Arduino Mega 2560 microcontroller will give commands to the ultrasonic sensor, which functions to read the distance value from the ultrasonic sensor readings. The error reading on the ultrasonic sensor when the robot is navigating is used as a reference value for PID control so that the motor can rotate according to a predetermined PID set. This value will be calculated by the Arduino Mega 2560 microcontroller and converted to the distance traveled by the robot. So that with the PID controller, the navigation of the robot will match what the user wants.

Robot Navigation System Design
The design of the robot uses a square frame on each motor with a previously calculated angle of 45ᵒ. It can be seen in Fig. 5  between the motor and the other according to the kinematic theory of robot motion. The robot uses the Omni wheel to navigate in all directions (holonomic).
This basic frame is designed so that the placement of the motor and the driving wheel can be symmetrical with each other so as to form a degree value of 45ᵒ between the wheels. This is based on the calculation of the formula given to the system so that it is in accordance with the actual situation.

Electrical Control Unit Robot
It was making an ECU (Electrical Control Unit) which aims to make it simple so that a robot can be programmed easily. ECU (Electronic Central Unit) is the control center of the robot in making ECU (Electronic Central Unit) using eagle software. This ECU (Electronic Central Unit) system will, of course, receive signals from the input pins that have been connected to sensors on the robot, such as ultrasonic sensors, proximity sensors, and push buttons that have been made in this system. Fig. 6 is the design of a mini robot system used as an ECU (Electrical Control Unit) based on the Arduino Mega 2560 platform. In this series, the digital PINs used for ultrasonic sensor input are 22, 24, 26, 28, 30, 32, 34, and 36 on the Arduino Mega 2560 are used as input from the ultrasonic sensors used by the robot to navigate, namely the wall following. The digital PIN is used because it is a pin that provides the interrupt facility provided by the Arduino Mega 2560 platform. In addition to the interrupt pin on the digital pin, it also provides I2C (Inter-Integrated Circuit) facilities as a two-way serial communication module that functions to send and receive data. Both are SCL (Serial Clock) and SDA (Serial Data). These two PINs certainly save a lot on the use of PINs on the Arduino Mega 2560 when compared to using LCDs without I2C.
In Fig. 6, the digital PIN 20, 21, GND, and 5 Volt are used as the 20x4 LCD output to display the characters that have been previously processed by the microcontroller. Then the digital PIN numbers 4, 7, 10, 13, 23 are used as the output PIN of the DC forward motor and the digital PIN 3, 6, 9, 12, 25 as the output pin of the backward DC motor. The PWM (Pulse Width Modulation) facility found on the Arduino Mega 2560 is integrated at pins 2, 5, 8, 11, 27, which functions to activate the 30A H-bridge Embedded Module Series (EMS) Driver, which is used to control the direction of rotation and speed of the DC motor.

Flowchart Robot
The reading of the robot program that uses the Arduino IDE software using the C language aims to make programming easier because there is a library that is already available. In Fig. 7, there is an order to read the distance value from the ultrasonic sensor. This reading of the value aims to get a reading of the actual distance value with a predetermined setpoint value. Then the error generated by the ultrasonic sensor will then be processed by the PID contained in the program. Ultrasonic sensors are used as wall-following systems in robots.  The program code in Fig. 7 is used to set the ultrasonic sensor distance point that has been determined, as well as to read the actual distance value from the sensor to the object, namely the wall. The program is used as a wall following system from the reading of the distance value from the ultrasonic sensor when the ultrasonic sensor detects an object, namely a wall.
In the flowchart in Fig. 8, before the program is executed, there is a command to read the distance value from the ultrasonic sensor to get the error value generated by the ultrasonic sensor, then it will be processed by the PID contained in the program. The PID program applied to the robot is used as the output value of the motor, namely PWM.

Robot PID Control Program
Based on the flow chart in Fig. 8, the program will initialize it for the first time. Then, after the program initializes, the program will read the distance value on the ultrasonic sensor. Then the next step is to enter the setpoint value on the ultrasonic sensor. After knowing the process of calculating the distance according to the setpoint, an error is obtained so that the error value is entered into the formula of the basic theory of the programming language. The PID control program is embedded in the microcontroller for motor motion which will be called when the program is run. In this program, it is expected that the robot can move as desired. The PID Control Program can be seen in Fig. 9  In Fig. 9, the PID control program can be seen that the variables used in the PID control are built from KP, KI, and KD variables [14]. Each variable has an important role in creating stability in the movement of the robot so that the wall following system can be built. The values for KP, KI, and KD were determined manually by trial and error method to obtain stable results.

Result and Discussion
In the test carried out, it aims to determine the results of the reading of the distance value from the ultrasonic sensor as a wall following system, which then the error from the ultrasonic sensor reading will be processed with the PID, which is forwarded to the PG36 DC motor using Arduino Mega as a microcontroller from an automatic robot.

Ultrasonic Sensor Testing
Tests carried out on ultrasonic sensors aim to test the accuracy of the resulting distance value readings based on the reflection of ultrasonic waves against walls or objects. The setpoints that have been entered into the program are 40cm. The output results from the reading of the value on the sensor are shown in Fig. 10. Based on Fig. 10, outputs 44 and 45 are the reading of the distance value from the ultrasonic sensor to the wall or object. This ultrasonic sensor test is done by reading the number of pulse signals whose results can be seen on the LCD on the robot. The installed ultrasonic sensor displays the reading in cm (centimeter) located at the bottom of the robot frame. In reading the value of the ultrasonic sensor distance, the ultrasonic sensor will obtain distance data so that the distance will be converted into an appropriate pulse signal. The reading of the distance value on the ultrasonic sensor is forwarded to the PWM motor as the PID wall following value on the robot.

Ultrasonic Sensor Reading Testing
The test results with a set point reading distance value on the ultrasonic sensor, namely 40 cm with a PWM value set at 100, 150, 200, and 250, obtained results that can be seen in Table  1. Ultrasonic sensor testing is carried out in Table 1 by reading the number of pulse signals generated with an average reading of 41.5 cm with a reading of the ultrasonic sensor distance value. The ultrasonic sensor will obtain distance data so that the distance will be converted into an appropriate pulse signal. The reading of the distance value on the ultrasonic sensor is forwarded to the PWM motor as the PID wall following value on the robot. The ultrasonic sensor reading with a set point of 40 cm when less than 40 cm the robot will adjust and vice versa when the distance reading from the ultrasonic sensor is more than 40, the PID wall following program on the robot will adjust so that the robot remains at the 40 cm set point reading distance.

PID Controller Testing
Testing with the trial and error method on the motor PID control aims to obtain the constant values of KP, KI, and KD used for PID control in order to have a fast rise time and also low oscillations. The effect of PID control on motor rotation speed is also observed. With good PID control, it is hoped that the motor can maintain the motor rotation speed without being affected by the load and battery condition so that it is more adaptive to all conditions. In this test, each motor is given PID control in order to maintain the motor rotational speed within the predetermined PWM. Robot testing that has been applied to PID control. In this test, the robot is instructed to move straight on a path bounded by the wall according to predetermined rules. This aims to determine the accuracy of the wall following the system. Robot motion testing uses a wide variety of variations in velocity and PID values, KP for Proportional (P), KI for Integral (I), KD for Derivatives (D). Fig. 11 is a robot test with a wall following system and PID control.

PID tuning constant testing KP = 5, KI = 0 and KD = 3 with PWM 150
In this test using the manual trial and error method, the proportional constant value is set with a value of 5, an integral constant value with a value of 0, and a derivative constant with a value of 3. The results of the PID control applied to the motor can be seen in Table 2, which is the result of PID control on each motor with a given PWM value is 150 PWM.
In Table 2, the average error generated when reading the distance value from the ultrasonic sensor is 44.3 cm. The analysis of the ultrasonic sensor testing on the robot shows that the sensor readings in a straight line and the actual reference value reading for the robot have an error value that is not too large, so it can be concluded that the ultrasonic sensor is working well. These errors have no effect on the performance of the system that is designed because of the system. Fig. 12 is a graphical form of the PID control given in this test.

PID tuning constant testing KP = 5, KI = 0 and KD = 3 with PWM 200
In this test using the manual trial and error method, the proportional constant value is set with the value 5, the integral constant value with a value of 0, and the derivative constant with a value of 3. The results of the PID control applied to the motor can be seen in Table 3, which is the result of PID control of each motor with a given PWM value is 200 PWM.
In Table 3, the average error generated when reading the distance value from the ultrasonic sensor is 39.6 cm. The analysis of the ultrasonic sensor testing on the robot shows that the sensor readings in a straight line and the actual reference value reading for the robot have an error value that is not too large, so it can be concluded that the ultrasonic sensor is working well. These errors have no effect on the performance of the system that is designed because of the system. Fig. 13 is a graphical form of the PID control given in this test.

PID tuning constant testing KP = 5, KI = 0 and KD = 3 with PWM 250
In this test using the manual trial and error method, the proportional constant value is set with a value of 5, an integral constant value with a value of 0, and a derivative constant with a value of 3. The results of the PID control applied to the motor can be seen in Table 4, which is the result of PID control of each motor with a given PWM value is 250 PWM.
In Table 4, the average error generated when reading the distance value from the ultrasonic sensor is 39.1 cm. The analysis of the ultrasonic sensor testing on the robot shows that the sensor readings in a straight line and the actual reference value reading for the robot have an error value that is not too large, so it can be concluded that the ultrasonic sensor is working well. These errors have no effect on the performance of the system that is designed because of the system. Fig. 14 is a graphical form of the PID control given in this test.

Conclusion
The results of ultrasonic sensor testing on the robot show that the wall following system will continue to oscillate because the distance reading is always changing. On each motor that has been entered, the PID control shows different rotational speeds but not too big. Whereas in the testing process, the reading of the distance value by the ultrasonic sensor shows that the ultrasonic sensor has an error value that is not too large, so it can be concluded that the ultrasonic sensor is working well. At the PWM 150 set point, the value of the ultrasonic sensor distance reading to the object in the form of a wall with an average error of 4.4 cm. At the PWM 200 set point, the value of the ultrasonic sensor distance reading to the object in the form of a wall with an average error of 0.4 cm. At the PWM 250 set point, the value of the ultrasonic sensor distance reading to an object in the form of a wall with an average error of 0.8 cm. This error does not have an effect on the performance of the wall following system because the system Error PID PWM only uses the distance value reading data with a decimal point in front of the comma. So it can be concluded that the wall following system designed using ultrasonic sensors with measurement error that occurs is zero. The tuning results of the trial and error method as the application of the PID controller in the wall following system obtained the values of KP = 5, KI = 0, and KD = 3. The wall-following robot has been able to make the robot's movement stable and able to make the robot maneuver smoothly, responsively, and quickly.