A real-time self-balancing two-wheeled robot powered by an STM32 microcontroller. The robot actively corrects its tilt using feedback from inertial sensors and a cascaded PID controller, restoring its upright posture within milliseconds of disturbance.
- Microcontroller: STM32 DISCO Board
- Sensors:
- On-board IMU (gyroscope + accelerometer)
- External ADXL345 accelerometer (for redundancy/testing)
- Actuators:
- Two DC motors (differential drive)
- Motor Drivers: H-Bridge motor driver (not shown in schematic)
The robot uses a cascaded PID controller implemented in C++ with Mbed RTOS:
- Angle Estimation:
Sensor fusion combines gyroscope and accelerometer data to compute pitch angle via complementary filtering. - Inner Loop:
A fast-acting PID controller adjusts motor torque to correct tilt angle in real time.
- Stabilizes from ±15° tilt in < 100 ms
- Maintains balance on flat and mildly uneven surfaces
- Real-time operation under Mbed RTOS on bare-metal STM32
