Skip to content

Commit

Permalink
Apply SOC_RESET_VOLTAGE after SOC_RESET_AFTER_DAYS regardless of …
Browse files Browse the repository at this point in the history
…charge mode

Fixes #123
  • Loading branch information
mr-manuel committed Jan 2, 2025
1 parent e67fba8 commit 94a4738
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* Added: Possibility to add external sensor for SoC by @mr-manuel
* Added: Signal handler for clean service restart/shutdown by @mr-manuel
* Changed: A lot of under the hood optimizations by @mr-manuel
* Changed: Apply `SOC_RESET_VOLTAGE` after `SOC_RESET_AFTER_DAYS` regardless of whether the battery is in absorption, bulk, or float mode https://github.com/mr-manuel/venus-os_dbus-serialbattery/issues/123 by @mr-manuel
* Changed: Consumed capacity must be negative values by @mr-manuel
* Changed: Daly CAN - Refactored driver to match new CAN standard by @mr-manuel and @transistorgit
* Changed: Dependencies are now shipped with the driver and not downloaded anymore which allows a complete offline installation by @mr-manuel
Expand Down
32 changes: 21 additions & 11 deletions dbus-serialbattery/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,23 @@ def manage_charge_voltage_linear(self) -> None:
and self.allow_max_voltage
):
self.max_voltage_start_time = current_time
# allow max voltage again, if cells are unbalanced or SoC threshold is reached

# allow max voltage again, if:
# - SoC threshold is reached
# - Cells are unbalanced
# - SoC reset was requested
elif (
utils.SWITCH_TO_BULK_SOC_THRESHOLD > self.soc_calc or voltage_cell_diff >= utils.CELL_VOLTAGE_DIFF_TO_RESET_VOLTAGE_LIMIT
utils.SWITCH_TO_BULK_SOC_THRESHOLD > self.soc_calc
or voltage_cell_diff >= utils.CELL_VOLTAGE_DIFF_TO_RESET_VOLTAGE_LIMIT
or self.soc_reset_requested
) and not self.allow_max_voltage:
self.allow_max_voltage = True

# do nothing (only for readability)
else:
pass

# timer started
else:
if voltage_cell_diff > utils.CELL_VOLTAGE_DIFF_KEEP_MAX_VOLTAGE_TIME_RESTART:
self.max_voltage_start_time = current_time
Expand Down Expand Up @@ -794,6 +804,7 @@ def manage_charge_voltage_linear(self) -> None:

if self.get_balancing() and voltage_cell_diff >= utils.CELL_VOLTAGE_DIFF_TO_RESET_VOLTAGE_LIMIT:
self.charge_mode += " + Balancing"

# Float mode
else:
float_voltage = round((utils.FLOAT_CELL_VOLTAGE * self.cell_count), 2)
Expand Down Expand Up @@ -964,17 +975,17 @@ def manage_charge_voltage_step(self) -> None:
voltage_cell_diff = self.get_max_cell_voltage() - self.get_min_cell_voltage()

if self.max_voltage_start_time is None:
# check if max voltage is reached and start timer to keep max voltage
# start timer, if max voltage is reached
if (self.max_battery_voltage - utils.VOLTAGE_DROP) <= voltage_sum and self.allow_max_voltage:
# example 2
self.max_voltage_start_time = current_time

# check if reset soc is greater than battery soc
# this prevents flapping between max and float voltage
elif utils.SWITCH_TO_BULK_SOC_THRESHOLD > self.soc_calc and not self.allow_max_voltage:
# allow max voltage again, if:
# - SoC threshold is reached
# - SoC reset was requested
elif (utils.SWITCH_TO_BULK_SOC_THRESHOLD > self.soc_calc or self.soc_reset_requested) and not self.allow_max_voltage:
self.allow_max_voltage = True

# do nothing
# do nothing (only for readability)
else:
pass

Expand All @@ -985,16 +996,15 @@ def manage_charge_voltage_step(self) -> None:
self.allow_max_voltage = False
self.max_voltage_start_time = None

else:
pass

# Bulk or Absorption mode
if self.allow_max_voltage:
self.control_voltage = self.max_battery_voltage
self.charge_mode = "Bulk" if self.max_voltage_start_time is None else "Absorption"

if self.max_battery_voltage == self.soc_reset_battery_voltage:
self.charge_mode += " & SoC Reset"

# Float mode
else:
# check if battery changed from bulk/absoprtion to float
if self.charge_mode is not None and not self.charge_mode.startswith("Float"):
Expand Down

0 comments on commit 94a4738

Please sign in to comment.