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-Crossing
3. 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.3
void 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 Datasheet
ki = CURRDIV*(0.5/0x17D338); //(0.5/0x17D338) From Datasheet
ke = (10/16.0)*VOLTDIV*CURRDIV/4096.0; // 1/(2^12)
basetime = (1.0*NUMCYC)/100.0; // tiempo por el cual se acumula energia
kt=CLKIN/8; //period register, resolution x.y[us]/LSB -per bit-
while(1)
{
Serial.print(meter.getMode());
v1=meter.vrms();
i1=meter.irms();
Serial.print("\nVoltaje RMS [V]: ");
Serial.println(v1);
Serial.println(kv*v1,2);
Serial.println("\nCorriente RMS [A]: ");
Serial.println(i1);
Serial.println(ki*i1,3);
Serial.println();
delay(2000);
}
}
</code>
Attached is schematic. Both arduino & ADE7753 is 5V powered.
2. Code gets stuck in liobrary code:
while( ! ( ADE7753::getInterruptStatus() & ZX ) ) // wait Zero-Crossing
3. 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.3
void 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 Datasheet
ki = CURRDIV*(0.5/0x17D338); //(0.5/0x17D338) From Datasheet
ke = (10/16.0)*VOLTDIV*CURRDIV/4096.0; // 1/(2^12)
basetime = (1.0*NUMCYC)/100.0; // tiempo por el cual se acumula energia
kt=CLKIN/8; //period register, resolution x.y[us]/LSB -per bit-
while(1)
{
Serial.print(meter.getMode());
v1=meter.vrms();
i1=meter.irms();
Serial.print("\nVoltaje RMS [V]: ");
Serial.println(v1);
Serial.println(kv*v1,2);
Serial.println("\nCorriente RMS [A]: ");
Serial.println(i1);
Serial.println(ki*i1,3);
Serial.println();
delay(2000);
}
}
</code>
Attachments
-
60.7 KB Views: 93
-
13.6 KB Views: 39