Fix TODOs by adding new events for LEAF

This commit is contained in:
Daniel 2024-04-15 21:58:49 +03:00
parent e7f81854c0
commit e61956372f
3 changed files with 23 additions and 27 deletions

View file

@ -140,10 +140,6 @@ static uint16_t min_max_voltage[2]; //contains cell min[0] and max[1] values
static uint16_t cell_deviation_mV = 0; //contains the deviation between highest and lowest cell in mV static uint16_t cell_deviation_mV = 0; //contains the deviation between highest and lowest cell in mV
static uint16_t HX = 0; //Internal resistance static uint16_t HX = 0; //Internal resistance
static uint16_t insulation = 0; //Insulation resistance static uint16_t insulation = 0; //Insulation resistance
static int32_t Battery_current_1 =
0; //High Voltage battery current; its positive if discharged, negative when charging
static int32_t Battery_current_2 =
0; //High Voltage battery current; its positive if discharged, negative when charging (unclear why two values exist)
static uint16_t temp_raw_1 = 0; static uint16_t temp_raw_1 = 0;
static uint8_t temp_raw_2_highnibble = 0; static uint8_t temp_raw_2_highnibble = 0;
static uint16_t temp_raw_2 = 0; static uint16_t temp_raw_2 = 0;
@ -284,7 +280,8 @@ void update_values_battery() { /* This function maps all the values fetched via
//Normal stop request. For stationary storage we don't disconnect contactors, so we ignore this. //Normal stop request. For stationary storage we don't disconnect contactors, so we ignore this.
break; break;
case (4): case (4):
//Caution Lamp Request //TODO: Should we create info event for this? //Caution Lamp Request
set_event(EVENT_BATTERY_CAUTION, 0);
break; break;
case (5): case (5):
//Caution Lamp Request & Normal Stop Request //Caution Lamp Request & Normal Stop Request
@ -336,6 +333,15 @@ void update_values_battery() { /* This function maps all the values fetched via
set_event(EVENT_CAN_RX_WARNING, 0); set_event(EVENT_CAN_RX_WARNING, 0);
} }
if (LB_HeatExist) {
if (LB_Heating_Stop) {
set_event(EVENT_BATTERY_WARMED_UP, 0);
}
if (LB_Heating_Start) {
set_event(EVENT_BATTERY_REQUESTS_HEAT, 0);
}
}
if (system_bms_status == FAULT) { //Incase we enter a critical fault state, zero out the allowed limits if (system_bms_status == FAULT) { //Incase we enter a critical fault state, zero out the allowed limits
system_max_charge_power_W = 0; system_max_charge_power_W = 0;
system_max_discharge_power_W = 0; system_max_discharge_power_W = 0;
@ -351,13 +357,6 @@ void update_values_battery() { /* This function maps all the values fetched via
print_with_units(", Max cell voltage: ", min_max_voltage[1], "mV "); print_with_units(", Max cell voltage: ", min_max_voltage[1], "mV ");
print_with_units(", Min cell voltage: ", min_max_voltage[0], "mV "); print_with_units(", Min cell voltage: ", min_max_voltage[0], "mV ");
print_with_units(", Cell deviation: ", cell_deviation_mV, "mV "); print_with_units(", Cell deviation: ", cell_deviation_mV, "mV ");
if (LB_Heating_Stop) { //TODO: Should we create info event for this?
Serial.println("Battery requesting heating pads to stop. The battery is now warm enough.");
}
if (LB_Heating_Start) { //TODO: Should we create info event for this?
Serial.println("COLD BATTERY! Battery requesting heating pads to activate");
}
#endif #endif
} }
@ -483,23 +482,10 @@ void receive_can_battery(CAN_frame_t rx_frame) {
if (group_7bb == 1) //High precision SOC, Current, voltages etc. if (group_7bb == 1) //High precision SOC, Current, voltages etc.
{ {
if (rx_frame.data.u8[0] == 0x10) { //First frame if (rx_frame.data.u8[0] == 0x10) { //First frame
Battery_current_1 = (rx_frame.data.u8[4] << 24) | //High precision Battery_current_1 resides here, but has been deemed unusable by 62kWh owners
(rx_frame.data.u8[5] << 16 | ((rx_frame.data.u8[6] << 8) | rx_frame.data.u8[7]));
if (Battery_current_1 & 0x8000000 == 0x8000000) {
Battery_current_1 = ((Battery_current_1 | -0x100000000) / 1024);
} else {
Battery_current_1 = (Battery_current_1 / 1024);
}
} }
if (rx_frame.data.u8[0] == 0x21) { //Second frame if (rx_frame.data.u8[0] == 0x21) { //Second frame
Battery_current_2 = (rx_frame.data.u8[3] << 24) | //High precision Battery_current_2 resides here, but has been deemed unusable by 62kWh owners
(rx_frame.data.u8[4] << 16 | ((rx_frame.data.u8[5] << 8) | rx_frame.data.u8[6]));
if (Battery_current_2 & 0x8000000 == 0x8000000) {
Battery_current_2 = ((Battery_current_2 | -0x100000000) / 1024);
} else {
Battery_current_2 = (Battery_current_2 / 1024);
}
} }
if (rx_frame.data.u8[0] == 0x23) { // Fourth frame if (rx_frame.data.u8[0] == 0x23) { // Fourth frame

View file

@ -136,6 +136,7 @@ void init_events(void) {
events.entries[EVENT_KWH_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_INFO; events.entries[EVENT_KWH_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_INFO;
events.entries[EVENT_BATTERY_EMPTY].level = EVENT_LEVEL_INFO; events.entries[EVENT_BATTERY_EMPTY].level = EVENT_LEVEL_INFO;
events.entries[EVENT_BATTERY_FULL].level = EVENT_LEVEL_INFO; events.entries[EVENT_BATTERY_FULL].level = EVENT_LEVEL_INFO;
events.entries[EVENT_BATTERY_CAUTION].level = EVENT_LEVEL_INFO;
events.entries[EVENT_BATTERY_CHG_STOP_REQ].level = EVENT_LEVEL_ERROR; events.entries[EVENT_BATTERY_CHG_STOP_REQ].level = EVENT_LEVEL_ERROR;
events.entries[EVENT_BATTERY_DISCHG_STOP_REQ].level = EVENT_LEVEL_ERROR; events.entries[EVENT_BATTERY_DISCHG_STOP_REQ].level = EVENT_LEVEL_ERROR;
events.entries[EVENT_BATTERY_CHG_DISCHG_STOP_REQ].level = EVENT_LEVEL_ERROR; events.entries[EVENT_BATTERY_CHG_DISCHG_STOP_REQ].level = EVENT_LEVEL_ERROR;
@ -208,12 +209,18 @@ const char* get_event_message_string(EVENTS_ENUM_TYPE event) {
return "Info: Battery is completely discharged"; return "Info: Battery is completely discharged";
case EVENT_BATTERY_FULL: case EVENT_BATTERY_FULL:
return "Info: Battery is fully charged"; return "Info: Battery is fully charged";
case EVENT_BATTERY_CAUTION:
return "Info: Battery has raised a general caution flag. Might want to inspect it closely.";
case EVENT_BATTERY_CHG_STOP_REQ: case EVENT_BATTERY_CHG_STOP_REQ:
return "ERROR: Battery raised caution indicator AND requested charge stop. Inspect battery status!"; return "ERROR: Battery raised caution indicator AND requested charge stop. Inspect battery status!";
case EVENT_BATTERY_DISCHG_STOP_REQ: case EVENT_BATTERY_DISCHG_STOP_REQ:
return "ERROR: Battery raised caution indicator AND requested discharge stop. Inspect battery status!"; return "ERROR: Battery raised caution indicator AND requested discharge stop. Inspect battery status!";
case EVENT_BATTERY_CHG_DISCHG_STOP_REQ: case EVENT_BATTERY_CHG_DISCHG_STOP_REQ:
return "ERROR: Battery raised caution indicator AND requested charge/discharge stop. Inspect battery status!"; return "ERROR: Battery raised caution indicator AND requested charge/discharge stop. Inspect battery status!";
case EVENT_BATTERY_REQUESTS_HEAT:
return "Info: COLD BATTERY! Battery requesting heating pads to activate!";
case EVENT_BATTERY_WARMED_UP:
return "Info: Battery requesting heating pads to stop. The battery is now warm enough.";
case EVENT_LOW_SOH: case EVENT_LOW_SOH:
return "ERROR: State of health critically low. Battery internal resistance too high to continue. Recycle " return "ERROR: State of health critically low. Battery internal resistance too high to continue. Recycle "
"battery."; "battery.";

View file

@ -38,9 +38,12 @@
XX(EVENT_KWH_PLAUSIBILITY_ERROR) \ XX(EVENT_KWH_PLAUSIBILITY_ERROR) \
XX(EVENT_BATTERY_EMPTY) \ XX(EVENT_BATTERY_EMPTY) \
XX(EVENT_BATTERY_FULL) \ XX(EVENT_BATTERY_FULL) \
XX(EVENT_BATTERY_CAUTION) \
XX(EVENT_BATTERY_CHG_STOP_REQ) \ XX(EVENT_BATTERY_CHG_STOP_REQ) \
XX(EVENT_BATTERY_DISCHG_STOP_REQ) \ XX(EVENT_BATTERY_DISCHG_STOP_REQ) \
XX(EVENT_BATTERY_CHG_DISCHG_STOP_REQ) \ XX(EVENT_BATTERY_CHG_DISCHG_STOP_REQ) \
XX(EVENT_BATTERY_REQUESTS_HEAT) \
XX(EVENT_BATTERY_WARMED_UP) \
XX(EVENT_LOW_SOH) \ XX(EVENT_LOW_SOH) \
XX(EVENT_HVIL_FAILURE) \ XX(EVENT_HVIL_FAILURE) \
XX(EVENT_INTERNAL_OPEN_FAULT) \ XX(EVENT_INTERNAL_OPEN_FAULT) \