Nathan Law
In progressPersonalJan 2025 – Present

Two-Wheeled Self-Balancing Robot

TODO: 1-2 sentence summary — what it is and the headline result (e.g. recovery angle, balance time).

My role

Designed, built, and programmed solo.

Two-Wheeled Self-Balancing Robot

Problem

TODO: why build a self-balancing robot — what were you trying to learn or prove?

Constraints

TODO: budget, parts availability, what you deliberately kept simple in Rev 1.

Design & Decisions

TODO: overall concept and the big design decisions (sensing, actuation, control approach) — the revisions below cover how this evolved.

Build

TODO: mechanical build, electronics, firmware/software stack. List the tools and skills used, e.g. CAD, embedded C/C++, PID control, PCB design.

Testing & Results

TODO: how you tested it, and the quantified results (e.g. recovery angle, time to settle, disturbance rejection).

What I’d Do Differently

TODO: honest retrospective, or what’s planned for the next revision.

Revisions

Spec comparison

SpecRev 1 — First balance, bang-bang controlRev 2 — Switch to PID controlRev 3 — Faster controller, sensor fusionRev 4 — BLDC motors, cascaded PIDRev 5 — LQR control on ESP32
Motors28BYJ-48 stepper (x2)NEMA17 stepper (x2)NEMA17 stepper (x2)BLDC gimbal motor (x2)BLDC gimbal motor (x2)
ControllerArduino UnoArduino UnoSTM32F4 NucleoSTM32F4 NucleoESP32
ImuMPU6050MPU6050MPU9250MPU9250BNO055
Battery4x AA2S LiPo, 7.4 V2S LiPo, 7.4 V3S LiPo, 11.1 V3S LiPo, 11.1 V
Control MethodBang-bangPIDPID + complementary filterCascaded PIDLQR
Mass650 g720 g740 g810 g790 g
Balance Performance~10 s before falling~45 s before fallingStable indefinitely on flat groundRecovers from small pushesRecovers from pushes up to ~15°, holds station-keeping

Timeline

  1. Rev 5 — LQR control on ESP32

    Jun 2026

    Why: Wanted better disturbance rejection and to remove manual PID retuning between tests.

    Changes

    • Moved to an ESP32 for onboard wireless telemetry/tuning
    • Switched from cascaded PID to an LQR controller
    • Upgraded IMU to a BNO055 with onboard sensor fusion

    Outcome: Recovers from pushes up to roughly 15 degrees and holds station-keeping on a flat floor.

    TODO: optional longer notes for this revision.

  2. Rev 4 — BLDC motors, cascaded PID

    Feb 2026

    Why: Steppers couldn't react fast enough to reject larger disturbances like pushes.

    Changes

    • Replaced steppers with BLDC gimbal motors for smoother, higher-bandwidth control
    • Restructured control as a cascaded PID (velocity loop inside the angle loop)
    • Upgraded to a 3S LiPo pack for the higher-current motors

    Outcome: Robot now recovers from small pushes instead of just holding still on flat ground.

    TODO: optional longer notes for this revision.

  3. Rev 3 — Faster controller, sensor fusion

    Oct 2025

    Why: The Arduino's control loop rate was limiting how aggressive the PID gains could be.

    Changes

    • Moved from Arduino Uno to an STM32F4 Nucleo for a faster control loop
    • Upgraded IMU and added a complementary filter for sensor fusion

    Outcome: Achieved indefinite stable balance on flat ground, with noticeably less drift.

    TODO: optional longer notes for this revision.

  4. Rev 2 — Switch to PID control

    Jun 2025

    Why: Bang-bang control was too jerky to hold a stable balance point; needed proportional control.

    Changes

    • Upgraded to NEMA17 steppers for more torque
    • Replaced bang-bang control with a tuned PID loop
    • Moved from AA batteries to a 2S LiPo pack

    Outcome: Balance time improved to roughly 45 seconds before falling, with much smoother motion.

    TODO: optional longer notes for this revision.

  5. Rev 1 — First balance, bang-bang control

    Feb 2025

    Why: Prove the chassis and sensing concept would work before investing in a proper controller.

    Changes

    • First working chassis and two-wheel drivetrain
    • Basic bang-bang balance control to prove the concept

    Outcome: Balanced for roughly 10 seconds before falling; confirmed the IMU placement and wheel base were workable.

    TODO: optional longer notes for this revision.