From bca9f8a58799210e7de4f59434454118f3d4becc Mon Sep 17 00:00:00 2001 From: Thorsten Laux Date: Sun, 28 Jul 2019 10:41:03 +0200 Subject: [PATCH] better idle defaults and don't set idle_throttle if not enabled --- src/main/build/debug.c | 1 + src/main/build/debug.h | 1 + src/main/flight/mixer.c | 10 +++++++++- src/main/flight/pid.c | 4 ++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/build/debug.c b/src/main/build/debug.c index 21f3e005fc..148e1e9031 100644 --- a/src/main/build/debug.c +++ b/src/main/build/debug.c @@ -92,4 +92,5 @@ const char * const debugModeNames[DEBUG_COUNT] = { "CRSF_LINK_STATISTICS_DOWN", "BARO", "GPS_RESCUE_THROTTLE_PID", + "DYN_IDLE", }; diff --git a/src/main/build/debug.h b/src/main/build/debug.h index be92a3fa05..0d1c4222a2 100644 --- a/src/main/build/debug.h +++ b/src/main/build/debug.h @@ -108,6 +108,7 @@ typedef enum { DEBUG_CRSF_LINK_STATISTICS_DOWN, DEBUG_BARO, DEBUG_GPS_RESCUE_THROTTLE_PID, + DEBUG_DYN_IDLE, DEBUG_COUNT } debugType_e; diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index a2b4331483..6f0ad0507d 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -585,6 +585,12 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs) const float pidSum = constrainf(currentPidProfile->idle_p * 0.0001f * error, -currentPidProfile->idle_pid_limit, currentPidProfile->idle_pid_limit); motorRangeMinIncrease = constrainf(motorRangeMinIncrease + pidSum * dT, 0.0f, maxIncrease); oldMinRpm = minRpm; + + DEBUG_SET(DEBUG_DYN_IDLE, 0, motorRangeMinIncrease * 1000); + DEBUG_SET(DEBUG_DYN_IDLE, 1, targetRpmChangeRate); + DEBUG_SET(DEBUG_DYN_IDLE, 2, error); + DEBUG_SET(DEBUG_DYN_IDLE, 3, minRpm); + } #endif @@ -849,7 +855,9 @@ FAST_CODE_NOINLINE void mixTable(timeUs_t currentTimeUs, uint8_t vbatPidCompensa #endif #ifdef USE_DYN_IDLE - throttle += currentPidProfile->idle_throttle * 0.001f; + if (currentPidProfile->idle_hz) { + throttle += currentPidProfile->idle_throttle * 0.001f; + } #endif #if defined(USE_THROTTLE_BOOST) diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 5cc047b974..e936ab75e3 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -207,9 +207,9 @@ void resetPidProfile(pidProfile_t *pidProfile) .transient_throttle_limit = 15, .profileName = { 0 }, .idle_hz = 0, - .idle_adjustment_speed = 200, + .idle_adjustment_speed = 50, .idle_throttle = 60, - .idle_p = 40, + .idle_p = 50, .idle_pid_limit = 200, .idle_max_increase = 150, );