Drone réglages des PID

https://drive.google.com/file/d/1WxgSUsG6UnvXjyxJSsAdw9iqoO21Ddmq/view

Your quad is controlled by what is known as a PID loop. As we are doing flips and rolls we are changing
the “Command” (what we know as the Setpoint in the quad world [a.k.a. the sticks]), causing the PID loop
to react. The goal of tuning is to tweak the PID loop so that it achieves the fastest response to commands
possible, without overshooting/oscillating. These Principles apply for ALL PID CONTROLLERS! ANY flight
firmware and ANY quad copter class. The guide and videos focus on Betaflight because it is the most
widely used firmware in the hobby for freestyle and racing. But the same principles apply to: FalcoX, KISS,
iNAV, Cleanflight, EmuFlight, Baseflight, etc. They all use a PID controller!
In this example, “Command” goes
from 0 to 110% at time zero. The
PID loop then reacts to move the
machine – in our case the quad – to
the new value. The Command line
is our sticks. The red, green, and
yellow lines are different gyro
(quad movement) responses based
on different PID tunes.
You want a tune that produces a
“Critically damped” response
(measured by the gyro feedback to
the PID loop).
Tuning your quad copter is an easy process involving the below 4 key steps. It only takes 1 or 2 packs. It
can be done Line-of-Sight (LOS), with FPV goggles, or using Blackbox. I use Blackbox a lot because it helps
to understand what is happening (to explain it) and also it gives the most precision in tuning, but it is NOT
necessary to use blackbox to tune your quad.
The steps are outlined in more detail below. Steps #1 thru #3 are critical for good general flight
performance, including:
 good prop wash handling;
 no wobbles or oscillations;
 no “throbbles” (bobble of the nose on
throttle punches);

 good reaction to wind
 tight stick tracking (direct feel).

Step #1 – Tune your Filters – The PID controller can’t work well if it’s fighting vibrations in the gyro signal
Step #2 – Tune ‘P/D Balance’ – Every quad has a specific P/D Balance that we need to find
Step #3 – Tune ‘PD Gain’ gain – increases the speed of the influence (force) the PID gains exert on the

motors

Step #4 – Tune FeedForward (“FF”) – Adding a fourth control term to reduce the inherent latency in a

standard PID controller

Page 2 of 8

Step #1 – Tune your Filters:
a) Setup your quad using the new RPM filters. See Betaflight 4.1 Filter Setup – RPM Notches are the
Future! for details on that process. The advantage of RPM filters – FOR ANY QUAD CLASS – is twofold:
1) the RPM filters more accurately track and crush motor peak noise. 2) it frees up the Dynamic Notch
to look for and track frame resonance or other peaks of noise (antennas vibrating, frame cracked,
etc…) and crush it out. Once RPM filters are setup per the video (with the Dynamic Notch
adjustments) move on to Step b).
b) Work up the lowpass filter sliders TOGETHER at the top of the Filters tab to try to get to a 1.5 or 2.0.
With the other settings (as outlined in the video above) this will result in a reasonable balance of filter
delay savings vs. not going too low and under filtering your quad. MILEAGE HERE WILL VARY! So do
it slowly moving up one or two steps at a time with full throttle / hard move flights in-between.

CHECK YOUR MOTOR TEMPS as you move up the sliders. Listen for excessive noise (grinding) sounds
on the motors at idle or during flight. Do prop wash turns and sharp moves. See if things are getting
better or worse as you move up the sliders. If better, move them up some more. If worse, stop and
move back one position. It is possible that motor will not be hot, but flight performance can get worse
with higher filters (noise to signal ratio gets too high on D-term). Use your senses and perception on
if prop wash is getting better or worse as you move up the sliders.
OPTIONAL: Do a blackbox log with the following settings in the BlackBox tab:
Do a full throttle and hard moves flight. Do NOT hit stuff and avoid any
ground bouncing at the beginning or ending of the flight (not critical, but
can throw analytical tools off if not trimmed out). Look at a spectrum of the
Gyro signal and D-term signal. Make sure all peaks of noise are completely
crushed out in the gyro signal spectrum and that the D-term signal doesn’t
have excessive noise between 100hz and 200hz.
For a video guide on the flight and looking at logs to tune up your filters, see:

  1. PID Tuning Principles: Step #1 – Filters Tuning (guide on getting the raw noise log)
  2. PID Tuning Principles: Step #1 Follow-up – Finalize YOUR Filters (how to customize your filters)
    For the basics on filters OR an in-depth understanding of how filters work and what “phase delay” is, see
    my Filter Fundamentals series.
    In general, you want to use Gyro filters to crush out any motor peaks of high frequency vibrations
    (“noise”). Then use the D-term filtering to tame the D-term property of doubling gain response to

