Detecting Cleanflight PID tuning issues with Blackbox: excess P gain
Almost all quadcopter PID tuning tutorials can be summarized into one sentence: "Increase P until you see oscillations, then lower it". Plus some thoughts about I and very vague advices about D and that is all. When I got into the hobby, I've read all of those tutorials. And I did know more about PID tuning than before that. I even had more questions than before. How to recognize high frequency oscillations, how to recognize low frequency oscillations. Lower P? OK, but how much? And D? How to tune this bloody D? As a result, every time I tried, I ended up with very snappy but shaky quadcopter that maybe responded very quickly to commands, but was very shaky and was making strange noises.
And then came Cleanflight and Blackbox. Live became simpler. What I've learned from Blackbox logs is that I wanted high P so much, I had too much of it in the end. Actual oscillations begins before we see or hear them and excess D introduces jello. Blackbox simplified things, but still, logs analysis is something like an art. You have to know what to look for.
Like I wrote above, the most common mistake in PID tuning is excess P gain that leads to oscillations. Those oscillations might not by visible or audible, but gyro will detect them and they will influence control loop, increase power usage, might introduce jello and worsen flight characteristics. So, what to look for?
First, open a log that has everything: low throttle section, hover, hight throttle section, turns, maybe roll or flip. Analyze each axis separately. I like to begin with roll, then go to pitch and finally to yaw. The most useful graph layout is the one where upper section show axis gyro and RC command, and lower one P, I and D for this axis.
Scroll to low throttle section without RC input. If it looks similar to image above, your P is fine for hover. There is some noise in gyro, P and D but it is not moving very much. No high amplitude changes, looks like quad is in a state of balance. It hovers.
But, if it looks like this
P gain for this axis is most probably too high. There is constant movement on gyro, but RC input is at 0. P jumps up and down, as well as D. At this point you can stop analysis, lower P, and perhaps D, record new log and check what is happening there. If there are no oscillations, you can move further. If oscillations persists, lower P again and record new log.
When there are no oscillations on no RC input and low throttle, next step would be to check what is happening when RC input is applied.
Look at image above. Roll input is applied, P (and D) does their work and gyro readout follows input. At one point P and D goes negative to slow down roll speed but this is normal. Also gyro readout has some noise, but this is also normal, nothing to worry about. P gain looks fine. Maybe not perfect, but multirotor would be fully flyable. If gyro would not follow input, follow with a big delay or multirotor would be changing attitude into different direction than input, that would mean that P is too low or there is something else very very wrong. But it this case you would not be able to fly.
On image above is an example of oscillations on RC input. Gyro readout is following input, but roll rate is accelerating and slowing down. At one point, it even starts to roll in opposite direction due to overshoot. Once again, P gain is too high. Situation when you do not have oscillations on hover and oscillations on delicate RC input are rare. Usually they appear only on hard stick movement or stick release. And in this case it is about finding balance between both states.
The last step for P tuning for axis would be to check how it looks like on high throttle. By high I mean like 100%. If oscillations would appear there, you have two choices.
- lower P some more, but that might be not enough and might induce instability on hover,
- apply TPA (Throttle PID Attenuation) to suppress this state.
Unfortunately, I do not have any log examples that covers this state. Maybe next time. Either way, that is not very different than low throttle analysis. Find a point when oscillations appears, set this value as TPA start point and try to find good attenuation value that suppresses high throttle oscillations.
Here is an example of all three axises readouts:
Do you see the difference between roll, pitch and yaw? I surely hope so. Roll goes crazy while pitch and yaw are quite steady even when there is pitch RC input.
This procedure might be time consuming and requires few test flights, but is much better and faster than blind tuning only by feeling. There is hard data you can look at and compare with previous tests. I'm not pretending I'm Blackbox expert. I'm far far away from that. But it's not magic and everyone can learn it, look for patterns and conclude.
I'm Paweł Spychalski and I do things. Mainly software development, FPV drones and amateur cinematography. Here are my YouTube channels: