cleanup, add debug printout when cell OV/UV happens
This commit is contained in:
parent
d5885ae849
commit
4ecb91ba39
@ -85,8 +85,8 @@ typedef struct {
|
|||||||
uint16_t sumOfCellMeasurements;
|
uint16_t sumOfCellMeasurements;
|
||||||
uint16_t refVoltage;
|
uint16_t refVoltage;
|
||||||
|
|
||||||
uint32_t overVoltage;
|
uint32_t overVoltage; // Bitfield of overvoltage flags
|
||||||
uint32_t underVoltage;
|
uint32_t underVoltage; // " undervoltage "
|
||||||
|
|
||||||
} Cell_Module;
|
} Cell_Module;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ HAL_StatusTypeDef amsReset() {
|
|||||||
CHECK_RETURN(writeCMD(ADCV | ADCV_CONT | ADCV_RD, flagsbuffer, 0)); //start continuous cell voltage measurement with redundancy
|
CHECK_RETURN(writeCMD(ADCV | ADCV_CONT | ADCV_RD, flagsbuffer, 0)); //start continuous cell voltage measurement with redundancy
|
||||||
CHECK_RETURN(writeCMD(ADAX | ADAX_CONV_ALL, flagsbuffer, 0)); //start aux measurement
|
CHECK_RETURN(writeCMD(ADAX | ADAX_CONV_ALL, flagsbuffer, 0)); //start aux measurement
|
||||||
|
|
||||||
return 0;
|
return HAL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL_StatusTypeDef initAMS(SPI_HandleTypeDef* hspi) {
|
HAL_StatusTypeDef initAMS(SPI_HandleTypeDef* hspi) {
|
||||||
|
@ -69,6 +69,28 @@ HAL_StatusTypeDef battery_update() {
|
|||||||
debug_log_cont(LOG_LEVEL_ERROR, " (on BMS ID: %hd)", ret.bms_id);
|
debug_log_cont(LOG_LEVEL_ERROR, " (on BMS ID: %hd)", ret.bms_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret.status == ADBMS_OVERVOLT || ret.status == ADBMS_UNDERVOLT) {
|
||||||
|
if (ret.bms_id != -1 && ret.bms_id < N_BMS) {
|
||||||
|
const char* error_type = (ret.status == ADBMS_OVERVOLT) ? "overvoltage" : "undervoltage";
|
||||||
|
uint32_t voltage_flags = (ret.status == ADBMS_OVERVOLT) ?
|
||||||
|
modules[ret.bms_id].overVoltage :
|
||||||
|
modules[ret.bms_id].underVoltage;
|
||||||
|
|
||||||
|
debug_log(LOG_LEVEL_ERROR, "Cell %s detected on module %d, affected cells: ",
|
||||||
|
error_type, ret.bms_id);
|
||||||
|
|
||||||
|
for (size_t cell = 0; cell < N_CELLS; cell++) {
|
||||||
|
if (voltage_flags & (1UL << cell)) {
|
||||||
|
debug_log_cont(LOG_LEVEL_ERROR, "%zu (%d mV) ", cell, modules[ret.bms_id].cellVoltages[cell]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!voltage_flags) {
|
||||||
|
debug_log_cont(LOG_LEVEL_ERROR, "none (something went wrong?)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
update_error_window(true, ret.bms_id);
|
update_error_window(true, ret.bms_id);
|
||||||
return HAL_ERROR;
|
return HAL_ERROR;
|
||||||
}
|
}
|
||||||
@ -137,7 +159,7 @@ HAL_StatusTypeDef battery_update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cellTemps[i][j] > (MAX_TEMP * (uint16_t)(TEMP_CONV))) {
|
if (cellTemps[i][j] > (MAX_TEMP * (uint16_t)(TEMP_CONV))) {
|
||||||
debug_log(LOG_LEVEL_ERROR, "Cell %zu on BMS %zu overtemp: %d C", j, i, cellTemps[i][j]);
|
debug_log(LOG_LEVEL_ERROR, "Cell %zu on BMS %zu overtemp: %d0 mC", j, i, cellTemps[i][j]);
|
||||||
can_send_error(TS_ERRORKIND_CELL_OVERTEMP, i);
|
can_send_error(TS_ERRORKIND_CELL_OVERTEMP, i);
|
||||||
ts_sm_set_error_source(TS_ERROR_SOURCE_SLAVES, TS_ERRORKIND_CELL_OVERTEMP, true);
|
ts_sm_set_error_source(TS_ERROR_SOURCE_SLAVES, TS_ERRORKIND_CELL_OVERTEMP, true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
void can_init(FDCAN_HandleTypeDef *handle) {
|
void can_init(FDCAN_HandleTypeDef *handle) {
|
||||||
ftcan_init(handle);
|
ftcan_init(handle);
|
||||||
ftcan_add_filter(CAN_ID_SHUNT_BASE, 0xFF0);
|
ftcan_add_filter(CAN_ID_SHUNT_BASE, 0xFF0);
|
||||||
// ftcan_add_filter(CAN_ID_AMS_IN, 0xFFF);
|
ftcan_add_filter(CAN_ID_AMS_IN, 0xFFF);
|
||||||
// ftcan_add_filter(CAN_ID_SLAVE_PANIC, 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_BASE, 0xFF0);
|
||||||
// ftcan_add_filter(CAN_ID_SLAVE_LOG, 0xFFF);
|
// ftcan_add_filter(CAN_ID_SLAVE_LOG, 0xFFF);
|
||||||
|
@ -9,16 +9,7 @@
|
|||||||
ShuntData shunt_data;
|
ShuntData shunt_data;
|
||||||
|
|
||||||
void shunt_init() {
|
void shunt_init() {
|
||||||
shunt_data.current = 0;
|
shunt_data = (ShuntData){};
|
||||||
shunt_data.voltage_veh = 0;
|
|
||||||
shunt_data.voltage_bat = 0;
|
|
||||||
shunt_data.voltage3 = 0;
|
|
||||||
shunt_data.busbartemp = 0;
|
|
||||||
shunt_data.power = 0;
|
|
||||||
shunt_data.energy = 0;
|
|
||||||
shunt_data.current_counter = 0;
|
|
||||||
shunt_data.last_message = 0;
|
|
||||||
shunt_data.last_current_message = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void shunt_check() {
|
void shunt_check() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user