ADE9000 DELTA connection, Error in Power register values (Real power, reactive power and apparent power) calibration issue

Dear ADE

i have been working ADE9000 with arduino zero,  I have successfully configured XIRMS and XVRMS registers and getting Real voltage and current values but Power values not coming as expected, i have done phase calibration using 0.5PF and phase calibration using 1 pf load in 3wire delta connection. i had using fluke 438-ii series power analyzer for my calibration. i have set 3 wire delta config in both fluke meter and ADE9000 (ACCMODE= 0X0090). I am using calibration excel sheet for calculating gain values.    

The arduino calibration sketch does not perform phase calibration and power gain calibration.

I am using same conversion constants for  Active power, reactive power and power factor as stated in the UG1098,   

i am not getting power register values any closer to fluke meter, power factor values comes 0.89PF in resistive load (expected 0.98PF),

is there any specific settings need to be done to get real values in delta connection ?

 i have posted my arduino sketch.

#include <SPI.h>
#include  <ADE9000RegMap.h>
#include <ADE9000API.h>
// new line added
// working with load - tested by karthi on 06-dec-2018 - 10:26 am
/*Basic initializations*/
ADE9000Class ade9000;
#define SPI_SPEED 5000000     //SPI Speed
#define CS_PIN 8 //8-->Arduino Zero. 16-->ESP8266 
#define ADE9000_RESET_PIN 5 //Reset Pin on HW
#define PM_1 4              //PM1 Pin: 4-->Arduino Zero. 15-->ESP8266 

//double AVRMS1012 = 0;
double AVRMS1 = 0;
double BVRMS1 = 0;
double CVRMS1 = 0;
double AIRMS1 = 0;
double BIRMS1 = 0;
double CIRMS1 = 0;
double AWATT1 = 0;
double BWATT1 = 0;
double CWATT1 = 0;
double AVAR1 = 0;
double BVAR1 = 0;
double CVAR1 = 0;
double AVA1 = 0;
double BVA1 = 0;
double CVA1 = 0;


/*Structure decleration */
struct ActivePowerRegs powerRegs;     // Declare powerRegs of type ActivePowerRegs to store Active Power Register data
struct ReactivePowerRegs ReactPowerRegs;
struct ApparentPowerRegs ApparPowerRegs;
struct CurrentRMSRegs curntRMSRegs;   //Current RMS
struct VoltageRMSRegs vltgRMSRegs;    //Voltage RMS
struct VoltageTHDRegs voltageTHDRegsnValues; //Voltage THD
struct ResampledWfbData resampledData; // Resampled Data
struct PowerFactorRegs Pfreg;
struct PeriodRegs Freq;


/*Function Decleration*/
void readRegisterData(void);
void readResampledData(void);
void resetADE9000(void);


/////////////////////////////////////////////kumarasamy lab test - fluke meter/////////////////////
int sample_times = 1000 ;// this is for samples count
int serial_plotter  =  false ; // use serial plotter
////////////////////////////////////////////// runtime variable ///////////////////////////////////
int i_loop_vars;

unsigned long previous_calib_val_1 = 0;
unsigned long previous_calib_val_2 = 0;
unsigned long previous_calib_val_3 = 0;

unsigned long current_calib_val_1 = 0;
unsigned long current_calib_val_2 = 0;
unsigned long current_calib_val_3 = 0;

long calib_val_diff_1 = 0;
long calib_val_diff_2 = 0;
long calib_val_diff_3 = 0;

unsigned long avg_calib_val_1 = 0;
unsigned long avg_calib_val_2 = 0;
unsigned long avg_calib_val_3 = 0;

unsigned long calib_val_temp_1 = 0;
unsigned long calib_val_temp_2 = 0;
unsigned long calib_val_temp_3 = 0;

///////////////////////////////////////////////////////////////////////////////////////////////////////

