Skip to content
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

Update D_CUT to D_MIN, add setpoint input, change nomenclature #7538

Merged
merged 1 commit into from Feb 9, 2019

Conversation

Projects
None yet
5 participants
@ctzsnooze
Copy link
Contributor

ctzsnooze commented Feb 5, 2019

This is an incremental improvement to the original D_Cut proposal, based on user feedback.

Lots of thanks and full credit to JoeLucid for the original boost ideas and his ongoing support and encouragement.

Changes:

  • D boost cannot exceed the user's set D value; that D value becomes a 'max'
  • User can directly and easily set their intended minimum value for D on pitch and roll.
  • Boost to the primary D setting is generated from gyro or setpoint input, whichever is higher.
  • Setpoint input is stick derived, faster by 10ms approx, and does not respond to propwash.
  • Gyro input is motor derived and slower, but responds to propwash
  • Code boosts by max of setpoint or gyro input
  • d_min_advance value is a percentage setpoint multiplier, sets how much can be added
  • d_min_boost_gain value sets overall sensitivity
  • default D mins are 20 roll 22 pitch
  • default D is 35 38, if undefined then normal D values
  • previous range and smoothing lowpass values are now constants in pid.c

Tuning:

  • adjust D value for desired overshoot control; higher P and D than usual can be used if needed
  • tune D min to a lower value to control noise, noting that lower values mean cooler motors but perhaps more propwash.
  • in propwash, boost typically allows an increase to about ⅓ way towards max D. The d_min value, primarily, dictates propwash.
  • higher d_min_advance values will bring the D boost in earlier. Usually only needed for very high rate overshoot (ie >1300 deg/sec), or overshoot in heavier freestyle builds, e.g. where there is a significant delay between setpoint change and motor response.

Logging

  • set debug_mode = D_MIN logs the boost factor for gyro and setpoint into debug 0 and 1, and logs the actual 'realtime' D value (times 10), into debug 2 and 3.

Disabling / rendering ineffective

  • D_min >= Dmax
  • D_min = 0

@ctzsnooze ctzsnooze requested review from mikeller and etracer65 and removed request for mikeller Feb 5, 2019

@fujin
Copy link
Member

fujin left a comment

tested OK - some minor things need fixing up.

Show resolved Hide resolved src/main/cli/settings.c Outdated
Show resolved Hide resolved src/main/flight/pid.c Outdated
Show resolved Hide resolved src/main/flight/pid.c Outdated
Show resolved Hide resolved src/main/flight/pid.h Outdated
Show resolved Hide resolved src/main/flight/pid.h Outdated
@ctzsnooze

This comment has been minimized.

Copy link
Contributor Author

ctzsnooze commented Feb 5, 2019

A note about defaults...
D_CUT users noticed propwash was typically worse, but motor temps better, and often didn't increase D as much as they could and perhaps should have. Also the default gain and timing values resulted in not as much boost during propwash as these defaults.

Propwash should not be so negatively impacted by this code, but with the proposed defaults, which are a bit 'soft', it may be.Users can, and probably should, use a bit more P and a bit more D than 'normal'.

During propwash events, D will be boosted by about ⅓. With defaults, D on roll is 35 and d_min is 20. D would be about 25 during propwash, a bit less than usual default D of 30.

A D of 40 with d_min of 25 would make D closer to default during propwash, and would make suitable alternative values. However for the more modern powerful quads, those values may be a bit higher than ideal, hence the 'softer' defaults.

@mikeller
Copy link
Member

mikeller left a comment

Just cosmetic remarks.

Show resolved Hide resolved src/main/cli/settings.c Outdated
Show resolved Hide resolved src/main/flight/pid.c Outdated
Show resolved Hide resolved src/main/flight/pid.c Outdated

@mikeller mikeller added this to the 4.0 milestone Feb 6, 2019

@McGiverGim

This comment has been minimized.

Copy link
Member

McGiverGim commented Feb 6, 2019

I suppose that the wiki will be updated after merged ;) https://github.com/betaflight/betaflight/wiki/d_cut

Show resolved Hide resolved src/main/flight/pid.c
@etracer65
Copy link
Member

etracer65 left a comment

I think it probably short-sighted to exclude yaw D from this. We fully support D on yaw so it doesn't make sense to exclude. The code can take into account cases where D gain == 0 for an axis and avoid initialization and calculation for these cases.

@ctzsnooze

This comment has been minimized.

