Find the right P D gain using step response graph

In this tutorial, we'll spend about 5 minutes to learn how to use step response graph to find the right P-D gain for your quad.

Feel free to skip this section if you don't want to get into too much detail for now.

First, what is P-D balance and why it matters? To answer this question, let's first answer why do we want to tune our quad. There are two main reasons

  • #1 When we move our sticks, we want the quad do what we ask it to do, right away with no lag if possible.
  • #2 When we are not moving our sticks, and there are external disturbances (wind turbulence), we want the quad to resist those disturbances. Prop wash situations for example.

For Betaflight, P-D balance is mostly for #1. Here's is how it works, when we move our sticks, the P component of the PID loop is the factor that pushes the quad into the move[1], whereas the D component is the factor that prevents the quad from moving. In fact, in Betaflight D is always a factor that prevents the quad from any kind of movement. We'll go into more details on this in later tutorials.

We need a good P to D ratio to achieve good response from our quad -- in the beginning of our stick move, we mostly need P to kick the quad into the move, and don't need D, but at the end of our stick move, we need D to stop the quad from further movement to avoid overshoot. If P/D ratio is too high, the quad will move more than what we command it to do (overshoot), if P/D ratio is too low, the quad will be sluggish to do what we command it to do.[2]

With that, let's take a look at how to use Dronesitter's "Step Response Overview" feature to find the best P/D ratio for your quad.

1
Clear out your blackbox storage, set the blackbox recording speed to 1kHz.
2
Put in the following settings to make sure we get the best step response data:

  1. Use default P and D values as a start, for regular 5 inch, 35-45 should work, if it doesn't fly well, turn both down to 30
  2. Turn off Feedforward by setting the value to 0
  3. Turn off Absolute Control by setting the gain to 0
  4. Turn off D-MIN
  5. Turn I gain down, for normal 5 inch, 30-40 is good
  6. Turn off TPA (set it to 1.0)
As shown in the following screenshot


3
Fly the quad and let it record some logs. One minute of flying is usually enough. You can use Brian White's basement tuning method, where you basically just hover the quad, and quickly move your roll stick left and right. Do it for one minute.
4
Then plug in the quad to the computer, enable blackbox mass storage mode. Then you can access the FC's blackbox like a u-disk.
5
Use Dronesitter to open the blackbox you just generated.
6
Use Dronesitter's "Step Response Overview" feature to analyze.

Click on the "Step Response Overview" button at the top. In 1 or 2 seconds, it should generate the step response graph for all ROLL, PITCH, YAW axes.


You should see three graphs that look like this

Since we only moved ROLL, we only need to look the ROLL axis, you can also do the same to other axis, but if PITCH and ROLL Is symmetric, they can share the same P/D ratio.
The X axis of this graph is time in milli seconds, the Y axis is drone's response. To understand this graph, you can think of at time 0ms, you ask the drone to reach to state 1 (i.e. asking the drone to reach to certain angular velocity), the line then plots how the drone responds to your command (i.e. the actual drone's angular velocity).

The graph above is a good example for P being too high thus it swings several times before converge. The following is what a good P/D balance looks like:

7
Adjust the P/D ratio and iterate

If it looks like P/D is too high, lower P, otherwise increase P until your graph looks similar to the good P/D balance. Then go back to step 3.

Once you find the perfect P/D balance, you can increase P and D up with the ratio kept until you get oscillations. This is then the perfect value for P and D.[3] This step makes sure your quad and resist disturbances well. We'll get into more details on this in later tutorials.

This is basically how you tune the P and D gain of your quads. Which are two of most important tuning parameters of a quad. This will help the quad better track your stick input and overcome any prop wash or turbulence.

  • [1] "Move" here means change of angular velocity, for ease of understanding, just consider it as movement.
  • [2] Note that with the introduction of Feedforward, P/D ratio should be called PF/D ratio as Feedforward will also affect the quad movement. But we'll come back to this in later tutorial.
  • [3] Some adjustment will be needed when you enable other features like Feedforward, D-MIN, we'll touch on these in later tutorials.