Nunchuk speed control glitch fix

This commit is contained in:
Benjamin Vedder 2015-08-03 23:43:34 +02:00
parent f032111b9b
commit 383208bdbd
2 changed files with 6 additions and 2 deletions

View File

@ -186,6 +186,7 @@ static msg_t output_thread(void *arg) {
static bool is_reverse = false; static bool is_reverse = false;
static bool was_z = false; static bool was_z = false;
const float current_now = mcpwm_get_tot_current_directional_filtered(); 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) { if (chuck_d.bt_c && chuck_d.bt_z) {
led_external_set_state(LED_EXT_BATT); 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; continue;
} }
@ -322,7 +327,6 @@ static msg_t output_thread(void *arg) {
} }
// Apply ramping // Apply ramping
static float prev_current = 0.0;
const float current_range = mcconf->l_current_max + fabsf(mcconf->l_current_min); 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; const float ramp_time = fabsf(current) > fabsf(prev_current) ? config.ramp_time_pos : config.ramp_time_neg;

View File

@ -27,7 +27,7 @@
// Firmware version // Firmware version
#define FW_VERSION_MAJOR 1 #define FW_VERSION_MAJOR 1
#define FW_VERSION_MINOR 9 #define FW_VERSION_MINOR 10
#include "datatypes.h" #include "datatypes.h"