Fixing alt hold constraints to be 8192 instead of 8196.

The previous code before 5b1de9cce966c033ae7b01d9318161e0e40e08a8 was
using (x / 8) and then constraining using +/- 1024.  Removing the / 8 in
commit 5b1de9cce966c033ae7b01d9318161e0e40e08a8 should have meant the
new constraint values were (1024 * 8) = 8192.
This commit is contained in:
Dominic Clifton 2014-08-01 22:43:01 +01:00
parent 75f94aa11b
commit ff82839f89
1 changed files with 2 additions and 2 deletions

View File

@ -406,8 +406,8 @@ int32_t calculateBaroPid(int32_t vel_tmp, float accZ_tmp, float accZ_old)
// I
errorAltitudeI += (pidProfile->I8[PIDVEL] * error);
errorAltitudeI = constrain(errorAltitudeI, -(8196 * 200), (8196 * 200));
newBaroPID += errorAltitudeI / 8196; // I in range +/-200
errorAltitudeI = constrain(errorAltitudeI, -(8192 * 200), (8192 * 200));
newBaroPID += errorAltitudeI / 8192; // I in range +/-200
// D
newBaroPID -= constrain(pidProfile->D8[PIDVEL] * (accZ_tmp + accZ_old) / 512, -150, 150);