PID Attenuation and scaling - iNavFlight/inav GitHub Wiki
This topic covers methods used to dynamically adjust your models PID gains, to prevent control oscillations as the models airspeed changes throughout the flight; while still maintaining an adequate stabilization response.
Multiple methods are used to accomplish this. Depending on whether it's a multicopter or fixedwing platform.
-
Multicopter TPA - Throttle PID Attenuation
-
Fixedwing APA - AirSpeed PID Attenuation and boost (INAV 9.0)
-
Fixedwing TPA and Pitch Angle - Throttle and Pitch Angle PID Attenuation and boost (INAV 9.0)
-
Fixedwing TPA - Throttle PID Attenuation and boost (Before INAV 9.0)
Multicopter TPA
Settings :
-
TPA_Rate - percentage of PID attenuation that will occur when the throttle is increased above the
TPA_breakpoint. Range0 - 100 -
TPA_Breakpoint - is the throttle [
uS] value in the curve at whichTPA_Ratewill be applied. Below this value the PIDs are not attenuated at all.
How to use it?
- Firstly, set
TPA_Rate = 15as a starting point.
The PID's should be tuned in the approximate throttle range your copter will comfortably cruise at. - Once the throttle is moved higher than this point, you may start experiencing oscillations. So begin increasing the
TPA_breakpointto a throttle value just prior to the onset of those oscillations. - Then incrementally increase the
TPA_ratevalue until the oscillations in the higher throttle ranges are gone.
It may require increasing considerably higher on more powerful freestyle or race quads.
Note - TPA is not recommended for reverse motor 3D installs.
Example of Multicopter TPA curve

Fixedwing
[!Warning]
Fixedwing dynamic PIDFF adjustment is broken into multiple methods, based on changes made in INAV 9.0.
It is important to understand the operation of both new methods.TPA and Pitch angle must also be tuned, due to it becoming a fall-back if the APA speed source fails.
Loading the configurator platform type defaults for the TPA and Pitch angle settings are workable. But may not be perfect for all aircraft.Failure of an airspeed source will lead to the following fall-back order -
Pitot>Virtual>Throttle / Pitch
Fixedwing APA
This method uses the planes airspeed to determine the optimal dynamic PIDFF gain adjustments required.
INAV 9.0
Settings :
-
Fw_reference_airspeed- Is the cruise airspeed at which your PIDs, Rates and Feedforwards should be optimally tuned, to provide a strong stabilization response.
It is from thefw_reference_airspeedthat the gains will either be boosted at speeds below it, or attenuated at speeds above it. -
apa_pow- Sets how aggressively the gains will be dynamically adjusted from your base PIDFF tune. Range0 - 200
Increasing its value will boost the gains more aggressively below thefw_reference_airspeed, and attenuate them more aggressively above thefw_reference_airspeed, which is more applicable to aircraft that have a narrower flight speed envelope.
While decreasingapa_powwill provide less aggressive gain scaling, allowing attenuation and boost to occur over a broader speed range. It effectively flattens the curve and stretches it to account for aircraft with a broader flight speed envelope.
FUNCTION :
Airspeed can be obtained from either a Pitot airspeed sensor. Or Virtual airspeed, derived from Wind estimation and GNSS data, requiring a 3D satellite fix..
As with the throttle TPA_rate setting, APA_pow also uses a similar scaling limit factor of [2x boost] 100% increase of the base gain tune - [0.3 attenuation] 70% reduction of the base gain tune.
Proportional and Derivative are scaled the same. While Integral is scaled at a lower rate.
[!Caution]
Neither airspeed source is perfect. A Pitot tube can become partially blocked in flight. And Virtual airspeed may fluctuate depending on its data quality. For this reason, do not tune your base PID gains too tight. For the same reason, do not increaseapa_powtoo far above 120, unless you have a slower airplane.Virtual airspeed requires a heading adjustment greater than 11.5° every 15 minutes. Otherwise the airspeed estimation will become stale.
How to use this?
apa_pow = 0is disabled. Meaning the TPA and Pitch angle control method is active by default.
To use airspeeed PID attenuation control. Ensure you have your Airspeed hardware source selected in the Configuration tab, under Sensors and buses.
Think back, or estimate the highest airspeed your airplane can reach. Take note of the plot curve and setapa_powaccording to that value.
[!Note] The flight speed range you set
apa_powto operate over, is proportional to the point you setfw_reference_airspeed. Based on the plot, decreasing or increasing thefw_reference_airspeedwill slide the boost/attenuation scaling limit speed left or right by the same value.
-
If you have not done so; firstly tune your airplanes rates and feedforwards with AutoTune, using the default PID gains. But if you already have a workable tune for your airplane, start with that.
-
Enter an airspeed value your airplane will comfortably cruise at, into the
fw_reference_airspeedsetting[cm/s]. This will be the speed for the base gain tune. -
Start incrementally increasing your PID gains, while holding the approximate cruise airspeed you entered in the above setting. Tuning can be done easier via inflight tuning.
Ideally you do not want to tune the PID gains too tight. Backing them off at least 15% from the point you experience oscillations, gives the software some working room. This is also extremely important in the case of airplanes that can reach a high top speed. -
Once this is complete. You will notice that the stabilization automatically becomes tighter when the airspeed reduces below the
fw_reference_airspeed. And control surface oscillations are prevented as the airspeed increases above that point. -
However if you have a very faster airplane that encounters control surface oscillations at much higher speeds. You can decrease the value of
apa_powa little more. It will allow the dynamic gain adjustment to occur over a broader flight speed envelope. Which also prevents the boost scaling limit being reached too far above the airplanes minimum flight speed.
Keep in mind. The strength or tightness of the base PID tune will also effect this (mostly P-term). e.g. The tighter the tune, the more noticeable control surface oscillation may become if the flight speed continues to rise above the point of which the attenuation scaling limit is reached, becauseapa_powisn't set correctly.
NOTE : Do not make adjustments of more than 10 at a time. -
fw_tpa_time_constantis not used for airspeed based dynamic PID adjustment.
Example of a Fixedwing APA curve
This plot shows how adjusting apa_pow alters the scaling of the gains across the airplanes whole speed envelope.
Take note of the airspeed at which the gain scaling limits will be reached, depending on the relationship between fw_reference_airspeed and apa_pow.
Altering either will mathematically change the points in the speed curve at which the attenuation and boost scaling limits are reached.
Fixedwing TPA and Pitch Angle
This method uses the throttle position, combine with the airplanes climb or dive angle, to determine the optimal dynamic PIDFF gain adjustments required.
INAV 9.0
Settings :
-
TPA_rate- is the amount of scaling apply to the dynamic PID adjustment. Range0 - 200
200%TPA_rateallows the base PID tune to be scaled by a factor of[2x boost]100% increase of the base gain tune -[0.4 attenuation]60% reduction of the base gain tune. See plot -
TPA_breakpoint- is the throttle value when the base PID tune is not boosted or attenuated. This value should approximate the amount of throttle/thrust the airplane requires to hold its optimal cruise speed when flying in no wind, or a crosswind. Ideally you should aim for a throttle value that approximates the same speed as you have APAfw_reference_airspeedset. -
tpa_pitch_compensation- is used to calculate the collective effect pitch (gravity) will exert on-top of the raw throttle command, to reverse the way gains are dynamically adjusted in response to the throttle. Put simply - Boosted gains will begin to Attenuate, and Attenuated gains will begin to Boost under certain flight conditions.
Range0 - 20- default = 8
DECREASING its value will provide a weaker gravity induced pitch angle influence over the raw throttle, and therefor the gains.
While INCREASING it will provide a stronger pitch angle influence over the raw throttle. See plot
[!Note] Setting
tpa_pitch_compensation = 0causes fixedwing TPA to work as it did in pre-9.0 software. Which isn't desirable.
fw_tpa_time_constant- is a smoothing and time delay constant, reflecting the non-instantaneous speed response of an airplane to throttle changes, based on relative drag, inertia and thrust. Range0 - 5seconds
This asymmetric filter accounts for throttle adjustments and the influence gravity has upon speed during a climb or dive.
An airplane that is very aerodynamic is slower to wash-off speed when the throttle is lowered, or when a climb is commanded. This generally requires a higher time constant value.
While an airplane that is under powered, will take longer for the speed to rise after the throttle is increased; also requiring a higher time constant.
The only time you may need to decrease the time constant. Is if your airplane is over powered and also has a very high drag coefficient.
FUNCTION :
The Stick or Nav throttle input is used collectively with the climb/dive angle, to more accurately attenuation or boost the gains if the airspeed source fails. Or if you choose not to fly with an airspeed source.
The dynamic PID attenuation/boost strength is determined by how high you set TPA_rate.
Because this method accounts for the pitch angle. It can override the conventional throttle based gain adjustments, according to the effect gravity has on the airplane in a climb or a dive. i.e. The airplane will either speed up in a fall, or slow down in a climb; which throttle position alone can not determine.
Example :
If your airplane is flying level at 80% throttle, the gains will have some attenuation applied to them at that airspeed to prevent control oscillations.
But if you then pull back on the elevator stick, so the airplane starts climbing at a high angle. The vertical airspeed will generally start to wash-off if your airplane is not over powered. Leading to a transition from the gain attenuation to mild gain boost. This will tighten the gains as the airplane slows closer to a stall, even when the throttle is higher.
The same applies if the airplane is placed into a low throttle steep downward dive.
When using the old TPA method, having the throttle low in this case would cause the gains to boost. But because this method knows the airplane is in a dive, it will override the raw throttle command and start attenuating the gains to prevent oscillations; because the airplanes free-fall speed is increasing, irrespective of the throttle.
How to use this?
-
If you have NOT already loaded the Configurator platform type defaults. You should increase the
TPA_Ratefrom the Setting default of zero, to a conservative value of 80% when you're tuning the base gains. So it allows some dynamic PID adjustment to occur. Otherwise a tight base gain tune around theTPA_breakpointwill begin causing oscillations if you increase the throttle/speed. -
If you haven't already tuned your airplane. Make sure you complete an AutoTune with the default PID gains. Otherwise you can use the tune you already have.
-
Set
TPA_breakpointto the approximate throttle value your airplane will comfortably cruise at, when flying in no wind. This should approximate the same speed as you have APAfw_reference_airspeedset.
[!Tip] If you have already tuned your base PID gains firmly using the APA function. You do not need to re-tune them again, as stated in the next step.
-
While inflight you can start increasing the P and D gains around the throttle value you have
TPA_breakpointset. Keep an eye on the OSD airspeed indicator. Make sure it doesn't wonder too far from the approximate speed, which correlates to holding the throttle stick position you set for theTPA_breakpoint. This is better done on a day with little wind. -
Once you have the
TPA_breakpointbase PID gains tuned firmly, but not tight. Push the throttle upwards toward full and let the speed increase. If oscillations start to occur. Incrementally increase theTPA_rateuntil they are gone.
Now when your flying at lower throttle, your airplane should feel tighter in its stabilization response. And when flying at higher throttle (up to full throttle), the control surfaces should not oscillate. -
Due to drag also effecting how fast a given airplane will gain or lose speed.
fw_tpa_time_constantmay require adjustment to account for the time it takes for the speed to ramp up or ramp down, based on climb or dive pitch angle, or a fast throttle stick command. -
If your airplane has a high thrust to weight ratio and can climb at a high angle and at high speed. It can be beneficial to start incrementally decreasing
tpa_pitch_compensation. This will reduce the effect pitch angle has over raw throttle. Thus preventing the gains for being inversely boosted too much in a high speed climb, reducing the likelihood of control surface oscillations.
The same will apply in a lower throttle dive, if you feel the gains are being attenuated too much. You can also incrementally reducetpa_pitch_compensation.
NOTE : I wouldn't recommend going lower than 5 in either case, unless your airplane is very fast. Or is powerful, but not very aerodynamic. Otherwise it will reduce the effect pitch angle scaling has over throttle in a high speed dive. See plot
Example of a Fixedwing TPA curve
This plot shows how adjusting the TPA_rate will effect the scaling of the gains at different points in the throttle/speed range.
Example of a Fixedwing TPA + pitch angle
This plot shows the collective effect pitch angle and raw throttle have on PID scaling. And the influence which lowering tpa_pitch_compensation has on those gains, to prevent oscillations on powerful planes while in a sustained high speed climb. The plot also shows a slight increase in the gains while in a dive at lower throttle. This is why reducing tpa_pitch_compensation below 5 is not recommend. Especially if your airplane is very aerodynamic.
Fixedwing TPA
Before INAV 9.0
Settings :
-
TPA_Rate- the amount of scaling apply to the PIDs. 100% TPA_Rate allows the base PID tune to be scaled by a limiting factor of[2x boost]-[0.5 attenuation]. -
TPA_breakpoint- is the point in the throttle curve when the base PID tune is not boosted or attenuated. -
fw_tpa_time_constant- is a smoothing and time delay constant, reflecting the non-instantaneous speed response of an airplane to throttle changes, based on drag and inertia.
FUNCTION :
The Throttle stick position is used to not only attenuate the PID gains in the higher throttle range, above the TPA_Breakpoint. But also boosts them in the lower throttle range, below the TPA_breakpoint, for tighter stabilization control when flying or gliding at lower speeds with minimal or no throttle.
How to use this?
-
Tune your PIDs to the throttle range you intend to fly your airplane. nav_fw_cruise_thr is ideal. Set that value as the
TPA_breakpoint. e.g. 1400 - 1480uS -
Once your P and D gains are tuned, and before you add any
TPA_Rate. You may notice when flying at lower throttle, your airplane handles more loosely. And when flying at higher throttle (up to full throttle) control surfaces may begin to oscillate.
You can now start increasing theTPA_Ratevalue until those oscillations are gone or minimal in the higher throttle/speed range. This will also translate to better handling at lower throttle/speeds, by boosting the PID gains.
[!NOTE] The above method had its limitations. It can not attenuate the PIDs at lower throttle values if the airplane is placed into a dive, causing the air-speed to increase. This could lead to control surface oscillations.