From af7cd36cb861b7867b2094b7fa6f925efbe226b3 Mon Sep 17 00:00:00 2001 From: Benjamin Vedder Date: Thu, 22 Oct 2020 08:37:32 +0200 Subject: [PATCH] Added hall sensor interpolation ERPM config option --- CHANGELOG | 1 + conf_general.h | 2 +- mcpwm_foc.c | 3 ++- utils.c | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 01b27d41..ec1b550b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ * Added locking time and ramp up time parameters to sensorless startup. * Removed D axis current injection. * Initial VESC IO-board support +* Added hall sensor interpolation ERPM config option. === FW 5.01 === * Fixed PPM bug in previous release. diff --git a/conf_general.h b/conf_general.h index f18c8af6..fa8ba171 100644 --- a/conf_general.h +++ b/conf_general.h @@ -24,7 +24,7 @@ #define FW_VERSION_MAJOR 5 #define FW_VERSION_MINOR 02 // Set to 0 for building a release and iterate during beta test builds -#define FW_TEST_VERSION_NUMBER 10 +#define FW_TEST_VERSION_NUMBER 12 #include "datatypes.h" diff --git a/mcpwm_foc.c b/mcpwm_foc.c index aeadc7c9..7d9a7144 100644 --- a/mcpwm_foc.c +++ b/mcpwm_foc.c @@ -3991,7 +3991,8 @@ static float correct_hall(float angle, float dt, volatile motor_all_state_t *mot motor->m_ang_hall_int_prev = ang_hall_int; if (((60.0 / (2.0 * M_PI)) * ((M_PI / 3.0) / - fmaxf(fabsf(motor->m_hall_dt_diff_now), fabsf(motor->m_hall_dt_diff_last)))) < 100) { + fmaxf(fabsf(motor->m_hall_dt_diff_now), + fabsf(motor->m_hall_dt_diff_last)))) < conf_now->foc_hall_interp_erpm) { // Don't interpolate on very low speed, just use the closest hall sensor. The reason is that we might // get stuck at 60 degrees off if a direction change happens between two steps. motor->m_ang_hall = ang_hall_now; diff --git a/utils.c b/utils.c index e04f5351..61934816 100644 --- a/utils.c +++ b/utils.c @@ -767,7 +767,8 @@ uint8_t utils_second_motor_id(void) { * Use hall sensor port for second motor on dual motor hardware. * * @param samples - * The number of samples to read and filter over. + * The number of extra samples to read and filter over. If this + * is 0, only one sample will be used. * * @return * The state of the three hall sensors.