Removed dynamic MPPT PWM limit

This commit is contained in:
Thomas Kolb 2020-04-12 17:13:13 +02:00
parent a1fb967d1b
commit a1913be97b
1 changed files with 5 additions and 27 deletions

View File

@ -426,8 +426,6 @@ struct MPPState {
fxp_t powerAccu;
int32_t powerSamples;
int32_t mppMaxPWM;
};
#define MPP_TEST_IGNORE_DURATION 5 /* ms */
@ -629,8 +627,6 @@ int main(void)
power_state.power_avg = 0;
power_state.temp_avg = fxp_from_int(-999);
mpp_state.mppMaxPWM = CONV_PWM_MAX;
/* initialize mpp_state */
mpp_state.maxPWM = CONV_PWM_MAX;
mpp_state.refPWM = CONV_PWM_MAX;
@ -821,7 +817,7 @@ int main(void)
}
if(time_in_state > 1000 && power_state.vout_avg < VOLTAGE_THR_CV_TO_MPP) {
pwm = CONV_PWM_MAX * 8 / 10;
pwm = CONV_PWM_PERIOD * 8 / 10;
operState = ConvMPP;
}
@ -945,32 +941,18 @@ int main(void)
case ConvMPP:
mpp_run(time_in_state, &mpp_state, &power_state, &pwm);
if(pwm > mpp_state.mppMaxPWM) {
pwm = mpp_state.mppMaxPWM;
} else if(pwm < CONV_PWM_PERIOD/100) {
pwm = CONV_PWM_PERIOD/100;
if(pwm > CONV_PWM_MAX) {
pwm = CONV_PWM_MAX;
} else if(pwm < CONV_PWM_PERIOD/10) {
pwm = CONV_PWM_PERIOD/10;
}
timer_set_oc_value(TIM1, TIM_CH_CONV, pwm);
if((mpp_state.mppMaxPWM < CONV_PWM_MAX) &&
time_in_state > 5000 && ((time_in_state % 3000) == 10)) {
mpp_state.mppMaxPWM++;
}
if(time_in_state > 5000 && power_state.current_avg < CURRENT_THRESHOLD) {
operState = Bootstrap;
nextState = ConvMPP;
mpp_state.testIdx = -1;
if(mpp_state.mppMaxPWM > CONV_PWM_MAX/50) {
mpp_state.mppMaxPWM -= 10;
} else {
// limit has gone too low -> retry at maximum
mpp_state.mppMaxPWM = CONV_PWM_MAX;
}
pwm = mpp_state.mppMaxPWM;
}
if(power_state.vout_avg > MPP_MAX_VOLTAGE) {
@ -983,7 +965,6 @@ int main(void)
if(power_state.vin_avg < power_state.vout_avg) {
operState = Idle;
mpp_state.mppMaxPWM = CONV_PWM_MAX;
}
#ifdef DEBUG
@ -991,9 +972,6 @@ int main(void)
debug_send_string("PWM: ");
fxp_format_int(pwm, msg);
debug_send_string(msg);
debug_send_string(" Limit: ");
fxp_format_int(mpp_state.mppMaxPWM, msg);
debug_send_string(msg);
sentSomething = 1;
}
#endif