charge_control: implement voltage transition

This commit is contained in:
Thomas Kolb 2021-07-01 21:10:13 +02:00
parent 49bd9247e0
commit 79fe1113de

View file

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