Take both current override limits into account in the relative current mode

This commit is contained in:
Benjamin Vedder 2023-10-13 13:56:03 +02:00
parent c5d89c4b74
commit 004af85dc1
1 changed files with 7 additions and 1 deletions

View File

@ -734,7 +734,13 @@ void mc_interface_set_current_rel(float val) {
}
volatile mc_configuration *cfg = &motor_now()->m_conf;
mc_interface_set_current(val * cfg->lo_current_max);
float duty = mc_interface_get_duty_cycle_now();
if (fabsf(duty) < 0.02 || SIGN(val) == SIGN(duty)) {
mc_interface_set_current(val * cfg->lo_current_max);
} else {
mc_interface_set_current(val * fabsf(cfg->lo_current_min));
}
if (fabsf(val * cfg->l_abs_current_max) > cfg->cc_min_current) {
mc_interface_set_current_off_delay(0.1);