Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspired by #659 #711

Merged
merged 4 commits into from
Jun 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions etc/dbus-serialbattery/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def init_values(self):
self.min_battery_voltage = None
self.allow_max_voltage = True
self.max_voltage_start_time = None
self.transition_start_time = None
self.control_voltage_at_transition_start = None
self.charge_mode = None
self.charge_limitation = None
self.discharge_limitation = None
Expand Down Expand Up @@ -342,14 +344,28 @@ def manage_charge_voltage_linear(self) -> None:

else:
floatVoltage = round((utils.FLOAT_CELL_VOLTAGE * self.cell_count), 3)
chargeMode = "Float"
if self.control_voltage:
if self.control_voltage >= (floatVoltage + 0.005):
self.control_voltage -= 0.005
else:
self.control_voltage = floatVoltage
if not self.charge_mode.startswith("Float"):
self.transition_start_time = int(time())
self.initial_control_voltage = self.control_voltage
chargeMode = "Float Transition"
elif self.charge_mode.startswith("Float Transition"):
elapsed_time = int(time()) - self.transition_start_time
# Duration in seconds for smooth voltage drop from absorption to float
# depending on the number of cells
FLOAT_MODE_TRANSITION_DURATION = self.cell_count * 12
t = min(1, elapsed_time / FLOAT_MODE_TRANSITION_DURATION)
self.control_voltage = (
1 - t
) * self.initial_control_voltage + t * floatVoltage
if t == 1:
chargeMode = "Float"
else:
chargeMode = "Float Transition"
else:
self.control_voltage = floatVoltage
self.charge_mode = "Float"
self.charge_mode = chargeMode

if (
self.allow_max_voltage
Expand Down