Made variable names more consistent

This commit is contained in:
Thomas Kolb 2020-04-12 17:29:34 +02:00
parent a1913be97b
commit 5e1bfc2d78
1 changed files with 19 additions and 15 deletions

View File

@ -580,17 +580,21 @@ int main(void)
fxp_t AVG_FACT = fxp_from_float(0.01f);
fxp_t AVG_FACT_INV = fxp_sub(fxp_from_int(1), AVG_FACT);
fxp_t MPP_MAX_VOLTAGE = fxp_from_float(14.400f);
fxp_t CONST_VOLTAGE = MPP_MAX_VOLTAGE;
fxp_t CONST_FLOAT_VOLTAGE = fxp_from_float(13.800f);
fxp_t MAX_CURRENT = fxp_from_float( 5.000f);
// mode-changing thresholds and target definitions
fxp_t VOLTAGE_THR_MPP_TO_CV = fxp_from_float(14.400f); // V
fxp_t CONST_VOLTAGE = VOLTAGE_THR_MPP_TO_CV;
fxp_t CONST_FLOAT_VOLTAGE = fxp_from_float(13.800f); // V
fxp_t CURRENT_THR_ANY_TO_CC = fxp_from_float( 5.000f); // A
fxp_t CURRENT_THR_CC_TO_MPP = fxp_sub(CURRENT_THR_ANY_TO_CC, fxp_from_float(0.500f));
fxp_t VOLTAGE_THR_CV_TO_MPP = fxp_sub(CONST_VOLTAGE, fxp_from_float(0.300f));
fxp_t VOLTAGE_THR_FLOAT_TO_MPP = fxp_sub(CONST_FLOAT_VOLTAGE, fxp_from_float(0.300f));
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);
fxp_t POWER_THR_MPP_TO_IDLE = fxp_from_float(0.500f); // W
// input voltage must exceed this value to leave idle mode
fxp_t VOLTAGE_THR_IDLE_TO_MPP = fxp_from_float(19.0f); // V
// switch off load below LOAD_OFF_THRESHOLD to protect the battery; when the
// battery recovers above LOAD_ON_THRESHOLD the load is switched on again.
@ -821,7 +825,7 @@ int main(void)
operState = ConvMPP;
}
if(power_state.current_avg > MAX_CURRENT) {
if(power_state.current_avg > CURRENT_THR_ANY_TO_CC) {
operState = ConvConstCurrent;
}
@ -887,7 +891,7 @@ int main(void)
operState = ConvMPP;
}
if(power_state.current_avg > MAX_CURRENT) {
if(power_state.current_avg > CURRENT_THR_ANY_TO_CC) {
operState = ConvConstCurrent;
}
@ -902,7 +906,7 @@ int main(void)
}
// calculate error values
pErr = fxp_sub(MAX_CURRENT, power_state.current_avg);
pErr = fxp_sub(CURRENT_THR_ANY_TO_CC, power_state.current_avg);
iErr = fxp_add(iErr, pErr);
// limit integral error range
@ -929,11 +933,11 @@ int main(void)
nextState = ConvConstCurrent;
}
if(time_in_state > 1000 && power_state.current_avg < MPP_CURRENT_THR) {
if (time_in_state > 1000 && power_state.current_avg < CURRENT_THR_CC_TO_MPP) {
operState = ConvMPP;
}
if(power_state.vout_avg > MPP_MAX_VOLTAGE) {
if(power_state.vout_avg > VOLTAGE_THR_MPP_TO_CV) {
operState = ConvConstVoltage;
}
break;
@ -955,11 +959,11 @@ int main(void)
mpp_state.testIdx = -1;
}
if(power_state.vout_avg > MPP_MAX_VOLTAGE) {
if(power_state.vout_avg > VOLTAGE_THR_MPP_TO_CV) {
operState = ConvConstVoltage;
}
if(power_state.current_avg > MAX_CURRENT) {
if(power_state.current_avg > CURRENT_THR_ANY_TO_CC) {
operState = ConvConstCurrent;
}
@ -983,7 +987,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 && power_state.vin_avg > fxp_add(power_state.vout_avg, WAKEUP_OFFSET_VOLTAGE)) {
if(time_in_state > 1000 && power_state.vin_avg > VOLTAGE_THR_IDLE_TO_MPP) {
sleep_time = 10;
operState = Bootstrap;
nextState = ConvMPP;