Skip to content

Commit

Permalink
Nunchuk speed control glitch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Aug 3, 2015
1 parent f032111 commit 383208b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion applications/app_nunchuk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion conf_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Firmware version
#define FW_VERSION_MAJOR 1
#define FW_VERSION_MINOR 9
#define FW_VERSION_MINOR 10

#include "datatypes.h"

Expand Down

0 comments on commit 383208b

Please sign in to comment.