In this post I will share how I use Blackbox to tune PID, following some basic and simple steps.
PID tuning is a big part of Multicopter and FPV flying. Originally PID tuning was mostly a guessing game, trial and error: where you adjust PID values by spotting any wiggles either through line of sight or FPV.
The invention of Blackbox in Cleanflight makes PID tuning much easier in my opinion, and it allows you to adjust PID values more scientifically. You can now see what is causing vibration, and which PID value needs to be changed.
New to all these?
Here is a more detailed guide of how to setup Blackbox on your quadcopter.
If you are not familiar with PID and the basic tuning process, have a read on Understanding PID for Multicopters.
Disclaimer: I am no expert in this, I am just sharing what works for me. If you have any different ideas or approach please leave me a comment as I would love to know. It’s all about sharing the knowledge :D
There are much more in PID tuning than what I am trying to explain here, but I hope it gets you started with the long PID journey ahead.
What to Record in Blackbox logs
My flight test is simple, and only require less than a minute. Of course you can just record your normal flight, and analyse it from there.
- Turn on Rate mode (acro mode)
- Hover, then start flying forward for a few seconds
- Roll left and right several times (maybe 45 degrees)
- Do some 360 rolls
- Pitch forward and backward several times (maybe 45 degrees)
- Do some 360 flips
- Yaw left and right several times (maybe 45 degrees)
- Do some 360 yaws
The Steps to Analyse Blackbox Data
General Performance Checking
Before going into PID, I normally check the motor outputs first. I need to make sure the quad is flying normal, otherwise the blackbox log data would be invalid.
I look at data from the hovering tests, the motor outputs should be at similar level. If not, the problems are usually caused by:
- CoG (centre of gravity) not in the middle of frame
- Propellers or motors are in bad condition
If for example the rear back motors are working harder than the front 2 motors, then your quad might be tail heavy, possibly caused by your lipo battery sitting too far back.
If just one of your motors is working harder than the rest, then that indicates a potentially bad prop, or motor, or even ESC.
But if all 4 of your motors are spinning at the similar speed constantly when hovering, then your quad is in good condition (motors, props are all good), and it’s in good balance. It doesn’t need to be exactly the same, close enough would be fine.
PID Tuning Diagnose
With good PID tuning, we can get the following achievements:
- smooth gyro traces, has as little noise and oscillation as possible.
- smooth motor outputs – motors will run quieter and cooler. Motors and ESC would heat up if motor traces have a lot of oscillation, or the outputs look like Pacman. Your quad will also draw more current from battery which leads to shorter flight time.
- gyro traces respond to RC Command well, and doesn’t oscillate.
I generally uses 2 graphs:
- Graph 1: rcCommand, gyro
- Graph 2: PID_P, PID_I, PID_D, PID_sum
And I go through these graphs on Roll, Pitch then Yaw separately.
Graph 1 shows you where you change input, and how the quad is responding to your stick (gyro). It also shows you how PID (next graph) is affecting Gyro.
Next graph – PID, is more important. These are what I think good PID traces should look like (not strictly though), and how they respond to increase/decrease gain values.
- P – Ideally P shouldn’t cause too much noise in the Gyro. It might have some ripple which is normal, but to a reasonable extent. If P is too high, you will see the noise increases and get into the gyro trace, ripple will also increase (slower frequency oscillations)
- D – Ideally D gain should follow P, but actually a step ahead of P. It should also have similar magnitude as P. However D is usually much noisier than P, so it normal to keep it a little lower, or decrease your “Dterm_cut_hz” (a variable introduced in Betaflight – Read more).
- I – To keep it simple, I generally just ignore I and tune it at the field. I usually have I values low, as long as the multirotor doesn’t drift, or wobble at descent. Some people recommend doing punch outs, and see if the quad is keeping the angle correctly, if not increase I. But I found low I gain is better when you do aggressive flying, the quad feels more fluid.
Blackbox Log PID Tuning – Examples
Roll/Pitch – P
Clearly, P gain is too high in this example.
As I move my roll stick, P starts to oscillate, and those wiggles get into the gyro trace as you can see (yellow circled)
Now I decreased P.
Much better, no more constant oscillations in P and gyro.
Roll/Pitch – D
There are two ways of tuning this, or two stages as I prefer. Apart from looking at blackbox log, you should also check in your FPV footage if you have any bounces at extreme flips and rolls. As long as you are happy with it, there is no need to keep increasing D.
Here is an example of low D gain.
I would imagine the quad would get some bounce backs when doing sharp bank turns or flips.
Here I increased D gain. Magnitude of D is now closer to that of P. You might see more noise in your case, but I am lucky that mine isn’t too bad. Some quads are just noisier than others, due to all sorts of reasons, either electrically or mechanically.
I would now go out and fly it, if I am still getting bounces I would increase it a bit more, if not I would just leave it there.
Another good example would be the graphs on “Roll/Pitch P”, I also adjusted (increased D gain) on the 2nd test.
Yaw P and D?
Pretty much like pitch and roll, increase yaw P would give you better yaw response, but might introduce overshoot. If you have drifting in yaw then increase I, but try to keep I low. As for D, I usually just give it a little, maybe 5-10.
Yaw P do show some oscillations in the graph, but that’s completely normal and doesn’t seem to affect my flying much. Oscillation exists in Yaw because quadcopter hasn’t got the strongest yaw authority.
I also notice that with the same setup, smaller frame, lower pitch props or higher KV motors would show cleaner yaw traces. That indicates the oscillation is linked to yaw authority.
Here is a graph from my EVO250 running 1960KV motor with 6045 Props.
And this is my Ghost220 running 2300KV motors with 5045 Props.
Both quads fly great! The yaw oscillation is not end of the world. IThe noise dies down on my 250 quad, when I reduce yaw P, but yaw becomes less responsive and softer which I don’t like.
Need help with tuning?
Join our group and upload some logs if you want.