My first balancing robot using SimpleFOC

:robot: My First Self-Balancing Robot

:movie_camera: Demo video (YouTube Shorts):


:hammer_and_wrench: Hardware Setup

  • 1 × Makerbase ESP32 FOC v2.0
  • 2 × AS5600 magnetic encoders (I2C)
  • 1 × BMI160 IMU (I2C)
  • 2 × Mitoot gimbal motors 2804 – 100KV
  • 3 × 18650 Li-ion batteries

:gear: Control Architecture

This robot uses a dual-loop PID control system:

  • Pitch Angle PID

    • Keeps the robot balanced (inverted pendulum control)
    • Uses pitch data from the BMI160 IMU
  • Velocity PID

    • Controls forward/backward movement
    • Uses motor velocity feedback from AS5600 encoders

The output of the pitch PID feeds into the velocity loop, allowing smooth and stable balancing while responding to movement commands.

4 Likes

good strategy. For a balanced robot, dual-loop PID on SimpleFOC is the ideal solution.

Simply ensure that the pitch of your BMI160 is appropriately filtered; noisy angle data will ruin the pitch PID. If AS5600 + BMI160 share the bus, check your I2C speed (400kHz helps) and maintain the pitch loop quicker than the velocity loop.

Additionally, make sure your FOC voltage and current restrictions are met. 2804 100KV gimbals on three 18650s may quickly saturate and seem unstable when they are just reaching their limits.