Skip to main content
Version: ACS CC

Two-Wheeled Self-Balancing Robot

info

Author: Calmac Stefan
GitHub Project Link: link_to_project

Description

The system maintains an upright position on two wheels by continuously adjusting the speed of the motor. It receives data on the angle of inclination and angular velocity from an inertial measurement unit as inputs. A microcontroller processes this data using a PID control algorithm to calculate the necessary corrective forces. The output consists of PWM signals sent to the motor drivers, which actuate the wheels to move forward or backward, counteracting the inclination and keeping the system balanced in real time. The robot will also be controllable from a phone.

Motivation

I’ve been itching to bridge the gap between my software-heavy coursework and hands-on hardware, and a self-balancing robot is the perfect "final boss" to start with. It’s a great way to finally dive into Control Systems and PID algorithms, moving beyond theory to see my code actually fight gravity in real time. Plus, adding smartphone control gives it that extra bit of polish and functionality that makes the whole engineering challenge even more rewarding.

Architecture

Diagram

Log

Week 20 - 24 April

Made initial documentation and ordered hardware parts.

Week 27 - 30 April

Tested all components

Week 4 - 8 April

Assembled first prototype

Week 11 - 15 April

Implemented basic control loop and tested balancing.

Week 18 - 22 April

Added smartphone control and refined LQR parameters.

Hardware

  • Microcontroller: The central logic unit (likely an Arduino, ESP32, or similar) that processes sensor data and controls the motor drivers.

  • MPU6050 IMU: A 6-axis motion tracking device combining a 3-axis gyroscope and a 3-axis accelerometer to measure orientation and acceleration.

  • 42BYGHW609 Stepper Motors (x2): High-torque NEMA 17 stepper motors used for precise positioning or movement.

  • Motor Drivers: (Inferred) Interfaces like the A4988 or DRV8825 used to translate logic signals from the microcontroller into high-current power for the stepper motors.

  • Power Supply: A dedicated DC source (such as a LiPo battery or 12V adapter) to provide sufficient current for the motors and logic circuits.

Schematics

Schematic

Bill of Materials

DeviceUsagePrice
STM32Microcontroller129 RON
MPU6050IMU (Gyroscope + Accelerometer)14.68 RON
HC-06Bluetooth Module30.40 RON
7805CVVoltage Regulator2.29 RON
2 X DRV8825Stepper Motor Driver14.49 RON
2 X 42BYGHW609Stepper Motor2 x 55 RON
HubsCoupling Hubs12 RON
3 X 18650Battery44 RON
WheelsMoving34 RON
2sc3399Transistor2.50 RON
Capacitor 1000uF/16VFiltering0.59 RON
Capacitor 1000uF/25VFiltering0.59 RON
Capacitor 470uF/25VFiltering0.49 RON

Software

LibraryDescriptionUsage
embassy-stm32Hardware InterfaceBase library for project.
defmtCompact logging frameworkDebug and runtime status messages.
defmt-rttReal-Time TransferLogging backend.
panic-probePanic handler for embedded RustReports useful diagnostic information
embassy-executorAsync task executor used by the Embassy embedded framework.Structure async tasks.
embassy-futuresProvides async utilities for embedded systemsjoin4 runs four async operations concurrently and waits for all of them.
embassy-timeProvides timing primitives for Embassy-based embedded firmware.Used where a blocking-style delay object is required by a driver, especially sensor initialization.
embedded-halDefines generic traits for embedded hardware interfaces.Used the PWM trait abstraction for controlling PWM behavior generically.
mpu6050-dmpRust driver crate for the MPU6050 IMU.Used to: initialize the MPU6050,configure accelerometer range, configure gyroscope range, read motion data.
  1. https://www.youtube.com/watch?v=I6z26LVu5y0
  2. https://zenn.dev/tana_ash
  3. https://github.com/tana/balance-robot2