From ff82839f8942d130e7211949b19a61cbcdf9069e Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 1 Aug 2014 22:43:01 +0100 Subject: [PATCH] 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. --- src/main/flight/imu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/flight/imu.c b/src/main/flight/imu.c index 8ac601a62..b0a660bd5 100755 --- a/src/main/flight/imu.c +++ b/src/main/flight/imu.c @@ -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);