Betaflight Yaw Spin To The Moooooooon

Some flight controllers running Betaflight are subject to a condition known as "Yaw Spin To The Moon" (YSTTM). YSTTM usually happens when a racer clips a gate at high speed. The quad goes into a climbing yaw spin that can't be stopped except by disarming.

The root cause of YSTTM is a bug in the gyro chip's firmware. When the angular rate exceeds the maximum value that the gyro can measure, a programming condition known as a "2's complement overflow" occurs. The effect is that the gyro reading flips over from +4000 degrees per second to -4000 degrees per second. The PID loop perceives that the quad has gone from spinning 4000 dps to the left, to 4000 dps to the right.

When YSTTM occurs, the gyro is giving incorrect information to the PID loop. So the PID loop's response is also incorrect. Garbage in = garbage out, as they say in programming. The PID loop perceives that the quad is spinning very fast to the right, so it gives the motors maximum yaw to the left, to counteract the spin. But because the gyro's output has inverted, the PID loop actually makes the quad spin faster.

The way to break out of YSTTM is to allow the angular rate to go below 4000 dps, but since the PID loop is reinforcing the spin, this will never happen. This is known as a "latching condition". Once it occurs, it will never stop occurring without external intervention.

This firmware bug is exclusive to the newer ICM206XX series of gyros. The MPU6000 is immune, which is one reason why I selected it for use on my JBF4 AIO flight controller.

Even though the MPU6000 doesn't have the overflow bug, it still can sometimes experience YSTTM. Because YSTTM can be caused purely by physical conditions. If the quad is spinning fast and also wobbling a bit, the PID loop can simply get "behind the curve" and not be able to cancel out the unwanted motion. You know that thing that happens where you're trying to pass someone in a hallway and you both move left, then right, then left again, repeatedly failing to get out of each other's way? It's kind of like that. In some extreme spin/wobble states, the PID loop can accidentally reinforce the spin. The difference is that the overflow bug on the ICM206XX series of gyros is 100% guaranteed to cause a YSTTM every time the gyro exceeds 4000 dps. Whereas the MPU6000 will only experience it rarely.

Betaflight devs are working hard to come up with a software solution to address YSTTM, regardless of its cause. YSTTM is pretty easy to detect. Any time the yaw gyro reads more than a "sane" value, the code can assume it's in a YSTTM condition. The current approach simply disables the PIDs when the yaw angular rate is too high, which allows the quad to slow down. You're probably not doing much flying anyway when you're spinning at 2000+ dps, so the lack of PID controller shouldn't affect you too much.

Of course, the real answer should be for Invensense to fix the bug in the gyro itself. Or for FC designers to use the MPU6000!