From 383208bdbd9b56cca18bf6016a2743d621b7ff01 Mon Sep 17 00:00:00 2001 From: Benjamin Vedder Date: Mon, 3 Aug 2015 23:43:34 +0200 Subject: [PATCH] Nunchuk speed control glitch fix --- applications/app_nunchuk.c | 6 +++++- conf_general.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/applications/app_nunchuk.c b/applications/app_nunchuk.c index 3dd07889..5e9ec4a5 100644 --- a/applications/app_nunchuk.c +++ b/applications/app_nunchuk.c @@ -186,6 +186,7 @@ static msg_t output_thread(void *arg) { static bool is_reverse = false; static bool was_z = false; const float current_now = mcpwm_get_tot_current_directional_filtered(); + static float prev_current = 0.0; if (chuck_d.bt_c && chuck_d.bt_z) { led_external_set_state(LED_EXT_BATT); @@ -271,6 +272,10 @@ static msg_t output_thread(void *arg) { } } + // Set the previous ramping current to not get a spike when releasing + // PID control and to get a smooth transition. + prev_current = current_now; + continue; } @@ -322,7 +327,6 @@ static msg_t output_thread(void *arg) { } // Apply ramping - static float prev_current = 0.0; const float current_range = mcconf->l_current_max + fabsf(mcconf->l_current_min); const float ramp_time = fabsf(current) > fabsf(prev_current) ? config.ramp_time_pos : config.ramp_time_neg; diff --git a/conf_general.h b/conf_general.h index e79a3e9e..33331d9b 100644 --- a/conf_general.h +++ b/conf_general.h @@ -27,7 +27,7 @@ // Firmware version #define FW_VERSION_MAJOR 1 -#define FW_VERSION_MINOR 9 +#define FW_VERSION_MINOR 10 #include "datatypes.h"