This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28379D: Can somebody explain me with the following code for the ADCPPB1OFFREF value determination:

Part Number: TMS320F28379D

from my understanding, ADCPPBOFFREF should be a fixed value. But I didn't understand whats the purpose of the "for loop" is for in the below code. Is it for the calibration? If it for the calibration  

I have the following questions:

1. How the K1,K2 values are determined 

2. How the following equation is been derived:

offset_lemV = K1*offset_lemV + K2*(IFB_LEMV)*ADC_PU_SCALE_FACTOR;

*******************************************************************************************************************************************************************

#define IFB_LEMV AdcaResultRegs.ADCRESULT1
#define IFB_LEMW AdcbResultRegs.ADCRESULT1

#define ADC_PU_SCALE_FACTOR        0.000244140625     //1/2^12

_iq K1 = _IQ(0.998), // Offset filter coefficient K1: 0.05/(T+0.05);
      K2 = _IQ(0.001999); // Offset filter coefficient K2: T/(T+0.05);

offset_lemW = 0;
offset_lemV = 0;

for (OffsetCalCounter=0; OffsetCalCounter<20000; )
{
if(EPwm11Regs.ETFLG.bit.INT==1)
{
if(OffsetCalCounter>1000)
{

offset_lemV = K1*offset_lemV + K2*(IFB_LEMV)*ADC_PU_SCALE_FACTOR;
offset_lemW = K1*offset_lemW + K2*(IFB_LEMW)*ADC_PU_SCALE_FACTOR;

}
EPwm11Regs.ETCLR.bit.INT=1;
OffsetCalCounter++;
}
}

AdcaRegs.ADCPPB2OFFREF = (offset_lemV*4096.0); // setting LEM Iv offset
AdcbRegs.ADCPPB2OFFREF = (offset_lemW*4096.0); // setting LEM Iw offset

******************************************************************************************************************************************************************

I took the above code from IDDK_PM_SERVO_F2839x-v2 example file.