Add contactor weld warning event, change events to native latch type

This commit is contained in:
James Brookes 2025-09-27 18:03:56 +01:00
parent 04d9a36292
commit 706b4a7cea
2 changed files with 12 additions and 8 deletions

View file

@ -483,13 +483,18 @@ void TeslaBattery::
} else { } else {
clear_event(EVENT_BATTERY_FUSE); clear_event(EVENT_BATTERY_FUSE);
} }
// Raise any informational Tesla BMS events in BE // Raise any Tesla BMS events in BE
if (BMS_a145_SW_SOC_Change == true && !BMS_SW_SOC_Change_Latch) { // BMS has newly recalibrated pack SOC // Events: Informational
BMS_SW_SOC_Change_Latch = true; // Only set event once, BMS_a145 can be active for a while if (BMS_a145_SW_SOC_Change) { // BMS has newly recalibrated pack SOC
set_event(EVENT_BATTERY_SOC_RECALIBRATION, 0); set_event_latched(EVENT_BATTERY_SOC_RECALIBRATION, 0); // Latcched as BMS_a145 can be active for a while
} else if (!BMS_a145_SW_SOC_Change) {
clear_event(EVENT_BATTERY_SOC_RECALIBRATION); clear_event(EVENT_BATTERY_SOC_RECALIBRATION);
} else if (BMS_a145_SW_SOC_Change == false) { }
BMS_SW_SOC_Change_Latch = false; // Events: Warning
if (BMS_contactorState == 5) { // BMS has detected welded contactor(s)
set_event_latched(EVENT_CONTACTOR_WELDED, 0);
} else if (BMS_contactorState != 5) {
clear_event(EVENT_CONTACTOR_WELDED);
} }
if (user_selected_tesla_GTW_chassisType > 1) { //{{0, "Model S"}, {1, "Model X"}, {2, "Model 3"}, {3, "Model Y"}}; if (user_selected_tesla_GTW_chassisType > 1) { //{{0, "Model S"}, {1, "Model X"}, {2, "Model 3"}, {3, "Model Y"}};
@ -553,7 +558,7 @@ void TeslaBattery::
datalayer.battery.settings.user_requests_tesla_soc_reset = false; datalayer.battery.settings.user_requests_tesla_soc_reset = false;
logging.println("INFO: SOC reset requested"); logging.println("INFO: SOC reset requested");
} else { } else {
logging.println("ERROR: SOC reset failed, SOC not < 15 or > 90"); logging.println("ERROR: SOC reset failed, SOC not < 15 or > 90, or contactors not open");
stateMachineSOCReset = 0xFF; stateMachineSOCReset = 0xFF;
datalayer.battery.settings.user_requests_tesla_soc_reset = false; datalayer.battery.settings.user_requests_tesla_soc_reset = false;
set_event(EVENT_BATTERY_SOC_RESET_FAIL, 0); set_event(EVENT_BATTERY_SOC_RESET_FAIL, 0);

View file

@ -877,7 +877,6 @@ class TeslaBattery : public CanBattery {
bool BMS_a141_SW_BMB_Status_Warning = false; bool BMS_a141_SW_BMB_Status_Warning = false;
bool BMS_a144_Hvp_Config_Mismatch = false; bool BMS_a144_Hvp_Config_Mismatch = false;
bool BMS_a145_SW_SOC_Change = false; bool BMS_a145_SW_SOC_Change = false;
bool BMS_SW_SOC_Change_Latch = false;
bool BMS_a146_SW_Brick_Overdischarged = false; bool BMS_a146_SW_Brick_Overdischarged = false;
bool BMS_a149_SW_Missing_Config_Block = false; bool BMS_a149_SW_Missing_Config_Block = false;
bool BMS_a151_SW_external_isolation = false; bool BMS_a151_SW_external_isolation = false;