From 6a4e6055060ac01389cd2bc40447a9d95c8c2ec0 Mon Sep 17 00:00:00 2001 From: Cleric-K <9365881+Cleric-K@users.noreply.github.com> Date: Wed, 6 Jun 2018 00:22:32 +0300 Subject: [PATCH 1/4] Support for 16-bit DTerm Setpoint Weight --- locales/en/messages.json | 2 +- src/js/msp/MSPHelper.js | 8 +++++++- src/js/tabs/pid_tuning.js | 4 ++++ src/tabs/pid_tuning.html | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index cda9f6f3..aa289e95 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1256,7 +1256,7 @@ "message": "With this parameter, D Setpoint Weight can be reduced near the center of the sticks, which results in smoother end of flips and rolls.
The value represents a point of stick deflection: 0 - stick centered, 1 - full deflection. When the stick is above that point, Setpoint Weight is kept constant at its configured value. When the stick is positioned below that point, Setpoint Weight is reduced proportionally, reaching 0 at the stick center position.
Value of 1 gives maximum smoothing effect, while value of 0 keeps the Setpoint Weight fixed at its configured value over the whole stick range." }, "pidTuningDtermSetpointHelp": { - "message": "This parameter determines the stick accelerating effect within derivative component.
Value of 0 equals to old Measuemenent method where D only tracks gyro, while value of 1 equals to old Error method with equal gyro and stick tracking ratio.
Lower value equals to slower/smoother stick response, while higher value provides more stick acceleration response.
Note that RC interpolation is recommended to be enabled with higher values to prevent control kicks making noise." + "message": "This parameter determines the stick accelerating effect within derivative component.
Value of 0 equals to old Measuemenent method where D only tracks gyro, while value of 1.27 equals to old Error method with equal gyro and stick tracking ratio.
Lower value equals to slower/smoother stick response, while higher value provides more stick acceleration response.
Note that RC interpolation is recommended to be enabled with higher values to prevent control kicks making noise.
Since BF3.4.0 you can set value up to 20 by entering it manually in the number box or through the CLI." }, "pidTuningDtermSetpointTransitionWarning": { "message": "$t(warningTitle.message):<\/strong> The use of a D Setpoint transition greater than 0 and less than 0.1 is highly discouraged. Doing may lead instability and reduced stick responsiveness as the sticks cross the centre point.<\/span>" diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 3067f42c..d48f71ec 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -864,6 +864,9 @@ MspHelper.prototype.process_data = function(dataHandler) { ADVANCED_TUNING.itermThrottleThreshold = data.readU16(); ADVANCED_TUNING.itermAcceleratorGain = data.readU16(); } + if (semver.gte(CONFIG.apiVersion, "1.39.0")) { + ADVANCED_TUNING.dtermSetpointWeight = data.readU16(); + } } break; case MSPCodes.MSP_SENSOR_CONFIG: @@ -1479,7 +1482,7 @@ MspHelper.prototype.crunch = function(code) { .push8(ADVANCED_TUNING.deltaMethod) .push8(ADVANCED_TUNING.vbatPidCompensation) .push8(ADVANCED_TUNING.dtermSetpointTransition) - .push8(ADVANCED_TUNING.dtermSetpointWeight) + .push8(Math.min(ADVANCED_TUNING.dtermSetpointWeight, 254)) .push8(ADVANCED_TUNING.toleranceBand) .push8(ADVANCED_TUNING.toleranceBandReduction) .push8(ADVANCED_TUNING.itermThrottleGain) @@ -1493,6 +1496,9 @@ MspHelper.prototype.crunch = function(code) { buffer.push16(ADVANCED_TUNING.itermThrottleThreshold) .push16(ADVANCED_TUNING.itermAcceleratorGain); } + if (semver.gte(CONFIG.apiVersion, "1.39.0")) { + buffer.push16(ADVANCED_TUNING.dtermSetpointWeight); + } } // only supports 1 version pre bf 3.0 else { diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index 743040f3..a055d9f8 100755 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -516,6 +516,10 @@ TABS.pid_tuning.initialize = function (callback) { $('.tab-pid_tuning .pidTuningFeatures').hide(); } + if (semver.lt(CONFIG.apiVersion, "1.39.0")) { + $('input[name="dtermSetpoint-number"]').attr('max', '2.54'); + } + // translate to user-selected language i18n.localizePage(); diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index 267aa287..6cd85bef 100755 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -294,7 +294,7 @@ - +
From 0fd9efd0c2c28cdfeec5a707e4b5531b96f54fca Mon Sep 17 00:00:00 2001 From: Cleric-K <9365881+Cleric-K@users.noreply.github.com> Date: Wed, 6 Jun 2018 10:05:28 +0300 Subject: [PATCH 2/4] Setting the "D From Error" point from 1.27 back to 1.0 Reflecting https://github.com/betaflight/betaflight/pull/6052 --- locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index aa289e95..04c858fb 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1256,7 +1256,7 @@ "message": "With this parameter, D Setpoint Weight can be reduced near the center of the sticks, which results in smoother end of flips and rolls.
The value represents a point of stick deflection: 0 - stick centered, 1 - full deflection. When the stick is above that point, Setpoint Weight is kept constant at its configured value. When the stick is positioned below that point, Setpoint Weight is reduced proportionally, reaching 0 at the stick center position.
Value of 1 gives maximum smoothing effect, while value of 0 keeps the Setpoint Weight fixed at its configured value over the whole stick range." }, "pidTuningDtermSetpointHelp": { - "message": "This parameter determines the stick accelerating effect within derivative component.
Value of 0 equals to old Measuemenent method where D only tracks gyro, while value of 1.27 equals to old Error method with equal gyro and stick tracking ratio.
Lower value equals to slower/smoother stick response, while higher value provides more stick acceleration response.
Note that RC interpolation is recommended to be enabled with higher values to prevent control kicks making noise.
Since BF3.4.0 you can set value up to 20 by entering it manually in the number box or through the CLI." + "message": "This parameter determines the stick accelerating effect within derivative component.
Value of 0 equals to old Measuemenent method where D only tracks gyro, while value of 1 equals to old Error method with equal gyro and stick tracking ratio.
Lower value equals to slower/smoother stick response, while higher value provides more stick acceleration response.
Note that RC interpolation is recommended to be enabled with higher values to prevent control kicks making noise.
Since BF3.4.0 you can set value up to 20 by entering it manually in the number box or through the CLI." }, "pidTuningDtermSetpointTransitionWarning": { "message": "$t(warningTitle.message):<\/strong> The use of a D Setpoint transition greater than 0 and less than 0.1 is highly discouraged. Doing may lead instability and reduced stick responsiveness as the sticks cross the centre point.<\/span>" From 4430e89fdaf34e68b989bc5fddbbc62db653c55f Mon Sep 17 00:00:00 2001 From: Cleric-K <9365881+Cleric-K@users.noreply.github.com> Date: Wed, 6 Jun 2018 16:39:46 +0300 Subject: [PATCH 3/4] Dynamic range for D Setpoint Weight Slider Applying patch by @mikeller https://github.com/betaflight/betaflight-configurator/pull/1034#issuecomment-395041697 --- locales/en/messages.json | 2 +- src/js/tabs/pid_tuning.js | 26 ++++++++++++++++++++++---- src/tabs/pid_tuning.html | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 04c858fb..cda9f6f3 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -1256,7 +1256,7 @@ "message": "With this parameter, D Setpoint Weight can be reduced near the center of the sticks, which results in smoother end of flips and rolls.
The value represents a point of stick deflection: 0 - stick centered, 1 - full deflection. When the stick is above that point, Setpoint Weight is kept constant at its configured value. When the stick is positioned below that point, Setpoint Weight is reduced proportionally, reaching 0 at the stick center position.
Value of 1 gives maximum smoothing effect, while value of 0 keeps the Setpoint Weight fixed at its configured value over the whole stick range." }, "pidTuningDtermSetpointHelp": { - "message": "This parameter determines the stick accelerating effect within derivative component.
Value of 0 equals to old Measuemenent method where D only tracks gyro, while value of 1 equals to old Error method with equal gyro and stick tracking ratio.
Lower value equals to slower/smoother stick response, while higher value provides more stick acceleration response.
Note that RC interpolation is recommended to be enabled with higher values to prevent control kicks making noise.
Since BF3.4.0 you can set value up to 20 by entering it manually in the number box or through the CLI." + "message": "This parameter determines the stick accelerating effect within derivative component.
Value of 0 equals to old Measuemenent method where D only tracks gyro, while value of 1 equals to old Error method with equal gyro and stick tracking ratio.
Lower value equals to slower/smoother stick response, while higher value provides more stick acceleration response.
Note that RC interpolation is recommended to be enabled with higher values to prevent control kicks making noise." }, "pidTuningDtermSetpointTransitionWarning": { "message": "$t(warningTitle.message):<\/strong> The use of a D Setpoint transition greater than 0 and less than 0.1 is highly discouraged. Doing may lead instability and reduced stick responsiveness as the sticks cross the centre point.<\/span>" diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index a055d9f8..d9851884 100755 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -6,7 +6,10 @@ TABS.pid_tuning = { updating: true, dirty: false, currentProfile: null, - currentRateProfile: null + currentRateProfile: null, + SETPOINT_WEIGHT_RANGE_LOW: 2.55, + SETPOINT_WEIGHT_RANGE_HIGH: 20, + SETPOINT_WEIGHT_RANGE_LEGACY: 2.54 }; TABS.pid_tuning.initialize = function (callback) { @@ -517,7 +520,8 @@ TABS.pid_tuning.initialize = function (callback) { } if (semver.lt(CONFIG.apiVersion, "1.39.0")) { - $('input[name="dtermSetpoint-number"]').attr('max', '2.54'); + $('input[name="dtermSetpoint-number"]').attr('max', self.SETPOINT_WEIGHT_RANGE_LEGACY); + $('input[name="dtermSetpoint-range"]').attr('max', self.SETPOINT_WEIGHT_RANGE_LEGACY); } // translate to user-selected language @@ -711,11 +715,25 @@ TABS.pid_tuning.initialize = function (callback) { var dtermNumberElement = $('input[name="dtermSetpoint-number"]'); var dtermRangeElement = $('input[name="dtermSetpoint-range"]'); + + function adjustRangeElement(value) { + var range = dtermRangeElement.attr('max'); + if (value >= self.SETPOINT_WEIGHT_RANGE_LOW && range <= self.SETPOINT_WEIGHT_RANGE_LOW) { + dtermRangeElement.attr('max', self.SETPOINT_WEIGHT_RANGE_HIGH); + } else if (value < self.SETPOINT_WEIGHT_RANGE_LOW && range > self.SETPOINT_WEIGHT_RANGE_LOW) { + dtermRangeElement.attr('max', self.SETPOINT_WEIGHT_RANGE_LOW); + } + } + dtermNumberElement.change(function () { - dtermRangeElement.val($(this).val()); + var value = $(this).val(); + adjustRangeElement(value); + dtermRangeElement.val(value); }); dtermRangeElement.change(function () { - dtermNumberElement.val($(this).val()); + var value = $(this).val(); + adjustRangeElement(value); + dtermNumberElement.val(value); }); } else { $('.tab-pid_tuning .rate_profile').hide(); diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index 6cd85bef..eec6e174 100755 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -295,7 +295,7 @@ - +