Compare commits
No commits in common. "4ecb91ba39c566bed9e52ba91e70168f34719eca" and "4926e9b2a44d604a341b10305f12119d1297981a" have entirely different histories.
4ecb91ba39
...
4926e9b2a4
@ -76,7 +76,7 @@ struct ADBMS6830_Internal_Status {
|
||||
typedef struct {
|
||||
int16_t cellVoltages[MAXIMUM_CELL_VOLTAGES];
|
||||
int16_t auxVoltages[MAXIMUM_AUX_VOLTAGES];
|
||||
uint64_t bmsID;
|
||||
uint32_t bmsID;
|
||||
|
||||
struct ADBMS6830_Internal_Status status;
|
||||
int16_t internalDieTemp;
|
||||
@ -85,8 +85,8 @@ typedef struct {
|
||||
uint16_t sumOfCellMeasurements;
|
||||
uint16_t refVoltage;
|
||||
|
||||
uint32_t overVoltage; // Bitfield of overvoltage flags
|
||||
uint32_t underVoltage; // " undervoltage "
|
||||
uint32_t overVoltage;
|
||||
uint32_t underVoltage;
|
||||
|
||||
} Cell_Module;
|
||||
|
||||
|
@ -62,7 +62,7 @@ HAL_StatusTypeDef amsReset() {
|
||||
id |= sidbuffer[BUFFER_BMS_OFFSET(i, SID_GROUP_SIZE) + j] << (j * 8);
|
||||
}
|
||||
modules[i].bmsID = id;
|
||||
debug_log_cont(LOG_LEVEL_INFO, "0x%08lx%08lx ", (uint32_t)(id >> 32), (uint32_t)(id & 0xFFFFFFFF)); //newlib does not support %llu
|
||||
debug_log_cont(LOG_LEVEL_INFO, "0x%lx%lx ", (uint32_t)(id >> 32), (uint32_t)(id & 0xFFFFFFFF)); //newlib does not support %llu
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(ADAX | ADAX_CONV_ALL, flagsbuffer, 0)); //start aux measurement
|
||||
|
||||
return HAL_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef initAMS(SPI_HandleTypeDef* hspi) {
|
||||
|
@ -68,28 +68,6 @@ HAL_StatusTypeDef battery_update() {
|
||||
if (ret.bms_id != -1) {
|
||||
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);
|
||||
return HAL_ERROR;
|
||||
@ -159,7 +137,7 @@ HAL_StatusTypeDef battery_update() {
|
||||
}
|
||||
|
||||
if (cellTemps[i][j] > (MAX_TEMP * (uint16_t)(TEMP_CONV))) {
|
||||
debug_log(LOG_LEVEL_ERROR, "Cell %zu on BMS %zu overtemp: %d0 mC", j, i, cellTemps[i][j]);
|
||||
debug_log(LOG_LEVEL_ERROR, "Cell %zu on BMS %zu overtemp: %d C", j, i, cellTemps[i][j]);
|
||||
can_send_error(TS_ERRORKIND_CELL_OVERTEMP, i);
|
||||
ts_sm_set_error_source(TS_ERROR_SOURCE_SLAVES, TS_ERRORKIND_CELL_OVERTEMP, true);
|
||||
} else {
|
||||
|
@ -15,7 +15,7 @@
|
||||
void can_init(FDCAN_HandleTypeDef *handle) {
|
||||
ftcan_init(handle);
|
||||
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_STATUS_BASE, 0xFF0);
|
||||
// ftcan_add_filter(CAN_ID_SLAVE_LOG, 0xFFF);
|
||||
|
@ -173,7 +173,7 @@ int main(void)
|
||||
debug_log(LOG_LEVEL_INFO, "AMS_Master on %s (%s), compiled at %s", COMMIT_BRANCH, COMMIT_HASH, COMPILE_DATE);
|
||||
debug_log(LOG_LEVEL_INFO, "Starting BMS...");
|
||||
auto ret = battery_init(&hspi1);
|
||||
while (ret != HAL_OK) { //TODO: properly handle reapeated initialization failure
|
||||
while (ret != HAL_OK) {
|
||||
debug_log(LOG_LEVEL_ERROR, "Failed to initialize BMS!");
|
||||
HAL_Delay(100);
|
||||
debug_log(LOG_LEVEL_INFO, "Retrying BMS initialization...");
|
||||
|
@ -14,7 +14,6 @@ void print_battery_info() {
|
||||
|
||||
for (size_t i = 0; i < N_BMS; i++) {
|
||||
debug_log(LOG_LEVEL_INFO, "Module %d status:", i);
|
||||
debug_log(LOG_LEVEL_INFO, " BMS ID: 0x%08lx%08lx", (uint32_t)(modules[i].bmsID >> 32), (uint32_t)(modules[i].bmsID & 0xFFFFFFFF));
|
||||
|
||||
// Print cell voltages in 4x4 format
|
||||
debug_log(LOG_LEVEL_INFO, " Cell voltages (mV):");
|
||||
@ -138,6 +137,7 @@ void print_battery_info() {
|
||||
" Module %d voltage issues - OV: 0x%08lX, UV: 0x%08lX", i,
|
||||
modules[i].overVoltage, modules[i].underVoltage);
|
||||
}
|
||||
|
||||
debug_log(LOG_LEVEL_INFO, "\n------ Updated at %lu ------", HAL_GetTick());
|
||||
}
|
||||
debug_log(LOG_LEVEL_INFO, "\n------ Updated at %lu ------", HAL_GetTick());
|
||||
}
|
@ -9,7 +9,16 @@
|
||||
ShuntData shunt_data;
|
||||
|
||||
void shunt_init() {
|
||||
shunt_data = (ShuntData){};
|
||||
shunt_data.current = 0;
|
||||
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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user