noise as the noise doubles in frequency. Meaning, higher frequency noise (100hz+) drives the D-
term to go crazy, resulting in vibrations in smooth flight or HOT motors.

Figure 1: Gyro and D-term (lowpass) Filters sliders in Filters tab

Figure 2: Blackbox Setting in Blackbox Tab

Page 3 of 8

Step #2 – Tune the ‘P/D Balance’:
Paste the below into the CLI tab in BF. This will
turn off all the BetaFlight advance PID control
features; features that push the PID controller
beyond basic fundamentals. Once pasted, do a
flight with lots of flips and rolls (Line-of-Sight or
FPV), sharp stick inputs back and forth, and keep
increasing P-gains until you see sharp bounce-back. For LOS or FPV you really need to listen for it vs. seeing
it (it is so fast). It is easy to visualize however in blackbox (BBL). You can set your D-gains to the same
number for Pitch and Roll based on the noise floor after your filtering setup in Step #1. This is subjective
based on how noisy you want your D-term signal to be to the PID Sum. Best advice is 30’s or 40’s for a 4S
5-in quad. For 6S 5-in quad could be down in 20’s and 30’s. For a brushless whoop, more like 60’s or 70’s.
You want to keep raising P-gains until you start to get overshooting based on sharp stick inputs
and then back it down a little to get the “Critically damped” stepped response (see Figure 7).
Again, it is easiest to listen for it LOS or FPV. To see it check out a BBL.
For a video guide on this step, and what to look for in blackbox, see:
PID Tuning Principles: Step #2 – Tune the PID Controller (P/D Ratio)
CLI commands to paste and save before completing Step #2:

PID Gains Settings

set d_min_pitch = 0
set d_min_roll = 0
set f_pitch = 0
set f_roll = 0
set f_yaw = 0

PID Controller Settings

Set pidsum_limit = 1000
set pidsum_limit_yaw = 1000
set feedforward_transition = 0
set abs_control_gain = 0
set use_integrated_yaw = OFF
set iterm_relax_cutoff = 10
save
Once you have found the proper P vs.
D ratio (Balance) you can re-enable
the PID tuning Sliders and move them
around (between “Master Multiplier”
and “PD Balance”) to get close to the
numbers you had set manually. NOT
all quad classes will be covered by the
sliders extent. So if you are tuning a whoop, toothpick, or 10-inch they may not be flexible enough to suit
your needs. Betaflight defaults and slider extents were design around a 6S – 5” quad.
As we are doing the flips, rolls, and half rate moves (as show in the above video) we are drawing out the
Stepped Response in the PID controller. THIS IS HOW YOU TUN A PID CONTROLLER; period! See Figure 5
for how the different terms impact the quads performance and Figure 7 for a description of what a
“Critically damped” Stepped Reponses looks like.

Figure 3: PD Balance in PIDs tab

Figure 4: Enable Sliders button on PIDs tab

Page 4 of 8

A Deeper understanding of Stepped Response tuning:
Figure 5 below, shows a summary for what increasing one term will do when keeping the other two
constant. For example looking at the top row in the table, holding I-term and D-term constant and
Increasing P-term will:

  1. Decrease Rise Time (speed of quad moving to match the stick commands);
  2. Increase Overshoot (if excessive);
  3. Small Increase of Settling Time (if excessive);
  4. Decrease Steady-State Error (when optimal);
  5. Degrade Stability (if excessive).
    THE KEY is to have the right balance of P and D term to get a “Critically damped” Stepped Response
    (see Figure 7). The CLI paste in Step #2 above helps us isolate P & D gains to find the perfect balance!

Effects of Independent P, I, D, and FF tuning

