这是一段在AD段里采样平均值的程序
思想应该是这个值起码也累加8次的采样值后再去除以8对吧,
可是这段程序我感觉是只有AD中断进入都会除以8.这有问题吗?
还是我理解错误,C基础不太好,希望高手指点
flybackCurrent2Sum ,和rectifiedInverterOutputCurrentSum都一样吧
第一averageFlybackCurrent1 = flybackCurrent1Sum >> 3;等同于除以flybackCurrent1Sum8吧。
void __attribute__((interrupt, no_auto_psv)) _ADCP3Interrupt()
{
// Moving Average of Flyback Currents for load sharing
flybackCurrent1Sum = flybackCurrent1Sum + flybackCurrent1 - flybackCurrent1Array[currentArrayCnt];
averageFlybackCurrent1 = flybackCurrent1Sum >> 3;
flybackCurrent2Sum = flybackCurrent2Sum + flybackCurrent2 - flybackCurrent2Array[currentArrayCnt];
averageFlybackCurrent2 = flybackCurrent2Sum >> 3;
flybackCurrent1Array[currentArrayCnt] = flybackCurrent1;
flybackCurrent2Array[currentArrayCnt] = flybackCurrent2;
// Moving Average of AC Current for AC Current Fault
rectifiedInverterOutputCurrentSum = rectifiedInverterOutputCurrentSum + rectifiedInverterOutputCurrent -
rectifiedInverterOutputCurrentArray[currentArrayCnt];
averageRectifiedCurrent = rectifiedInverterOutputCurrentSum >> 3;
rectifiedInverterOutputCurrentArray[currentArrayCnt++] = rectifiedInverterOutputCurrent;
if(currentArrayCnt >= 8)
{
currentArrayCnt = 0;
}
}
|