Skip to content

Commit 86cbc92

Browse files
committed
Fixed regression in sensorless braking
1 parent 44053fb commit 86cbc92

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

conf_general.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define FW_VERSION_MAJOR 5
2525
#define FW_VERSION_MINOR 03
2626
// Set to 0 for building a release and iterate during beta test builds
27-
#define FW_TEST_VERSION_NUMBER 48
27+
#define FW_TEST_VERSION_NUMBER 49
2828

2929
#include "datatypes.h"
3030

mcpwm_foc.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ typedef struct {
151151

152152
float m_phase_before;
153153
float m_duty_abs_filtered;
154+
float m_duty_filtered;
154155
bool m_was_full_brake;
155156
bool m_was_control_duty;
156157
float m_duty_i_term;
@@ -2637,9 +2638,12 @@ void mcpwm_foc_adc_int_handler(void *p, uint32_t flags) {
26372638
float iq_set_tmp = motor_now->m_iq_set;
26382639
motor_now->m_motor_state.max_duty = conf_now->l_max_duty;
26392640

2640-
UTILS_LP_FAST(motor_now->m_duty_abs_filtered, fabsf(motor_now->m_motor_state.duty_now), 0.1);
2641+
UTILS_LP_FAST(motor_now->m_duty_abs_filtered, fabsf(motor_now->m_motor_state.duty_now), 0.01);
26412642
utils_truncate_number_abs((float*)&motor_now->m_duty_abs_filtered, 1.0);
26422643

2644+
UTILS_LP_FAST(motor_now->m_duty_filtered, motor_now->m_motor_state.duty_now, 0.01);
2645+
utils_truncate_number_abs((float*)&motor_now->m_duty_filtered, 1.0);
2646+
26432647
float duty_set = motor_now->m_duty_cycle_set;
26442648
bool control_duty = motor_now->m_control_mode == CONTROL_MODE_DUTY ||
26452649
motor_now->m_control_mode == CONTROL_MODE_OPENLOOP_DUTY ||
@@ -2650,7 +2654,7 @@ void mcpwm_foc_adc_int_handler(void *p, uint32_t flags) {
26502654
// applying active braking. Use a bit of hysteresis when leaving
26512655
// the shorted mode.
26522656
if (motor_now->m_control_mode == CONTROL_MODE_CURRENT_BRAKE &&
2653-
motor_now->m_duty_abs_filtered < conf_now->l_min_duty * 1.5 &&
2657+
fabsf(motor_now->m_duty_filtered) < conf_now->l_min_duty * 1.5 &&
26542658
(motor_now->m_motor_state.i_abs * (motor_now->m_was_full_brake ? 1.0 : 1.5)) <
26552659
fminf(fabsf(iq_set_tmp), fabsf(conf_now->l_current_min))) {
26562660
control_duty = true;

0 commit comments

Comments
 (0)