How to Write your own Flight Controller Software — Part 4
Calculating the PID Error Term & Motor Mixing
In Part 3 of our series on writing your own flight controller software, we looked at PID control and what that consists of. When writing complex software, it is usually easier to break it down into smaller parts which you can test independantly.
Our path to functioning flight control firmware on an Arduino looks like this:
- Pilot input (i.e. decoding SBUS);
- Gyroscope output;
- PID control loops; and
- Motor mixing and motor output.
Our next challenge is part 4, feeding the error signal e(t) for roll and pitch into our PID loop and then outputting a corresponding PWM control signal to drive our four motors.
However, we have a problem. In researching best practice PID control loops for quadcopters, it quickly became apparent that there are a number of different approaches to how you can implement these. Our initial thinking was that we were…