Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ADE7763 line voltage and current detection

Status
Not open for further replies.

deepak4you

Member level 1
Joined
Apr 7, 2015
Messages
34
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
423
Hello Experts!

Calling out for help again while I'm in difficulty.

I'm working on a power meter setup using the ADE7763 and finding it difficult to get the correct Vrms, Vpeak, Irms, Ipeak values from the chip. I am using the attached schematic where R7+R6 = 510K, R8 = 1k. R12 and R13 are 8.8 ohms each. These are the values prescribed in the ADE7763 Evaluation Board and application note AN639 as well.

My calculation is:

1Vpp (+/- 0.5V) at ADC input (V2P and V2N) corresponds to 260Vrms/367.64Vpp at full range
ADC LSB = 1(Vpp)/10322 (ADE7763 Datasheet Page 23)

To calculate the Vpp, I read the value in VPEAK Register and do the below calculation:
Output Vpp = ADC LSB * VPEAK * 367.64
Output Vrms = Output Vpp/1.414

Similarly, for current I do the below calculations:
1Vpp (+/- 0.5V) at ADC input (V1P and V2N) corresponds to 20A of AC current
ADC LSB = 1(Vpp)/2,642,412 (ADE7763 Datasheet Page 23)

To calculate Ipp, I read the IPEAK register and do the following calculations:
Output Ipp = ADC LSB * IPEAK * 20
Output Irms = Output Ipp/1.414

I'm not getting the correct values despite these above calculations. Is there something wrong in my calculations? Or am I missing/overlooking something from the datasheet?

- - - Updated - - -

On the other hand, a very basic question as well (Apologies if this is too basic a question).

For a differential ADC, if the datasheet mentions a full scale input of 0.5V or full scale input of +/- 0.5 V, does that imply that the full range is -0.25 to +0.25 totaling to 0.5V, or, -0.5 to +0.5 totaling to 1V?

- - - Updated - - -

Reading through the datasheet further, I think I need to make corrections as below:

R7+R6 = 1M

0.5Vpp at ADC input (V2P and V2N) corresponds to 260Vrms/367.64Vpp at full range
ADC LSB (resolution) = 0.5/10322 Volts/Level (ADE7763 Datasheet Page 23)

VRMS register should directly give me the ADC code converted to RMS value.

Similarly, for current I do the below calculations:
0.754Vpp at ADC input (V1P and V2N) corresponds to 20A of AC current
ADC LSB (resolution) = 0.754/2,642,412 Volts/Level(ADE7763 Datasheet Page 23)

IRMS register should directly give me the ADC code converted to RMS value.

I wonder if these above calculations are correct for my measurement parameters?
 

I do not see the attached schematic.

You reported your calculations, but not the output of the IC. How far apart are the various values?

Output Vrms = Output V peak/1.414 (i.e. root 2) not Output Vpeak to peak /1.414
Output Irms = output Ipeak/1.414 (i.e root 2) not output I peak to peak/1.414
These equations assume sin waves.

If you don't have sin waves, you can't find RMS values this way.
 

My apologies @wwfeldman, and thanks for your reply as well. I indeed forgot to upload the schematic. Same is attached now. ADE7763_Schematics.png

I am indeed using the board for AC power measurement. Infact we're actually building a product in itself for some specific purpose, but we're unable to get stable correct values.

Values which we see are anywhere between 8000 to 2,000,000+ for voltage. I understand that the latter might be spurious spikes from track capacitance, leak etc. I also understand that the voltage divider resistors are mix of 5% and 10% tolerance which would futher contribute to errors. I will get to those later, but I first wanted to understand if my theoretical calculations are correct based on the datasheet. Because if my fundamental calculations are wrong and if I add them to the code, then no matter what, I will have all wrong values. Hence, the request for help.
 

Here's the code and the output. I made a new clean ADE board and that is also giving the same trouble. After the first few readings, the Irms and Vrms values are reported the same. This, without any AC load/connection connected :(

Code:
#include <SPI.h>
//#include <SoftwareSerial.h>

const char PIN_ADE_INT  = 2;  // Interrupt from ADE
const char PIN_ADE_RST  = 3;  // ~Reset to ADE
const char PIN_ADE_CS   = 5;  // SPI ~chip select to ADE    
const char PIN_ADE_CLK  = 18;  // SPI clock to ADE
const char PIN_ADE_MISO = 19;  // SPI MISO from ADE 
const char PIN_ADE_MOSI = 23;  // SPI MOSI from ADE 

const int MR_IRMS      = 0x16; /* Current Channel 1 RMS Value. */
const int MR_VRMS      = 0x17; /* Voltage Channel 2 RMS Value. */
const int MR_IPEAK     = 0x22; /* Current Channel Peak Register. */
const int MR_VPEAK     = 0x24; /* Voltage Channel Peak Register. */