PID Term to Change Rise Time Overshoot Settling Time Steady-State Error Stability
Increasing P-term Decrease Increase Small Increase Decrease Degrade
Increasing I-Term Small Increase Increase Increase Large Decrease Degrade
Increasing Dmax-term* Small Increase Decrease Small Decrease No Impact Small Improve
Increasing Dmin-term* Increase Decrease Decrease Minor Change Improve
Increasing FF-term Large Decrease Minor Increase No Impact Can Increase** No Impact

  • when D_min is enabled, it is the D-term in the PID controller. Only on sharp inputs does the active D-gain go to Dmax. See “FF
    induced overshoot:” in Step #4 for more details.
    ** through unstable RX signal (Cross Fire, R9 and all FrSky rx’s)
    Figure 5: Effect of PID changes (source: http://eprints.gla.ac.uk/3815/1/IEEE_CS_PID_01580152.pdf)

Figure 7 outlines the above terms. As we are doing flips and rolls we are
changing the “Command” (what we know as the Setpoint in the quad world
[a.k.a. the sticks]), causing the PID loop to react so we can see how it manages
the change (the Stepped change Response). We want to do this with both full
rate and half rate moves to see how it manages these two things to optimize
the tune.
Again, the CLI paste helps us to isolate the P and D terms (turns off FF and
getting I-term out of the way) so we can adjust P-term to determine the
optimal P/D Balance (ratio); looking for the “Critically Damped” PID response.
This means the highest P/D Balance possible without overshoot!

Figure 7: Stepped Response diagram.

Figure 6: Analog of PID terms

In this example, “Command” goes
from 0 to 110% at time zero. The PID
loop then reacts to move the machine

  • in our case the quad – to the new
    value. The Command line is our sticks.
    The red, green, and yellow lines are
    different gyro (quad movement)
    responses based on different PID
    tunes.
    You want a tune that produces a
    “Critically damped” quad movement
    response (measured by the gyro
    feedback to the PID loop).

The Goal PID
Response

Think of the PID
controller like a
strut on your car.

Page 5 of 8

Step #3 – Tune ‘PD Gain’ gain:
With the “P/D Balance” for your specific rig figured out WE NEVER WANT TO DO ANYTHING TO CHANGE
THAT as we increase gains or reintroduce the advance PID controller parameters (FF, D_min, etc…). The
PID sliders are built with that fundamental in
mind and are there to help speed things up. With

this understood, this step is to increase both P-
gains and D-gains TOGETHER to get better prop

wash handling and closer tracking to the stick
inputs (Setpoint).
“P/D Balance” = P-gain ÷ D-gain.
e.g.: 60 (P-gain) / 35 (D-gain) = 1.71 (P/D Balance)
In the above example we have a 1.71 P/D Balance ratio. Therefore, if you increase D-gain from 35 to 40,
you need to increase P-gain from 60 to 68 (40 (new D-gain) x 1.71 = 68 (new P-gain)). If you use the P and D Gain
slider to move up the terms, it holds the PD Balance automatically.
Do prop wash inducing moves (180 turns or split-S moves). Push up your P and D gains to reduce
prop wash. As you are moving up P and D gains, you will get to a point where the higher D-gains could
start to cause motor heat or vibrations in smooth forward flight (typically gains of 40 to 60 on a 4s 5-inch
OR 30 to 40 on a 6s 5-inch). Also, you will hit a point where prop wash will not get better. This point is
called “motor saturation” and is due to motor/prop mechanical limitations. You can see this in flight just
by things not getting any better or by looking at the Motor Command traces in a blackbox log (they hit
100% for 1 or 2ms). THIS IS THE POINT YOU WANT TO BE AT for the best tune you can have on your quads
specific mechanical setup. The ONLY way to improve prop wash handling from this point is making
mechanical changes. The cheapest way is finding the best (lightest) props to match your motors(not under
or over propped), your desired response curve/feel, and your durability preference. So if you can’t shake
that last big of prop wash to your desired liking and you have followed these practices to a tee, it is a
mechanical limitation; not the firmware.

Figure 8: P and D Gain slider in PIDs tab

Page 6 of 8

Step #4 – Tune FeedForward (“FF”):
Step #4 is ONLY important if you want to sharpen up stick responsiveness (typically for racing). Maybe
freestyle pilots like FF = 0 for smoother feel.
Once you have the P and D gain strengthsto a point
where you are getting motor saturation when
trying to induce prop wash, you can still push the
PID controller further with Betaflight’s advanced
PID controller features. FeedForward (“FF”) will
provide an additional push (alongside P-term) to
get the quad moving for sharp stick commands. FF-terms are based on the speed of your stick moves; like
the mouse accelerator on your PC or Mac. FF is similar to a D-gain, except it is based on the sticks (not the
gyro like the D-term) and pushes the quad (instead of dampens like the D-term). FF is mostly about feel,
so increase as you see fit (or don’t) to get the desired feel.
DON’T BE AFRAID TO USE HIGH FF GAINS (300+)! In my experience, a 4S – 650g – 5” quad may need FF
gains as high as 300 to have the Gyro completely track the Setpoint for rates that top out at 1020 deg/sec.
For a video guide on this step, see:
PID Tuning Principles: Step #4 – Tuning FeedForward and D_min to Track Setpoint
FF induced overshoot: As you increase FF-gains, the quad may start to get some minor overshooting.
This is much less of an issue in BF 4.1+ than ever before because some code was added to detect and shut
off the pushing of FF as it saw it was
approaching the target. However, if

you do have some overshooting, re-
enabling D_min can address the

overshooting by the added push of FF.
Once D_min is activated the “D_min” column adds to the
PID gains grid (Figure 10). The D_min column is now
your base D-gains in normal forward flight! The quad
will spend most of the time flying at the D_min value.
The “Derivative” column is the boosted D-gains in sharp stick input and during prop wash (aka “D_max”).
A typical D_max setting that addresses any FF overshooting is approximately equal to your P-gains. If
you are using the sliders, they automatically keep an appropriate ratio.
A deeper understanding of D_min:
Once you activate D_min, the quad will fly with D = D_min. If the quad needs more D-gain due to sharp
moves, prop wash, etc, it will ramp up to D_max (the value in « Derivative » column) in order to combat the
move / induced error. D_min boosts the active D-gains during prop wash detection as well. You can raise
the “D_min Gain” value (shown as “27” in Figure 10) to increase the sensitivity of prop wash detection.
Default is 27 but you can increase as high as 50 to make D_min raise the active D-gains sooner and stay
higher longer. However, this will increase Rise Time for stick moves as the active D-gain will boost sooner
in sharp stick moves. See the below videos for more on the D_min feature:
D_min Details and use for Noisy rigs to reduce filtering: https://youtu.be/n8iwIcJSuWs
D_min as “D_Boost” for a high performance tune (what we want): https://youtu.be/RtsQwGVTHg4
Figure 9: Stick Response Gain slider (FF slider) in PIDs tab

Figure 10: D_min Activation
IMPORTANT:
With D_min active, these
are base D-gains NOW.

D-max Gains (boosted
gain values on sharp
moves and in prop wash.)

Page 7 of 8
Once you are all done, you should have a tune that the Gyro
completely tracks the sticks (the most DIRECT feel possible) and
combats prop wash, wind, wobble, bobbles, etc… up to your quad’s
mechanical limits.
Step #5 – Yaw tuning: yaw is a very slow axis to respond to stick commands (Setpoint) when
compared to roll or pitch. Most of the influence for yaw is through motor/prop inertia shifts (2 motors
speed up and 2 slow down). Therefore, it typically doesn’t overshoot Setpoint and hence D-gains in BF for
yaw are defaulted to 0 negating the D-term opposition to P-gains on yaw (but is a gain you can adjust if

desired). To increase the initial push of yaw, like other axis’s, increase your P-gains. If you add in Yaw D-
gain, it will oppose that push requiring higher P-gains. This will give yaw an initial jump to get things

moving. However, since so slow to react, yaw requires a much higher I-gain to keep it tracking Setpoint.
Like with I-term tuning in Step #6, it is best to tune yaw through blackbox and looking at how well the yaw
axis gyro reading is tracking the yaw axis Setpoint as you do sharp yaw moves. Then apply the principles
of Step #2 to the yaw axis. I find you need a HIGH P-gain and I-gain on yaw (P = 80 / 90 and default I-gains).
For a video guide on this step, see: PID Tuning Principles: Step #5 – Yaw Axis Tuning

Note in BF 4.0+, the Yaw I-gains are multiplied by 2.5 in the code to give an even higher I-
gain control on Yaw. So in earlier versions of BF (3.5 and lower) Yaw I-gains are way too

low.
Integrated Yaw feature in BF 4.0: If activated this changes the advice above. Note the
paste in Step #2 disables Integrated Yaw for the time being until this new yaw tuning
approach can be vetted (with Absolute Control) and this guide can be updated. If you want
to play, knock yourself out. If you want to keep it simple, keep Integrated Yaw disabled.
Step #6 – I-term tuning: With the addition of the i-Term Relax feature in BF, you can run very high

I-gains without negative ramifications. The best way to tune I-term is through feel or blackbox. Higher I-
gains will make the quad track the Setpoint more accurately in sweeping turns. It will also make your quad

feel a little stiffer for entering sharp moves. In the end, it is not that touchy of a term/gain. So the best
way is to get everything else set and then get a backbox log and see how well the quad is tracking the
Setpoint through sweeping moves/turns.
If the Gyro trace seems to run high or low of the Setpoint for an extended period of time, you need higher
I-gains. If you have very, very slow bouncing of the Gyro trace above and below the Setpoint trace, that
means your I-term is too high (this would be very rare and require I-gains of 100+ in most cases – look for
a 4-leaf clover that day and play the PowerBall!). In most cases, quads fall within the large window for
decent I-gains set by the Defaults so typically little focus is placed on I-term tuning. But generally racers
want higher I-gains for better tracking in broad and tight turns so try raising them up a bunch (20 or 30)
and see how you like it for around the track. If you like a more loose feel for free style, try lower I-gains
and maybe even FF = 0 for smoother molasses HD footage.

Page 8 of 8

DEFINITIONS:
« Overshoot »: is when you induce a change the desired roll, pitch or yaw rotation rate and the quad
moves to match your new commanded rate (in deg/sec) but overshoots the target. This
is also known as “bounceback” when referred to as motion seen in the FPV feed, LOS, or
in blackbox logs at the end of sharp flip or roll. So the term “bounceback” is the quad
overshooting the commanded change in motion and hence has to “bounce back” to the
commanded rate. Looking at Figure 7 above, overshoot is a sign of an “Underdamped”
PID controller; not a good PID tune.

« Bounceback »: is the quad doing a small shutter (or shake) at the end of a sharp flip or roll. You can see
bounceback in your FPV feed, HD footage or blackbox log. It is typically the quad going
past the desired roll or flip rate (Setpoint) and bouncing back to the Setpoint. Looking at
Figure 7 above, bounceback is a sign of an “Underdamped” PID controller; not a good PID
tune.

If the Bounceback is fast:

  • If the quad seems to go past the Setpoint and bounce back to the Setpoint, that means
    your P/D Balance is too high. Either increase D-term or reduce P-term.
  • If the quad seems to stop short of the Setpoint and then bounce further to hit the
    Setpoint (rare), that means your P/D Balance is too low (see Figure 7 – Overdamped
    condition). Either reduce D-term or increase P-term.
    If the Bounceback is slow:
  • That is I-term windup causing the I-term to drag the quad past (or stop short) of the
    Setpoint and then it slowly adjusts back (or forward) to the Setpoint. HOWEVER, with
    the CLI paste in Step #2 above, setting the ‘i-Term Relax’ feature to a cutoff of “10”
    will prevent I-term windup from dragging the quad past the Setpoint. For more on
    the i-Term Relax feature, see: https://youtu.be/QfiGTG5LfCk

« Setpoint »: is what you are telling the quad to do. For example: when you do a sharp roll, the Setpoint
ramps from a rotation rate of 0 degrees/second roll rate to what you have your max roll
rate set to in the Rates tab. We tell the quad the roll, pitch and yaw rates with our TX
sticks (the rest is just throttle amount) and the PID loop controls the quad getting to and
sustaining the commanded rates (Setpoint). You can see how close you are tracking to
Setpoint through feel experience (lots of it) or more simply through looking at a blackbox
log.

Laisser un commentaire