Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conf_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions confgenerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion confgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdbool.h>

// Constants
#define MCCONF_SIGNATURE 3698540221
#define MCCONF_SIGNATURE 1034840274
#define APPCONF_SIGNATURE 2460147246

// Functions
Expand Down
1 change: 1 addition & 0 deletions datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions mcconf/mcconf_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions mcpwm_foc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down