Self-Balancing Robot

A two-wheel robot uses continuous feedback to stay upright like an inverted pendulum.

← All project briefs

Safety and scope

Use a physical catch frame or tether during early tuning. Ensure the emergency stop is accessible and the battery is secured.

Plan, predict and test

Suggested virtual study time: about 45 minutes. This is a planning estimate, not a validated construction time.

Preparation: Foundation electronics, embedded programming and subsystem testing. Review a foundation lesson ↗

Use paper, a spreadsheet or a simulator. This is not a verified physical assembly guide.

  1. Scenario: Use a target angle of 0° and measured tilt of +5°. Compute error = target − measurement.
  2. Expected result: Error is −5°. Repeat with opposite tilt before exploring the virtual PID tool.
  3. Checkpoint: Write your prediction, test it in the virtual model and explain any difference.

Knowledge check

Can generic PID gains be transferred directly to hardware?

A correct answer does not certify the physical system.

Record your validation

Use only virtual inputs and indicators until the actual components, pinouts and electrical limits have been verified.

CaseWhat to record
Normal inputTarget 0°, measured +5° → error −5°
BoundaryMeasured −5° → +5°; measured 0° → 0°
Missing or invalid inputInvalid angle → stop simulated control; stability requires plant testing.
Repeat testRepeat the virtual test, record the actual output and compare with the expected result.

These are test-planning requirements, not recorded hardware results.

Before building: understand the listed components and the relevant low-voltage safety rules. This is a concept brief, not a tested assembly manual.

What it does

Study sensor fusion, control-loop timing, PID tuning and the mechanical balance of an unstable system.

Engineering principle

The MPU6050 provides accelerometer and gyroscope data. Sensor fusion estimates the tilt angle and angular velocity. The controller compares tilt with the upright setpoint and feeds the error to a PID controller. Its output drives the wheels toward the direction of the fall so the chassis can recover.

Hardware and components

  • Arduino Uno or NanoRuns the real-time balance loop.
  • MPU6050 IMUMeasures tilt-related acceleration and angular velocity.
  • TB6612FNG or suitable motor driverDrives both motors; driver selection must match motor current.
  • 2 × DC gear motors with wheelsMove the wheel contact points under the centre of mass.
  • Battery pack and chassisProvide portable power and a mechanically appropriate centre of gravity.

Suggested build sequence

  1. Build the chassis with the battery and board firmly secured.
  2. Calibrate IMU offsets and validate raw readings while stationary.
  3. Estimate tilt using a complementary filter or another suitable sensor-fusion method.
  4. Run the control loop at a consistent interval and implement a PID controller.
  5. Tune proportional, integral and derivative gains gradually with a safe catch/kill method.

Learning outcomes

  • Inverted-pendulum dynamics
  • IMU calibration and sensor fusion
  • PID feedback control
  • Real-time loop tuning

Possible upgrades

Add encoder feedback, Bluetooth tuning, telemetry plots or a motion-command state machine.

Related briefs