Removed dynamic MPPT PWM limit
This commit is contained in:
parent
a1fb967d1b
commit
a1913be97b
32
src/main.c
32
src/main.c
|
@ -426,8 +426,6 @@ struct MPPState {
|
||||||
|
|
||||||
fxp_t powerAccu;
|
fxp_t powerAccu;
|
||||||
int32_t powerSamples;
|
int32_t powerSamples;
|
||||||
|
|
||||||
int32_t mppMaxPWM;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MPP_TEST_IGNORE_DURATION 5 /* ms */
|
#define MPP_TEST_IGNORE_DURATION 5 /* ms */
|
||||||
|
@ -629,8 +627,6 @@ int main(void)
|
||||||
power_state.power_avg = 0;
|
power_state.power_avg = 0;
|
||||||
power_state.temp_avg = fxp_from_int(-999);
|
power_state.temp_avg = fxp_from_int(-999);
|
||||||
|
|
||||||
mpp_state.mppMaxPWM = CONV_PWM_MAX;
|
|
||||||
|
|
||||||
/* initialize mpp_state */
|
/* initialize mpp_state */
|
||||||
mpp_state.maxPWM = CONV_PWM_MAX;
|
mpp_state.maxPWM = CONV_PWM_MAX;
|
||||||
mpp_state.refPWM = 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) {
|
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;
|
operState = ConvMPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,32 +941,18 @@ int main(void)
|
||||||
case ConvMPP:
|
case ConvMPP:
|
||||||
mpp_run(time_in_state, &mpp_state, &power_state, &pwm);
|
mpp_run(time_in_state, &mpp_state, &power_state, &pwm);
|
||||||
|
|
||||||
if(pwm > mpp_state.mppMaxPWM) {
|
if(pwm > CONV_PWM_MAX) {
|
||||||
pwm = mpp_state.mppMaxPWM;
|
pwm = CONV_PWM_MAX;
|
||||||
} else if(pwm < CONV_PWM_PERIOD/100) {
|
} else if(pwm < CONV_PWM_PERIOD/10) {
|
||||||
pwm = CONV_PWM_PERIOD/100;
|
pwm = CONV_PWM_PERIOD/10;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_set_oc_value(TIM1, TIM_CH_CONV, pwm);
|
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) {
|
if(time_in_state > 5000 && power_state.current_avg < CURRENT_THRESHOLD) {
|
||||||
operState = Bootstrap;
|
operState = Bootstrap;
|
||||||
nextState = ConvMPP;
|
nextState = ConvMPP;
|
||||||
mpp_state.testIdx = -1;
|
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) {
|
if(power_state.vout_avg > MPP_MAX_VOLTAGE) {
|
||||||
|
@ -983,7 +965,6 @@ int main(void)
|
||||||
|
|
||||||
if(power_state.vin_avg < power_state.vout_avg) {
|
if(power_state.vin_avg < power_state.vout_avg) {
|
||||||
operState = Idle;
|
operState = Idle;
|
||||||
mpp_state.mppMaxPWM = CONV_PWM_MAX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -991,9 +972,6 @@ int main(void)
|
||||||
debug_send_string("PWM: ");
|
debug_send_string("PWM: ");
|
||||||
fxp_format_int(pwm, msg);
|
fxp_format_int(pwm, msg);
|
||||||
debug_send_string(msg);
|
debug_send_string(msg);
|
||||||
debug_send_string(" Limit: ");
|
|
||||||
fxp_format_int(mpp_state.mppMaxPWM, msg);
|
|
||||||
debug_send_string(msg);
|
|
||||||
sentSomething = 1;
|
sentSomething = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue