Louisvdw / dbus-serialbattery

Battery Monitor driver for serial battery in VenusOS GX systems
MIT License
494 stars 157 forks source link

nightly from dev does not start up. #898

Closed cflenker closed 6 months ago

cflenker commented 6 months ago

Describe the problem

Driver does not start up.

Driver version

v1.1.20231223dev

Venus OS device type

Cerbo GX

Venus OS version

v3.00

BMS type

JKBMS / Heltec BMS

Cell count

16

Connection type

Serial USB adapter to TTL

Config file

[DEFAULT]

; If you want to add custom values/settings, then check the values/settings you want to change in "config.default.ini"
; and insert them below to persist future driver updates.

; Example (remove the semicolon ";" to uncomment and activate the value/setting):
; MAX_BATTERY_CHARGE_CURRENT = 50.0
; MAX_BATTERY_DISCHARGE_CURRENT = 60.0

; --------- Battery Current limits ---------
MAX_BATTERY_CHARGE_CURRENT    = 80.0
MAX_BATTERY_DISCHARGE_CURRENT = 80.0

; --------- Cell Voltages ---------
; Description: Cell min/max voltages which are used to calculate the min/max battery voltage
; Example: 16 cells * 3.45V/cell = 55.2V max charge voltage. 16 cells * 2.90V = 46.4V min discharge voltage
MIN_CELL_VOLTAGE   = 2.900
; Max voltage can seen as absorption voltage
; CF: MAX_CELL_VOLTAGE auf 3.55 gesetzt, damit penalty nicht zu frueh greift
;     und die CVL runterholt was zu einem starken toggeln führt
;     Die wirkliche Absobtion-Spannung wird über DVCC auf 55.2V begrenzt.
MAX_CELL_VOLTAGE   = 3.450
FLOAT_CELL_VOLTAGE = 3.375
;
;
;
;
; Specify in seconds how often the linear values should be recalculated
LINEAR_RECALCULATION_EVERY = 60
; Specify in percent when the linear values should be recalculated immediately
; Example: 5 for a immediate change, when the value changes by more than 5%
LINEAR_RECALCULATION_ON_PERC_CHANGE = 5

; --------- Charge Voltage limitation (affecting CVL) ---------
; Description: Limit max charging voltage (MAX_CELL_VOLTAGE * cell count), switch from max voltage to float
;              voltage (FLOAT_CELL_VOLTAGE * cell count) and back
;     False: Max charging voltage is always kept
;     True: Max charging voltage is reduced based on charge mode
;         Step mode: After max voltage is reached for MAX_VOLTAGE_TIME_SEC it switches to float voltage. After
;                    SoC is below SOC_LEVEL_TO_RESET_VOLTAGE_LIMIT it switches back to max voltage.
;         Linear mode: After max voltage is reachend and cell voltage difference is smaller or equal to
;                      CELL_VOLTAGE_DIFF_KEEP_MAX_VOLTAGE_UNTIL it switches to float voltage after 300 (fixed)
;                      additional seconds.
;                      After cell voltage difference is greater or equal to CELL_VOLTAGE_DIFF_TO_RESET_VOLTAGE_LIMIT
;                      OR
;                      SoC is below SOC_LEVEL_TO_RESET_VOLTAGE_LIMIT
;                      it switches back to max voltage.
; Example: The battery reached max voltage of 55.2V and hold it for 900 seconds, the the CVL is switched to
;          float voltage of 53.6V to don't stress the batteries. Allow max voltage of 55.2V again, if SoC is
;          once below 90%
;          OR
;          The battery reached max voltage of 55.2V and the max cell difference is 0.010V, then switch to float
;          voltage of 53.6V after 300 additional seconds to don't stress the batteries. Allow max voltage of
;          55.2V again if max cell difference is above 0.080V or SoC below 90%.
; Charge voltage control management enable (True/False).
CVCM_ENABLE = True

; -- CVL reset based on cell voltage diff (linear mode)
; Specify cell voltage diff where CVL limit is kept until diff is equal or lower
CELL_VOLTAGE_DIFF_KEEP_MAX_VOLTAGE_UNTIL = 0.010
; Specify cell voltage diff where MAX_VOLTAGE_TIME_SEC restarts if diff is bigger
CELL_VOLTAGE_DIFF_KEEP_MAX_VOLTAGE_TIME_RESTART = 0.013
; Specify cell voltage diff where CVL limit is reset to max voltage, if value get above
; the cells are considered as imbalanced, if the cell diff exceeds 5% of the nominal cell voltage
; e.g. 3.2 V * 5 / 100 = 0.160 V
CELL_VOLTAGE_DIFF_TO_RESET_VOLTAGE_LIMIT = 0.080

; -- CVL reset based on SoC option (step mode & linear mode)
; Specify how long the max voltage should be kept
;     Step mode: If reached then switch to float voltage
;     Linear mode: 
;         * Cells are judged to be balanced when max voltage is reached and cell difference is below CELL_VOLTAGE_DIFF_TO_RESET_VOLTAGE_LIMIT 
;           for FLOAT_TRANSITION_DEBOUNCE_SEC seconds
;         * If cells are judged to be balanced keep max voltage for further MAX_VOLTAGE_TIME_SEC seconds
FLOAT_TRANSITION_DEBOUNCE_SEC = 900
MAX_VOLTAGE_TIME_SEC = 1800

; Specify SoC where CVL limit is reset to max voltage, if value gets below
SOC_LEVEL_TO_RESET_VOLTAGE_LIMIT = 90

; --------- SOC limitation (affecting CCL/DCL) ---------
; Description: Maximal charge / discharge current will be increased / decreased depending on State of Charge,
;              see CC_SOC_LIMIT1 etc.
; Example: The SoC limit will be monitored to control the currents.
; Charge current control management enable (True/False).
CCCM_SOC_ENABLE = False
; Discharge current control management enable (True/False).
DCCM_SOC_ENABLE = False

; --------- Cell Voltage limitation (affecting CVL) ---------
; This function prevents a bad balanced battery to overcharge the cell with the highest voltage and the bms to
; switch off because of overvoltage of this cell.
;
; Example:
; 15 cells are at 3.4v, 1 cell is at 3.6v. Total voltage of battery is 54.6v and the Victron System sees no reason to
; lower the charging current as the control_voltage (Absorbtion Voltage) ist 55.2v
; In this case the Cell Voltage limitation kicks in and lowers the control_voltage to keep it close to the MAX_CELL_VOLTAGE.
;
; In theory this can also be done with CCL, but doing it with CVL has 2 advantages:
;   - In a well balanced system the current can be kept quite high till the end of charge by using MAX_CELL_VOLTAGE for charging.
;   - In systems with MPPTs and DC-feed-in activated the victron systems do not respect CCL, so CVL is the only way to prevent the
;     highest cell in a bad balanced system from overcharging.
;
; There are 2 methods implemented to calculate CVL:
;   1. PenaltySum-Method (CVL_ICONTROLLER_MODE = False)
;      The voltage-overshoot of all cells that exceed MAX_CELL_VOLTAGE is summed up and the control voltage is lowered by this "penaltysum".
;      This is calculated every LINEAR_RECALCULATION_EVERY seconds.
;   2. I-Controller (CVL_ICONTROLLER_MODE = True)
;      An I-Controller tries to control the voltage of the highest cell to MAX_CELL_VOLTAGE + CELL_VOLTAGE_DIFF_KEEP_MAX_VOLTAGE_UNTIL.
;      (for example 3.45V+0.01V =3.46V). If the voltage of the highest cell is above this level, CVL is reduced. If the voltage is below, CVL is 
;      increased until cellcount*MAX_CELL_VOLTAGE.
;      An I-Part of 0.2 V/Vs (CVL_ICONTROLLER_FACTOR) has proved to be a stable and fast controlling-behaviour.
;      This method is not as fast as the PenaltySum-Method but usually smoother and more stable against toggeling and has no stationary deviation.
CVL_ICONTROLLER_MODE = True 
CVL_ICONTROLLER_FACTOR = 0.2

; --------- SOC calculation ---------
; Description: Calculate the SOC in the driver. Do not use the SOC reported by the BMS
; SOC_CALCULATION:
;     True: Calc SOC in the driver, do not use SOC reported from BMS
;         - The SOC is calculated by integration of the current reported by the BMS
;         - The current reported from the BMS can be corrected by
;           the map (SOC_CALC_CURRENT_REPORTED_BY_BMS, SOC_CALC_CURRENT_MEASURED_BY_USER)
;         - The SOC is set to 100% if the following conditions apply for at least SOC_RESET_TIME seconds:
;             * Current is lower than SOC_RESET_CURRENT amps
;             * Sum of cell voltages >= self.max_battery_voltage - VOLTAGE_DROP
;         - The calculated SOC is stored in dbus to persist a driver restart
;     False: Use SOC reported from BMS (none of the other parameters apply)
; More info: https://github.com/Louisvdw/dbus-serialbattery/pull/868
SOC_CALCULATION = True
SOC_RESET_CURRENT = 7
SOC_RESET_TIME = 60
SOC_CALC_CURRENT_REPORTED_BY_BMS  = -300,      -1, -0.9, 0.9,      1, 300
SOC_CALC_CURRENT_MEASURED_BY_USER = -289, -0.7753,    0,   0, 0.7753, 289

; --------- 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.05

Relevant log output

@400000006587845c360fe994 KeyError: 'CUSTOM_BATTERY_NAMES'
@4000000065878481339a3e44 Traceback (most recent call last):
@4000000065878481339a616c   File "/opt/victronenergy/dbus-serialbattery/dbus-serialbattery.py", line 18, in <module>
@4000000065878481339a710c     from dbushelper import DbusHelper
@4000000065878481339a78dc   File "/opt/victronenergy/dbus-serialbattery/dbushelper.py", line 8, in <module>
@4000000065878481339be424     from utils import logger, publish_config_variables
@4000000065878481339befdc   File "/opt/victronenergy/dbus-serialbattery/utils.py", line 237, in <module>
@4000000065878481339e8fbc     CUSTOM_BATTERY_NAMES = _get_list_from_config(
@4000000065878481339e9f5c   File "/opt/victronenergy/dbus-serialbattery/utils.py", line 30, in _get_list_from_config
@4000000065878481339eaefc     rawList = config[group][option].split(",")
@4000000065878481339ebab4   File "/usr/lib/python3.8/configparser.py", line 1254, in __getitem__
@4000000065878481339ec66c     raise KeyError(key)
@4000000065878481339f3f84 KeyError: 'CUSTOM_BATTERY_NAMES'

Any other information that may be helpful

No response

cflenker commented 6 months ago

It was fixed when I added the following line in my config.ini:

CUSTOM_BATTERY_NAMES = /dev/ttyUSB0:JKBMS1_Flenker

But maybe it should also work without defining a custom battery name in the config.ini.

Otherwise please just close this issue. Thank you! Merry Christmas 🎅

mr-manuel commented 6 months ago

Thanks for reporting. Theoretically the custom names are now stored in the dbus instead of the config file. I will check tet immediately. Merry Christmas also to you :-)

mr-manuel commented 6 months ago

Fixed