Skip to content

Additional TPA breakpoint for low Throttle #13006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 4, 2023

Conversation

pichim
Copy link
Contributor

@pichim pichim commented Aug 4, 2023

Extension of the current TPA curve to lower the TPA factor for low throttle.

I have observed that the quadcopter can produce rough sounds up to jumping around when a higher loop gain is applied. During flight, these PID and filter settings behave fine and provide sufficient robustness margins, and the motor traces appear acceptable.

I attempted to address this issue through the use of dynamic filters and dynamic D gain; however, I discovered that using static filter and static D term settings result in better flight performance, particularly for handling prop wash.

During testing it was beneficial to extend the TPA curve by reducing the TPA factor for low throttle levels to resolve the quads issues after arming.

  • It's just a proposal
  • Needs testing
  • Default values need TBC

Update 13.11.2023

According to @haslinghuis proposal the name of all *_vanish parameters where changed to *_fade.

Parameters

Name Default Value Range Short Explanation
tpa_rate_lower 20 0 - 100 Percent reduction in P or D at zero throttle
tpa_breakpoint_lower 1050 1000 - 2000 Breakpoint where lower TPA is deactivated
tpa_breakpoint_lower_fade ON ON, OFF off, on - if on lower TPA is only active until tpa_breakpoint_lower is reached the first time

Update 19.08.2023:

Included tpa_breakpoint_lower_vanish option so that the lower TPA curve vanishes with air mode. If this is set to ON the the TPA curve starts at 0 with the value 100 - tpa_rate_lower and increases linear to 100 until 'airmode_start_throttle_percent * 10 + 1000' is reached. TPA lower is only active if air mode is disabled. This means after throttle is over airmode_start_throttle_percent once TPA lower will no longer be active and the user has full PID strength at low throttle.

  • With the vanishing option ON it just prevents the quad from beeing jumpy at zero throttle until you activate air mode via switch or increase throttle and reach 'airmode_start_throttle_percent`
  • With the vanishing option OFF PID gains are reduces accordingly over the hole flight

Also want to thank @SupaflyFPV and @KarateBrot for the discussions, the testing and helping with with the code itself.

Update 31.08.2023:

Removed dependency from TPA lower with the vanish option ON and airmode_start_throttle_percent. The behavior of TPA is now dependent only on the three parameters listed below.

Parameters

Name Default Value Range Short Explanation
tpa_rate_lower 20 0 - 100 Percent reduction in P or D at zero throttle
tpa_breakpoint_lower 1050 1000 - 2000 Breakpoint where lower TPA is deactivated
tpa_breakpoint_lower_vanish ON ON, OFF off, on - if on lower TPA is only active until tpa_breakpoint_lower is reached the first time

Propposed Default TPA Curve

tpa_lower_curve

Measured Sensitivity Function Roll-Axis

tpa_lower_sensitivity_roll

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Do you want to test this code? You can flash it directly from Betaflight Configurator:

  • Simply put #13006 (this pull request number) in the Select commit field of the Configurator firmware flasher tab (you need to Enable expert mode, Show release candidates and Development).

WARNING: It may be unstable. Use only for testing!

@blckmn
Copy link
Member

blckmn commented Aug 4, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> PASS
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> PASS
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> PASS
  • Tested label found -> FAIL
  • assigned to an approver -> FAIL
  • approver count at least three -> FAIL

@SupaflyFPV
Copy link
Contributor

SupaflyFPV commented Aug 18, 2023

this is a great idea, due to the high PIDs which pilots are now using with modern tuning methods, and trying to chase the last 5% propwash with highest PIDs possible. With PIDs at full strength at rest/0 throttle this yeilds a lot of noise on arming, and a Tasmanian devil of a touchy quad which requires some distance and care....

This is an example of the PR being tested with 0% low TPA, 20% TPA and 50% TPA

The 50% was used with a 'Vanish' option which switched off the TPA after the airmode activation point was reached - a great feature allowing more docile low TPA settings, whilst in flight the full PID strength was returned...

PTB_FIGS_2023-08-16-2

