mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
Add CRITICAL cell voltage safeties
This commit is contained in:
parent
7140b68d07
commit
7c14b8a0c0
3 changed files with 28 additions and 8 deletions
|
@ -8,6 +8,7 @@ static bool battery_full_event_fired = false;
|
||||||
static bool battery_empty_event_fired = false;
|
static bool battery_empty_event_fired = false;
|
||||||
|
|
||||||
#define MAX_SOH_DEVIATION_PPTT 2500
|
#define MAX_SOH_DEVIATION_PPTT 2500
|
||||||
|
#define CELL_CRITICAL_MV 100 // If cells go this much outside design voltage, shut battery down!
|
||||||
|
|
||||||
//battery pause status begin
|
//battery pause status begin
|
||||||
bool emulator_pause_request_ON = false;
|
bool emulator_pause_request_ON = false;
|
||||||
|
@ -54,13 +55,24 @@ void update_machineryprotection() {
|
||||||
clear_event(EVENT_BATTERY_UNDERVOLTAGE);
|
clear_event(EVENT_BATTERY_UNDERVOLTAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cell overvoltage, critical latching error without automatic reset. Requires user action.
|
// Cell overvoltage, further charging not possible. Battery might be imbalanced.
|
||||||
if (datalayer.battery.status.cell_max_voltage_mV >= datalayer.battery.info.max_cell_voltage_mV) {
|
if (datalayer.battery.status.cell_max_voltage_mV >= datalayer.battery.info.max_cell_voltage_mV) {
|
||||||
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
|
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
|
||||||
|
datalayer.battery.status.max_charge_power_W = 0;
|
||||||
}
|
}
|
||||||
// Cell undervoltage, critical latching error without automatic reset. Requires user action.
|
// Cell CRITICAL overvoltage, critical latching error without automatic reset. Requires user action to inspect battery.
|
||||||
|
if (datalayer.battery.status.cell_max_voltage_mV >= (datalayer.battery.info.max_cell_voltage_mV + CELL_CRITICAL_MV)) {
|
||||||
|
set_event(EVENT_CELL_CRITICAL_OVER_VOLTAGE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cell undervoltage. Further discharge not possible. Battery might be imbalanced.
|
||||||
if (datalayer.battery.status.cell_min_voltage_mV <= datalayer.battery.info.min_cell_voltage_mV) {
|
if (datalayer.battery.status.cell_min_voltage_mV <= datalayer.battery.info.min_cell_voltage_mV) {
|
||||||
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
|
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
|
||||||
|
datalayer.battery.status.max_discharge_power_W = 0;
|
||||||
|
}
|
||||||
|
//Cell CRITICAL undervoltage. critical latching error without automatic reset. Requires user action to inspect battery.
|
||||||
|
if (datalayer.battery.status.cell_min_voltage_mV <= (datalayer.battery.info.min_cell_voltage_mV - CELL_CRITICAL_MV)) {
|
||||||
|
set_event(EVENT_CELL_CRITICAL_UNDER_VOLTAGE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Battery is fully charged. Dont allow any more power into it
|
// Battery is fully charged. Dont allow any more power into it
|
||||||
|
|
|
@ -173,8 +173,10 @@ void init_events(void) {
|
||||||
events.entries[EVENT_INTERFACE_MISSING].level = EVENT_LEVEL_INFO;
|
events.entries[EVENT_INTERFACE_MISSING].level = EVENT_LEVEL_INFO;
|
||||||
events.entries[EVENT_MODBUS_INVERTER_MISSING].level = EVENT_LEVEL_INFO;
|
events.entries[EVENT_MODBUS_INVERTER_MISSING].level = EVENT_LEVEL_INFO;
|
||||||
events.entries[EVENT_ERROR_OPEN_CONTACTOR].level = EVENT_LEVEL_INFO;
|
events.entries[EVENT_ERROR_OPEN_CONTACTOR].level = EVENT_LEVEL_INFO;
|
||||||
events.entries[EVENT_CELL_UNDER_VOLTAGE].level = EVENT_LEVEL_ERROR;
|
events.entries[EVENT_CELL_CRITICAL_UNDER_VOLTAGE].level = EVENT_LEVEL_ERROR;
|
||||||
events.entries[EVENT_CELL_OVER_VOLTAGE].level = EVENT_LEVEL_ERROR;
|
events.entries[EVENT_CELL_CRITICAL_OVER_VOLTAGE].level = EVENT_LEVEL_ERROR;
|
||||||
|
events.entries[EVENT_CELL_UNDER_VOLTAGE].level = EVENT_LEVEL_WARNING;
|
||||||
|
events.entries[EVENT_CELL_OVER_VOLTAGE].level = EVENT_LEVEL_WARNING;
|
||||||
events.entries[EVENT_CELL_DEVIATION_HIGH].level = EVENT_LEVEL_WARNING;
|
events.entries[EVENT_CELL_DEVIATION_HIGH].level = EVENT_LEVEL_WARNING;
|
||||||
events.entries[EVENT_UNKNOWN_EVENT_SET].level = EVENT_LEVEL_ERROR;
|
events.entries[EVENT_UNKNOWN_EVENT_SET].level = EVENT_LEVEL_ERROR;
|
||||||
events.entries[EVENT_OTA_UPDATE].level = EVENT_LEVEL_UPDATE;
|
events.entries[EVENT_OTA_UPDATE].level = EVENT_LEVEL_UPDATE;
|
||||||
|
@ -349,12 +351,16 @@ const char* get_event_message_string(EVENTS_ENUM_TYPE event) {
|
||||||
"Check other error code for reason!";
|
"Check other error code for reason!";
|
||||||
case EVENT_MODBUS_INVERTER_MISSING:
|
case EVENT_MODBUS_INVERTER_MISSING:
|
||||||
return "Modbus inverter has not sent any data. Inspect communication wiring!";
|
return "Modbus inverter has not sent any data. Inspect communication wiring!";
|
||||||
|
case EVENT_CELL_CRITICAL_UNDER_VOLTAGE:
|
||||||
|
return "CELL VOLTAGE CRITICALLY LOW! Not possible to continue. Inspect battery!";
|
||||||
case EVENT_CELL_UNDER_VOLTAGE:
|
case EVENT_CELL_UNDER_VOLTAGE:
|
||||||
return "CELL UNDERVOLTAGE!!! Stopping battery charging and discharging. Inspect battery!";
|
return "Cell undervoltage. Further discharge not possible. Check balancing of cells";
|
||||||
case EVENT_CELL_OVER_VOLTAGE:
|
case EVENT_CELL_OVER_VOLTAGE:
|
||||||
return "CELL OVERVOLTAGE!!! Stopping battery charging and discharging. Inspect battery!";
|
return "Cell overvoltage. Further charging not possible. Check balancing of cells";
|
||||||
|
case EVENT_CELL_CRITICAL_OVER_VOLTAGE:
|
||||||
|
return "CELL VOLTAGE CRITICALLY HIGH! Not possible to continue. Inspect battery!";
|
||||||
case EVENT_CELL_DEVIATION_HIGH:
|
case EVENT_CELL_DEVIATION_HIGH:
|
||||||
return "HIGH CELL DEVIATION!!! Inspect battery!";
|
return "Large cell voltage deviation! Check balancing of cells";
|
||||||
case EVENT_UNKNOWN_EVENT_SET:
|
case EVENT_UNKNOWN_EVENT_SET:
|
||||||
return "An unknown event was set! Review your code!";
|
return "An unknown event was set! Review your code!";
|
||||||
case EVENT_DUMMY_INFO:
|
case EVENT_DUMMY_INFO:
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
// #define INCLUDE_EVENTS_TEST // Enable to run an event test loop, see events_test_on_target.cpp
|
// #define INCLUDE_EVENTS_TEST // Enable to run an event test loop, see events_test_on_target.cpp
|
||||||
|
|
||||||
#define EE_MAGIC_HEADER_VALUE 0x0019 // 0x0000 to 0xFFFF
|
#define EE_MAGIC_HEADER_VALUE 0x0020 // 0x0000 to 0xFFFF
|
||||||
|
|
||||||
#define GENERATE_ENUM(ENUM) ENUM,
|
#define GENERATE_ENUM(ENUM) ENUM,
|
||||||
#define GENERATE_STRING(STRING) #STRING,
|
#define GENERATE_STRING(STRING) #STRING,
|
||||||
|
@ -71,6 +71,8 @@
|
||||||
XX(EVENT_INTERFACE_MISSING) \
|
XX(EVENT_INTERFACE_MISSING) \
|
||||||
XX(EVENT_MODBUS_INVERTER_MISSING) \
|
XX(EVENT_MODBUS_INVERTER_MISSING) \
|
||||||
XX(EVENT_ERROR_OPEN_CONTACTOR) \
|
XX(EVENT_ERROR_OPEN_CONTACTOR) \
|
||||||
|
XX(EVENT_CELL_CRITICAL_UNDER_VOLTAGE) \
|
||||||
|
XX(EVENT_CELL_CRITICAL_OVER_VOLTAGE) \
|
||||||
XX(EVENT_CELL_UNDER_VOLTAGE) \
|
XX(EVENT_CELL_UNDER_VOLTAGE) \
|
||||||
XX(EVENT_CELL_OVER_VOLTAGE) \
|
XX(EVENT_CELL_OVER_VOLTAGE) \
|
||||||
XX(EVENT_CELL_DEVIATION_HIGH) \
|
XX(EVENT_CELL_DEVIATION_HIGH) \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue