I bought the EV-ADE9153A Shield and set up a test configuration with an Arduino Uno using the software provided by Analog Devices. I ran some tests with different loads and it works fine except that I keep getting negative Watts and negative power factor values, even with a 100W incandescent lamp as a load.
I am based in Belgium and we have a TT grid, meaning that the neutral is only grounded at the transformer cabin and floating at my place. I tried reversing the L & N connection but it doesn't resolve the issue. Any ideas what could be the cause of this issue?
There is also another issue with the supplied ADE9153AAPI.h that contains following statement at the top :
#define ADE9153A_AI_PGAGAIN 0x000A /*Signal on IAN, current channel gain=16x*/
To me it seems that it should be :
#define ADE9153A_AI_PGAGAIN 0x0012
0xA = 1010b so it will set bits 0 & 2 to 0 and bits 1 & 3 to 1 but bit 3 is a reserved bit (read only). Bits 1 & 0 are set to 1 & 0 respectively => gain = 16x
According to the documentation of the device, bit 4 of that register should be set to 1 unless one wants to inverse the polarity.
The first issue you mention with negative power is an issue with the code. At some point the connection on the board for the Live in and Live to Load were shifted around causing the current to be 180 degrees out of phase with the voltage. This can be corrected with the following code change.
Comment out the line that says:
Then replace it with the following code in order to fix the issue:
long Igain = (-(acalVals.AICC / 838.190) - 1) * 134217728;
long Vgain = ((acalVals.AVCC / 13411.05) - 1) * 134217728;
For the AI_PGAGAIN register, since the signal is on IAN and IAP is near ground, the AI_SWAP bit must be 0. Bit 3 (Reserved) is always 1 and can't be written to, you can verify this by reading back the register after setting this bit to 0. Finally, bits [2:0] are 010b for 16x gain. This gives you a value of 10d for AI_PGAGAIN.
The AI_SWAP bit (bit 4 of AI_PGAGAIN) is set based on which sense terminal of the shunt is closer to ground. In this case, ADE9153A ground is Live_In and the sense terminal nearest ground is connected to IAP, then the signal is on IAN.
Thanks Diath but it doesn't solve the problem, it creates another issue.The code you indicate to be changed is part of the auto calibration routine.
However, the auto calibration routine seems to go into an endless loop and never ends.
I found out there's a bug in the runLength function causing it to go into an endless loop if called with a value in excess 32 like it is the case after the voltage calibration where it is called with a value of 40.
I solved it by changing (int seconds) to (unsigned long seconds)
Anyway, after forcing auto calibration by pressing the "User button", I don't get any measured values anymore. Current, voltage power ... all remain at zero.
This happens with the original code as well as with the modified code you suggested. If I don't run auto calibration, the code change doesn't do anything of course.
Any idea what I'm doing wrong?
I found some errors in the Arduino code and in the ADE9153AAPI.cpp code as well.
The attached pdf contains the corrections that solved the issues with power sign and mSure calibration.
EV-ADE9153A SHIELDZ Code corrections.pdf
I think there is no problem to the library and to the code.... But i follow your the runlength cuz it looks like clean... You only need to press the user input button which is the auto calibration feature and then thats it...