Pages: [1] 2   Go Down
Author Topic: Question re: phase lag on energy measurements  (Read 3809 times)
0 Members and 1 Guest are viewing this topic.
Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 691
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys and gals,

I hooked up the front end of my ADC to my oscilloscope and measured something interesting. Specifically, there appears to be a variable phase lag between the transformer for the voltage signal (ERA 0.08VA) and the current transformer (CR Magnetics CR8348-2500-N) as a function of load. Voltage always is lagging current.

The phase lag ranges from ~ 1.32ms at a 40W load to 0.722ms lag with a 1340W load. Both loads have unitary gain, i.e. a 40W light bulb and a toaster. Is this normal?
Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 53
Posts: 1991
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the impedance of your mains?
Logged

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 691
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good question, Pito. I thought the impedance of mains is assumed to be very, very low. IIRC, the house has a 400 Ampere service feed @ 240VAC and the outlet is fed by 12AWG wire (@ 120VAC through a 15A circuit breaker). So I'd like to think that the impedance would be low. However, that jogs a memory. We did some past measurements here with high-powered microwaves that had a nasty tendency to depress the line voltage out of spec re: the test procedure. Only measuring at the panel worked (i.e. stay within 1% of the stated line voltage even with a 1800W load attached).

I will re-measure right at the panel and see if that influences the results. Thanks for the suggestion!
« Last Edit: August 13, 2013, 08:58:55 am by Constantin » Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 53
Posts: 1991
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've seen somewhere it could be (or it shall be) something like Z=0.4+j0.25 ohm in EU
PS:
IEC TR 60725:   0.4 + j0.25 ohm at 90% of sites
Zref_1phase = 0.40 + j0.25 ohm
Zref_3phase = 0.24 + j0.15 ohm
PS1: with precise measurements you have to consider impedance at higher harmonics too..
« Last Edit: August 13, 2013, 09:47:55 am by pito » Logged

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 691
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I hope to have a look tonight. Any idea how much the above references would influence the measurements of loads with a power factor of one? The two loads I tested both should be 1 as one is a light bulb, the other a toaster. Now the latter features relay/contactor and both also enjoyed a Killawatt being in the measurement circuit but I doubt the killawatt nor the contactor would have meaningful impacts on the measurements.

What was also very interesting is how much 'fuzzier' the current signal was. Far more noise there than on the voltage signal.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

1. Are you sure that your toaster is a pure resistive load? Many modern toasters include electronics to do timing etc. and the small amount of current taken to feed the electronics could be leading or lagging the voltage.

2. Have you tried looking at the mains voltage directly with the oscilloscope, to see how much lead/lag the voltage transformer introduces?

3. Do the voltages you get on the transformer secondaries look like good sinusoids? Can you see any variation of waveshape with load?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 691
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

1. Are you sure that your toaster is a pure resistive load? Many modern toasters include electronics to do timing etc. and the small amount of current taken to feed the electronics could be leading or lagging the voltage.

Interesting thought. It never occurred to me that even a very small non-resistive component could have a measurable impact. I noted a similar lag however with an incandescent 40W lamp and a simple on/off switch.

2. Have you tried looking at the mains voltage directly with the oscilloscope, to see how much lead/lag the voltage transformer introduces?

Whoa... I don't think I'm comfortable to stick a oscilloscope probe into a mains outlet, even with a voltage divider circuit, etc... call me a ninny but my oscilloscope is PC-based and I'd be afraid the computer would turn into molten slag rather quickly in my hands...

3. Do the voltages you get on the transformer secondaries look like good sinusoids? Can you see any variation of waveshape with load?

The oscilloscope suggests that the curves are pretty good. However, one thing I noticed is that the usual approach of using sum(V^2) followed by a sqrt operation to determine Vrms is fraught with trouble when you start with a 16-bit ADC, take 1.4ksps, etc. Even the teensy 3 (a 32-bit platform) seems to require the use of the big numbers library to make it work because the Arduino 1.0x environment seems to continue to use 8-bit referenced variables (i.e. a long on a 32-bit ARM is not a 128 bit number).
« Last Edit: September 01, 2013, 08:39:43 pm by Constantin » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The oscilloscope suggests that the curves are pretty good. However, one thing I noticed is that the usual approach of using sum(V^2) followed by a sqrt operation to determine Vrms is fraught with trouble when you start with a 16-bit ADC, take 1.4ksps, etc. Even the teensy 3 (a 32-bit platform) seems to require the use of the big numbers library to make it work because the Arduino 1.0x environment seems to continue to use 8-bit referenced variables (i.e. a long on a 32-bit ARM is not a 128 bit number).

