From e4846f2ecc4a0df2e25522287e86d84556a43ead Mon Sep 17 00:00:00 2001 From: supiiik Date: Tue, 22 May 2018 19:59:47 +0200 Subject: [PATCH] New calculation for DTERM setpoint weight I'm flying race with betaflight and on all my race quads I have setpoint on maximum value 2.54. But I feel, that it's not enough. This calculation of setpoint is almost same as old method up to number 2.0 (previously 2.54) but numbers above 2.0 have more aggresive impact on Dterm RC stick commands. With this calculation i found, that value 2.3 is fine for me. 2.3 is equivalent to 6,35 with old calculation method (which was not possible of course, because there is 8bit limit). With higher values have quad much sharper responses and feel more "locked in". I think, that most freestyle pilots have setpoint at values around 1, so there is almost no change and race pilots using higher values and for those, who are limited by the value 2.54 (like me and my friends) should be solution new setpoint calculation method. This is my first pull request to betaflight, so I hope, that I did everything well according your rules --- src/main/flight/pid.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 10859b5dcc..55e3d99cc1 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -317,7 +317,10 @@ void pidInitConfig(const pidProfile_t *pidProfile) pidCoefficient[axis].Kd = DTERM_SCALE * pidProfile->pid[axis].D; } - dtermSetpointWeight = pidProfile->dtermSetpointWeight / 127.0f; + dtermSetpointWeight = pidProfile->dtermSetpointWeight / 100.0f; + if (dtermSetpointWeight > 2.0f) { + dtermSetpointWeight = 10 * (dtermSetpointWeight - 2.0f) + 2.0f; + } if (pidProfile->setpointRelaxRatio == 0) { relaxFactor = 0; } else {