void MPPTRoutine(void) {
int deltaV = 0; //
inputAverageCompletedFlag = 0; // 即将计算
// Store last InputPower information, calculate new InputPower
prevInputPower = inputPower;
inputPower = (__builtin_mulss((int) inputVoltageAverage,
(int) inputCurrentAverage) >> 15);
deltaV = inputVoltageAverage - prevInputVoltageAverage;
if (inputPower >= (prevInputPower)) { //功率升高 //修改
if (deltaV <= -100) {
mpptFactor -= MAXDECREMENTMPPTFACTOR; //-80
} else if (deltaV < -30) {
mpptFactor += MININCREMENTMPPTFACTOR; //30
} else if (deltaV < -10) {
mpptFactor += 35; //35 //添加
} else if (deltaV < 0) {
mpptFactor += MAXINCREMENTMPPTFACTOR; //40
} else if (deltaV >= 30) {
mpptFactor -= MAXDECREMENTMPPTFACTOR; //-80
} else if (deltaV >= 20) {
mpptFactor -= 65; //添加
} else if (deltaV >= 10) {
mpptFactor -= 40;
} else if (deltaV > 0) {
mpptFactor -= 20; //-50
}
} else if (inputPower < (prevInputPower)) { //功率降低
if (deltaV <= -150) {
mpptFactor -= (MAXDECREMENTMPPTFACTOR << 2); //-320
} else if (deltaV <= -100) {
mpptFactor -= (MAXDECREMENTMPPTFACTOR << 1); //添加
} else if (deltaV <= -30) {
mpptFactor -= MAXDECREMENTMPPTFACTOR; //-80
} else if (deltaV < 0) {
mpptFactor -= MINDECREMENTMPPTFACTOR; //-50
} else if (deltaV >= 30) {
mpptFactor += MININCREMENTMPPTFACTOR; //30
} else if (deltaV > 0) {
mpptFactor += MAXINCREMENTMPPTFACTOR; //40
}
}
//else { //维持功率
// else if (deltaV <= -60) {
// mpptFactor -= MINDECREMENTMPPTFACTOR; //-50
// }
//}
// Saturate the MPPT limit to min and max values
if (mpptFactor >= mpptFactorMaximum) {
mpptFactor = mpptFactorMaximum;
} else if (mpptFactor <= MPPTFACTORMINIMUM) {
mpptFactor = MPPTFACTORMINIMUM;
}
prevInputVoltageAverage = inputVoltageAverage;
}
void MPPTRoutine(void) {
int deltaV = 0; //
inputAverageCompletedFlag = 0; // 即将计算
// Store last InputPower information, calculate new InputPower
prevInputPower = inputPower;
inputPower = (__builtin_mulss((int) inputVoltageAverage,
(int) inputCurrentAverage) >> 15);
deltaV = inputVoltageAverage - prevInputVoltageAverage;
if(order==0){
mpptFacotrPower[0]=inputPower;//储存
/*下一次*/
mpptFactor=mpptFactorBase;//order1的mppt 中间
order=1;
}else if(order==1){
mpptFacotrPower[1]=inputPower;
/*下一次*/
mpptFactor=mpptFactorBase+mpptFactorDelta; //order2的mppt 右边
order=2;
}else if(order==2){
mpptFacotrPower[2]=inputPower;
/*比较判断*/
if(mpptFacotrPower[0]<mpptFacotrPower[1])
mpptCompare=1;
else mpptCompare=-1;
if(mpptFacotrPower[1]<mpptFacotrPower[2])
mpptCompare+=1;
else mpptCompare-=1;
if(mpptCompare==2){
mpptFactorBase+=MININCREMENTMPPTFACTOR;
}
else if(mpptCompare==-2){
mpptFactorBase-=MINDECREMENTMPPTFACTOR;
}else {
;
}
/*限幅*/
if (mpptFactorBase >= mpptFactorMaximum) {
mpptFactorBase = mpptFactorMaximum;
} else if (mpptFactorBase <= MPPTFACTORMINIMUM) {
mpptFactorBase = MPPTFACTORMINIMUM;
}
/*下一次*/
mpptFactor=mpptFactorBase-mpptFactorDelta; //order0的mppt 左边
order=0;
}
/*if (inputPower >= (prevInputPower)) { //功率升高 //修改
if (deltaV <= -100) {
mpptFactor -= MAXDECREMENTMPPTFACTOR; //-80
} else if (deltaV < -30) {
mpptFactor += MININCREMENTMPPTFACTOR; //30
} else if (deltaV < -10) {
mpptFactor += 35; //35 //添加
} else if (deltaV < 0) {
mpptFactor += MAXINCREMENTMPPTFACTOR; //40
} else if (deltaV >= 30) {
mpptFactor -= MAXDECREMENTMPPTFACTOR; //-80
} else if (deltaV >= 20) {
mpptFactor -= 65; //添加
} else if (deltaV >= 10) {
mpptFactor -= 40;
} else if (deltaV > 0) {
mpptFactor -= 20; //-50
}
} else if (inputPower < (prevInputPower)) { //功率降低
if (deltaV <= -150) {
mpptFactor -= (MAXDECREMENTMPPTFACTOR << 2); //-320
} else if (deltaV <= -100) {
mpptFactor -= (MAXDECREMENTMPPTFACTOR << 1); //添加
} else if (deltaV <= -30) {
mpptFactor -= MAXDECREMENTMPPTFACTOR; //-80
} else if (deltaV < 0) {
mpptFactor -= MINDECREMENTMPPTFACTOR; //-50
} else if (deltaV >= 30) {
mpptFactor += MININCREMENTMPPTFACTOR; //30
} else if (deltaV > 0) {
mpptFactor += MAXINCREMENTMPPTFACTOR; //40
}
}*/
//else { //维持功率
// else if (deltaV <= -60) {
// mpptFactor -= MINDECREMENTMPPTFACTOR; //-50
// }
//}
// Saturate the MPPT limit to min and max values
if (mpptFactor >= mpptFactorMaximum) {
mpptFactor = mpptFactorMaximum;
} else if (mpptFactor <= MPPTFACTORMINIMUM) {
mpptFactor = MPPTFACTORMINIMUM;
}
// prevInputVoltageAverage = inputVoltageAverage;
}