TMS320F280049C: ADC Accuracy issue

Part Number: TMS320F280049C

Tool/software:

Hello,

We are using TMS320F280049C Microcontroller for Inverter applications were we are converting DC to AC. But the output current is not stable it is varying with respect to input voltage after we start the inverter without any load (NO-LOAD) . When we Start Inverter without load and the input voltage range we are varying 350 - 450 then the values are in between 1000mA - 4000ma and after applying load we are getting 1A  difference. Here is the code   

int Ifb_V;
int Ifb_U;
int Ifb_V_real;
int Ifb_U_real;
long ISqrtSum_U;
long ISqrtSum_V;
int Ifb_V_rms;
int Ifb_U_rms;
int Ifb_V_rms_f;
int Ifb_U_rms_f;
float32_t ifb_v_real, ifb_u_real, ifb_total;


/************************ this part of code is in main loop **********************/

Sum2 += AdcbResultRegs.ADCRESULT4;
Sum2 += AdcbResultRegs.ADCRESULT5;
Sum2 += AdcbResultRegs.ADCRESULT6;
Sum2 += AdcbResultRegs.ADCRESULT7;

// calculate the midpoint of Iac_U
Sum3 += AdcaResultRegs.ADCRESULT0;
Sum3 += AdcaResultRegs.ADCRESULT1;
Sum3 += AdcaResultRegs.ADCRESULT2;
Sum3 += AdcaResultRegs.ADCRESULT3;

Ifb_V_ref = Sum2 >> 2; //get reference of Ifb_V channel
Ifb_U_ref = Sum3 >> 2; // get reference of Ifb_U channel


interrupt void epwm1_isr(void)
{

Ifb_V = AdcbResultRegs.ADCRESULT2;
Ifb_U = AdcaResultRegs.ADCRESULT1;

Ifb_V = (int) Ifb_V_ref - Ifb_V; //-30
Ifb_U = Ifb_U - Ifb_U_ref; //+30

Ifb_V_real = (int) (((long) Ifb_V * 85) >> 9); //34.158*1499/512 =10, 1 for 0.01A
Ifb_U_real = (int) (((long) Ifb_U * 85) >> 9); //34.158*1499/512 =10, 1 for 0.01A

ifb_v_real = (float32_t) Ifb_V_real;
ifb_u_real = (float32_t) Ifb_U_real;
ifb_total = ifb_v_real - ifb_u_real; // Not needed


if (abs(Ifb_V_real) > Ifb_real_max)
{
Ifb_real_max = abs(Ifb_V_real);
}
if (abs(Ifb_U_real) > Ifb_real_max)
{
Ifb_real_max = abs(Ifb_U_real);
}


ISqrtSum_U += (long) (Ifb_U_real) * (Ifb_U_real);
ISqrtSum_V += (long) (Ifb_V_real) * (Ifb_V_real);


tempI1 = (ISqrtSum_U * 41) >> 12;
Ifb_U_rms = _IQ1sqrt(tempI1);
Ifb_U_rms = (Ifb_U_rms >> 1);
Ifb_U_rms_f += ((Ifb_U_rms - Ifb_U_rms_f) >> 2);

tempI2 = (ISqrtSum_V * 41) >> 12;
Ifb_V_rms = _IQ1sqrt(tempI2);
Ifb_V_rms = (Ifb_V_rms >> 1);
Ifb_V_rms_f += ((Ifb_V_rms - Ifb_V_rms_f) >> 2);

}

/****************** This is in other function where we are calculating current *******************/
curr_rms_print = (int) (_IQ1int(((Ifb_V_rms_f + Ifb_U_rms_f) >> 1)) >> 1);
curr_rms_print *= 1000; //converting current to mA

void initGlobalVariables(void)
{

ISqrtSum_U = 0;
ISqrtSum_V = 0;
Ifb_V_rms = 0;
Ifb_U_rms = 0;
Ifb_V_rms_f = 0;
Ifb_U_rms_f = 0;
ifb_v_real = 0.0f;
ifb_u_real = 0.0f;
ifb_total = 0.0f;

}

Regards,

Swaminadhan