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

D_CUT #7373

Merged
merged 1 commit into from Jan 13, 2019

Conversation

Projects
None yet
4 participants
@ctzsnooze
Copy link
Contributor

ctzsnooze commented Jan 11, 2019

This code cuts D by a specified percentage durning normal flight, and lets D smoothly rise back to normal with rapid gyro moves like flips and rolls. D will also increase little bit during prop wash events.
Users can now tune D in the 'normal' 35-40 range like in 3.5, but have the benefit of less D unless it is needed.

For example, if D is 40, a d_cut_percentage of 65 will cut D to 14 in normal flight, but the quad will still get full 40 of D to control bounce-back after flips and about 25 of D during strong prop wash.
The d_cut_percentage can be adjusted via the OSD, from the D filtering page.

Adding d_cut results in cooler motors, lower amounts of noise in motor traces in normal flight, and faster reactions to quick stick inputs.

Too much d_cut_percentage may result in not enough D generally, bringing out P oscillation if P is tuned quite high, but this has not been an issue to date.

Input to the boost signal is gyro differential (from gyro delta in the pid loop) with frequencies above 40hz (above propwash) attenuated with a configurable cutoff biquad filter (d_cut_range_hz). Lower values of d_cut_range_hz, but probably not less than 30hz, can be used, if the quad is very noisy or gets low frequency D resonant oscillation. Up to 50 or 60hz may be better on clean quads where prop wash control is the main priority. Too high results in D being boosted from noise in normal flight.

The boost signal is 'integrated, smoothed and delayed' with a 7hz PT1 'd_cut_lowpass_hz' filter. The default of 7Hz gives about the right amount of smoothing and delay. Higher numbers cause the boost to come on faster, with less delay, but this is not usually desirable, since then the D boost starts to interfered with stick responsiveness, and can make the boost wobble around more than one might like. This parameter could be removed from the CLI if users find the default is fine.

The gain control amplifies the input to the boosting effect. Logging with set debug_mode = D_CUT allows recording of realtime D values on roll and pitch into debug 2 and 3. If the user has quicker thumbs or a fast reacting quad, the gain control can be reduced. Ideally the gain hits max D and sort of flat tops the boost around the time D would naturally peak. Gain of 13 seems pretty good on most test machines.

Typically this code doesn't do much except in the context of very rapid gyro moves, such as flips.

For freestylers it allows quite high D, snappy entry into moves, and soft exits. For racers I would not push D so high as a freestyler might. That's because with repetitive fast inputs d will remain boosted and may dampen responsiveness, or smooth things out, a bit more than you might like, e.g. in slaloms or rapid zig-zags. That's about the only downside. Some people might like this, I don't know. But the solution is to not go crazy on how high to push D, e.g. use D of say 30 with cut of 50% say.

This code works well with around 50% of D cut on TPA also, leaving as little as 6 of D on full throttle. Unless P is over-tuned, this hasn't seemed to be a problem, and definitely cuts motor noise on full throttle significantly. This has been tested by the usual suspects and a few ring-ins, so far all responses have been positive.

The downside is extra CPU from one more biquad and one more PT1, both at PID loop speed.

I am sure the coding can be improved and will be grateful for any suggestions to make it more efficient.

@ctzsnooze

This comment has been minimized.

Copy link
Contributor Author

ctzsnooze commented Jan 11, 2019

A significant detail is that the default D values are back up to high values, since the Cut is enabled by default, which allows using relatively high D like we enjoyed in the past once again. I'd be grateful for advice on whether these values are too high or not. They should be fine on new installations if the cut is enabled for the target, but some targets won't support d_cut, and then they may well be too high.
Back in 3.2 we had D of 30 on Roll and 35 on Pitch, we now have them lower at 25 and 27, but many pilots would quite like higher D values if possible.
I'm proposing 44 and 47, which perhaps may be a little on the high side.
Maybe we could test like this, and then, based on more user feedback, see if this will be OK?

@mikeller mikeller added this to the 4.0 milestone Jan 12, 2019

Show resolved Hide resolved src/main/flight/pid.h Outdated
Show resolved Hide resolved src/main/flight/pid.h
@mikeller

This comment has been minimized.

Copy link
Member

mikeller commented Jan 12, 2019

This is overflowing RAM on LUXV2_RACE, so it needs to be either disabled for LUXV2_RACE, or only enabled for >= F4.

Show resolved Hide resolved src/main/target/LUX_RACE/target.h Outdated
Show resolved Hide resolved src/main/cms/cms_menu_imu.c
DTERM_CUT
This code cuts D by a specified percentage durning normal flight.

It lets D smoothly rise up to normal during rapid gyro moves like flips and rolls, and increase during prop wash events.

D should now be tuned to values the 'normal' 30-45 range.

If D is 40, a dterm_cut_percentage of 65 will cut D to 14 in normal flight, but the quad will still get full 40 of D to control bounce-back after flips and about 25 of D during strong prop wash.

The dterm_cut_percentage can be adjusted via the OSD, from the D filtering page.
Adding d_cut results in cooler motors, lower amounts of noise in motor traces and faster reactions to quick stick inputs.

Too high a dterm_cut_percentage may bring out P oscillation from lack of D.  Values of 70% are generally OK.

Input is gyro differential (delta).  Frequencies above 40hz (above propwash) are attenuated with a configurable (dterm_cut_range_hz) biquad filter.  Lower values for range can be used if the quad is very noisy or gets low frequency D resonant oscillation.  Up to 50 or 60hz may suit clean quads where prop wash control is the main priority.  Too high a range value results in D being boosted from noise in normal flight.

The boost signal is 'integrated, smoothed and delayed' with a 7hz PT1 'dterm_cut_lowpass_hz' filter.  The default of 7Hz gives about the right amount of smoothing and delay.  Higher numbers cause the boost to come on faster, with less delay. Lower values delay the boost effect and cause it to last longer.

The dterm_cut_gain amount controls the strength of the boost effect by amplifying the input to the boosting effect.  If the quad is flow gently, a higher gain value may be needed to gain full boost.

Logging with set debug_mode = D_CUT allows recording of realtime D values on roll and pitch into debug 2 and 3.  The reatime D value should reach its set maximum during rapid turns, ideally at about the time D itself peaks.  If it fails to reach the maximum, gain should be increased.

The D_Cut feature is not enabled on LUXV2RACE, OMNIBUS, SPRACINGF3NEO because there isn't enough flash space.

@ctzsnooze ctzsnooze force-pushed the ctzsnooze:D_CUT branch from 51a2abe to 7e3e564 Jan 13, 2019

@ctzsnooze

This comment has been minimized.

Copy link
Contributor Author

ctzsnooze commented Jan 13, 2019

Rebased and squashed. Very slightly different defaults based on user feedback. Thanks to everyone who helped develop and test this code, especially George and Ken.

@mikeller mikeller merged commit c2ccf10 into betaflight:master Jan 13, 2019

@BrenLaw

This comment has been minimized.

Copy link

BrenLaw commented Jan 15, 2019

@ctzsnooze You mentioned this works well with TPA, but what about Thrust Linearization? Should people using Thrust Linearization still run lower D terms than the newly raised defaults?

@jcutcher01

This comment has been minimized.

Copy link

jcutcher01 commented Jan 15, 2019

I am running D=43 freestyle on Stingy and Alien frames. I look forward to testing this out.

@ctzsnooze ctzsnooze deleted the ctzsnooze:D_CUT 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.