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
charge_state = control_solar_charging( if(charge_time_in_state < INITIAL_TO_FLOAT_TRANSITION_TIME) {
u_bat_float_full, fxp_t u_bat_full =
u_bat_float_low, fxp_add(u_bat_initial_full,
uptime_ms, fxp_mult(
meas, fxp_sub(u_bat_float_full, u_bat_initial_full),
charge_state, fxp_div(charge_time_in_state, INITIAL_TO_FLOAT_TRANSITION_TIME)));
charge_time_in_state);
// time limit for transition to float charging fxp_t u_bat_low = fxp_sub(u_bat_full, u_bat_regulation_corridor);
if(charge_time_in_state > INITIAL_TO_FLOAT_TRANSITION_TIME) {
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; charge_state = CHARGE_FLOAT;
break; break;
} }
break; break;
case CHARGE_FLOAT: case CHARGE_FLOAT: