Skip to content

Scale lead-acid temperature compensation by battery cell count - #142

Open
Solarboaters wants to merge 1 commit into
LibreSolar:mainfrom
Solarboaters:fix/lead-acid-temperature-scaling
Open

Solarboaters wants to merge 1 commit into
LibreSolar:mainfrom
Solarboaters:fix/lead-acid-temperature-scaling

Conversation

@Solarboaters

@Solarboaters Solarboaters commented Nov 12, 2026 •

Copy link
Copy Markdown

The built-in lead-acid defaults describe temperature compensation as -3 mV/°C/cell, but assign -0.003 V/°C to the whole battery regardless of num_cells. The charging states apply this value directly to the battery-level voltage setpoint. For a six-cell battery, the compensation is therefore six times too small.

Multiply the per-cell coefficient by num_cells, consistent with the existing custom-battery initialization. Added regression coverage for flooded, AGM and gel batteries with 1, 6 and 12 cells.

An isolated C++ harness executing battery_conf_init reproduced -0.003 V/°C for six cells before the fix and verified -0.018 V/°C afterward. All nine lead-acid combinations and the zero-compensation lithium controls passed. Full Zephyr and hardware testing remain pending.

Evidence audit — 17 November 2026

Individually rebuilt and ran the production Zephyr native test image from public revision 3a5a4c5db: 96 tests, zero failures. This is separate from the combined run of #135–#145, which passes all 103 tests. Replacing the relevant production implementations with the original code reproduces the new regression failures.

Reproduction in the west workspace, from the firmware directory:

ZEPHYR_TOOLCHAIN_VARIANT=host west build -b native_sim/native/64 -d ../build tests -- -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DDTC_OVERLAY_FILE=boards/native_sim.overlay
../build/zephyr/zephyr.exe

Environment: Linux x86-64, GCC host toolchain, Zephyr 4.4.2, manifest dependencies. These tests use the project's native simulated interfaces; no ARM board or charging hardware was operated.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant