Problem Reading ADE7753 arduino - Page 1
Forum section: electronics / beginners

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: November 28, 2016, 05:36:04 am
content: 1. I had made a code for reading ADE7753. I am using library for ADE7753 also.Attached is schematic. Both arduino & ADE7753 is 5V powered.2. Code gets stuck in liobrary code:while( ! ( ADE7753::getInterruptStatus() & ZX ) ) // wait Zero-Crossing3. If I surpass this line, then reading is random & do not get correct values.Library with arduino code is in attached zip file.<code>#include "ADE7753.h"#include <SPI.h>#define ratioTraf (220/12) //18.3void setup(){Serial.begin(9600);Serial.write("h");}void loop(){ADE7753 meter = ADE7753();meter.analogSetup(GAIN_1,GAIN_1, 0,0,0,0);meter.resetStatus();long v1,i1,e1,e2,e3,ae1,ae2,ae3,r1,r2,r3;float totEnergy = 0;float kv,ki,ke,ka,kt,f1,basetime;float voltage, current, energy, aparent, reactive, PF;String typeLoad = "";int t1;int loopCounter = 1;//Constantes de proporcionalidad.kv = (ratioTraf)*VOLTDIV*(0.5/0x2851EC); //(0.5/0x2851EC) From Datasheetki = CURRDIV*(0.5/0x17D338); //(0.5/0x17D338) From Datasheetke = (10/16.0)*VOLTDIV*CURRDIV/4096.0; // 1/(2^12)basetime = (1.0*NUMCYC)/100.0; // tiempo por el cual se acumula energiakt=CLKIN/8; //period register, resolution x.y/LSB -per bit-while(1){Serial.print(meter.getMode());v1=meter.vrms();i1=meter.irms();Serial.print("\nVoltaje RMS : ");Serial.println(v1);Serial.println(kv*v1,2);Serial.println("\nCorriente RMS : ");Serial.println(i1);Serial.println(ki*i1,3);Serial.println();delay(2000);}}</code>

author: mjkuwp
author_rank: Unknown
timestamp: November 28, 2016, 05:04:45 pm
content: one thing that will help - at least make it easy for people familiar with Arduino to read.in the Arduino IDE "void loop()" makes an implied infinite loop. It should contain the items you presently have inside the while(1) loop.move the other things to the end of the setup() function.Are the voltage readings stable? Is it only the current that appears random?

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: November 30, 2016, 05:50:48 am
content: THis library works perfectly.https://github.com/lordofnaz/ardugrid7753/blob/master/ADE7753.cppI have to measure voltage, current & active power.1. Calculations of voltage I have done are, as per page 27 of datasheet 05.V is 1,561,400 in decimal. So I read the VRMS(0x17) & use below formula for get voltage value. Divider is 1M:1KV = (0.5 / 1561400.0) * Vrms * 1001.0Is this formula correct?I have done that there were some shift in values. But after two point calibration now values i read are ok.2. Similarly for current, page 26 gives, 0.5V is 1,868,467. I am reading IRMS(0x16), burden is 10ohm & CT is 1800:1.I = (0.5 / 1868467.0) * Irms / 10.0 * 1800.0;Is this formula correct?Even after calibration, I am getting some wrong values in it. I am checking hardware if it has some issues. But right now I dont know yet.3. In the library link above, ADE7753.h, CLKIN is defined 4Mhz at line 186. But I use 3.579545 MHz crsytal as mentioned in datsheet. So should I change this value here only? Or anything else to be changed also? OR I should also chnage crystal to 4Mhz in my board. But datasheet has 3.579545 MHz4. I need to measure 1Watt to 6KW in the system. So at 220V(suppose), equivalent current for 1W is 0.00455A & for 6Kw it is 27.27A. I keep 30A to add safety limitCan I measure such low current with IC while I use CT=1800:1 & burden 20ohm.

author: rohity
author_rank: Newbie
timestamp: December 03, 2016, 01:54:33 pm
content: Hello Vindhyachal.takniki,I am struggling to use ADE7753 with ESP8266 using arduino ide.( SPI communication )Will you please share the final code which worked for you.Your help will be really appreciated.Waiting for your reply.

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: December 13, 2016, 04:24:35 am
content: Below are answer I got from AD forum:1) The formula should be:V = (0.5 / 1561400.0/sqrt(2)) * Vrms * 1001.0 . The 0.5V max listed in the datasheet is maximum rating. It should be converted to RMS to ensure similarity.2) similarly I = (0.5 / 1868467.0/sqrt(2)) * Irms / 10.0 * 1800.0;What is the current level and error after calibration? IRMS is 0.5% accurate upto 100:1 dynamic range i.e. from ~60A to 600mArms3) In the datasheet, all the parameters/calculations specified are at 3.579545 MHz. Using this will simplify the design. However it does say that the Max clock can be 4MHz. You have to update the calculations accordingly. If you already have a 3.579545Mhz crystal on board, i would recommend using that crystal and changing the code4)The energy measurements are 0.1% accurate upto 1000:1 range. So with 20 Ohm burden the energy measurements will be accurate from ~30A to 30mA and the Current RMS measurements will be 0.5% accurate from 30A to 300mArms. Beyond 300mA, the accuracy drops significantly and can vary from device to device.