charge_control: first state transition wins
This commit is contained in:
parent
add925bba0
commit
62b63efba3
|
@ -91,16 +91,19 @@ static void solar_fsm_update(uint64_t uptime_ms, struct MeasurementResult *meas)
|
|||
// temperature limit
|
||||
if(meas->temperature > internal_temperature_limit) {
|
||||
charge_state = CHARGE_HIGH_TEMPERATURE;
|
||||
break;
|
||||
}
|
||||
|
||||
// time limit for initial charging
|
||||
if(charge_time_in_state > INITIAL_CHARGE_HOLD_TIME) {
|
||||
charge_state = CHARGE_TRANSITION;
|
||||
break;
|
||||
}
|
||||
|
||||
// low-current limit (go to sleep at night)
|
||||
if(meas->i_solar < sleep_solar_current) {
|
||||
charge_state = CHARGE_SLEEP;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -111,16 +114,19 @@ static void solar_fsm_update(uint64_t uptime_ms, struct MeasurementResult *meas)
|
|||
// temperature limit
|
||||
if(meas->temperature > internal_temperature_limit) {
|
||||
charge_state = CHARGE_HIGH_TEMPERATURE;
|
||||
break;
|
||||
}
|
||||
|
||||
// time limit for transition to float charging
|
||||
if(charge_time_in_state > INITIAL_TO_FLOAT_TRANSITION_TIME) {
|
||||
charge_state = CHARGE_FLOAT;
|
||||
break;
|
||||
}
|
||||
|
||||
// low-current limit (go to sleep at night)
|
||||
if(meas->i_solar < sleep_solar_current) {
|
||||
charge_state = CHARGE_SLEEP;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -130,11 +136,13 @@ static void solar_fsm_update(uint64_t uptime_ms, struct MeasurementResult *meas)
|
|||
// temperature limit
|
||||
if(meas->temperature > internal_temperature_limit) {
|
||||
charge_state = CHARGE_HIGH_TEMPERATURE;
|
||||
break;
|
||||
}
|
||||
|
||||
// low-current limit (go to sleep at night)
|
||||
if(meas->i_solar < sleep_solar_current) {
|
||||
charge_state = CHARGE_SLEEP;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -149,6 +157,7 @@ static void solar_fsm_update(uint64_t uptime_ms, struct MeasurementResult *meas)
|
|||
if(solar_excess_voltage > sleep_solar_excess_voltage) {
|
||||
// resume operation
|
||||
charge_state = CHARGE_WAIT_CHARGEPUMP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -161,6 +170,7 @@ static void solar_fsm_update(uint64_t uptime_ms, struct MeasurementResult *meas)
|
|||
|
||||
if(meas->temperature < internal_temperature_recovery) {
|
||||
charge_state = CHARGE_WAIT_CHARGEPUMP;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -296,8 +306,8 @@ void charge_control_update(uint64_t uptime_ms, struct MeasurementResult *meas)
|
|||
// either charge or discharge control is waiting for the charge
|
||||
// pump, so power it up!
|
||||
charge_pump_start();
|
||||
} else if((charge_state == CHARGE_SLEEP)
|
||||
&& (discharge_state == DISCHARGE_VOLTAGE_LOW)) {
|
||||
} else if(((charge_state == CHARGE_SLEEP) || charge_control_is_charge_blocked())
|
||||
&& ((discharge_state == DISCHARGE_VOLTAGE_LOW) || charge_control_is_discharge_blocked())) {
|
||||
// no power from the solar panel and the battery voltage is too
|
||||
// low, so both switches are off and we can safely stop the charge
|
||||
// pump
|
||||
|
|
Loading…
Reference in a new issue