Added a thermal shutdown state

This commit is contained in:
Thomas Kolb 2019-10-03 01:46:05 +02:00
parent 5e63547f15
commit 6f591ab2f7

View file

@ -34,6 +34,7 @@ enum OperState {
ConvFloat,
ConvConstCurrent,
ConvMPP,
ThermalShutdown,
Idle,
};
@ -614,6 +615,10 @@ int main(void)
fxp_t ADC2CURRENT_M = fxp_from_float( 0.00225f);
fxp_t ADC2CURRENT_T = fxp_from_float(-0.2255f);
// Thermal shutdown thresholds
fxp_t SHUTDOWN_TEMPERATURE = fxp_from_float(55.0f);
fxp_t RECOVER_TEMPERATURE = fxp_from_float(45.0f);
/* if power changes by more than this factor, MPP is tested again */
MPP_MAX_POWER_CHANGE_FACTOR = fxp_from_float(0.2f);
@ -1041,6 +1046,16 @@ int main(void)
break;
case ThermalShutdown:
// shut down the converter
timer_set_oc_value(TIM1, TIM_CH_CONV, 0);
if(power_state.temp_avg < RECOVER_TEMPERATURE) {
nextState = ConvMPP;
operState = Bootstrap;
}
break;
default:
debug_send_string("Invalid state detected!");
sentSomething = 1;
@ -1049,6 +1064,10 @@ int main(void)
break;
}
if(power_state.temp_avg > SHUTDOWN_TEMPERATURE) {
operState = ThermalShutdown;
}
if(operState != lastState) {
time_in_state = 0;
lastState = operState;
@ -1073,6 +1092,9 @@ int main(void)
case ConvMPP:
lcd_send_string("MPP");
break;
case ThermalShutdown:
lcd_send_string("TRM");
break;
default:
lcd_send_string("???");
break;