Do you really need to use 16 bits to get the desired accuracy? I would have thought 10 to 12 was more than enough, so that the square will fit in 19 to 23 bits (bearing in mind that the square can be unsigned) and you can sum at least 512 samples using 32-bit maths.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 691
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi DC,

Well, put it this way - I'd love to be able to use a 16-bit number in order to differentiate this unit from the other stuff out there - like openenergymonitor, kill-a-watt, etc. The ADC can actually deliver a 24-bit output but I consider that resolution to be somewhat questionable in terms of what the upstream signal conditioning can handle, my ham-fisted attempts at PCB design smiley-mr-green, the ADC itself (MCP3911) and so on. So I stick to 16 bits. But summing squared 16-bit results does trend towards very big numbers!
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Using a 16-bit ADC may give you a very high resolution, but it won't give a correspondingly high accuracy, because of errors introduced by the current and voltage transformers. The behaviour of real transformers is non-linear and temperature-dependent. Try searching for "current transformer errors", "current transformer accuracy", "current transformer linearity" and similar terms.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Rapa Nui
Offline Offline
Edison Member
*
Karma: 53
Posts: 1991
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Even the teensy 3 (a 32-bit platform) seems to require the use of the big numbers library to make it work because the Arduino 1.0x environment seems to continue to use 8-bit referenced variables (i.e. a long on a 32-bit ARM is not a 128 bit number).. But summing squared 16-bit results does trend towards very big numbers!

I do not think it is an issue even for an 8bit arduino.. smiley

This works and takes 71ms per calculation (an example only):

Code:
int mil, i, j, adc_i, adc_v;
long long sum;
mil = millis();
for(i=1; i<=10; i++) {
sum = 0LL;
for(j=1; j<=512; j++){
adc_i = 29342 - j;  // ADC I
adc_v = -29342 + j;  // ADC V
sum = sum + ((long long)(adc_i) * (long long)(adc_i));
sum = sum + ((long long)(adc_v) * (long long)(adc_v));
}
}
mil = millis() - mil;
Serial.println("############################");
Serial.println(sum);
Serial.println(sqrt(sum));
Serial.println(mil/10);

Results (sum, sqrt(sum), time elapsed for single j-loop):
Code:
############################
866291871232
930748.00
71

You can store a sum of 2billions of 16bit adc samples squared into a single "long long" (int64_t), supported by arduino.
« Last Edit: September 02, 2013, 01:18:34 pm by pito » Logged

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 691
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Pito,

You are correct, 2^64 numbers are supported on the math side of the IDE, but try printing one.

My comment re: the Teensy 3 is that the IDE apparently has not caught up with the numbers that a 32 bit MCU will easily handle, etc. Hence my use of the big number library since it also allows me to print big numbers for debugging purposes.
Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 53
Posts: 1991
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

smiley And it prints 64bitters as well (see my above replay):

http://forum.arduino.cc/index.php?topic=179111.msg1375203#msg1375203

Just use the new print.cpp and print.h, it supports new floating point formats as well.
You have to enable it in print.h
Code:
// uncomment if you want: int64 support, scientific notation and overflow testing
#define PRINT_LONGLONG
#define PRINT_SCIENTIFIC_AND_ENGINEERING
#define PRINT_NAN_INF

Code:
sum = 123456789123456789LL;
Serial.println(sum);
        sum = -123456789123456789LL;
Serial.println(sum);
..
123456789123456789
-123456789123456789
« Last Edit: September 03, 2013, 02:17:02 am by pito » Logged

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 691
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey, that's awesome news. I had no idea that Rob had updated print to allow longer numbers. I wish this was part of the default IDE.
Logged

0
Offline Offline
Shannon Member
****
Karma: 162
Posts: 10523
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys and gals,

I hooked up the front end of my ADC to my oscilloscope and measured something interesting. Specifically, there appears to be a variable phase lag between the transformer for the voltage signal (ERA 0.08VA) and the current transformer (CR Magnetics CR8348-2500-N) as a function of load. Voltage always is lagging current.

That's the difference between an actual and an ideal transformer.   With no load the transformer will approximate
an inductor in series with a resistor.

There may also be time delays in the measuring chain, which can be calibrated if you replace the transformer
directly with a resistive mains load like a tungsten bulb.
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1] 2   Go Up
Jump to: