Hi Izak @iburger
Thank you for your efforts.
This is the algo I am using for some days and below the cell evolution.
Instead of capping the voltage from up downwards, I am imposing a lower limit and then I am going up slowly, following the lowest voltage cell.
I am also controlling the current for avoiding sawtooth voltage and error #29
DESIRED_BATTERY_VOLTAGE = 52.50 # 3.50V per cell
MINIMUM_BATTERY_VOLTAGE = 52.05 # 3.47V per cell
battery_target_voltage = DESIRED_BATTERY_VOLTAGE
if charge_current > 0.1:
# still charging (CCL != 0) so keep an eye for over voltages
battery_target_voltage = (bms.mincellvoltage + 0.035) * 15 # wait for slower cells, max 35mV deltaV between cells
battery_target_voltage = min(battery_target_voltage, DESIRED_BATTERY_VOLTAGE) # just to be sure it's between the limits - max one
battery_target_voltage = max(battery_target_voltage, MINIMUM_BATTERY_VOLTAGE) # just to be sure it's between the limits - min one
difference = max(0, battery_target_voltage - 0.02 - bms.voltage) # starts after 0.02V below target voltage
system_idle_current = difference * 20 + 0.3 # a 0.3A minimum idle current to avoid error 29
system_idle_current = round(system_idle_current, 1) # round the current nicely to 1 decimal
system_target_voltage = battery_target_voltage + 0.05 # an addition of 0.05V for compensate cable loss
system_target_voltage = round(system_target_voltage, 2) # round the voltage nicely to 2 decimals
return (min(charge_voltage, system_target_voltage), max(charge_current, min(system_idle_current, 30)), feedback_allowed, False) # idle current of no more than 30A