Removed hall sensor rate limiter as it could get stuck in certain conditions

This commit is contained in:
Benjamin Vedder 2024-05-08 12:31:08 +02:00
parent f3ce571a4d
commit 36b8a063c5
3 changed files with 2 additions and 17 deletions

View File

@ -550,7 +550,6 @@ float foc_correct_hall(float angle, float dt, motor_all_state_t *motor, int hall
float rad_per_sec = motor->m_speed_est_fast_corrected;
float rpm_abs = fabsf(RADPS2RPM_f(motor->m_pll_speed));
float rpm_abs_hall = fabsf(RADPS2RPM_f(rad_per_sec));
motor->m_using_hall = rpm_abs < conf_now->foc_sl_erpm;
float angle_old = angle;
@ -604,21 +603,8 @@ float foc_correct_hall(float angle, float dt, motor_all_state_t *motor, int hall
}
}
// Limit hall sensor rate of change. This will reduce current spikes in the current controllers when the angle estimation
// changes fast.
float angle_step = (fmaxf(rpm_abs_hall, conf_now->foc_hall_interp_erpm) / 60.0) * 2.0 * M_PI * dt * 1.4;
float angle_diff = utils_angle_difference_rad(motor->m_ang_hall, motor->m_ang_hall_rate_limited);
if (fabsf(angle_diff) < angle_step) {
motor->m_ang_hall_rate_limited = motor->m_ang_hall;
} else {
motor->m_ang_hall_rate_limited += angle_step * SIGN(angle_diff);
}
utils_norm_angle_rad((float*)&motor->m_ang_hall_rate_limited);
utils_norm_angle_rad((float*)&motor->m_ang_hall);
if (motor->m_using_hall) {
angle = motor->m_ang_hall_rate_limited;
angle = motor->m_ang_hall;
}
} else {
// Invalid hall reading. Don't update angle.

View File

@ -215,7 +215,6 @@ typedef struct {
int m_ang_hall_int_prev;
bool m_using_hall;
float m_ang_hall;
float m_ang_hall_rate_limited;
float m_hall_dt_diff_last;
float m_hall_dt_diff_now;
bool m_motor_released;

View File

@ -1390,7 +1390,7 @@ float mcpwm_foc_get_phase_encoder(void) {
}
float mcpwm_foc_get_phase_hall(void) {
float angle = RAD2DEG_f(get_motor_now()->m_ang_hall_rate_limited);
float angle = RAD2DEG_f(get_motor_now()->m_ang_hall);
utils_norm_angle(&angle);
return angle;
}