Rename some charger variables
- Float charging is the more correct and more commonly used term compared to trickle charging - Putting voltage at the end of some variable names for more consistency
This commit is contained in:
+30
-30
@@ -25,7 +25,7 @@ static void init_structs()
|
||||
void no_start_at_high_voltage()
|
||||
{
|
||||
init_structs();
|
||||
bat_terminal.bus->voltage = bat_conf.voltage_recharge + 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.recharge_voltage + 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ void no_start_after_short_rest()
|
||||
{
|
||||
init_structs();
|
||||
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge + 1;
|
||||
bat_terminal.bus->voltage = bat_conf.voltage_recharge - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||
}
|
||||
@@ -43,7 +43,7 @@ void no_start_outside_temperature_limits()
|
||||
{
|
||||
init_structs();
|
||||
charger.bat_temperature = bat_conf.charge_temp_max + 1;
|
||||
bat_terminal.bus->voltage = bat_conf.voltage_recharge - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||
|
||||
@@ -56,7 +56,7 @@ void start_if_everything_just_fine()
|
||||
{
|
||||
init_structs();
|
||||
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge - 1;
|
||||
bat_terminal.bus->voltage = bat_conf.voltage_recharge - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_BULK, charger.state);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ void enter_topping_at_voltage_setpoint()
|
||||
{
|
||||
init_structs();
|
||||
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge - 1;
|
||||
bat_terminal.bus->voltage = bat_conf.voltage_recharge - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.recharge_voltage - 0.1;
|
||||
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_BULK, charger.state);
|
||||
@@ -82,7 +82,7 @@ void topping_to_bulk_after_8h_low_power()
|
||||
charger.time_state_changed = time(NULL) - 8 * 60 * 60 + 1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage - 0.1;
|
||||
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
||||
bat_terminal.current = bat_conf.topping_current_cutoff + 0.1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current + 0.1;
|
||||
bat_terminal.current_filtered = bat_terminal.current;
|
||||
|
||||
charger.charge_control(&bat_conf);
|
||||
@@ -98,7 +98,7 @@ void stop_topping_after_time_limit()
|
||||
enter_topping_at_voltage_setpoint();
|
||||
|
||||
charger.target_voltage_timer = bat_conf.topping_duration - 1;
|
||||
bat_terminal.current = bat_conf.topping_current_cutoff + 0.1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current + 0.1;
|
||||
bat_terminal.current_filtered = bat_terminal.current;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
@@ -109,7 +109,7 @@ void stop_topping_after_time_limit()
|
||||
|
||||
charger.target_voltage_timer = bat_conf.topping_duration + 1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_TRICKLE, charger.state);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_FLOAT, charger.state);
|
||||
}
|
||||
|
||||
void stop_topping_at_cutoff_current()
|
||||
@@ -117,22 +117,22 @@ void stop_topping_at_cutoff_current()
|
||||
enter_topping_at_voltage_setpoint();
|
||||
|
||||
charger.target_voltage_timer = 0;
|
||||
bat_terminal.current = bat_conf.topping_current_cutoff - 0.1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
||||
bat_terminal.current_filtered = bat_terminal.current;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_TRICKLE, charger.state);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_FLOAT, charger.state);
|
||||
}
|
||||
|
||||
void trickle_to_idle_for_li_ion()
|
||||
void float_to_idle_for_li_ion()
|
||||
{
|
||||
enter_topping_at_voltage_setpoint();
|
||||
battery_conf_init(&bat_conf, BAT_TYPE_LFP, 4, 100);
|
||||
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal.current = bat_conf.topping_current_cutoff - 0.1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
@@ -152,7 +152,7 @@ void no_equalization_if_disabled()
|
||||
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage + 0.1;
|
||||
bat_terminal.current = bat_conf.topping_current_cutoff - 0.1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_NOT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||
}
|
||||
@@ -170,12 +170,12 @@ void no_equalization_if_limits_not_reached()
|
||||
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage + 0.1;
|
||||
bat_terminal.current = bat_conf.topping_current_cutoff - 0.1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_NOT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||
}
|
||||
|
||||
void trickle_to_equalization_if_enabled_and_time_limit_reached()
|
||||
void float_to_equalization_if_enabled_and_time_limit_reached()
|
||||
{
|
||||
enter_topping_at_voltage_setpoint();
|
||||
bat_conf.equalization_enabled = true;
|
||||
@@ -183,7 +183,7 @@ void trickle_to_equalization_if_enabled_and_time_limit_reached()
|
||||
time(NULL) - bat_conf.equalization_trigger_days * 24*60*60;
|
||||
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal.current = bat_conf.topping_current_cutoff - 0.1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
@@ -191,7 +191,7 @@ void trickle_to_equalization_if_enabled_and_time_limit_reached()
|
||||
}
|
||||
|
||||
|
||||
void trickle_to_equalization_if_enabled_and_deep_dis_limit_reached()
|
||||
void float_to_equalization_if_enabled_and_deep_dis_limit_reached()
|
||||
{
|
||||
enter_topping_at_voltage_setpoint();
|
||||
bat_conf.equalization_enabled = true;
|
||||
@@ -199,7 +199,7 @@ void trickle_to_equalization_if_enabled_and_deep_dis_limit_reached()
|
||||
charger.num_deep_discharges - bat_conf.equalization_trigger_deep_cycles;
|
||||
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal.current = bat_conf.topping_current_cutoff - 0.1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
@@ -209,7 +209,7 @@ void trickle_to_equalization_if_enabled_and_deep_dis_limit_reached()
|
||||
|
||||
void stop_equalization_after_time_limit()
|
||||
{
|
||||
trickle_to_equalization_if_enabled_and_time_limit_reached();
|
||||
float_to_equalization_if_enabled_and_time_limit_reached();
|
||||
|
||||
charger.time_state_changed = time(NULL) - bat_conf.equalization_duration + 1;
|
||||
bat_terminal.bus->voltage = bat_conf.equalization_voltage -
|
||||
@@ -220,10 +220,10 @@ void stop_equalization_after_time_limit()
|
||||
|
||||
charger.time_state_changed = time(NULL) - bat_conf.topping_duration - 1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_TRICKLE, charger.state);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_FLOAT, charger.state);
|
||||
}
|
||||
|
||||
void restart_bulk_from_trickle_if_voltage_drops()
|
||||
void restart_bulk_from_float_if_voltage_drops()
|
||||
{
|
||||
TEST_ASSERT(0);
|
||||
}
|
||||
@@ -236,7 +236,7 @@ void stop_discharge_at_low_voltage()
|
||||
charger.discharge_control(&bat_conf);
|
||||
TEST_ASSERT_LESS_THAN(0, bat_terminal.neg_current_limit);
|
||||
|
||||
bat_terminal.bus->voltage = bat_conf.voltage_absolute_min - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage - 0.1;
|
||||
charger.discharge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
|
||||
}
|
||||
@@ -266,17 +266,17 @@ void restart_discharge_if_allowed()
|
||||
init_structs();
|
||||
|
||||
// stop because of undervoltage
|
||||
bat_terminal.bus->voltage = bat_conf.voltage_absolute_min - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage - 0.1;
|
||||
charger.discharge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
|
||||
|
||||
// increase voltage slightly above absolute minimum
|
||||
bat_terminal.bus->voltage = bat_conf.voltage_absolute_min + 0.05;
|
||||
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage + 0.05;
|
||||
charger.discharge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
|
||||
|
||||
// increase voltage above hysteresis voltage
|
||||
bat_terminal.bus->voltage = bat_conf.voltage_absolute_min + 0.15;
|
||||
bat_terminal.bus->voltage = bat_conf.absolute_min_voltage + 0.15;
|
||||
charger.discharge_control(&bat_conf);
|
||||
TEST_ASSERT_LESS_THAN(0, bat_terminal.neg_current_limit);
|
||||
}
|
||||
@@ -312,17 +312,17 @@ void bat_charger_tests()
|
||||
RUN_TEST(stop_topping_after_time_limit);
|
||||
RUN_TEST(stop_topping_at_cutoff_current);
|
||||
|
||||
// trickle
|
||||
RUN_TEST(trickle_to_idle_for_li_ion);
|
||||
// float
|
||||
RUN_TEST(float_to_idle_for_li_ion);
|
||||
|
||||
// equalization
|
||||
RUN_TEST(no_equalization_if_disabled);
|
||||
RUN_TEST(no_equalization_if_limits_not_reached);
|
||||
RUN_TEST(trickle_to_equalization_if_enabled_and_time_limit_reached);
|
||||
RUN_TEST(trickle_to_equalization_if_enabled_and_deep_dis_limit_reached);
|
||||
RUN_TEST(float_to_equalization_if_enabled_and_time_limit_reached);
|
||||
RUN_TEST(float_to_equalization_if_enabled_and_deep_dis_limit_reached);
|
||||
RUN_TEST(stop_equalization_after_time_limit);
|
||||
|
||||
//RUN_TEST(restart_bulk_from_trickle_if_voltage_drops);
|
||||
//RUN_TEST(restart_bulk_from_float_if_voltage_drops);
|
||||
|
||||
// TODO: temperature compensation
|
||||
// TODO: current compensation
|
||||
|
||||
Reference in New Issue
Block a user