mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 10:19:29 +02:00
Event clearning added, LEAF safety improved
This commit is contained in:
parent
362824f944
commit
cc0d4ea4bf
4 changed files with 33 additions and 13 deletions
|
@ -222,6 +222,8 @@ void update_values_kiaHyundai_64_battery() { //This function maps all the value
|
|||
}
|
||||
if (cell_deviation_mV > MAX_CELL_DEVIATION) {
|
||||
set_event(EVENT_CELL_DEVIATION_HIGH, 0);
|
||||
} else {
|
||||
clear_event(EVENT_CELL_DEVIATION_HIGH);
|
||||
}
|
||||
|
||||
if (bms_status == FAULT) { //Incase we enter a critical fault state, zero out the allowed limits
|
||||
|
|
|
@ -267,11 +267,15 @@ void update_values_leaf_battery() { /* This function maps all the values fetched
|
|||
if (LB_Full_CHARGE_flag) { //Battery reports that it is fully charged stop all further charging incase it hasn't already
|
||||
set_event(EVENT_BATTERY_FULL, 0);
|
||||
max_target_charge_power = 0;
|
||||
} else {
|
||||
clear_event(EVENT_BATTERY_FULL);
|
||||
}
|
||||
|
||||
if (LB_Capacity_Empty) { //Battery reports that it is fully discharged. Stop all further discharging incase it hasn't already
|
||||
set_event(EVENT_BATTERY_EMPTY, 0);
|
||||
max_target_discharge_power = 0;
|
||||
} else {
|
||||
clear_event(EVENT_BATTERY_EMPTY);
|
||||
}
|
||||
|
||||
if (LB_Relay_Cut_Request) { //LB_FAIL, BMS requesting shutdown and contactors to be opened
|
||||
|
@ -323,14 +327,18 @@ void update_values_leaf_battery() { /* This function maps all the values fetched
|
|||
default:
|
||||
break;
|
||||
}
|
||||
} else { //LB_Failsafe_Status == 0
|
||||
clear_event(EVENT_BATTERY_DISCHG_STOP_REQ);
|
||||
clear_event(EVENT_BATTERY_CHG_STOP_REQ);
|
||||
clear_event(EVENT_BATTERY_CHG_DISCHG_STOP_REQ);
|
||||
}
|
||||
|
||||
if (LB_StateOfHealth < 25) { //Battery is extremely degraded, not fit for secondlifestorage. Zero it all out.
|
||||
if (LB_StateOfHealth != 0) { //Extra check to see that we actually have a SOH Value available
|
||||
errorCode = 5;
|
||||
set_event(EVENT_LOW_SOH, LB_StateOfHealth);
|
||||
max_target_discharge_power = 0;
|
||||
max_target_charge_power = 0;
|
||||
} else {
|
||||
clear_event(EVENT_LOW_SOH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,9 +346,8 @@ void update_values_leaf_battery() { /* This function maps all the values fetched
|
|||
if (!LB_Interlock) {
|
||||
set_event(EVENT_HVIL_FAILURE, 0);
|
||||
errorCode = 6;
|
||||
SOC = 0;
|
||||
max_target_discharge_power = 0;
|
||||
max_target_charge_power = 0;
|
||||
} else {
|
||||
clear_event(EVENT_HVIL_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -359,6 +366,11 @@ void update_values_leaf_battery() { /* This function maps all the values fetched
|
|||
set_event(EVENT_CAN_RX_WARNING, 0);
|
||||
}
|
||||
|
||||
if (bms_status == FAULT) { //Incase we enter a critical fault state, zero out the allowed limits
|
||||
max_target_charge_power = 0;
|
||||
max_target_discharge_power = 0;
|
||||
}
|
||||
|
||||
/*Finally print out values to serial if configured to do so*/
|
||||
#ifdef DEBUG_VIA_USB
|
||||
if (errorCode > 0) {
|
||||
|
|
|
@ -236,6 +236,8 @@ void update_values_tesla_model_3_battery() { //This function maps all the value
|
|||
|
||||
if (hvil_status == 3) { //INTERNAL_OPEN_FAULT - Someone disconnected a high voltage cable while battery was in use
|
||||
set_event(EVENT_INTERNAL_OPEN_FAULT, 0);
|
||||
} else {
|
||||
clear_event(EVENT_INTERNAL_OPEN_FAULT);
|
||||
}
|
||||
|
||||
cell_deviation_mV = (cell_max_v - cell_min_v);
|
||||
|
@ -270,23 +272,27 @@ void update_values_tesla_model_3_battery() { //This function maps all the value
|
|||
|
||||
if (LFP_Chemistry) { //LFP limits used for voltage safeties
|
||||
if (cell_max_v >= MAX_CELL_VOLTAGE_LFP) {
|
||||
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
|
||||
set_event(EVENT_CELL_OVER_VOLTAGE, cell_max_v);
|
||||
}
|
||||
if (cell_min_v <= MIN_CELL_VOLTAGE_LFP) {
|
||||
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
|
||||
set_event(EVENT_CELL_UNDER_VOLTAGE, cell_min_v);
|
||||
}
|
||||
if (cell_deviation_mV > MAX_CELL_DEVIATION_LFP) {
|
||||
set_event(EVENT_CELL_DEVIATION_HIGH, 0);
|
||||
set_event(EVENT_CELL_DEVIATION_HIGH, cell_deviation_mV);
|
||||
} else {
|
||||
clear_event(EVENT_CELL_DEVIATION_HIGH);
|
||||
}
|
||||
} else { //NCA/NCM limits used
|
||||
if (cell_max_v >= MAX_CELL_VOLTAGE_NCA_NCM) {
|
||||
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
|
||||
set_event(EVENT_CELL_OVER_VOLTAGE, cell_max_v);
|
||||
}
|
||||
if (cell_min_v <= MIN_CELL_VOLTAGE_NCA_NCM) {
|
||||
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
|
||||
set_event(EVENT_CELL_UNDER_VOLTAGE, cell_min_v);
|
||||
}
|
||||
if (cell_deviation_mV > MAX_CELL_DEVIATION_NCA_NCM) {
|
||||
set_event(EVENT_CELL_DEVIATION_HIGH, 0);
|
||||
set_event(EVENT_CELL_DEVIATION_HIGH, cell_deviation_mV);
|
||||
} else {
|
||||
clear_event(EVENT_CELL_DEVIATION_HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ void init_events(void) {
|
|||
events.entries[EVENT_WATER_INGRESS].level = EVENT_LEVEL_ERROR;
|
||||
events.entries[EVENT_12V_LOW].level = EVENT_LEVEL_WARNING;
|
||||
events.entries[EVENT_SOC_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_ERROR;
|
||||
events.entries[EVENT_KWH_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_WARNING;
|
||||
events.entries[EVENT_KWH_PLAUSIBILITY_ERROR].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_CHG_STOP_REQ].level = EVENT_LEVEL_ERROR;
|
||||
|
@ -174,7 +174,7 @@ const char* get_event_message_string(EVENTS_ENUM_TYPE event) {
|
|||
case EVENT_SOC_PLAUSIBILITY_ERROR:
|
||||
return "ERROR: SOC% reported by battery not plausible. Restart battery!";
|
||||
case EVENT_KWH_PLAUSIBILITY_ERROR:
|
||||
return "Warning: kWh remaining reported by battery not plausible. Battery needs cycling.";
|
||||
return "Info: kWh remaining reported by battery not plausible. Battery needs cycling.";
|
||||
case EVENT_BATTERY_EMPTY:
|
||||
return "Info: Battery is completely discharged";
|
||||
case EVENT_BATTERY_FULL:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue