Self Balancing Robot is device that can balance itself from falling to the ground. Its function is to maintain balance using the motor’s axis movement of the wheels and body. There are several types of self-balancing robots, and in this particular case I will present you a way to make a Two-Wheeled Balancing Robot. Actually, I made this robot together with one of my students and it is a high school graduation project. This is the simplest type of balancing robot and only requires a few components to build.
First, let's explain the components used and their functions.
This project is sponsored by PCBWay. They has all the services you need to create your project at the best price, whether is a scool project, or complex professional project. On PCBWay you can share your experiences, or get inspiration for your next project. They also provide completed Surface mount SMT PCB assemblY service at a best price, and ISO9001 quality control. Visit pcbway.com for more services.
Now, let's briefly explain the working principle: The accelerometer gives a measure of the robot’s orientation relative to gravity, and the gyroscope detects the rate of tilt. The Arduino uses a PID (Proportional, Integral, Derivative) controller to process the data from the sensors.
The PID controller calculates the necessary speed and direction adjustments needed to maintain the robot’s balance. If the robot tilts forward, the motors spin faster to move the robot forward and prevent a fall. If it tilts backward, the motors move the robot backward to regain balance. As the robot detects an imbalance, it compensates by adjusting the wheel speed, shifting its center of mass, or moving forward or backward to maintain its position.
A few words about the Arduino code. The method of installing the code has been described many times before, so now I will only focus on the modifications that need to be made individually for each case due to the different characteristics of the components used, as well as the method of their placement.
Now comes the fun part, which is customizing the code specifically for our built device. Depending on the layout of the components, the center of gravity of the robot changes, and also each MPU6050 board has minimal differences that need to be compensated for in part of the code. If we look at the code in more detail, we will see that there is a place where the Gyro offset is set.
In this part of the code, errors are corrected during the manufacturing of the MPU6050 chip. For each individual chip, these values are different. Their value is determined using Arduino code made specifically for this purpose and you can download it at the end of this text.
Next, we need to move on to setting the Accelerometer. In the "double setpoint' line, we need to put a value that corresponds to our device.
To obtain this value, we need to hold the robot in an ideal vertical position, perpendicular to the surface, and read the required value on the serial monitor. In my case, it is about 182.
Finally, we need to experimentally determine the values of Kp, Kd, and Ki, needed for PID control.
For this purpose we set all three values to zero. Now we put some value for Kp and perform testing. Too little Kp will make robot fall over. Too much Kp will make the robot go back and forth wildly. A good Kp will make the robot go slightly back and forth. Next we need to set Kd. A gooD Kd value will lessen the oscilation until the robot is almost steady, and will keep the robot standing. Lastly set the Ki. The correct Ki value will shorten the time it takes for the robot to stabilize. I want to emphasize that the surface needs to be rough enough to increase the friction between it and the wheels.
And finally a short conclusion. This is a relatively simple, visually effective balancing robot project that only requires 3 components to make. However, its setup, although it can be time-consuming, is still a lot of fun trying to get the robot to stand steadily on its "own feet". Just to mention that we created this project together with my students as a final high school exam.
Comments
Please log in or sign up to comment.