void setup()
{
  Serial.begin(115200);
  pinMode(PM_1, OUTPUT);    //Set PM1 pin as output
  digitalWrite(PM_1, LOW);   //Set PM1 select pin low for PSM0 mode
  pinMode(ADE9000_RESET_PIN, OUTPUT);
  digitalWrite(ADE9000_RESET_PIN, HIGH);
  void resetADE9000();
  delay(1000);
  //Serial.print("WFB_CFG:");
  //Serial.println(ade9000.SPI_Read_32(ADDR_WFB_CFG),HEX);
  //  ade9000.SPI_Write_16(ADDR_WFB_CFG, 0x3F0);
  //  Serial.println("Energy Power Reg");
  //  Serial.println(ade9000.SPI_Read_16(ADDR_EP_CFG), HEX); //Energy Power REG

  ade9000.SPI_Init(SPI_SPEED, CS_PIN); //Initialize SPI
  ade9000.SetupADE9000();             //Initialize ADE9000 registers according to values in ADE9000API.h
//    ade9000.SPI_Write_16(ADDR_RUN, 0x0); //Set RUN=1 to turn on DSP. Uncomment if SetupADE9000 function is not used
  Serial.print("RUN Register: ");
  Serial.println(ade9000.SPI_Read_16(ADDR_RUN), HEX);
}

void loop() {
  readRegisterData();
  gain();
//      man_calib_func();
}


