diff --git a/conf_general.h b/conf_general.h index 9ca1f1a8c0..df9b90e9de 100644 --- a/conf_general.h +++ b/conf_general.h @@ -22,7 +22,7 @@ // Firmware version #define FW_VERSION_MAJOR 5 -#define FW_VERSION_MINOR 01 +#define FW_VERSION_MINOR 02 // Set to 0 for building a release and iterate during beta test builds #define FW_TEST_VERSION_NUMBER 0 diff --git a/confgenerator.c b/confgenerator.c index 032dbd6ff9..3024d35c2b 100644 --- a/confgenerator.c +++ b/confgenerator.c @@ -107,6 +107,7 @@ int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration * buffer_append_uint16(buffer, conf->foc_hfi_start_samples, &ind); buffer_append_float32_auto(buffer, conf->foc_hfi_obs_ovr_sec, &ind); buffer[ind++] = conf->foc_hfi_samples; + buffer_append_float32_auto(buffer, conf->foc_hfi_disable_stopped_erpm, &ind); buffer_append_int16(buffer, conf->gpd_buffer_notify_left, &ind); buffer_append_int16(buffer, conf->gpd_buffer_interpol, &ind); buffer_append_float32_auto(buffer, conf->gpd_current_filter_const, &ind); @@ -399,6 +400,7 @@ bool confgenerator_deserialize_mcconf(const uint8_t *buffer, mc_configuration *c conf->foc_hfi_start_samples = buffer_get_uint16(buffer, &ind); conf->foc_hfi_obs_ovr_sec = buffer_get_float32_auto(buffer, &ind); conf->foc_hfi_samples = buffer[ind++]; + conf->foc_hfi_disable_stopped_erpm = buffer_get_float32_auto(buffer, &ind); conf->gpd_buffer_notify_left = buffer_get_int16(buffer, &ind); conf->gpd_buffer_interpol = buffer_get_int16(buffer, &ind); conf->gpd_current_filter_const = buffer_get_float32_auto(buffer, &ind); @@ -687,6 +689,7 @@ void confgenerator_set_defaults_mcconf(mc_configuration *conf) { conf->foc_hfi_start_samples = MCCONF_FOC_HFI_START_SAMPLES; conf->foc_hfi_obs_ovr_sec = MCCONF_FOC_HFI_OBS_OVR_SEC; conf->foc_hfi_samples = MCCONF_FOC_HFI_SAMPLES; + conf->foc_hfi_disable_stopped_erpm = MCCONF_FOC_HFI_DISABLE_STOPPED_ERPM; conf->gpd_buffer_notify_left = MCCONF_GPD_BUFFER_NOTIFY_LEFT; conf->gpd_buffer_interpol = MCCONF_GPD_BUFFER_INTERPOL; conf->gpd_current_filter_const = MCCONF_GPD_CURRENT_FILTER_CONST; diff --git a/confgenerator.h b/confgenerator.h index 0385c4fd63..816252379c 100644 --- a/confgenerator.h +++ b/confgenerator.h @@ -8,7 +8,7 @@ #include // Constants -#define MCCONF_SIGNATURE 3698540221 +#define MCCONF_SIGNATURE 1034840274 #define APPCONF_SIGNATURE 2460147246 // Functions diff --git a/datatypes.h b/datatypes.h index a170f0567b..1e56c5df64 100644 --- a/datatypes.h +++ b/datatypes.h @@ -308,6 +308,7 @@ typedef struct { uint16_t foc_hfi_start_samples; float foc_hfi_obs_ovr_sec; foc_hfi_samples foc_hfi_samples; + float foc_hfi_disable_stopped_erpm; // GPDrive int gpd_buffer_notify_left; int gpd_buffer_interpol; diff --git a/mcconf/mcconf_default.h b/mcconf/mcconf_default.h index fbd4337cf8..3ed78b85e5 100644 --- a/mcconf/mcconf_default.h +++ b/mcconf/mcconf_default.h @@ -359,6 +359,9 @@ #ifndef MCCONF_FOC_HFI_SAMPLES #define MCCONF_FOC_HFI_SAMPLES HFI_SAMPLES_16 // Samples per motor revolution for HFI #endif +#ifndef MCCONF_FOC_HFI_DISABLE_STOPPED_ERPM +#define MCCONF_FOC_HFI_DISABLE_STOPPED_ERPM 0.0 +#endif // GPD #ifndef MCCONF_GPD_BUFFER_NOTIFY_LEFT diff --git a/mcpwm_foc.c b/mcpwm_foc.c index c7154bfde8..97b8b8aa9b 100644 --- a/mcpwm_foc.c +++ b/mcpwm_foc.c @@ -3204,6 +3204,14 @@ static void control_current(volatile motor_all_state_t *motor, float dt) { bool do_hfi = conf_now->foc_sensor_mode == FOC_SENSOR_MODE_HFI && !motor->m_phase_override && abs_rpm < (conf_now->foc_sl_erpm_hfi * (motor->m_cc_was_hfi ? 1.8 : 1.5)); + + if (do_hfi && abs_rpm < conf_now->foc_hfi_disable_stopped_erpm && + ((motor->m_control_mode == CONTROL_MODE_DUTY && motor->m_duty_cycle_set == 0) || + (motor->m_control_mode == CONTROL_MODE_SPEED && motor->m_speed_pid_set_rpm == 0))){ + do_hfi = false; + motor->m_hfi.est_done_cnt = 0; + } + motor->m_cc_was_hfi = do_hfi; // Only allow Q axis current after the HFI ambiguity is resolved. This causes