In the months leading up the original Segway’s release in 2001, it was hyped as the future of personal transportation. If you’re too young to remember the news, it was roughly on par with a royal wedding or a new Marvel movie — people were excited, despite not having any idea what a Segway would actually look like. The reality is that Segway has only ever achieved marginal commercial success. But the self-balancing system was still impressive, and has been replicated many times since. Over on the Gear Down For What? YouTube channel, they’ve utilized a similar system to build a speedy RC car.
Segway-style self-balancing robots and vehicles use the torque of the electric motors to remain upright. If a self-balancing robot starts to tip forward, that is immediately detected and the wheels spin forward a precise amount to correct the tip and keep the robot upright. The faster the wheels can respond, the more smoothly the robot can balance. In this case, Gear Down For What? used an interested dual PID (Proportional–Integral–Derivative) loop to keep the RC car upright, even at high speeds. That loop updates the wheel position and speed every 5 milliseconds, so the RC car move very smoothly.
PID control is common in industrial settings, and refers to a loop where control (usually for motors) is modulated in a cycle by taking the difference between the actual position (or speed) and the desired position. Hobbyists are probably most familiar with PID for drones, which is important for keeping them stable. Gear Down For What? took the same idea, and applied it twice using a Teensy microcontroller development board: once for standard balancing based on angle, and a second time for speed based on throttle control. The second speed loop modifies the first angle loop, which lets the RC car lean forward as it accelerates. That keeps it stable at high speeds. As they demonstrate, it also lets the RC car perform many other automated actions, like recovering from a tumble.