Hall sensor bug fix and tweaks

This commit is contained in:
Benjamin Vedder 2023-07-16 16:00:41 +02:00
parent 14994c6262
commit 1fee16de47
2 changed files with 9 additions and 5 deletions

View File

@ -18,7 +18,11 @@
* Added access to several config parameters.
* Many improvements and bug fixes.
* Better error descriptions.
* Hall sensors: smooth transition to sensorless.
* Hall sensors improvements:
* Smooth transition to sensorless.
* Bug fix in interpolation.
* Use less noisy speed estimator for interpolation.
* Adjusted rate limit.
* Added soft regen cutoff. See https://github.com/vedderb/vesc_tool/pull/310
* Attempt at limiting the input current when using MTPA and field weakening.
* Removed built-in balance app. The balance-package can be used instead, which is where new development is done.

View File

@ -544,7 +544,7 @@ float foc_correct_hall(float angle, float dt, motor_all_state_t *motor, int hall
mc_configuration *conf_now = motor->m_conf;
motor->m_hall_dt_diff_now += dt;
float rad_per_sec = (M_PI / 3.0) / motor->m_hall_dt_diff_last;
float rad_per_sec = motor->m_speed_est_fast;
float rpm_abs = fabsf(RADPS2RPM_f(motor->m_pll_speed));
float rpm_abs_hall = fabsf(RADPS2RPM_f(rad_per_sec));
@ -603,18 +603,18 @@ float foc_correct_hall(float angle, float dt, motor_all_state_t *motor, int hall
} else {
// Interpolate
float diff = utils_angle_difference_rad(motor->m_ang_hall, ang_hall_now);
if (fabsf(diff) < ((2.0 * M_PI) / 12.0)) {
if (fabsf(diff) < ((2.0 * M_PI) / 12.0) || SIGN(diff) != SIGN(rad_per_sec)) {
// Do interpolation
motor->m_ang_hall += rad_per_sec * dt;
} else {
// We are too far away with the interpolation
motor->m_ang_hall -= diff / 100.0;
motor->m_ang_hall -= diff * 0.01;
}
}
// 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.5;
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;