Compare commits

..

No commits in common. "fa3ef04b583487341dd7eabc9a0caabb50926aed" and "cef05f52bc31a71bd077262aed054abf2c76900e" have entirely different histories.

5 changed files with 7 additions and 13 deletions

View File

@ -12,7 +12,6 @@
#define CAN_ID_AMS_IN 0x00B
#define CAN_ID_AMS_ERROR 0x00C
#define CAN_ID_SLAVE_STATUS_BASE 0x080
#define CAN_ID_SLAVE_STATUS_FUCKED 0x0A0
#define CAN_ID_SLAVE_LOG 0x4F4
#define CAN_ID_SHUNT_BASE 0x520
#define CAN_ID_SHUNT_CURRENT 0x521

View File

@ -5,10 +5,9 @@
#include "stm32f3xx_hal.h"
#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
#define SHUNT_TIMEOUT 300 // ms
#define SHUNT_THRESH_OVERCURRENT 300000 // mA
#define SHUNT_THRESH_OVERTEMP 1000 // 1/10 °C
typedef struct {
int32_t current; // mA

View File

@ -18,7 +18,6 @@ void can_init(CAN_HandleTypeDef *handle) {
ftcan_add_filter(CAN_ID_AMS_IN, 0xFFF);
ftcan_add_filter(CAN_ID_SLAVE_PANIC, 0xFFF);
ftcan_add_filter(CAN_ID_SLAVE_STATUS_BASE, 0xFF0);
ftcan_add_filter(CAN_ID_SLAVE_STATUS_FUCKED, 0xFFF);
ftcan_add_filter(CAN_ID_SLAVE_LOG, 0xFFF);
}
@ -51,8 +50,6 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
} else if ((id & 0xFF0) == CAN_ID_SLAVE_STATUS_BASE) {
slaves_handle_status(data);
return;
} else if (id == CAN_ID_SLAVE_STATUS_FUCKED) {
slaves_handle_status(data);
}
switch (id) {
case CAN_ID_SLAVE_PANIC:

View File

@ -28,10 +28,9 @@ 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 ||
shunt_data.current <= -SHUNT_THRESH_OVERCURRENT_REGEN) {
} else if (shunt_data.current >= SHUNT_THRESH_OVERCURRENT) {
is_error = 1;
can_send_error(TS_ERRORKIND_SHUNT_OVERCURRENT, 0);
can_send_error(TS_ERRORKIND_SHUNT_OVERTEMP, 0);
} else if (shunt_data.busbartemp >= SHUNT_THRESH_OVERTEMP) {
is_error = 1;
can_send_error(TS_ERRORKIND_SHUNT_OVERTEMP, 0);

View File

@ -32,7 +32,7 @@ void soc_init() {
void soc_update() {
uint32_t now = HAL_GetTick();
if (abs(shunt_data.current) >= SOC_ESTIMATION_NO_CURRENT_THRESH) {
if (shunt_data.current >= SOC_ESTIMATION_NO_CURRENT_THRESH) {
last_current_time = now;
if (!current_was_flowing) {
soc_before_current = current_soc;
@ -52,7 +52,7 @@ void soc_update() {
// Otherwise, use the current counter to update SoC
float as_delta = shunt_data.current_counter - mAs_before_current;
float soc_delta = as_delta / SOC_ESTIMATION_BATTERY_CAPACITY * 100;
current_soc = soc_before_current - soc_delta;
current_soc = soc_before_current + soc_delta;
}
}