A three-year journey to build a reaction wheel
How do unstable things stay upright? True passive balancing is very difficult and isn’t dynamic, so it doesn’t help when there is movement. Active balancing is all about inertia and this is how a tightrope walker can traverse a chasm by making small adjustments with a long pole. This is the same principle behind “self-balancing robots” that utilize reaction wheels. But the control scheme necessary to get that right is very difficult to perfect, as demonstrated by Nikodem Bartnik’s project that was three years in the making.
Physically, this is about as simple as a self-balancing robot can be. It stands on a single foot designed to be unstable in one horizontal axis, but stable in the other. It is long, front-to-back, so the robot can’t tip forward or backward. But the bottom of the foot has a curve to it, so it can’t stand upright without tipping to one side or the other. A reaction wheel with bolts for weights is responsible for preventing that tipping.
This is supposed to work by spinning in order to “push” against nothing (thanks to inertia), which generates torque to stop the tip. But Bartnik discovered that it was a massive challenge to tune that spin.
An Arduino Nano board controls a small brushless DC motor that spins the reaction wheel. A gyroscope sensor lets the Arduino monitor tilt and power comes from a hobby LiPo battery. The Arduino utilizes PID (proportional-integral-derivative) algorithms to try an apply just enough spin to counteract tipping, but not so much that it overcorrects.
That’s where Bartnik ran into trouble, because PID tuning is hard. Each variable has to be at the exact value — relative to the others — for PID to work as intended. After countless hours of struggling, Bartnik added a Bluetooth module to the Arduino to change those values wirelessly without flashing new code every time. That sped up the process dramatically, allowing Bartnik to find a set of values that works pretty well to keep the robot upright.