diff --git a/packages/yambms/yambms_auto_ccl.yaml b/packages/yambms/yambms_auto_ccl.yaml index d94a928..f2559c0 100644 --- a/packages/yambms/yambms_auto_ccl.yaml +++ b/packages/yambms/yambms_auto_ccl.yaml @@ -1,5 +1,5 @@ -# Updated : 2026.06.27 -# Version : 1.3.3 +# Updated : 2026.10.04 +# Version : 1.3.4 # GitHub : https://github.com/Sleeper85/esphome-yambms # YamBMS ( Yet another multi-BMS Merging Solution ) @@ -37,6 +37,17 @@ substitutions: # A setting above 1 will reduce current at a slow rate after the float voltage is reached, then increase as a cell approaches the BMS "cell_voltage_overvoltage_protection" value. # A factor below 1 will reduce current at a fast rate after the float voltage is reached, then slow as a cell approaches the BMS "cell_voltage_overvoltage_protection" value. charge_a_factor_curve_shape: '1.8' + # Max cell voltage smoothing. Near the top of charge the curve is steep (several A per mV), + # so 1-3 mV of jitter in the BMS readings makes the CCL saw up and down. + # Time constant (s) of the moving average used for the curve. '0' disables the smoothing. + auto_ccl_max_cell_v_tau: '30' + # Safety guard: when a raw reading is more than this (V) above the average, + # the raw reading minus this margin is used, so real voltage rises still cut at once. + auto_ccl_max_cell_v_guard: '0.005' + # Lowest charge current (A) Auto CCL may request, also at or above the end of its curve. + # Keeps the charger from seeing a 0 A request from this function. '0' allows 0 A. + # Other limits (Auto EOC, Current Taper, charging not allowed, ...) can still request less. + auto_ccl_min_current: '1' switch: - platform: template @@ -84,6 +95,20 @@ interval: return; } + // Smooth the max cell voltage (time-based EMA), keep raw rises above the guard + static float max_cell_v_avg = NAN; + static uint32_t last_run_ms = 0; + const uint32_t now = millis(); + const float tau = ${auto_ccl_max_cell_v_tau}; + if (isnan(max_cell_v_avg) || tau <= 0.0f) { + max_cell_v_avg = max_cell_v; + } else { + const float dt = (now - last_run_ms) / 1000.0f; + max_cell_v_avg += (max_cell_v - max_cell_v_avg) * std::min(1.0f, dt / tau); + } + last_run_ms = now; + max_cell_v = std::max(max_cell_v_avg, max_cell_v - (float) ${auto_ccl_max_cell_v_guard}); + float cell_bulk_v = (bulk_v / cell_count); float cell_float_v = (float_v / cell_count); float cell_high_v = ((cell_ovp_v + cell_bulk_v) / 2.0f); @@ -108,6 +133,9 @@ interval: delta = max(0.0f, (-curve + 2.0f) * max_current) - max_current; } } + // Never reduce below the minimum current (and never raise above max_current) + const float min_current = ${auto_ccl_min_current}; + delta = std::min(0.0f, std::max(delta, min_current - max_current)); } // If switch is off, delta stays 0.0f. // Smoothly ramp from the old negative value back to 0 if required