State transition tuning

This commit is contained in:
Thomas Kolb 2016-08-14 22:46:12 +02:00
parent 2246ac0290
commit dac3d34691

View file

@ -374,7 +374,7 @@ int main(void)
fxp_t pErr = 0, iErr = 0;
fxp_t controlAction = 0;
fxp_t power_avg, refPower = 0;
fxp_t power_avg;
fxp_t testPower[2];
int32_t testPWM[2];
int testPWMStep = 5;
@ -389,7 +389,7 @@ int main(void)
fxp_t PGAIN_CC = fxp_from_float( 50.000f);
fxp_t IGAIN_CC = fxp_from_float( 0.300f);
fxp_t CURRENT_THRESHOLD = fxp_from_float(0.01f);
fxp_t CURRENT_THRESHOLD = fxp_from_float(0.002f);
fxp_t AVG_FACT = fxp_from_float(0.10f);
fxp_t AVG_FACT_INV = fxp_sub(fxp_from_int(1), AVG_FACT);
@ -401,6 +401,9 @@ int main(void)
fxp_t MPP_VOLTAGE_THR = fxp_sub(CONST_VOLTAGE, fxp_from_float(0.500f));
fxp_t MPP_CURRENT_THR = fxp_sub(MAX_CURRENT, fxp_from_float(0.500f));
// input voltage must exceed output voltage by this value to leave idle mode
fxp_t WAKEUP_OFFSET_VOLTAGE = fxp_from_float(1.0f);
// Calculated values
//fxp_t VIN_SCALE = fxp_from_float(3.3f * (100 + 12.4f) / 12.4f / 4095.0f);
//fxp_t VOUT_SCALE = fxp_from_float(3.3f * (100 + 12.0f) / 12.0f / 4095.0f);
@ -612,15 +615,15 @@ int main(void)
case 4:
if(testPower[1] > testPower[0]) {
refPower = testPower[1];
pwm = testPWM[1];
} else {
refPower = testPower[0];
pwm = testPWM[0];
}
if(pwm < (CONV_PWM_PERIOD/2) || pwm > CONV_PWM_MAX) {
if(pwm < (CONV_PWM_PERIOD/2)) {
pwm = 3 * CONV_PWM_PERIOD / 4;
} else if(pwm > CONV_PWM_MAX) {
pwm = CONV_PWM_MAX;
}
timer_set_oc_value(TIM1, TIM_CH_CONV, pwm);
@ -667,7 +670,7 @@ int main(void)
timer_set_oc_value(TIM1, TIM_CH_CONV, 0);
timer_set_oc_value(TIM1, TIM_CH_BOOTSTRAP, 0);
if(time_in_state > 1000 && vin_avg > vout_avg) {
if(time_in_state > 1000 && vin_avg > fxp_add(vout_avg, WAKEUP_OFFSET_VOLTAGE)) {
sleep_time = 10;
operState = Bootstrap;
nextState = ConvMPP;
@ -695,7 +698,7 @@ int main(void)
sleep_time = MAX_SLEEP_TIME;
}
force_display_update_time = timebase_ms + 20;
force_display_update_time = timebase_ms + 10;
}
break;