Copy link
Contributor Author

ctzsnooze commented Feb 7, 2019

D_min is now fully integrated for yaw also.

Show resolved Hide resolved src/main/flight/pid.c Outdated
Show resolved Hide resolved src/main/flight/pid.c
Show resolved Hide resolved src/main/flight/pid.c Outdated
Show resolved Hide resolved src/main/flight/pid.c Outdated
Show resolved Hide resolved src/main/flight/pid.c Outdated
Show resolved Hide resolved src/main/cms/cms_menu_imu.c
@ctzsnooze

This comment has been minimized.

Copy link
Contributor Author

ctzsnooze commented Feb 8, 2019

A general question - should the D_min values appear in the OSD, on the same screen as the other PIDs, alongside the primary D (max) values?

@etracer65

This comment has been minimized.

Copy link
Member

etracer65 commented Feb 8, 2019

I would suggest keeping them separate from the main PID values for now.

@kmitchel kmitchel force-pushed the ctzsnooze:D_Cut_Setpoint_DMin branch from b7f32f1 to 7fed41a Feb 8, 2019

@ctzsnooze ctzsnooze force-pushed the ctzsnooze:D_Cut_Setpoint_DMin branch from 7fed41a to b7f32f1 Feb 8, 2019

Show resolved Hide resolved src/main/flight/pid.c
Show resolved Hide resolved src/main/flight/pid.c Outdated

@ctzsnooze ctzsnooze force-pushed the ctzsnooze:D_Cut_Setpoint_DMin branch 2 times, most recently from 5a264a0 to fc24145 Feb 8, 2019

Show resolved Hide resolved src/main/flight/pid.c Outdated

@ctzsnooze ctzsnooze force-pushed the ctzsnooze:D_Cut_Setpoint_DMin branch from a20d3d0 to 3b23261 Feb 9, 2019

@fujin
Copy link
Member

fujin left a comment

looks good pending flight test, loading up rigs now.

@fujin
Copy link
Member

fujin left a comment

flight tested OK. very intuitive behavior. ended up with 'normal' D's @ 35/38, and d min 12/15, with d min boost gain 25.

float dMinFactor = 1.0f;
#if defined(USE_D_MIN)
if (dMinPercent[axis]) {
float dMinFactor = 1.0f;

This comment has been minimized.

@fujin

fujin Feb 9, 2019

Member

there's probably no harm from this, but now that it's also done at L1359, we don't need it here.

This comment has been minimized.

@etracer65

etracer65 Feb 9, 2019

Member

Actually there is harm in this. The second declaration will only be in the scope of the if (dMinPercent[axis]) { block and calculated dMinFactor will lose scope below it and the D calculation will always use 1.0.

This comment has been minimized.

@ctzsnooze

ctzsnooze Feb 9, 2019

Author Contributor

Thanks eTracer for looking so closely into this, and fixing so many potential issues - I really do appreciate your advice and the time you take on these things.

@ctzsnooze ctzsnooze force-pushed the ctzsnooze:D_Cut_Setpoint_DMin branch from 7aabf16 to 0d52929 Feb 9, 2019

Update D_CUT to D_MIN, add setpoint
Directly and easily set the minimum value for D on pitch and roll.
- Boost back to the primary D setting is generated from gyro or setpoint inputs.
- Setpoint input is stick derived, faster by 10ms approx, and does not respond to propwash.
- Gyro input is motor derived and slower, but responds to propwash
- timing value sets balance between gyro (100) and setpoint (0) boost factors
- gain value sets overall sensitivity
- default D mins are 20 roll 22 pitch
- default D is 35, 38; if undefined then normal 30, 32 values
TUNING
- D value to flip overshoot control
- D_min to noise, lower values mean cooler motors but perhaps more propwash.
- Advance, higher values bring the boost in earlier, and stronger overall, useful for very high flip rates, but dampen stick responsiveness slightly.
- Gain value adjust against logs, checking maximal boost with flips and some rise with propwash, should be edging to get up from the min value in normal flight.

@ctzsnooze ctzsnooze force-pushed the ctzsnooze:D_Cut_Setpoint_DMin branch from 0d52929 to b70d34f Feb 9, 2019

@mikeller mikeller merged commit ca98ee7 into betaflight:master Feb 9, 2019

@ctzsnooze ctzsnooze deleted the ctzsnooze:D_Cut_Setpoint_DMin branch Mar 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.