From 59da9eac2ba72095e3e130b7e10cb73d3810f41a Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 10 Nov 2023 23:29:25 +0200 Subject: [PATCH 1/3] Add SOC% plausibility detection --- Software/src/battery/NISSAN-LEAF-BATTERY.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp index 32dd0d4a..4e5c1b2e 100644 --- a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp +++ b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp @@ -241,6 +241,14 @@ void update_values_leaf_battery() { /* This function maps all the values fetched max_target_discharge_power = 0; } + //Check if SOC% is plausible + if (battery_voltage > (ABSOLUTE_MAX_VOLTAGE - 100)) { + if (LB_SOC < 650) { + bms_status = FAULT; + Serial.println("ERROR: SOC% reported by battery not plausible. Restart battery!"); + } + } + if (LB_Full_CHARGE_flag) { //Battery reports that it is fully charged stop all further charging incase it hasn't already max_target_charge_power = 0; } From 3545c3d8ba7c43578e626de5ecc34471461368de Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 21 Nov 2023 20:17:07 +0200 Subject: [PATCH 2/3] Improve comment on plausability check --- Software/src/battery/NISSAN-LEAF-BATTERY.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp index 4e5c1b2e..c66c81e1 100644 --- a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp +++ b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp @@ -242,7 +242,7 @@ void update_values_leaf_battery() { /* This function maps all the values fetched } //Check if SOC% is plausible - if (battery_voltage > (ABSOLUTE_MAX_VOLTAGE - 100)) { + if (battery_voltage > (ABSOLUTE_MAX_VOLTAGE - 100)) { // When pack voltage is close to max, and SOC% is still low, raise FAULT if (LB_SOC < 650) { bms_status = FAULT; Serial.println("ERROR: SOC% reported by battery not plausible. Restart battery!"); From e89717f1676aba2d512f9115006ce53e1c89fe30 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 21 Nov 2023 20:18:59 +0200 Subject: [PATCH 3/3] Fix pre-commit error --- Software/src/battery/NISSAN-LEAF-BATTERY.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp index c66c81e1..42cf263f 100644 --- a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp +++ b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp @@ -242,7 +242,8 @@ void update_values_leaf_battery() { /* This function maps all the values fetched } //Check if SOC% is plausible - if (battery_voltage > (ABSOLUTE_MAX_VOLTAGE - 100)) { // When pack voltage is close to max, and SOC% is still low, raise FAULT + if (battery_voltage > + (ABSOLUTE_MAX_VOLTAGE - 100)) { // When pack voltage is close to max, and SOC% is still low, raise FAULT if (LB_SOC < 650) { bms_status = FAULT; Serial.println("ERROR: SOC% reported by battery not plausible. Restart battery!");