user-img

Mirko Pavleski

+ Follow

Arduino two weel self Balancing Robot

This is a relatively simple, visually effective balancing robot project that only requires four components to make.

Arduino two weel self Balancing Robot
 
  • thumbnail-img
 

Hardware Components

  • Arduino UNO R3

    X 1
  • MPU6050 Accelerometer module

    X 1
  • Motor driver L298N 5AD type

    X 1
  • DC Motors

    X 1
  • Wheels

    X 1
  • Rechargeable Battery, Lithium Ion

    X 1

Tools, APP Software Used etc.

  • soldering kit

  • Arduino IDE

    Arduino IDE

    Arduino

Story

 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. 

Detailed video description at: https://youtu.be/aVi6dJwe6Y0

   First, let's explain the components used and their functions.

  - MPU6050 Accelerometer and Gyroscope sensor with Micro Electro Mechanical System(MEMS) technology, which is used to detect angle of tilt or inclination along the X, Y and Z axes.

  - The information from this sensor is transmitted to a microcontroller, and in our case it is an Arduino Uno board. This board is the brain of the robot, processes the sensor data and determines the actions needed to keep the robot upright.

  - Processed  data from the Arduino is sent to the motor driver board, which in our case is the  L298N 5AD type.  A motor driver circuit controls the direction and speed of the motors.

  - This robot uses two DC motors, each connected to a wheel. These motors adjust the speed of the wheels to correct the robot’s tilt.

  - and power source, specifically two Lithium batteries connected in series wich provides energy to the motors and electronics. All components are mounted on a suitable supporting structure made of 5mm thick PVC board.

  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.

 

Code
  • Code

    Code_Working_63192683367c9b3dcb490c.zip
    Download(0)
  • Set Gyro offset

    Code_Set_Gyro_Offset_48020803867c9b3fe262bc.zip
    Download(0)
Schematic and Layout

Arduino two weel self Balancing Robot

This is a relatively simple, visually effective balancing robot project that only requires four components to make.

15
 
1
0
0

Share your project on social media to expand its influence! Get more people to support it.

  • Comments( 0 )
  • Like( 1 )
/1000
Upload a photo:
You can only upload 1 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP

You May Also Like

View All
Add to cart
Board Type : GerberFile :
Layer : Dimensions :
PCB Qty :
Different PCB Design
PCB Thickness : PCB Color :
Surface Finish : Castellated Hole :
Copper Weight : 1 oz Production Time :
Total: US $
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.

PCB Assembly

PCBA Qty: BomFile:
NO. OF UNIQUE PARTS: NO. of Components:
Assembly Cost: US $
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
3dPrintingFile : Size :
Unit : Volumn :
3D Printing Qty : Material :
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
Acrylic Type : AcrylicFile :
Dimensions: Engrave:
Acrylic Qty :
Acrylic Thickness:
Acrylic Color:
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
CNC Milling File : Size:
Unit: Volumn:
CNC Milling Qty : Material:
Type of Aluminum: Surface Finish:
Tolerance:
Surface Roughness:
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
Item Price Qty Subtotal Delete
Total: US $0.00
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.