3 ms·
you were doing that kind of floating point math on an AVR? good lord...
by metalliqaz 5y ago
you were doing that kind of floating point math on an AVR? good lord...
- sgtnoodle 5y agoYep, for that project I implemented an RC airplane attitude controller. It would keep pitch and roll at 0 degrees with an offset based on the joystick input, toggle-able by a switch. It was fun, you could do really foolish stunts and just flip a switch to level out immediately if you got too disoriented. The AVR was reading a 6 axis IMU chip and estimating attitude using a floating point quaternion based complementary filter, at 100hz. Sqrt was used when normalizing vectors and quaternions, probably two or three times per cycle. It was also reading 6 channels from the radio receiver, and producing 6 RC PWM outputs. I believe the output was synchronized to the input, so that the throttle and servos would go limp if the radio went out of reception, rather than have the plane just keep flying level into the sunset. I vaguely remember it using about half the available CPU cycles doing all that. I even managed to get it talking to an RC simulator, so I could debug it without crashing my real plane. It worked perfectly on the first test flight!