Skip to main content
Version: ACS CC

Self-Balancing Cube

A self-balancing cube controlled by an STM32 microcontroller, using IMU feedback and internal reaction wheels to balance on an edge or corner.

info

Author: Ana-Maria-Raluca Lupu
GitHub Project Link: acs-project-2026-lupuana

Description

This project implements a self-balancing cube based on reaction-wheel control. The system reads motion and orientation data from an IMU sensor, estimates the cube state, and computes corrective motor commands in real time. Three internal motors spin reaction wheels to generate stabilizing torques, allowing the cube to recover balance and remain upright on an edge or corner.

Motivation

I chose this project because it combines embedded programming, control systems, electronics, mechanical design, and real-time testing in a single system. It is a good practical challenge because it requires both hardware integration and software development, especially sensor processing, feedback control, and actuator coordination on an STM32 platform.

Architecture

The main architecture components of the project are:

  • Sensing layer
    Reads acceleration and angular velocity data from the MPU6050 IMU and, in the final system, wheel-speed feedback from the motor encoder signals.

  • State estimation layer
    Processes raw sensor data and computes the current orientation and angular motion of the cube.

  • Control layer
    Runs the balancing algorithm and computes correction commands for each reaction-wheel axis.

  • Actuation layer
    Sends PWM and direction control signals to the three Nidec reaction-wheel motors.

  • Communication and tuning layer
    Supports calibration and parameter adjustment, initially through USB/debug output during development and later through a Bluetooth serial connection using the HC-05 module.

Architecture Diagram

Log

Week 14 - 29 April

  • Finalized the project theme and received approval.
  • Researched the reference project, selected the main components, and placed the orders.

Week 4 - 10 May

  • Received the ordered components.
  • Reviewed the hardware setup.

Week 11 - 17 May

  • Set up the Rust embedded project.
  • Verified firmware flashing and debugging on the STM32 board.
  • Tested one Nidec motor in both rotation directions using PWM and direction control.
  • Tested the MPU6050 IMU over I2C and verified gyroscope and accelerometer readings.
  • Implemented initial tilt estimation tests using roll and pitch angles.
  • Started integrating IMU input with motor response.

Week 18 - 24 May

  • Continue hardware integration of sensing and actuation.
  • Investigate encoder feedback from the motors.
  • Refine motor control behavior for smoother directional changes.
  • Continue toward full cube assembly, calibration, and balancing experiments.

Hardware

The hardware platform is built around an STM32 microcontroller, an MPU6050 IMU for motion sensing, and three Nidec brushless motors used as reaction wheels. The motors include feedback lines that are intended to be used for wheel-speed sensing during control. A Bluetooth module is planned for calibration and parameter tuning, while a buzzer will provide status feedback.

Schematics

Schematics

Bill of Materials

DeviceUsagePriceLink
Dupont wire kitPrototyping and signal wiring24.39 RONAliExpress
2x MPU6050 GY-521IMU sensing48.84 RONAliExpress
3x Nidec 24H brushless servo motorsReaction-wheel actuation138.57 RONAliExpress
HC-05 Bluetooth moduleWireless tuning and calibration24.35 RONAliExpress
3S LiPo 11.1V 500mAh batteryMain power source85.33 RONAliExpress
Active 5V buzzerAudio feedback / status signal15.72 RONAliExpress
LM7805 5V regulator moduleLogic power regulation16.72 RONAliExpress
3S LiPo balance chargerBattery charging28.24 RONAliExpress
ON/OFF switchMain power control21.29 RONAliExpress

Software

LibraryDescriptionUsage
embassy-stm32STM32 hardware abstraction layer for the Embassy ecosystemUsed for GPIO control, I2C communication with the MPU6050, UART/Bluetooth communication, timers, PWM generation, and encoder input handling
embassy-executorAsync task executor for embedded systemsRuns the main firmware tasks and coordinates sensing, control, communication, and actuation logic
embassy-timeTiming and delay utilitiesUsed for periodic sensor sampling, control-loop timing, calibration delays, and scheduled motor updates
libmMathematical functions for no_std environmentsUsed for trigonometric and square-root operations in orientation estimation and tilt-angle computation
defmtLightweight embedded logging frameworkUsed for runtime diagnostics, sensor debugging, motor-control validation, and calibration feedback
defmt-rttRTT transport backend for defmt logsSends debug messages from the STM32 board to the development PC through the ST-LINK interface
panic-probePanic handler for embedded Rust applicationsProvides useful crash information during firmware debugging
cortex-mLow-level ARM Cortex-M support crateProvides architecture-specific utilities and interrupt-safe embedded primitives
cortex-m-rtRuntime support for Cortex-M microcontrollersDefines startup behavior and memory initialization for the STM32 firmware