We explained “what Quadcopter PID is” in our last article, and in this tutorial we will explore the effect of PID tuning for a quadcopter. This does not only apply to quadcopters, but also other multicopter configurations too such as the tricopters and hexacopters.
PID Tuning Explained in Simple Terms
As explained previously, a PID controller is a control loop feedback mechanism widely used in control systems. A PID controller calculates an “error” value as the difference between a measured variable and a desired set-point. The controller attempts to minimize the error by adjusting the control inputs.
This can relate to something we are familiar with: in a multirotor, PID controller takes data from sensors and compare that against the expected values. The difference would be what we call an “error”. And so the flight controller alters the speed of the motors and hopefully the “error” will get smaller next time. And this is how PID stabilize a quadcopter.
As you might already know, PID has 3 parameters, P, I and D. Heuristically, these values can be interpreted in terms of time:
- P depends on the present error
- I on the accumulation of past errors
- D is a prediction of future errors, based on current rate of change
Still don’t get it? That’s okay.
Seriously, it’s not necessary to understand how PID work in order to be a good Quadcopter PID tuner. Read on…
PID Tuning in Practice
Here we will try to relate PID to how your quadcopter flies in the air. Hopefully it will give some your hints on how to tune PID better, and understand how each parameter affects quadcopter flight characteristics.
What is P term?
P is the main value you worry about, which determines the stability and handling. You can actually leave I and D values at 0 and your aircraft will still fly.
The higher P gain, the harder it tries to stabilize the copter. Generally speaking, high P gain means sharper control while low P gain means softer control. But if P is too high, the quadcopter becomes too sensitive and over-correct itself. Eventually it will cause overshoots, and you will have high frequency oscillations.
What is I term?
Very simply, the I term helps to hold the copter’s attitude against persistent bias (e.g. off-centered CG) and external variables (e.g. wind). Your quadcopter would feel stiffer with higher I gain.
Normally default I gain works pretty well on most modern FC software and hardware. But if you notice some drifting without user command, then increase I term. But when I is too high, you might notice slow vibrations at punch-outs (high throttle ascend).
What is D term?
D gain is like the opposite of P. If P was a hand to keep pushing the machine back to a stable position, then D was a spring between the hand and the machine which absorbs the shocks. By adding D gain, you can “soften” the movement just like adding a spring to it, and it remove the P gain oscillations.
When you begin to have slow vibration by raising P gain, don’t rush to bring it back down. Try to add a bit more D gain see if it can fix it. D gain allows higher P as it reduces some of the P term vibrations.
If you see some bumpiness or slight oscillations in your acro moves, or overshoots at the end of a flip and roll, give higher D also helps. D term also helps reducing propwash oscillations.
However too much D is not good, because it amplifies noise in the system, and cause oscillations in the quadcopter and motors overheat. Also your copter would feel sluggish and mushy with excess D value.
How To Enhance Flight Characteristics Apart from PID?
Not all oscillations are caused by high P term. You need to eliminate vibration sources as much as possible on your quadcopter before tuning PID. For example balancing of motors and propellers, frame rigidity etc. With a vibration free copter, you can set a much higher P gain, and smoother machine.
Center of Gravity (CG)
You want quad’s center of gravity to be right in the middle, where the 4 motors intersect on a horizontal plane.
What happens when your CG is off-centered? Some motors will have to work harder than others, not only it might cause motors overheat, it will also affect stability.
For example in a quad, maybe your LiPo battery is too far back, it shifts the CG to the back. And now the 2 rear motors have to work 100%, while the front 2 motors are only at 80%. If you want to push harder in throttle, you can’t! You quad might oscillate back and forth and won’t deliver any extra power because the rear motors have already maxed out.
Quadcopters with more centralized mass tend to feel more precise, snappy and responsive. When there is more mass on the outside of a quad, it takes more force to rotate it. Also due to the angular mass and inertia it’s harder to stop it from rotating.
That’s why X frames (mini quad frame shape) have taken over the mini quad market from H quads when people realized the benefits. Apart from frame design, lighter motors and ESC also helps reduce rotational inertia.
When to “Re-Tune” your PID?
Almost all the parts in your copter has some effect on your PID. So when you swap out components for a different brand/model, you must re-tune your PID gains. For example Frame, Propellers, Motors, ESC’s etc…
In Betaflight and Cleanflight, Looptime also has a great impact on your PID values. Once you changed Looptime make sure to return PID.