How to Write your own Flight Controller Software — Part 4

Calculating the PID Error Term & Motor Mixing

David Such
7 min readJan 24, 2021

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:

  1. Pilot input (i.e. decoding SBUS);
  2. Gyroscope output;
  3. PID control loops; and
  4. 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.

Figure 1. Quad PID Approach 1 — Pitch, Roll & Yaw Angles.

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…

--

--

David Such
David Such

Written by David Such

Reefwing Software · Embedded Systems Engineer · iOS & AI Development · Robotics · Drones · Arduino · Raspberry Pi · Flight Control

No responses yet