I have also flight tested with 0, 20, 30 and 40% TPA active in flight - with hard stop moves at 0 throttle. 40% was noticable but lower levels may not be depending on the PIDs of the quad.

40 TPA Roll 30 TPA Roll 20 TPA Roll 0 TPA Roll

@pichim
Copy link
Contributor Author

pichim commented Aug 19, 2023

@SupaflyFPV thanks for testing and sharing your findings :-)

Rebase on master and update comment

Make TPA lower independent from air mode

Included tpa_breakpoint_lower_vanish option

Changes according to PR comments

Corrected comment for API version

Bugfix in msp.c

Additional TPA breakpoint for low throttle
@ctzsnooze
Copy link
Member

ctzsnooze commented Dec 4, 2023

It may be easier to enable/disable via CLI, and perhaps more functionally clear, to re-name the CLI values:

  • TPA_LOW_RATE = Percent cut when throttle is below TPA_LOW_BREAKPOINT
  • TPA_LOW_BREAKPOINT = Breakpoint for the low throttle TPA reduction
  • TPA_LOW_ARM_ONLY= Whether TPA_LOW effect is only active only until takeoff

Not sure about TPA_LOW_ARM_ONLY. Tough to think of a good name. TPA_LOW_UNTIL_TAKEOFF is most intuitive, but is a bit long.

TPA_LOW_MODE is easy, but doesn't explain it.
Other options... TPA_LOW_ALWAYS or TPA_LOW_AFTER_TAKEOFF or TPA_LOW_IN_FLIGHT with reversed logic.

I tend to like TPA_LOW_IN_FLIGHT since when true we are confirming we want it to continue while we fly.

PS: Why do we need a separate threshold, other than just using the existing air mode threshold, to disable TPA_LOW if the user wants it only briefly at arming?

@SupaflyFPV
Copy link
Contributor

SupaflyFPV commented Dec 4, 2023

It may be easier to enable/disable via CLI, and perhaps more functionally clear, to re-name the CLI values:

  • TPA_LOW_RATE = Percent cut when throttle is below TPA_LOW_BREAKPOINT
  • TPA_LOW_BREAKPOINT = Breakpoint for the low throttle TPA reduction
  • TPA_LOW_ARM_ONLY= Whether TPA_LOW effect is only active only until takeoff

Not sure about TPA_LOW_ARM_ONLY. Tough to think of a good name. TPA_LOW_UNTIL_TAKEOFF is most intuitive, but is a bit long.

TPA_LOW_MODE is easy, but doesn't explain it. Other options... TPA_LOW_ALWAYS or TPA_LOW_AFTER_TAKEOFF or TPA_LOW_IN_FLIGHT with reversed logic.

I tend to like TPA_LOW_IN_FLIGHT since when true we are confirming we want it to continue while we fly.

PS: Why do we need a separate threshold, other than just using the existing air mode threshold, to disable TPA_LOW if the user wants it only briefly at arming?

I see what you mean

Could be

TPA_LOW_FOR_ARM
TPA_LOW_ON_ARM
?
TPA_LOW_UNTIL_ARM - is ok IMO too and clearest

The seperate threshold was created (used airmode initially) in order to remove the dependency for the feature on airmode. There may be situations where airmode is on a switch or off which complicates...if I remember correctly...

@haslinghuis
Copy link
Member

I am using AIRMODE on a switch (as some might be using Idle Up settings)

@pichim
Copy link
Contributor Author

pichim commented Dec 4, 2023

hey guys, thx for the feedback.

given names:
following a tip from @KarateBrot I named the parameters:

  • tpa_rate_lower, tpa_breakpoint_lower
    so that when you use get tpa_rate in CLI or search for tpa_rate in your dev environment you find both parameters, so tpa_rate and tpa_rate_lower (same idea for tpa_breakpoint) which i found practical.
  • tpa_breakpoint_lower_fade @haslinghuis proposed the name fade for the switch logic. i don't care that much about the name but found tpa_breakpoint_lower_fade a descriptive name. i also like "TPA_LOW_FOR_ARM" or "TPA_LOW_ARM_ONLY". just tell me what you want : - ) and i will change it.

