mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 10:19:29 +02:00
Add inverter exceeding limits event
This commit is contained in:
parent
7193938dcd
commit
170ba8f5bb
4 changed files with 31 additions and 3 deletions
|
@ -30,6 +30,8 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** int32_t */
|
/** int32_t */
|
||||||
/** Instantaneous battery power in Watts */
|
/** Instantaneous battery power in Watts */
|
||||||
|
/* Positive value = Battery Charging */
|
||||||
|
/* Negative value = Battery Discharging */
|
||||||
int32_t active_power_W;
|
int32_t active_power_W;
|
||||||
|
|
||||||
/** uint32_t */
|
/** uint32_t */
|
||||||
|
|
|
@ -34,7 +34,7 @@ void update_machineryprotection() {
|
||||||
clear_event(EVENT_BATTERY_UNDERVOLTAGE);
|
clear_event(EVENT_BATTERY_UNDERVOLTAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Battery is extremely degraded, not fit for secondlifestorage
|
// Battery is extremely degraded, not fit for secondlifestorage!
|
||||||
if (datalayer.battery.status.soh_pptt < 2500) {
|
if (datalayer.battery.status.soh_pptt < 2500) {
|
||||||
set_event(EVENT_LOW_SOH, datalayer.battery.status.soh_pptt);
|
set_event(EVENT_LOW_SOH, datalayer.battery.status.soh_pptt);
|
||||||
} else {
|
} else {
|
||||||
|
@ -49,6 +49,24 @@ void update_machineryprotection() {
|
||||||
clear_event(EVENT_CELL_DEVIATION_HIGH);
|
clear_event(EVENT_CELL_DEVIATION_HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inverter is charging with more power than battery wants!
|
||||||
|
if (datalayer.battery.status.active_power_W > 0) { // Charging
|
||||||
|
if (datalayer.battery.status.active_power_W > (datalayer.battery.status.max_charge_power_W + 2000)) {
|
||||||
|
set_event(EVENT_CHARGE_LIMIT_EXCEEDED, 0); // Alert when 2kW over requested max
|
||||||
|
} else {
|
||||||
|
clear_event(EVENT_CHARGE_LIMIT_EXCEEDED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inverter is pulling too much power from battery!
|
||||||
|
if (datalayer.battery.status.active_power_W < 0) { // Discharging
|
||||||
|
if (-datalayer.battery.status.active_power_W > (datalayer.battery.status.max_charge_power_W + 2000)) {
|
||||||
|
set_event(EVENT_DISCHARGE_LIMIT_EXCEEDED, 0); // Alert when 2kW over requested max
|
||||||
|
} else {
|
||||||
|
clear_event(EVENT_DISCHARGE_LIMIT_EXCEEDED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the BMS is still sending CAN messages. If we go 60s without messages we raise an error
|
// Check if the BMS is still sending CAN messages. If we go 60s without messages we raise an error
|
||||||
if (!datalayer.battery.status.CAN_battery_still_alive) {
|
if (!datalayer.battery.status.CAN_battery_still_alive) {
|
||||||
set_event(EVENT_CAN_RX_FAILURE, 0);
|
set_event(EVENT_CAN_RX_FAILURE, 0);
|
||||||
|
@ -57,7 +75,7 @@ void update_machineryprotection() {
|
||||||
clear_event(EVENT_CAN_RX_FAILURE);
|
clear_event(EVENT_CAN_RX_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also check if we have recieved too many malformed CAN messages
|
// Too many malformed CAN messages recieved!
|
||||||
if (datalayer.battery.status.CAN_error_counter > MAX_CAN_FAILURES) {
|
if (datalayer.battery.status.CAN_error_counter > MAX_CAN_FAILURES) {
|
||||||
set_event(EVENT_CAN_RX_WARNING, 0);
|
set_event(EVENT_CAN_RX_WARNING, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -139,6 +139,8 @@ void init_events(void) {
|
||||||
events.entries[EVENT_CAN_RX_WARNING].level = EVENT_LEVEL_WARNING;
|
events.entries[EVENT_CAN_RX_WARNING].level = EVENT_LEVEL_WARNING;
|
||||||
events.entries[EVENT_CAN_TX_FAILURE].level = EVENT_LEVEL_ERROR;
|
events.entries[EVENT_CAN_TX_FAILURE].level = EVENT_LEVEL_ERROR;
|
||||||
events.entries[EVENT_WATER_INGRESS].level = EVENT_LEVEL_ERROR;
|
events.entries[EVENT_WATER_INGRESS].level = EVENT_LEVEL_ERROR;
|
||||||
|
events.entries[EVENT_CHARGE_LIMIT_EXCEEDED].level = EVENT_LEVEL_INFO;
|
||||||
|
events.entries[EVENT_DISCHARGE_LIMIT_EXCEEDED].level = EVENT_LEVEL_INFO;
|
||||||
events.entries[EVENT_12V_LOW].level = EVENT_LEVEL_WARNING;
|
events.entries[EVENT_12V_LOW].level = EVENT_LEVEL_WARNING;
|
||||||
events.entries[EVENT_SOC_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_ERROR;
|
events.entries[EVENT_SOC_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_ERROR;
|
||||||
events.entries[EVENT_KWH_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_INFO;
|
events.entries[EVENT_KWH_PLAUSIBILITY_ERROR].level = EVENT_LEVEL_INFO;
|
||||||
|
@ -212,6 +214,10 @@ const char* get_event_message_string(EVENTS_ENUM_TYPE event) {
|
||||||
return "ERROR: High amount of corrupted CAN messages detected. Check CAN wire shielding!";
|
return "ERROR: High amount of corrupted CAN messages detected. Check CAN wire shielding!";
|
||||||
case EVENT_CAN_TX_FAILURE:
|
case EVENT_CAN_TX_FAILURE:
|
||||||
return "ERROR: CAN messages failed to transmit, or no one on the bus to ACK the message!";
|
return "ERROR: CAN messages failed to transmit, or no one on the bus to ACK the message!";
|
||||||
|
case EVENT_CHARGE_LIMIT_EXCEEDED:
|
||||||
|
return "Info: Inverter is charging with higher power amount than battery is sending as max allowed.";
|
||||||
|
case EVENT_DISCHARGE_LIMIT_EXCEEDED:
|
||||||
|
return "Info: Inverter is discharging with higher power amount than battery is sending as max allowed.";
|
||||||
case EVENT_WATER_INGRESS:
|
case EVENT_WATER_INGRESS:
|
||||||
return "Water leakage inside battery detected. Operation halted. Inspect battery!";
|
return "Water leakage inside battery detected. Operation halted. Inspect battery!";
|
||||||
case EVENT_12V_LOW:
|
case EVENT_12V_LOW:
|
||||||
|
|
|
@ -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 0x0005 // 0x0000 to 0xFFFF
|
#define EE_MAGIC_HEADER_VALUE 0x0006 // 0x0000 to 0xFFFF
|
||||||
|
|
||||||
#define GENERATE_ENUM(ENUM) ENUM,
|
#define GENERATE_ENUM(ENUM) ENUM,
|
||||||
#define GENERATE_STRING(STRING) #STRING,
|
#define GENERATE_STRING(STRING) #STRING,
|
||||||
|
@ -32,6 +32,8 @@
|
||||||
XX(EVENT_CANFD_RX_FAILURE) \
|
XX(EVENT_CANFD_RX_FAILURE) \
|
||||||
XX(EVENT_CAN_RX_WARNING) \
|
XX(EVENT_CAN_RX_WARNING) \
|
||||||
XX(EVENT_CAN_TX_FAILURE) \
|
XX(EVENT_CAN_TX_FAILURE) \
|
||||||
|
XX(EVENT_CHARGE_LIMIT_EXCEEDED) \
|
||||||
|
XX(EVENT_DISCHARGE_LIMIT_EXCEEDED \
|
||||||
XX(EVENT_WATER_INGRESS) \
|
XX(EVENT_WATER_INGRESS) \
|
||||||
XX(EVENT_12V_LOW) \
|
XX(EVENT_12V_LOW) \
|
||||||
XX(EVENT_SOC_PLAUSIBILITY_ERROR) \
|
XX(EVENT_SOC_PLAUSIBILITY_ERROR) \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue