Add debounce counter for UV error detection

This prevents switching off the load output due to short undervoltage
events during startup of pumps etc. when the battery is at low SOC.
This commit is contained in:
Martin Jaeger
2020-02-19 14:34:40 +01:00
committed by Martin Jäger
parent b717dea6d1
commit 68e0336279
4 changed files with 34 additions and 17 deletions
+25 -17
View File
@@ -295,26 +295,34 @@ void Charger::discharge_control(BatConf *bat_conf)
if (port->bus->voltage < num_batteries *
(bat_conf->voltage_load_disconnect - port->current * port->bus->droop_res))
{
// low state of charge
port->neg_current_limit = 0;
num_deep_discharges++;
dev_stat.set_error(ERR_BAT_UNDERVOLTAGE);
uv_debounce_counter++;
if (uv_debounce_counter >= 3) { // 3s in undervoltage --> switch off
// low state of charge
port->neg_current_limit = 0;
num_deep_discharges++;
dev_stat.set_error(ERR_BAT_UNDERVOLTAGE);
if (usable_capacity == 0.0F) {
// reset to measured value if discharged the first time
usable_capacity = discharged_Ah;
}
else {
// slowly adapt new measurements with low-pass filter
usable_capacity =
0.8 * usable_capacity +
0.2 * discharged_Ah;
}
if (usable_capacity == 0.0F) {
// reset to measured value if discharged the first time
usable_capacity = discharged_Ah;
}
else {
// slowly adapt new measurements with low-pass filter
usable_capacity =
0.8 * usable_capacity +
0.2 * discharged_Ah;
}
// simple SOH estimation
soh = usable_capacity / bat_conf->nominal_capacity;
// simple SOH estimation
soh = usable_capacity / bat_conf->nominal_capacity;
}
}
else if (bat_temperature > bat_conf->discharge_temp_max) {
else {
uv_debounce_counter = 0;
}
if (bat_temperature > bat_conf->discharge_temp_max) {
port->neg_current_limit = 0;
dev_stat.set_error(ERR_BAT_DIS_OVERTEMP);
}
+2
View File
@@ -282,6 +282,8 @@ public:
private:
void enter_state(int next_state);
int uv_debounce_counter = 0;
};
+5
View File
@@ -223,6 +223,9 @@ void stop_discharge_at_low_voltage()
bat_terminal.bus->voltage = bat_conf.voltage_load_disconnect - 0.1;
charger.discharge_control(&bat_conf);
charger.discharge_control(&bat_conf); // 2s: still on
TEST_ASSERT_NOT_EQUAL(0, bat_terminal.neg_current_limit);
charger.discharge_control(&bat_conf); // 3s: off
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
}
@@ -253,6 +256,8 @@ void restart_discharge_if_allowed()
// stop because of undervoltage
bat_terminal.bus->voltage = bat_conf.voltage_load_disconnect - 0.1;
charger.discharge_control(&bat_conf);
charger.discharge_control(&bat_conf);
charger.discharge_control(&bat_conf); // 3s debounce
TEST_ASSERT_EQUAL(0, bat_terminal.neg_current_limit);
// increase voltage slightly above DISconnect voltage
+2
View File
@@ -16,6 +16,7 @@
static void init_structs_buck()
{
dev_stat.error_flags = 0;
hv_terminal.init_solar();
hv_terminal.bus->voltage = 20;
hv_terminal.bus->src_voltage_bound = 18;
@@ -38,6 +39,7 @@ static void init_structs_buck()
static void start_buck()
{
dev_stat.error_flags = 0;
init_structs_buck();
half_bridge_init(70, 200, 12 / dcdc.hs_voltage_max, 0.97);
dcdc.control();