Multiply SoC delta by 100 to get percentage

This commit is contained in:
Jasper Blanckenburg 2023-08-01 14:38:43 +02:00
parent 61155995f8
commit cef05f52bc
1 changed files with 2 additions and 4 deletions

View File

@ -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;
}
}