dependency to air mode:
as @SupaflyFPV statet this is what we experimented initially. but i thought its maybe a good idea not to create a dependency.

i assume honestly this PR will mainly be used to tame the quad after arming until take-off for aggressive gains and / or filter settings.

pichim and others added 2 commits December 4, 2023 16:16
Co-authored-by: Jan Post <Rm2k-Freak@web.de>
Co-authored-by: Jan Post <Rm2k-Freak@web.de>
@KarateBrot KarateBrot merged commit 13d1dc8 into betaflight:master Dec 4, 2023
@ctzsnooze
Copy link
Member

@pichim please clarify what exactly tpa_rate_lower achieves, in the table above.
Does a value of 20 mean that TPA reduces D to 20% of normal, or does it mean a 20% reduction from normal.
Please edit the table at the top to clarify this, and maybe tidy up the on/off note.

@@ -237,6 +237,9 @@ typedef struct pidProfile_s {
uint8_t angle_feedforward_smoothing_ms; // Smoothing factor for angle feedforward as time constant in milliseconds
uint8_t angle_earth_ref; // Control amount of "co-ordination" from yaw into roll while pitched forward in angle mode
uint16_t horizon_delay_ms; // delay when Horizon Strength increases, 50 = 500ms time constant
uint8_t tpa_rate_lower; // Percent reduction in P or D at zero throttle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure the comment is absolutely clear. For example, does a value of 20 mean that the TPA effect will cut D to 20% of normal, or result in D that is 80% normal, at zero throttle?
Currently, TPA high of 80 will cut the D to 20% of normal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey chris, since tpa lower is just an extension of tpa I basically copied the logic of how it is applied and adjusted the description according to tpa_rate and tpa_breakpoint. default values in the table above are now correct and the red line in the figure represents the defaults. maybe @SupaflyFPV has some clearer explanations?

Copy link
Member

@KarateBrot KarateBrot Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pichi is very clear in his comment here. "Percent reduction" means that with a value of 20 you will get 20% reduction/attenuation, or 80% of your original value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah its the same as TPA_RATE. It follows the same logic, just for the LOWER breakpoint. 👌

freasy pushed a commit to freasy/betaflight that referenced this pull request Jan 22, 2024
* Removed white spaces and everything that is not new

Rebase on master and update comment

Make TPA lower independent from air mode

Included tpa_breakpoint_lower_vanish option

Changes according to PR comments

Corrected comment for API version

Bugfix in msp.c

Additional TPA breakpoint for low throttle

* Changes according to PR comments

* Update src/main/cms/cms_menu_imu.c

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

* Update src/main/flight/pid_init.c
@limonspb
Copy link
Member

limonspb commented Jan 28, 2024

Hey @pichim
i was going through the code and noticed this:
{ "TPA RATE LOW", OME_FLOAT, NULL, &(OSD_FLOAT_t) { &cmsx_tpa_rate_lower, 0, 100, 1, 10} },
is there a reason why its FLOAT here?
Because it is declared like this:
static uint8_t cmsx_tpa_rate_lower;
what am i missing? And what means the last "10" before the brackets close?

@pichim
Copy link
Contributor Author

pichim commented Jan 28, 2024

@limonspb tbh, i have no idea : - ) i just copied how it was already done for tpa

@haslinghuis
Copy link
Member

@limonspb please fix it :)

@nerdCopter
Copy link
Member

i think 10 is the increment size @limonspb. needs verification, however.

@limonspb
Copy link
Member

@limonspb please fix it :)

:)
#13337

davidbitton pushed a commit to davidbitton/betaflight that referenced this pull request Feb 5, 2024
* Removed white spaces and everything that is not new

Rebase on master and update comment

Make TPA lower independent from air mode

Included tpa_breakpoint_lower_vanish option

Changes according to PR comments

Corrected comment for API version

Bugfix in msp.c

Additional TPA breakpoint for low throttle

* Changes according to PR comments

* Update src/main/cms/cms_menu_imu.c

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

* Update src/main/flight/pid_init.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

10 participants