Self Balancing Robot Using Arduino

by ERL Engineering in Circuits > Electronics

658 Views, 3 Favorites, 0 Comments

Self Balancing Robot Using Arduino

Arduino project | Self balancing robot | MPU6050 | Boost Converter | Motor Driver

Welcome, everyone!

Today, I'm thrilled to guide you through the exciting process of constructing your very own self-balancing robot, capable of navigating its surroundings with agility while dodging obstacles along the way. This compact marvel is centered around the Arduino NANO development board and the MPU6050 accelerometer-gyroscope module.

Throughout this tutorial, we'll delve into integrating the MPU6050 with Arduino, deciphering the robot's inclination angle, and harnessing the power of PID (Proportional-Integral-Derivative) control to maintain impeccable balance. Additionally, we'll incorporate an ultrasonic rangefinder into our robot, ensuring it gracefully sidesteps any obstacles encountered during its explorations.

Supplies

Arduino Nano

GY-521 module featuring the MPU-6050

Motor driver

Two boost converters

US-020 ultrasonic distance sensor

18650 battery with holder

A pair of micro metal gear motors (N20, 6V, 200 rpm) with brackets

Two 42x19mm wheels

Three prototype PCBs

PCB spacers

Understanding the Basics

Before we dive into the assembly process, let's grasp some fundamental concepts. Picture a self-balancing robot as an upside-down pendulum. Unlike a traditional pendulum that naturally swings back and forth, our inverted pendulum struggles to maintain balance independently—it's prone to tipping over. So, how do we keep it upright? Imagine balancing a broomstick on your fingertip—a classic analogy for stabilizing an inverted pendulum. Just as we adjust our finger's position to counter the stick's lean, we'll manipulate the robot's wheel movements to counter its impending fall. The goal is simple: keep the robot's center of gravity precisely above its pivot point.


To accomplish this feat, we need vital information about the robot's state: its direction of tilt, degree of inclination, and falling velocity. These insights are gleaned from the MPU6050 readings. By synthesizing these inputs, we generate a control signal that regulates the motors, ensuring the robot maintains its equilibrium.

Assembly and Calibration

01.png
02.png
03.png
04.png
05.png
06.png

Follow the assembly instructions outlined in the accompanying video, and don't forget to calibrate the MPU6050 on a level surface as demonstrated.


Fine-Tuning PID Constants


Once assembled, it's time to fine-tune the PID constants for optimal performance:


Start by setting Ki and Kd to zero, gradually increasing Kp until the robot exhibits slight oscillations around the zero position.


Increment Ki to enhance the robot's response to imbalance, ensuring it swiftly corrects deviations from the upright position without exacerbating tilt.


Introduce Kd to dampen oscillations and minimize overshoot.


Iterate through these steps, meticulously adjusting each parameter until you achieve the desired outcome: a self-balancing robot that navigates with poise and precision.