Skip to content

Commit

Permalink
enforce minimum trip current value
Browse files Browse the repository at this point in the history
  • Loading branch information
yconst committed Feb 25, 2024
1 parent eb1b579 commit 1f8b4f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions firmware/src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@
#define BOARD_REV_IDX 21
#endif

#if defined BOARD_REV_R3 || defined BOARD_REV_R5
#define MIN_TRIP_CURRENT (5.0f) // A
#elif defined BOARD_REV_M5
#define MIN_TRIP_CURRENT (1.0f) // A
#endif

#define TIMER_FREQ_HZ (ACLK_FREQ_HZ >> TXCTL_PS_DIV)

#define SENSOR_COMMON_RES_BITS (13)
Expand Down
4 changes: 2 additions & 2 deletions firmware/src/controller/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ void Controller_ControlLoop(void)
{
state.warnings = 0;
const float Iq = controller_get_Iq_estimate();
if ((Iq > (config.I_limit * I_TRIP_MARGIN)) ||
(Iq < -(config.I_limit * I_TRIP_MARGIN)))
const float Iq_trip = our_fmaxf(config.I_limit * I_TRIP_MARGIN, MIN_TRIP_CURRENT);
if (our_fabsf(Iq) > Iq_trip)
{
state.errors |= CONTROLLER_ERRORS_CURRENT_LIMIT_EXCEEDED;
}
Expand Down

0 comments on commit 1f8b4f2

Please sign in to comment.