mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
Merge branch 'main' into improvement/debug-at-runtime
This commit is contained in:
commit
d2098e1de5
3 changed files with 15 additions and 5 deletions
|
@ -62,6 +62,14 @@ void handle_precharge_control(unsigned long currentMillis) {
|
|||
auto hia4v1_pin = esp32hal->HIA4V1_PIN();
|
||||
auto inverter_disconnect_contactor_pin = esp32hal->INVERTER_DISCONNECT_CONTACTOR_PIN();
|
||||
|
||||
// If we're in FAILURE state, completely disable any further precharge attempts
|
||||
if (datalayer.system.status.precharge_status == AUTO_PRECHARGE_FAILURE) {
|
||||
pinMode(hia4v1_pin, OUTPUT);
|
||||
digitalWrite(hia4v1_pin, LOW);
|
||||
digitalWrite(inverter_disconnect_contactor_pin, ON);
|
||||
return; // Exit immediately - no further processing allowed. Reboot required to recover
|
||||
}
|
||||
|
||||
int32_t target_voltage = datalayer.battery.status.voltage_dV;
|
||||
int32_t external_voltage = datalayer_extended.meb.BMS_voltage_intermediate_dV;
|
||||
|
||||
|
@ -120,10 +128,11 @@ void handle_precharge_control(unsigned long currentMillis) {
|
|||
pinMode(hia4v1_pin, OUTPUT);
|
||||
digitalWrite(hia4v1_pin, LOW);
|
||||
digitalWrite(inverter_disconnect_contactor_pin, ON);
|
||||
datalayer.system.status.precharge_status = AUTO_PRECHARGE_OFF;
|
||||
logging.printf("Precharge: Disabled (timeout reached / BMS fault) -> AUTO_PRECHARGE_OFF\n");
|
||||
datalayer.system.status.precharge_status = AUTO_PRECHARGE_FAILURE;
|
||||
logging.printf("Precharge: CRITICAL FAILURE (timeout/BMS fault) -> REQUIRES REBOOT\n");
|
||||
set_event(EVENT_AUTOMATIC_PRECHARGE_FAILURE, 0);
|
||||
|
||||
// Force stop any further precharge attempts
|
||||
datalayer.system.settings.start_precharging = false;
|
||||
// Add event
|
||||
} else if (datalayer.system.status.battery_allows_contactor_closing) {
|
||||
pinMode(hia4v1_pin, OUTPUT);
|
||||
|
|
|
@ -260,7 +260,7 @@ String get_event_message_string(EVENTS_ENUM_TYPE event) {
|
|||
case EVENT_PRECHARGE_FAILURE:
|
||||
return "Battery failed to precharge. Check that capacitor is seated on high voltage output.";
|
||||
case EVENT_AUTOMATIC_PRECHARGE_FAILURE:
|
||||
return "Automatic precharge failed to reach target voltae.";
|
||||
return "Automatic precharge FAILURE. Failed to reach target voltage or BMS timeout. Reboot emulator to retry!";
|
||||
case EVENT_INTERNAL_OPEN_FAULT:
|
||||
return "High voltage cable removed while battery running. Opening contactors!";
|
||||
case EVENT_INVERTER_OPEN_CONTACTOR:
|
||||
|
|
|
@ -27,7 +27,8 @@ enum PrechargeState {
|
|||
AUTO_PRECHARGE_START,
|
||||
AUTO_PRECHARGE_PRECHARGING,
|
||||
AUTO_PRECHARGE_OFF,
|
||||
AUTO_PRECHARGE_COMPLETED
|
||||
AUTO_PRECHARGE_COMPLETED,
|
||||
AUTO_PRECHARGE_FAILURE
|
||||
};
|
||||
|
||||
#define DISCHARGING 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue