AnsweredAssumed Answered

Help with ade7753 and arduino. Need help

Question asked by JuanTV on Mar 1, 2018
Latest reply on Mar 7, 2018 by JuanTV

Hi everyone,

 

Im student of Electronic engineering in the country of Colombia, for mi grade project I am implementing an energy meter with the ADE7753 and arduino (wemos d1 mini) the voltage line is 120 VAC and 60 Hz ,  for the current measurement I am using a hall effect sensor acs714 of 20 A and for voltage measurement a voltage divider, the schematic is as follows:

 

But the problem is i not getting any result from the spi registers of the ADE7753 ( the serial monitor is showing a value 0 for the three registers (Voltage, Current and Energy), i am not sure is the problem is the ade7753 or the arduino code, for more information, the arduino code for the spi communication with ADE7753 is this: 

 


#include <SPI.h>

 

const int slavePin = 15 // CS is D8 in wemos d1 mini but in IDE arduino is the 15

int v= 0 ;

float i =0;

int w=0;

 

void setup() {

 Serial.begin(115200);  // start serial monitor

SPI.begin(); // start SPI library

 pinMode(slavePin, OUTPUT); //CS as output pin

}

void loop(){

int v= readRegister(0x17,2);          // i call the reading function
 float i=readRegister(0x16,3);
 int w= readRegister(0x02,2);

 

 Serial.print(" VRMS 0x17:"); // i show the results in serial monitor 
  Serial.print(v);
  Serial.println();
  Serial.print(" IRMS 0x16:");
  Serial.print(i);
  Serial.println();
  Serial.print(" AENERGY 0x02:");
  Serial.print(w);

delay(100); 

}

// FUNCTION TO READ ADE7753 REGISTERS

unsigned int readRegister(byte thisRegister, int bytesToRead) {
  byte inByte = 0;           // Byte incoming from SPI
  unsigned int result = 0;   // Result to return
  Serial.print(thisRegister, BIN);
  Serial.print("\t");
  // byte variable to value of Adress of the ADE7753
  byte dataToSend = thisRegister;
  Serial.println(thisRegister, BIN);

// MODE 1 based on information of ADE7753 datasheet
  SPI.beginTransaction(SPISettings(4000000,MSBFIRST,SPI_MODE1)); // 4 MHz, MSB first, MODE 1 SPI
  // activate the chip
  digitalWrite(slavePin, LOW);
  // Send the Adress of the registers i want read
  SPI.transfer(dataToSend);
  // Send a 0x00 to get the incoming byte from ADE7753 register
  result = SPI.transfer(0x00);
  // decrease the num of bytes to read  :
  bytesToRead--;
  // if another byte to read, do:
  if (bytesToRead > 0) {
    // shift the first byte to left , then get the second byte:
    result = result << 8;
    inByte = SPI.transfer(0x00);
    // Combine bytes:
    result = result | inByte;
    // decrease the num of bytes to read :
    bytesToRead--;
  }
  // Disable the ADE chip:
  digitalWrite(slavePin, HIGH);
  // end of SPI transaction
  SPI.endTransaction();
  // return the result
    return (result);
}

 

 

end of code


I really need help , i want to know is i doing something wrong, beacuse i think the problem is with the ADE7753. Thanks for the attention

Attachments

Outcomes