const int MR_MODE      = 0x09; /* Mode Register. */
const int MR_CH1OS     = 0x0D; /* Current Channel Offset Adjust. */
const int MR_CH2OS     = 0x0E; /* Voltage Channel Offset Adjust. */
const int MR_GAIN      = 0x0F; /* PGA Gain Adjust. */
const int ADE_WRITE_FLAG = 0x80;

const int MR_IRMS_CNT      = 3;
const int MR_VRMS_CNT      = 3;
const int MR_IPEAK_CNT     = 3;
const int MR_VPEAK_CNT     = 3;
const int MR_MODE_CNT      = 2;
const int MR_CH1OS_CNT     = 1;
const int MR_CH2OS_CNT     = 1;
const int MR_GAIN_CNT      = 1;

/* Prototypes */

int count = 0;

void ADE_read (unsigned char addr,
               unsigned char * data,
               unsigned char count);
               
void ADE_write(unsigned char addr,
               unsigned char * data,
               unsigned char count);
/**********************************************************************
 *
 * Set up routine
 *
 *********************************************************************/
void setup(void) {
  
  unsigned int    ui;
  unsigned char   uc;
  /* Initialize the serial port to host */
  Serial.begin(115200);

  /* Configure Chip Select */    
  pinMode(PIN_ADE_CS,  OUTPUT);
  digitalWrite(PIN_ADE_CS, HIGH);  // Deselect
  delayMicroseconds(10);

  /* Enable SPI */  
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE1);   // clk idle low, sample falling edge
  SPI.setClockDivider(SPI_CLOCK_DIV4);
  
  /*****************************/
  /* Initialize the ADE        */
  /*****************************/
    /* Set the mode */
  ui = 0x0080;
  ADE_write (MR_MODE, (unsigned char *)&ui, MR_MODE_CNT);

    /* Set up the gain register */
  uc = 0x00;  // ADC1,2 gain = 1 full scale range is +-0.5V
  ADE_write (MR_GAIN, (unsigned char *)&uc, MR_GAIN_CNT);
  
  /* Set up the offset correction for ADC1 */
  uc = 0x00;
  ADE_write (MR_CH1OS, (unsigned char *)&uc, MR_CH1OS_CNT);
  
  /* Set up the offset correction for ADC2 */
  uc = 0x00;
  ADE_write (MR_CH2OS, (unsigned char *)&uc, MR_CH2OS_CNT);

  
  Serial.println("setup complete");
  
  return;
  
  
} /* end setup */

/**********************************************************************
 *
 * Main loop
 *
 *********************************************************************/
void loop(void) {
  int           i, v, p;
  unsigned long ul;
  int temp;
  float ADC_MAX_RANGE = 0.5;
  float Line_Vrms_Max = 260;
  int ADC_RES = 10322;
  double  Low_Vrms = 0.0;
  double  Full_Vrms = 0.0;
  delay(5000);

  ul = 0;
  ADE_read(MR_IRMS,      (unsigned char *)&ul, MR_IRMS_CNT);
  Serial.print("IRMS 0x");
  Serial.println(ul, HEX);
  Serial.print("Irms (dec): ");
  Serial.println((int)ul);
  
  
  ul = 0;
  ADE_read(MR_VRMS,      (unsigned char *)&ul, MR_VRMS_CNT);
  Serial.print("VRMS 0x");
  Serial.println(ul, HEX);
  Serial.print("VRMS (dec): ");
  
  temp = (int)ul;
  Serial.println(temp);
  Low_Vrms = ( ADC_MAX_RANGE / ADC_RES ) * temp; // Senthil check. This part is not working
  Serial.print("1Vrms equiv: ");
  Serial.println(Low_Vrms);
  Full_Vrms = Low_Vrms * Line_Vrms_Max; //Senthil check. This part is not working
  Serial.print("Full Vpp equiv: ");
  Serial.println(Full_Vrms);  
  
  ul = 0;
  ADE_read(MR_IPEAK,      (unsigned char *)&ul, MR_IPEAK_CNT);
  Serial.print("IPEAK 0x");
  Serial.println(ul, HEX);
  
  
  ul = 0;
  ADE_read(MR_VPEAK,      (unsigned char *)&ul, MR_VPEAK_CNT);
  Serial.print("VPEAK 0x");
  Serial.println(ul, HEX);
  Serial.print("VPEAK (dec): ");
  Serial.println((int)ul);       
  Serial.print("--------------Loop ends --------------");
  Serial.println(count);
  count++;

} /* end loop */

/**************************************************************************
 *   ADE_read
 *
 *   This routine enables the chip select and read the selected number
 *   of bytes from the ADE.
 *
 *   ADE is big endian and the Arduino is little. Therefore items are 
 *   assembled in revese order.
 *************************************************************************/
