mpp1

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;

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值