Skip to content

Commit

Permalink
Added: Configure voltage drop
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed May 9, 2023
1 parent 47a3d16 commit a2e988c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
4 changes: 2 additions & 2 deletions etc/dbus-serialbattery/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def manage_charge_voltage_linear(self) -> None:

if self.max_voltage_start_time is None:
if (
utils.MAX_CELL_VOLTAGE * self.cell_count <= voltageSum
(utils.MAX_CELL_VOLTAGE * self.cell_count) - utils.VOLTAGE_DROP <= voltageSum
and voltageDiff
<= utils.CELL_VOLTAGE_DIFF_KEEP_MAX_VOLTAGE_UNTIL
and self.allow_max_voltage
Expand Down Expand Up @@ -309,7 +309,7 @@ def manage_charge_voltage_step(self) -> None:
if self.max_voltage_start_time is None:
# check if max voltage is reached and start timer to keep max voltage
if (
utils.MAX_CELL_VOLTAGE * self.cell_count <= voltageSum
(utils.MAX_CELL_VOLTAGE * self.cell_count) - utils.VOLTAGE_DROP <= voltageSum
and self.allow_max_voltage
):
# example 2
Expand Down
17 changes: 16 additions & 1 deletion etc/dbus-serialbattery/config.default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ SOC_LOW_WARNING = 20
SOC_LOW_ALARM = 10

; -- Daly settings
; Battery capacity (amps) if the BMS does not support reading it
; Battery capacity (amps), if the BMS does not support reading it
BATTERY_CAPACITY = 50
; Invert Battery Current. Default non-inverted. Set to -1 to invert
INVERT_CURRENT_MEASUREMENT = 1
Expand All @@ -228,3 +228,18 @@ GREENMETER_ADDRESS = 1
LIPRO_START_ADDRESS = 2
LIPRO_END_ADDRESS = 4
LIPRO_CELL_COUNT = 15


; --------- Battery monitor specific settings ---------
; If you are using a SmartShunt or something else as a battery monitor, the battery voltage reported
; from the BMS and SmartShunt could differ. This causes, that the driver never goapplies the float voltage,
; since max voltage is never reached.
; Example:
; cell count: 16
; MAX_CELL_VOLTAGE = 3.45
; max voltage calculated = 16 * 3.45 = 55.20
; CVL is set to 55.20 and the battery is now charged until the SmartShunt measures 55.20 V. The BMS
; now measures 55.05 V since there is a voltage drop of 0.15 V. Since the dbus-serialbattery measures
; 55.05 V the max voltage is never reached for the driver and max voltage is kept forever.
; Set VOLTAGE_DROP to 0.15
VOLTAGE_DROP = 0.00
4 changes: 1 addition & 3 deletions etc/dbus-serialbattery/dbus-serialbattery.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ def get_port() -> str:
logger.info("No Port needed")
return "/dev/tty/USB9"

logger.info(
"dbus-serialbattery v" + str(utils.DRIVER_VERSION)
)
logger.info("dbus-serialbattery v" + str(utils.DRIVER_VERSION))

port = get_port()
battery = None
Expand Down
4 changes: 1 addition & 3 deletions etc/dbus-serialbattery/dbushelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ def setup_vedbus(self):
self._dbusservice.add_path(
"/ProductName", "SerialBattery(" + self.battery.type + ")"
)
self._dbusservice.add_path(
"/FirmwareVersion", str(utils.DRIVER_VERSION)
)
self._dbusservice.add_path("/FirmwareVersion", str(utils.DRIVER_VERSION))
self._dbusservice.add_path("/HardwareVersion", self.battery.hardware_version)
self._dbusservice.add_path("/Connected", 1)
self._dbusservice.add_path(
Expand Down
15 changes: 15 additions & 0 deletions etc/dbus-serialbattery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,21 @@ def _get_list_from_config(
LIPRO_CELL_COUNT = int(config["DEFAULT"]["LIPRO_CELL_COUNT"])


# --------- Battery monitor specific settings ---------
# If you are using a SmartShunt or something else as a battery monitor, the battery voltage reported
# from the BMS and SmartShunt could differ. This causes, that the driver never goapplies the float voltage,
# since max voltage is never reached.
# Example:
# cell count: 16
# MAX_CELL_VOLTAGE = 3.45
# max voltage calculated = 16 * 3.45 = 55.20
# CVL is set to 55.20 and the battery is now charged until the SmartShunt measures 55.20 V. The BMS
# now measures 55.05 V since there is a voltage drop of 0.15 V. Since the dbus-serialbattery measures
# 55.05 V the max voltage is never reached for the driver and max voltage is kept forever.
# Set VOLTAGE_DROP to 0.15
VOLTAGE_DROP = float(config["DEFAULT"]["VOLTAGE_DROP"])


# --------- Functions ---------
def constrain(val, min_val, max_val):
if min_val > max_val:
Expand Down

0 comments on commit a2e988c

Please sign in to comment.