mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Avoid oscillation in precharge incase it fails/timeoutus
This commit is contained in:
parent
10a60abd1a
commit
d715d169fe
2 changed files with 14 additions and 3 deletions
|
@ -64,6 +64,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;
|
||||
|
||||
|
@ -128,11 +136,13 @@ 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;
|
||||
datalayer.system.status.precharge_status = AUTO_PRECHARGE_FAILURE;
|
||||
#ifdef DEBUG_LOG
|
||||
logging.printf("Precharge: Disabled (timeout reached / BMS fault) -> AUTO_PRECHARGE_OFF\n");
|
||||
logging.printf("Precharge: CRITICAL FAILURE (timeout/BMS fault) -> REQUIRES REBOOT\n");
|
||||
#endif
|
||||
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) {
|
||||
|
|
|
@ -28,7 +28,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