-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PID Attenuation and scaling
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)
Settings :
-
TPA_Rate - percentage of PID attenuation that will occur when the throttle is increased above the
TPA_breakpoint. -
TPA_Breakpoint - the throttle micro-second value in the curve at which
TPA_Ratewill be applied. Below this value the PIDs are not attenuated at all.
- 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.

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 should also be tuned, due to it becoming a fall-back if the APA speed source fails.
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. -
apa_pow- Sets how aggressively the gains will be dynamically adjusted from the base PIDFF tune.
Increasing its value from the default of 120, will boost the gains more aggressively below thefw_reference_airspeed, and attenuate them more aggressively above thefw_reference_airspeed. Which will also cause the gain scaling factor to reach its limit at a lower maximum airspeed.
While decreasingapa_powwill provide less aggressive gain scaling, allowing attenuation/boost to occur over a broader speed range. See plot
Note
Setting apa_pow = 0 will disable this function and revert to using the TPA and Pitch Angle method instead.
If either GNSS data or the Pitot sensor data becomes untrusted. It will also revert back to the TPA and Pitch Angle method.
FUNCTION :
This method uses airspeed data to dynamically adjusts the PIDFF gains.
Airspeed can be obtained from either a Pitot airspeed sensor. Or Virtual airspeed, derived from 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 gains - [0.3 attenuation] 70% reduction of the base gains.
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 over tune your base PID gains. For the same reason, do not increase apa_pow too far above the default unless you have a slower airplane.
-
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 the airspeed value your airplane will comfortably cruise at, into the
fw_reference_airspeedsetting.[cm/s] -
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. -
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 faster airplane that encounters control surface oscillations at much higher speeds. You can decrease the value of
apa_pow. It will allow the dynamic gain attenuation to occur over a wider speed range. Which also prevents the boost scaling limit being reached too far above the planes minimum flight speed. Keep in mind. The strength or tightness of the base PID tune will also effect this. 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. See plot
NOTE : Do not make adjustments of more than 10 at a time. -
Also keep in mind that control surface throws as well as higher airspeed will influence the need to adjust
apa_pow.
If you have larger control surface throws, it may also require decreasing.
But if your airplane is very draggy and can't make it past 125km in a full throttle dive. You can increaseapa_powto provide a tighter stabilization response over the airplanes narrow flight speed envelope. -
fw_tpa_time_constantis not used for airspeed based dynamic PID adjustment.
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, depend 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/boost scaling limits are reached.
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.
200%TPA_rateallows the base PID tune to be scaled by a factor of[2x boost]100% increase of the base gains -[0.4 attenuation]60% reduction of the base gains. 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 will exert on-top of the raw throttle input, to reverse the way gains are dynamically adjusted. Put simply - Boost becomes Attenuation, and Attenuation becomes Boost under certain flight conditions.
The ideal value for this function is 8, which is the default.
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 = 0 allows it to work in way the old fixedwing TPA did. Which isn't really 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.
This filter accounts for rapid throttle movements and the effect gravity has upon speed in a climb or dive.
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 gain attenuation to 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.
-
You should increase the
TPA_Ratefrom the default, 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 the TPA_breakpoint will instantly cause oscillation if you increase the throttle/speed by too much. -
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/cruise speed your airplane will comfortably fly at. nav_fw_cruise_thr is ideal.
Tip
If you have already tuned your base PID gains tightly 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 boosted excessively at higher climb speeds, preventing 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. Other wise it may reduce the effect gravity induced pitch angle scaling has over TPA in a high speed dive. See plot
This plot shows how adjusting the TPA_rate will effect the scaling of the gains at different points in the throttle/speed range.
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.
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.
-
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.
INAV Version Release Notes
8.0.0 Release Notes
7.1.0 Release Notes
7.0.0 Release Notes
6.0.0 Release Notes
5.1 Release notes
5.0.0 Release Notes
4.1.0 Release Notes
4.0.0 Release Notes
3.0.0 Release Notes
2.6.0 Release Notes
2.5.1 Release notes
2.5.0 Release Notes
2.4.0 Release Notes
2.3.0 Release Notes
2.2.1 Release Notes
2.2.0 Release Notes
2.1.0 Release Notes
2.0.0 Release Notes
1.9.1 Release notes
1.9.0 Release notes
1.8.0 Release notes
1.7.3 Release notes
Older Release Notes
QUICK START GUIDES
Getting started with iNav
Fixed Wing Guide
Howto: CC3D flight controller, minimOSD , telemetry and GPS for fixed wing
Howto: CC3D flight controller, minimOSD, GPS and LTM telemetry for fixed wing
INAV for BetaFlight users
launch mode
Multirotor guide
YouTube video guides
DevDocs Getting Started.md
DevDocs INAV_Fixed_Wing_Setup_Guide.pdf
DevDocs Safety.md
Connecting to INAV
Bluetooth setup to configure your flight controller
DevDocs Wireless Connections (BLE, TCP and UDP).md\
Flashing and Upgrading
Boards, Targets and PWM allocations
Upgrading from an older version of INAV to the current version
DevDocs Installation.md
DevDocs USB Flashing.md
Setup Tab
Live 3D Graphic & Pre-Arming Checks
Calibration Tab
Accelerometer, Compass, & Optic Flow Calibration
Alignment Tool Tab
Adjust mount angle of FC & Compass
Ports Tab
Map Devices to UART Serial Ports
Receiver Tab
Set protocol and channel mapping
Mixer Tab
Set aircraft type and how its controlled
Outputs Tab
Set ESC Protocol and Servo Parameters
Modes Tab
Assign flight modes to transmitter switches
Standard Modes
Navigation Modes
Return to Home
Fixed Wing Autolaunch
Auto Launch
Configuration Tab
No wiki page currently
Failsafe Tab
Set expected behavior of aircraft upon failsafe
PID Tuning
Navigation PID tuning (FW)
Navigation PID tuning (MC)
EZ-Tune
PID Attenuation and scaling
Tune INAV PID-FF controller for fixedwing
DevDocs Autotune - fixedwing.md
DevDocs INAV PID Controller.md
DevDocs INAV_Wing_Tuning_Masterclass.pdf
DevDocs PID tuning.md
DevDocs Profiles.md
OSD and VTx
DevDocs Betaflight 4.3 compatible OSD.md
OSD custom messages
OSD Hud and ESP32 radars
DevDocs OSD.md
DevDocs VTx.md
LED Strip
DevDocs LedStrip.md
Programming
DevDocs Programming Framework.md
Adjustments
DevDocs Inflight Adjustments.md
Mission Control
iNavFlight Missions
DevDocs Safehomes.md
MultiWii Serial Protocol
MSP V2
MSP Messages reference guide
MSP Navigation Messages
INAV MSP frames changelog
Telemetry
INAV Remote Management, Control and Telemetry
MAVlink Control and Telemetry
Lightweight Telemetry (LTM)
Tethered Logging
Log when FC is connected via USB
Blackbox
DevDocs Blackbox.md
INAV blackbox variables
DevDocs USB_Mass_Storage_(MSC)_mode.md
CLI
iNav CLI variables
DevDocs Cli.md
DevDocs Settings.md
VTOL
DevDocs MixerProfile.md
DevDocs VTOL.md
TROUBLESHOOTING
"Something" is disabled Reasons
Blinkenlights
Sensor auto detect and hardware failure detection
Pixel OSD FAQs
TROUBLESHOOTING
Why do I have limited servo throw in my airplane
ADTL TOPICS, FEATURES, DEV INFO
AAT Automatic Antenna Tracker
Building custom firmware
Default values for different type of aircrafts
Source Enums
Features safe to add and remove to fit your needs.
Developer info
Making a new Virtualbox to make your own INAV[OrangeRX LRS RX and OMNIBUS F4](OrangeRX-LRS-RX-and-OMNIBUS-F4)
Rate Dynamics
Target and Sensor support
Ublox 3.01 firmware and Galileo
DevDocs Controls
DevDocs 1wire.md
DevDocs ADSB.md
DevDocs Battery.md
DevDocs Buzzer.md
DevDocs Channel forwarding.md
DevDocs Display.md
DevDocs Fixed Wing Landing.md
DevDocs GPS_fix_estimation.md
DevDocs LED pin PWM.md
DevDocs Lights.md
DevDocs OSD Joystick.md
DevDocs Servo Gimbal.md
DevDocs Temperature sensors.md
OLD LEGACY INFO
Supported boards
DevDocs Boards.md
Legacy Mixers
Legacy target ChebuzzF3
Legacy target Colibri RACE
Legacy target Motolab
Legacy target Omnibus F3
Legacy target Paris Air Hero 32
Legacy target Paris Air Hero 32 F3
Legacy target Sparky
Legacy target SPRacingF3
Legacy target SPRacingF3EVO
Legacy target SPRacingF3EVO_1SS
DevDocs Configuration.md
Request form new PRESET
DevDocs Introduction.md
Welcome to INAV, useful links and products
UAV Interconnect Bus
DevDocs Rangefinder.md
DevDocs Rssi.md
DevDocs Runcam device.md
DevDocs Serial.md
DevDocs Telemetry.md
DevDocs Rx.md
DevDocs Spektrum bind.md
DevDocs INAV_Autolaunch.pdf