Add regen overcurrent limit
This commit is contained in:
parent
7c7ae41ee6
commit
fa3ef04b58
|
@ -5,9 +5,10 @@
|
|||
|
||||
#include "stm32f3xx_hal.h"
|
||||
|
||||
#define SHUNT_TIMEOUT 300 // ms
|
||||
#define SHUNT_THRESH_OVERCURRENT 300000 // mA
|
||||
#define SHUNT_THRESH_OVERTEMP 1000 // 1/10 °C
|
||||
#define SHUNT_TIMEOUT 300 // ms
|
||||
#define SHUNT_THRESH_OVERCURRENT 300000 // mA
|
||||
#define SHUNT_THRESH_OVERCURRENT_REGEN 50000 // mA
|
||||
#define SHUNT_THRESH_OVERTEMP 1000 // 1/10 °C
|
||||
|
||||
typedef struct {
|
||||
int32_t current; // mA
|
||||
|
|
|
@ -28,9 +28,10 @@ void shunt_check() {
|
|||
if (HAL_GetTick() - shunt_data.last_message > SHUNT_TIMEOUT) {
|
||||
is_error = 1;
|
||||
can_send_error(TS_ERRORKIND_SHUNT_TIMEOUT, 0);
|
||||
} else if (shunt_data.current >= SHUNT_THRESH_OVERCURRENT) {
|
||||
} else if (shunt_data.current >= SHUNT_THRESH_OVERCURRENT ||
|
||||
shunt_data.current <= -SHUNT_THRESH_OVERCURRENT_REGEN) {
|
||||
is_error = 1;
|
||||
can_send_error(TS_ERRORKIND_SHUNT_OVERTEMP, 0);
|
||||
can_send_error(TS_ERRORKIND_SHUNT_OVERCURRENT, 0);
|
||||
} else if (shunt_data.busbartemp >= SHUNT_THRESH_OVERTEMP) {
|
||||
is_error = 1;
|
||||
can_send_error(TS_ERRORKIND_SHUNT_OVERTEMP, 0);
|
||||
|
|
Loading…
Reference in New Issue