From cef05f52bc31a71bd077262aed054abf2c76900e Mon Sep 17 00:00:00 2001 From: "Jasper v. Blanckenburg" Date: Tue, 1 Aug 2023 14:38:43 +0200 Subject: [PATCH] Multiply SoC delta by 100 to get percentage --- Core/Src/soc_estimation.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Core/Src/soc_estimation.c b/Core/Src/soc_estimation.c index 1bcb9f5..ed5d3df 100644 --- a/Core/Src/soc_estimation.c +++ b/Core/Src/soc_estimation.c @@ -21,7 +21,6 @@ float current_soc; int current_was_flowing; uint32_t last_current_time; -uint32_t first_current_time; float soc_before_current; float mAs_before_current; @@ -36,7 +35,6 @@ void soc_update() { if (shunt_data.current >= SOC_ESTIMATION_NO_CURRENT_THRESH) { last_current_time = now; if (!current_was_flowing) { - first_current_time = now; soc_before_current = current_soc; mAs_before_current = shunt_data.current_counter; } @@ -53,8 +51,8 @@ void soc_update() { } else { // Otherwise, use the current counter to update SoC float as_delta = shunt_data.current_counter - mAs_before_current; - current_soc = - soc_before_current + as_delta / SOC_ESTIMATION_BATTERY_CAPACITY; + float soc_delta = as_delta / SOC_ESTIMATION_BATTERY_CAPACITY * 100; + current_soc = soc_before_current + soc_delta; } }