Discuss general guidelines for self-balancing robots

I'd like to start a discussion to collect general knowledge of what to do and what not to do when building a two-wheeled self-balancing robot (SBR for short).  My hope is that this thread can become a somewhat comprehensive set of guidelines to help beginners and non-beginners build their first balancing robot or  achieve a more stable and successful subsequent design.  Things that I would like to understand include:

  1. What are the effects of wheel diameter?
  2. What are the effects of overall structural height?
  3. What are the effects of IMU placement (has a gyro and acceleromter)?
  4. Does using encoder feedback on the motors greatly reduce the time it takes to adjust PID parameters to get a succussfully balancing robot?
  5. Backlash (meaning there is slop in the gearing of the motors) can be detrimental, does anyone know of a good gearmotor available with encoders that does not exibit much backlash?
  6. Does a motor driver with braking give a balancing robot additional potential? (assume the braking or shorting of an H-bridge can be pulse-width modulated)

I'd also like your input to contrast the pros and cons of various techniques... easy vs. difficult to program, easy vs. difficult to get to balance once everything is mostly done, most stable vs. least stable, cheap vs. expensive, etc.

In the end it would be nice to determine how to implement the most basic SBR (inertial) and how to make the most robust SBR that can stop on a dime and spin circles.

For reference here are some of the balancing robots found here on LMR:







Here is another good robot project:


It is also possible to use infrared or ultrasonic sensors to balance, but this is not very practical for slopes, if the robot comes up to something in sight of the sensor, or in some cases if the color of the floor changes. Please share any of your experiences and knowledge you think may be relevent!


I’ll put this here to

I’ll put this here to start 






here is some info on doing

here is some info on doing it without a microcontroller:




Well as far as 1 & 2 go…1.

Well as far as 1 & 2 go…

1. Larger wheels makes it easier to balance, I assume because it makes the wheels cover ground faster. It also increases contact with the ground surface which increases friction.  Also important to have grippy wheels to prevent slipping/spinning.

2. Raising the center of mass can help greatly, I assume becuase it adds a counteractive torque which slows down the back and forth oscillations when overshooting.  Of course too much top weight will overcome the motors ability to compensate at some point.

Feel free to add your thoughts and dispute me on this stuff.

Also see I added a link to a good SBR project (gyrobot) with code examples in C.

With regard to point 2 you

With regard to point 2 you are correct.

For a given robot mass, moving the mass distribution away from the axis of rotation (wheel axles) will increase the mass moment of inertia (also goes by many other names). Increasing the mass moment of inertia makes the system respond more slowly to any torque applied to it - this includes the torque applied by gravity that is trying to make the robot fall over, but also the restoring torque applied by the motors.

As the centre of mass moves away from the wheel axles, the torque applied by gravity at a given angle will increase, but then again the torque applied by the motors will increase by the same factor. Gavity is applying a force at the centre of mass to rotate the robot about the wheel axles, while the motors apply a force at the wheel axles to rotate the robot about the centre of mass, so the distance (torque arm length as some call it) is the same in both cases.

Thanks for the good

Thanks for the good explanation Telefox