charge_control: implement voltage transition

This commit is contained in:
Thomas Kolb 2021-07-01 21:10:13 +02:00
parent 49bd9247e0
commit 79fe1113de
1 changed files with 18 additions and 9 deletions

View File

@ -136,19 +136,28 @@ static void solar_fsm_update(uint64_t uptime_ms, struct MeasurementResult *meas)
case CHARGE_TRANSITION:
// FIXME: dynamically adjust thresholds
charge_state = control_solar_charging(
u_bat_float_full,
u_bat_float_low,
uptime_ms,
meas,
charge_state,
charge_time_in_state);
if(charge_time_in_state < INITIAL_TO_FLOAT_TRANSITION_TIME) {
fxp_t u_bat_full =
fxp_add(u_bat_initial_full,
fxp_mult(
fxp_sub(u_bat_float_full, u_bat_initial_full),
fxp_div(charge_time_in_state, INITIAL_TO_FLOAT_TRANSITION_TIME)));
// time limit for transition to float charging
if(charge_time_in_state > INITIAL_TO_FLOAT_TRANSITION_TIME) {
fxp_t u_bat_low = fxp_sub(u_bat_full, u_bat_regulation_corridor);
charge_state = control_solar_charging(
u_bat_full,
u_bat_low,
uptime_ms,
meas,
charge_state,
charge_time_in_state);
} else {
// time limit for transition to float charging reached
charge_state = CHARGE_FLOAT;
break;
}
break;
case CHARGE_FLOAT: