Self-Balancing Bot

A two-wheeled self-balancing robot developed as my EL5214 Embedded Control Systems course final project. The robot balances itself upright and can be controlled using a joystick.

Role: Everything
Keywords: Embedded, Robotics, Control

  • Programming Languages: C
  • Tools and Frameworks: Arduino
  • Algorithms: PID Controller, Complementary Filter, Finite State Machine
  • Hardwares: Arduino Nano, MPU9250 IMU, Brushed DC Motors

The two-wheeled self-balancing robot.

The Self-Balancing Bot was built as my EL5214 Embedded Control Systems course final project during my master’s study in 2021. This robot is designed to balance itself upright robustly even in the presence of disturbances. The robot receives motion commands through a wired joystick.

The robot's main electric circuitry which consists of an Arduino Nano, an MPU9250 IMU, and an L298N motor driver.

The robot uses an Arduino Nano as its main computing unit and an MPU9250 IMU as its orientation sensor. The robot is actuated by a pair of JGA25 brushed DC motors controlled by an L298N motor driver. The gyroscope and accelerometer sensor readings from the IMU are fed into a complementary filter to estimate the robot’s orientation.

The Arduino is running a PID controller to regulate the robot’s orientation. A finite state machine (FSM) is used to process joystick inputs into orientation setpoints to be tracked by the PID controller. The PID controller uses the output of the complementary filter as orientation feedback. The controller outputs PWM duty cycles to be given to the motor driver. The dead zone of the motors is compensated by setting the lower bounds of the PWM duty cycles to a tunable value higher than zero.

Below are some GIFs showing the robot balancing itself. Even in the presence of disturbances, the robot is able to keep itself upright.

The robot balances itself even in the presence of disturbances.

The robot can also follow motion commands given through the wired joystick as shown in the following GIFs.

The robot balances itself while following motion commands given through the joystick.