From e083a3266d33d6566d36b8270a5c28f8be4ce586 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 30 May 2014 09:01:37 +0100 Subject: [PATCH] Decreasing autotune max oscillation value since a value of 4 was found to always cause P to increase. --- src/flight_autotune.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/flight_autotune.c b/src/flight_autotune.c index 4da107fd6..96e9c98d5 100644 --- a/src/flight_autotune.c +++ b/src/flight_autotune.c @@ -56,7 +56,7 @@ extern int16_t debug[4]; * Always autotune on a full battery. */ -#define AUTOTUNE_MAX_OSCILLATION_ANGLE 4.0f +#define AUTOTUNE_MAX_OSCILLATION_ANGLE 2.0f #define AUTOTUNE_TARGET_ANGLE 20.0f #define AUTOTUNE_D_MULTIPLIER 1.2f #define AUTOTUNE_SETTLING_DELAY_MS 250 // 1/4 of a second. @@ -237,15 +237,14 @@ float autotune(angle_index_t angleIndex, const rollAndPitchInclination_t *inclin #ifdef PREFER_HIGH_GAIN_SOLUTION if (oscillationAmplitude > AUTOTUNE_MAX_OSCILLATION_ANGLE) { // we have too much oscillation, so we can't increase D, so decrease P -#endif pid.p *= AUTOTUNE_DECREASE_MULTIPLIER; -#ifdef PREFER_HIGH_GAIN_SOLUTION } else { // we don't have too much oscillation, so we can increase D -#endif pid.d *= AUTOTUNE_INCREASE_MULTIPLIER; -#ifdef PREFER_HIGH_GAIN_SOLUTION } +#else + pid.p *= AUTOTUNE_DECREASE_MULTIPLIER; + pid.d *= AUTOTUNE_INCREASE_MULTIPLIER; #endif } else { // undershot