1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-20 14:55:21 +03:00

Merge pull request #895 from borisbstyle/pid1-horizon

Fix for extreme D level term PID1 Horizon
This commit is contained in:
Dominic Clifton 2015-05-17 21:32:50 +01:00
commit 85acf7dc1d

View file

@ -679,15 +679,9 @@ static void pidRewrite(pidProfile_t *pidProfile, controlRateConfig_t *controlRat
// Progressively turn off the horizon self level strength as the stick is banged over // Progressively turn off the horizon self level strength as the stick is banged over
horizonLevelStrength = (500 - mostDeflectedPos) / 5; // 100 at centre stick, 0 = max stick deflection horizonLevelStrength = (500 - mostDeflectedPos) / 5; // 100 at centre stick, 0 = max stick deflection
// PID D Level Term is used for Horizon Sensitivity. It is adjusted so the default value of 100 works pretty well. // Using Level D as a Sensitivity for Horizon. 0 more level to 255 more rate. Default value of 100 seems to work fine.
// Default Level D term of 100 equals to 80% sensitivity and 125 and above is 100% sensitivity. It is scaled to prevent too much truncating n integers // For more rate mode increase D and slower flips and rolls will be possible
if(pidProfile->D8[PIDLEVEL] == 0){ horizonLevelStrength = constrain((10 * (horizonLevelStrength - 100) * (10 * pidProfile->D8[PIDLEVEL] / 80) / 100) + 100, 0, 100);
horizonLevelStrength = 0;
} else if (pidProfile->D8[PIDLEVEL] >= 125){
horizonLevelStrength = 100;
} else {
horizonLevelStrength = constrain((10 * (horizonLevelStrength - 100) * (10 * pidProfile->D8[PIDLEVEL] / 125) / 100) + 100, 0, 100);
}
} }
// ----------PID controller---------- // ----------PID controller----------