void man_calib_func() {
  for (i_loop_vars = 0 ; i_loop_vars <= sample_times; i_loop_vars++) {
    gain();
    avg_calib_val_1 = calib_val_temp_1 + avg_calib_val_1;
    avg_calib_val_2 = calib_val_temp_2 + avg_calib_val_2;
    avg_calib_val_3 = calib_val_temp_3 + avg_calib_val_3;
  }
  // making average calib value
  avg_calib_val_1 = avg_calib_val_1 / sample_times;
  avg_calib_val_2 = avg_calib_val_2 / sample_times;
  avg_calib_val_3 = avg_calib_val_3 / sample_times;

  //making diff between old and current calib val
  current_calib_val_1 = avg_calib_val_1;
  current_calib_val_2 = avg_calib_val_2;
  current_calib_val_3 = avg_calib_val_3;

  calib_val_diff_1 = previous_calib_val_1 - current_calib_val_1 ;
  calib_val_diff_2 = previous_calib_val_2 - current_calib_val_2 ;
  calib_val_diff_3 = previous_calib_val_3 - current_calib_val_3 ;

  // printing avg calib value

  Serial.print("average calib value AP:");
  Serial.println(avg_calib_val_1);
  Serial.print("average calib value BP:");
  Serial.println(avg_calib_val_2);
  // Serial.print("average calib value C :");
  // Serial.println(avg_calib_val_3);

  //Serial.print("difference in calib value A:");
  //Serial.println(calib_val_diff_1);
  //Serial.print("difference in calib value B:");
  //Serial.println(calib_val_diff_2);
  //Serial.print("difference in calib value C:");
  //Serial.println(calib_val_diff_3);

  previous_calib_val_1 = current_calib_val_1;
  previous_calib_val_2 = current_calib_val_2;
  previous_calib_val_3 = current_calib_val_3;
  delay(10000);
}
void readRegisterData()
{
  /*Read and Print Specific Register using ADE9000 SPI Library */
  //  Serial.print("AIRMS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AIRMS), HEX); // AIRMS

  /*Read and Print RMS & WATT Register using ADE9000 Read Library*/
  ade9000.ReadVoltageRMSRegs(&vltgRMSRegs);    //Template to read Power registers from ADE9000 and store data in Arduino MCU
  ade9000.ReadActivePowerRegs(&powerRegs);
  ade9000.ReadReactivePowerRegs(&ReactPowerRegs);
  ade9000.ReadApparentPowerRegs(&ApparPowerRegs);
  ade9000.ReadPowerFactorRegsnValues(&Pfreg);
  ade9000.ReadPeriodRegsnValues(&Freq);
  //  Serial.print("AVRMS:");
  //  Serial.println(vltgRMSRegs.VoltageRMSReg_A); //Print AVRMS register
  //  Serial.print("AWATT:");
  //  Serial.println(powerRegs.ActivePowerReg_A); //Print AWATT register

  AVRMS1 = (vltgRMSRegs.VoltageRMSReg_A); //*1.1/100000;
  Serial.print("A_VRMS: ");
  AVRMS1 = (AVRMS1 * 10.74705975) / 1000000;//10.74705975
  Serial.println(AVRMS1); // A VRMS ONE

  BVRMS1 = (vltgRMSRegs.VoltageRMSReg_B); //*1.1/100000;
  Serial.print("B_VRMS: ");
  BVRMS1 = (BVRMS1 * 10.74705975) / 1000000; //10.7470597510707
  Serial.println(BVRMS1); // B VRMS ONE

  CVRMS1 = (vltgRMSRegs.VoltageRMSReg_C); //*1.1/100000;
  Serial.print("C_VRMS: ");
  CVRMS1 = (CVRMS1 * 10.74705975) / 1000000;
  Serial.println(CVRMS1); // C VRMS ONE

  Serial.print("AIRMS: ");
  AIRMS1 = (ade9000.SPI_Read_32(ADDR_AIRMS)); // AIRMS
  AIRMS1 = (AIRMS1 * 3.855475107) / 1000000; //3.85547510693196
  Serial.println(AIRMS1); // C VRMS ONE

  Serial.print("BIRMS: ");
  BIRMS1 = (ade9000.SPI_Read_32(ADDR_BIRMS)); // BIRMS
  BIRMS1 = (BIRMS1 * 3.855475107) / 1000000;
  Serial.println(BIRMS1); // C VRMS ONE

  Serial.print("CIRMS: ");
  CIRMS1 = (ade9000.SPI_Read_32(ADDR_CIRMS)); // CIRMS
  CIRMS1 = (CIRMS1 * 3.855475107) / 1000000;
  Serial.println(CIRMS1); // C VRMS ONE

  Serial.print("AWATT: ");
  AWATT1 = (powerRegs.ActivePowerReg_A); //Print AWATT register
  AWATT1 = (AWATT1 * 5.561314383) / 1000 ; //5.5613143833866
  Serial.println(AWATT1); // C VRMS ONE

  Serial.print("BWATT: ");
  BWATT1 = (powerRegs.ActivePowerReg_B); //Print AWATT register
  BWATT1 = (BWATT1 * 5.561314383) / 1000 ;
  Serial.println(BWATT1); // C VRMS ONE

  Serial.print("CWATT: ");
  CWATT1 = (powerRegs.ActivePowerReg_C); //Print AWATT register
  CWATT1 = (CWATT1 * 5.561314383) / 1000 ;
  Serial.println(CWATT1); // C VRMS ONE

  Serial.print("AVAR: ");
  AVAR1 = (ReactPowerRegs.ReactivePowerReg_A); //Print avr register
  AVAR1 = (AVAR1 * 5.561314383) / 1000 ;
  Serial.println(AVAR1); //

  Serial.print("BVAR: ");
  BVAR1 = (ReactPowerRegs.ReactivePowerReg_B); //Print avr register
  BVAR1 = (BVAR1 * 5.561314383) / 1000 ;
  Serial.println(BVAR1); // C VRMS ONE

  Serial.print("CVAR: ");
  CVAR1 = (ReactPowerRegs.ReactivePowerReg_C); //Print avr register
  CVAR1 = (CVAR1 * 5.561314383) / 1000 ;
  Serial.println(CVAR1); // C VRMS ONE

  Serial.print("AVA: ");
  AVA1 = (ApparPowerRegs.ApparentPowerReg_A); //Print avr register
  AVA1 = (AVA1 * 5.561314383) / 1000 ;
  Serial.println(AVA1); // C VRMS ONE

  Serial.print("BVA: ");
  BVA1 = (ApparPowerRegs.ApparentPowerReg_B); //Print avr register
  BVA1 = (BVA1 * 5.561314383) / 1000 ;
  Serial.println(BVA1); // C VRMS ONE

  Serial.print("CVA: ");
  CVA1 = (ApparPowerRegs.ApparentPowerReg_C); //Print avr register
  CVA1 = (CVA1 * 5.561314383) / 1000 ;
  Serial.println(CVA1); // C VRMS ONE

  Serial.print("APF: ");
  Serial.println(Pfreg.PowerFactorValue_A); //Print avr register

  Serial.print("BPF: ");
  Serial.println(Pfreg.PowerFactorValue_B);

  Serial.print("CPF: ");
  Serial.println(Pfreg.PowerFactorValue_C);
  //
  //  Serial.print("A_Frequency: ");
  //  Serial.println(Freq.FrequencyValue_A);
  //
  //  Serial.print("B_Frequency: ");
  //  Serial.println(Freq.FrequencyValue_B);
  //
  //  Serial.print("C_Frequency: ");
  //  Serial.println(Freq.FrequencyValue_C);
}