void ADE_read (unsigned char addr,
               unsigned char * data,
               unsigned char count)
{
  unsigned char i;
  
  /* If a 3 byte read, zero out the MSB of the 4 byte data */
  if (count == 3) {
    //*((unsigned long *)(data+4-1)) = 0;
  }

  /* Select the chip */
  digitalWrite(PIN_ADE_CS, LOW);
  delayMicroseconds(10);
  
  /* Point to the Arduino MSB */
  data += (count-1);

  /* Write the address to access */
  SPI.transfer(addr); 
                                     
  /* Must wait 4 us for data to become valid */
  delayMicroseconds(4);
  
  // Do for each byte in transfer
  for (i=0; i<count; i++)
  {

    /* Transer the byte */
    *data = SPI.transfer (0x00);
    data--;
  }

  /* Deselect the chip */
  digitalWrite(PIN_ADE_CS, HIGH);
  delayMicroseconds(10);
  

} /* end ADE_read */





/**************************************************************************
 *   ADE_write
 *   This routine enables chip select and reads the selected number of
 *   bytes from the ADE
 *
 *   ADE is big endian and the Arduino is little. Therefore items are 
 *   assembled in revese order.
 *************************************************************************/
void ADE_write(unsigned char addr,
               unsigned char * data,
               unsigned char count)
{
  unsigned char i;

  /* Select the chip */
  digitalWrite(PIN_ADE_CS, LOW);
  delayMicroseconds(10);
  
  /* Point to the Arduino MSB */
  data += (count-1);
  
  /* Write the address to access */
  SPI.transfer(addr | ADE_WRITE_FLAG);
                                 
  // Do for each byte */
  for (i=0; i<count; i++)
  {
    /* Transer the byte */
    SPI.transfer(*data);             // write all the bytes
    data--;
  }

  /* Deselect chip */
  digitalWrite(PIN_ADE_CS, HIGH);
  delayMicroseconds(10);

} /* end ADE_write */

Output
Code:
IRMS 0x0
Irms (dec): 0
VRMS 0x0
VRMS (dec): 0
1Vrms equiv: 0.00
Full Vpp equiv: 0.00
IPEAK 0x0
VPEAK 0x0
VPEAK (dec): 0
--------------Loop ends --------------1
IRMS 0x0
Irms (dec): 0
VRMS 0x0
VRMS (dec): 0
1Vrms equiv: 0.00
Full Vpp equiv: 0.00
IPEAK 0x0
VPEAK 0x0
VPEAK (dec): 0
--------------Loop ends --------------2
IRMS 0x0
Irms (dec): 0
VRMS 0x3DF
VRMS (dec): 991
1Vrms equiv: 0.05
Full Vpp equiv: 12.48
IPEAK 0x0
VPEAK 0x14A4
VPEAK (dec): 5284
--------------Loop ends --------------3
IRMS 0x3DF
Irms (dec): 991
VRMS 0x156E
VRMS (dec): 5486
1Vrms equiv: 0.27
Full Vpp equiv: 69.09
IPEAK 0x85F9
VPEAK 0x14A4
VPEAK (dec): 5284
--------------Loop ends --------------4
IRMS 0x156E
Irms (dec): 5486
VRMS 0x1F72
VRMS (dec): 8050
1Vrms equiv: 0.39
Full Vpp equiv: 101.39
IPEAK 0x7C85F9
VPEAK 0x14A4
VPEAK (dec): 5284
--------------Loop ends --------------5
IRMS 0x1F72
Irms (dec): 8050
VRMS 0x1F72
VRMS (dec): 8050
1Vrms equiv: 0.39
Full Vpp equiv: 101.39
IPEAK 0x7C85F9
VPEAK 0x14A4
VPEAK (dec): 5284
--------------Loop ends --------------6
IRMS 0x1F72
Irms (dec): 8050
VRMS 0x1F72
VRMS (dec): 8050
1Vrms equiv: 0.39
Full Vpp equiv: 101.39
IPEAK 0x7C85F9
VPEAK 0x14A4
VPEAK (dec): 5284
--------------Loop ends --------------7
IRMS 0x1F72
Irms (dec): 8050
VRMS 0x1F72
VRMS (dec): 8050
1Vrms equiv: 0.39
Full Vpp equiv: 101.39
IPEAK 0x7C85F9
VPEAK 0x14A4
VPEAK (dec): 5284
--------------Loop ends --------------8
IRMS 0x1F72
Irms (dec): 8050
VRMS 0x1F72
VRMS (dec): 8050
1Vrms equiv: 0.39
Full Vpp equiv: 101.39
IPEAK 0x7C85F9
VPEAK 0x14A4
VPEAK (dec): 5284
--------------Loop ends --------------9
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top