Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/bat_charger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void battery_conf_init(BatConf *bat, int type, int num_cells, float nominal_capa
bat->equalization_trigger_days = 60;
bat->equalization_trigger_deep_cycles = 10;

bat->temperature_compensation = -0.003F; // -3 mV/°C/cell
bat->temperature_compensation = -0.003F * num_cells; // -3 mV/°C/cell
break;

case BAT_TYPE_LFP:
Expand Down
15 changes: 15 additions & 0 deletions tests/src/tests_bat_charger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "tests.h"

#include <initializer_list>
#include <stdio.h>
#include <time.h>

Expand Down Expand Up @@ -292,10 +293,24 @@ void no_soc_below_0()
TEST_ASSERT(0);
}

void lead_acid_temperature_compensation_scales_with_cells()
{
for (int type : { BAT_TYPE_FLOODED, BAT_TYPE_AGM, BAT_TYPE_GEL }) {
for (int cells : { 1, 6, 12 }) {
BatConf config = {};
battery_conf_init(&config, type, cells, 100);
TEST_ASSERT_FLOAT_WITHIN(
0.00001F, -0.003F * cells, config.temperature_compensation);
}
}
}

int bat_charger_tests()
{
UNITY_BEGIN();

RUN_TEST(lead_acid_temperature_compensation_scales_with_cells);

// startup of charging
RUN_TEST(no_start_at_high_voltage);
RUN_TEST(no_start_after_short_rest);
Expand Down