void gain()
{
  ade9000.ReadVoltageRMSRegs(&vltgRMSRegs);    //Template to read Power registers from ADE9000 and store data in Arduino MCU
  ade9000.ReadActivePowerRegs(&powerRegs); /*Read and Print RMS & WATT Register using ADE9000 Read Library*/
  /*Read and Print Specific Register using ADE9000 SPI Library */
  //Serial.print("MEASURED AVRMS:");
  //  calib_val_temp_1 = (vltgRMSRegs.VoltageRMSReg_C); //Print AVRMS register
  //  calib_val_temp_2 = (ade9000.SPI_Read_32(ADDR_CIRMS)); //Print AVRMS register
  //  //calib_val_temp_3 = (vltgRMSRegs.VoltageRMSReg_C); //Print AVRMS register
  //Serial.println(calib_val_temp);
  //Serial.print("MEASURED AIRMS: ");
  //Serial.println(ade9000.SPI_Read_32(ADDR_AIRMS)); // AIRMS
  //  Serial.print("MEASURED AWATT:");
  //  Serial.println(powerRegs.ActivePowerReg_A); //Print AWATT register
  //  Serial.print("MEASURED BVRMS:");
  //Serial.print(vltgRMSRegs.VoltageRMSReg_A);
  //Serial.print("\t");
  //Serial.print(vltgRMSRegs.VoltageRMSReg_B); //Print BVRMS register
  //Serial.print("\t");
  // Serial.println((vltgRMSRegs.VoltageRMSReg_C)/10000);
  //  Serial.print("MEASURED BIRMS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BIRMS), HEX); // BIRMS
  //  Serial.print("MEASURED BWATT:");
  //  Serial.println(powerRegs.ActivePowerReg_B); //Print BWATT register
  //  Serial.print(" MEASURED CVRMS:");
  //  Serial.println(vltgRMSRegs.VoltageRMSReg_C); //Print CVRMS register
  //  Serial.print("MEASURED CIRMS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CIRMS), HEX); // CIRMS
  //  Serial.print("MEASURED CWATT:");
  //  Serial.println(powerRegs.ActivePowerReg_C); //Print CWATT register

  //Serial.print("AWATTHR_HI: ");
//  calib_val_temp_1 = (ade9000.SPI_Read_32(ADDR_AWATTHR_HI)); // XPGAIN
  //Serial.print("BWATTHR_HI: ");
  //Serial.println(ade9000.SPI_Read_32(ADDR_BWATTHR_HI), HEX); // XPGAIN
  //Serial.print("CWATTHR_HI: ");
  // Serial.println(ade9000.SPI_Read_32(ADDR_CWATTHR_HI), HEX); // XPGAIN

  //Serial.print("AVARHR_HI: ");
 calib_val_temp_2 = (ade9000.SPI_Read_32(ADDR_CWATTHR_HI)); // XPGAIN
  //  Serial.print("BVARHR_HI: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BVARHR_HI), HEX); // XPGAIN
  //  Serial.print("CVARHR_HI: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CVARHR_HI), HEX); // XPGAIN
  //
    Serial.print("APGAIN: ");
    Serial.println(ade9000.SPI_Read_32(ADDR_APGAIN), HEX); // XPGAIN
    Serial.print("BPGAIN: ");
    Serial.println(ade9000.SPI_Read_32(ADDR_BPGAIN), HEX); // XPGAIN
    Serial.print("CPGAIN: ");
    Serial.println(ade9000.SPI_Read_32(ADDR_CPGAIN), HEX); // XPGAIN

  //  ADE9000.SPI_Write_32(uint16_t Address , uint32_t Data );/////
//    ade9000.SPI_Write_32(ADDR_APGAIN, 0x533A4E9C);
//    ade9000.SPI_Write_32(ADDR_BPGAIN, 0x5FEF07CE);
//    ade9000.SPI_Write_32(ADDR_CPGAIN, 0x576DCABD);
  //      ade9000.SPI_Write_32(ADDR_APHCAL0, 0xF9B0436A);
  //      ade9000.SPI_Write_32(ADDR_BPHCAL0, 0xF671F623);
  //      ade9000.SPI_Write_32(ADDR_CPHCAL0, 0xF9EABC84);


  //  ade9000.SPI_Write_32(ADDR_AVGAIN, 0x5FFC4351);
  //  ade9000.SPI_Write_32(ADDR_AIGAIN, 0x3D8CD0);
  //  ade9000.SPI_Write_32(ADDR_BVGAIN, 0x57F3593C);
  //  ade9000.SPI_Write_32(ADDR_BIGAIN, 0x38DD7A);
  //  ade9000.SPI_Write_32(ADDR_CVGAIN, 0x65924D55);
  //  ade9000.SPI_Write_32(ADDR _CIGAIN, 0x1C98EF);

  //  Serial.print("AVRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AVRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("AIRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AIRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("AVAROS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AVAROS), HEX); //AVAROS
  //  Serial.print("AWATTOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AWATTOS), HEX); //
  //  Serial.print("AIFRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AIFRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("AVFRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AVRMSOS), HEX); //  AWATTOS
  //  Serial.print("AFWATTOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AFWATTOS), HEX); //AFWATTOS
  //  Serial.print("AFVAROS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AFVAROS), HEX); // AFVAROS

  //
  //  Serial.print("BIRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BIRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("BVRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BVRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("BVAROS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BVAROS), HEX); //AVAROS
  //  Serial.print("BWATTOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BWATTOS), HEX);
  //  Serial.print("BVFRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BVRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("BIFRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BIFRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("BFWATTOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BFWATTOS), HEX); //AFWATTOS
  //  Serial.print("BFVAROS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BFVAROS), HEX); // AFVAROS


  //  Serial.print("CVRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CVRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("CIRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CIRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("CVAROS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CVAROS), HEX); //AVAROS
  //  Serial.print("CWATTOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CWATTOS), HEX);
  //  Serial.print("CVFRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CVRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("CIFRMSOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CIFRMSOS), HEX); //  ADDR_AVRMSOS
  //  Serial.print("CFWATTOS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CFWATTOS), HEX); //AFWATTOS
  //  Serial.print("CFVAROS: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CFVAROS), HEX); // AFVAROS
  //
  //  Serial.print("AVGAIN: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AVGAIN), HEX); // AVGAIN
  //  Serial.print("BVGAIN: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BVGAIN), HEX); // AVGAIN
  //  Serial.print("CVGAIN: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CVGAIN), HEX); // AVGAIN
  //  Serial.print("AIGAIN: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_AIGAIN), HEX); // AVGAIN
  //  Serial.print("BIGAIN: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_BIGAIN), HEX); // AVGAIN
  //  Serial.print("CIGAIN: ");
  //  Serial.println(ade9000.SPI_Read_32(ADDR_CIGAIN), HEX); // AVGAIN

//  Serial.print("APHCAL0: ");
//  Serial.println(ade9000.SPI_Read_32(ADDR_APHCAL0), HEX); // XPHCAL
//  Serial.print("ABPHCAL0: ");
//  Serial.println(ade9000.SPI_Read_32(ADDR_BPHCAL0), HEX); // XPGAIN
//  Serial.print("ACPHCAL0: ");
//  Serial.println(ade9000.SPI_Read_32(ADDR_CPHCAL0), HEX); // XPGAIN

}


void resetADE9000(void)
{
  digitalWrite(ADE9000_RESET_PIN, LOW);
  delay(50);
  digitalWrite(ADE9000_RESET_PIN, HIGH);
  delay(1000);
  Serial.println("Reset Done");
}

Any help could be highly appreciated,

Thank you.



added arduino sketch
[edited by: karthi at 1:39 PM (GMT 0) on 6 Dec 2018]