Reply by iggy August 22, 20102010-08-22
>On 08/20/2010 11:13 AM, steveu wrote: >>> Hello. >>> >>> >>> I am sampling the current and voltage simultaniously. Right now I am >>> calculating reactive power in two ways: >>> >>> >>> 1). delay the current samples by a quarter of a period and then >>> multiplying: >>> >>> Q=i(n+pi/2)*u(n) >>> >>> >>> 2). or using the following procedure: >>> >>> P=1/(num. samples)*sum( i(n)*u(n) ) -> active power >>> >>> S=Irms*Urms -> apparent power >>> >>> Q=sqrt(P^2 - Q^2) -> reactive power >>> >>> >>> Unfortunatelly neither give me good results. Is there a nother way to >>> compute reactive power? I can't use any complicated FFt algorithm as
the
>>> processor isn't very browny. >> >> I presume browny == fast. If you are measuring something slow, I guess
we
>> are talking about measuring mains power consumption. >> >> Both your equations are capable of high accuracy in the right >> circumstances, but fall apart in the wrong ones. You will want to >> accumulate your signals over a whole number of cycles for stable
results.
>> If you don't, the long term average of your results will be fine, but >> adjacent readings will jitter. >> >> Your first equation will only behave properly if the signal you delay is
a
>> pure sine wave. If you delay a signal by 90 degree at the fundamental,
it
>> will be delayed the wrong amount at all the harmonics. Typically a
mains
>> voltage signal doesn't have a lot of harmonic content, but the current >> signal does. That means this approach is an OKish approximation in most >> cases. Note that the delay needs to be pretty accurate to ensure good >> results across the power factor range. At 0.5PF, just a 0.1 degree
phase
>> error will give you about 0.3% error in the power measurement. >> >> Your second equation requires both signals be pure sine waves. > >(snip) > >Exactly how so? I would say that the second equation removes any such >restriction at all, which is the exact opposite of what you're saying
here.
> >Real instantaneous power is, by definition, instantaneous current times >instantaneous voltage. So if the OP is capturing current and voltage >adequately* then averaging the instantaneous power would give average >power quite handily -- regardless of waveforms. >
There is only one definition for real power. Or at least I saw only one and the way that is written confirms what Tim is saying.
>Similarly, apparent power is, by definition, RMS voltage times RMS >current. Again assuming adequate capture of current and voltage, >calculating RMS power is conceptually straightforward (with all due >respect for the pitfalls). > >What's left is reactive power, and to my mind the only real barrier to >defining it as what's left after you take real power away from apparent >power is how one defines "reactive" -- but if you define it as "any >power that swishes back and forth without doing anything real" then >you're done. > >* And yes, that's a big "if", and subject to much interpretation >depending on how the OP defines adequacy. But in a perfect world... >
The problem with the OP is he only has a reference instrument which (he suspects) is using method 2 (power triangle) to obtain the Q[VAR] and the fact that absolutely no instructions/definitons/preferences were communicated to him on how to calculate Q. So I have too much choice on my hands and an accuracy problem.
>-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com > >Do you need to implement control loops in software? >"Applied Control Theory for Embedded Systems" was written for you. >See details at http://www.wescottdesign.com/actfes/actfes.html >
Reply by iggy August 22, 20102010-08-22
@steveu:


> >I presume browny == fast. If you are measuring something slow, I guess we >are talking about measuring mains power consumption. >
Both correct. Mcu not a shark, signal 50Hz.
>Both your equations are capable of high accuracy in the right >circumstances, but fall apart in the wrong ones. You will want to >accumulate your signals over a whole number of cycles for stable results. >If you don't, the long term average of your results will be fine, but >adjacent readings will jitter. >
I accumulate over 2 cycles. Frequency compensated.
>Your first equation will only behave properly if the signal you delay is
a
>pure sine wave. If you delay a signal by 90 degree at the fundamental, it >will be delayed the wrong amount at all the harmonics. Typically a mains >voltage signal doesn't have a lot of harmonic content, but the current >signal does. That means this approach is an OKish approximation in most >cases. Note that the delay needs to be pretty accurate to ensure good >results across the power factor range. At 0.5PF, just a 0.1 degree phase >error will give you about 0.3% error in the power measurement. >
Phase (delay) is adjustable, have 2xADC one for current the other for voltage. You are right it is OKish, but I as you mentioned it the harmonic content of my test setup (described in a reply to Tim) should be low on harmonics content. Still I get bad results. Could it be something with the SW? I think the results should be better.
>Your second equation requires both signals be pure sine waves. This is
much
>less likely to be even a rough approximation of reality. However, if both >signals are pure, it will produce accurate results for larger signals.
For
>very small signals the accuracy will normally degrade much faster than
with
>your first equation, due to noise correlating with itself as you perform >the RMS estimations. >
I do belive this is a problem for me. I tried to avoid it by using method 1.
>A third option which also works only for pure sine wave signals is to >accumulate V[n]*I[n-1] - V[n-1]*I[n] over your measurement interval, and >divide the final value by >2*sin(2*pi*frequency/sample_rate)/number_of_samples to scale it properly. >Obviously, you'll need an accurate estimate of the fundamental frequency >for this calculation. This looks wonderfully simple, but just try it. It
is
>capable of high precision for pure sine wave signals, but produces
dreadful
>results when even small amounts of high harmonics are present. You will >find this scheme proposed in some application notes on power metering,
and
>it may well be embodied in some actual metrology products. :-) >
Wonderfull. Will try that. But why should this work? Looks like correlation. I think.
>If you want to get things right with significant amounts of harmonic in >both signals, you really need a Hilbert transform. However this is >problematic. If you sample fast enough to catch the main harmonics (i.e.
at
>a few k samples/second) the fundamental is quite low in the band. A
Hilbert
>transform that handles the fundamental well requires a pretty long FIR,
or
>an IIR of far less complexity, but requiring huge word lengths. Even if
you
>have the processing power to evaluate the transform, you still need to be >really careful about coefficient noise spoiling the results. >
Hm. As I mentioned the mcu is a bit slow, but good to know.
>>Let me add that the i(n) and u(n) ared 12bit, unsigned. >> >> >>Any advice wellcome. > >Isn't that a drug company?
I don't know? Don't do drugs. Except for cigarettes, coffe, sugar and embedded projects.
> >Steve > >
Thank you Steve.
Reply by iggy August 22, 20102010-08-22
@Tim:


> >Define good results. >
My test setup: a transformer capable of giving me about 5A, connected to the mains voltage, a variable resistor and a 50uF capacitor (C parallel to R). The real power is changed from 100W up to 1.2kW with the resistor. The capacitor attached all the times draws about 30VAR. The change in VAR I observe is due to the transformer, and the sag of the voltage across the capacitor. Generally speaking the current trough the cap is about 140~190 mA, but the current trough the resistor varies from 1A to 5A. Now as you can see the angle between the real and apparent power is small and of course this is why I get the error. As I vary the real power the var figure drifts differently with regards to the calculation method. If I use method 2 sometimes the S is actually smaller than P. Not just like a glitch or two, but at some current the S result is consistently smaller than P, which is not true. So I can't have that. I realize that this is possible because of arithmetics errors, but if my reference says P=600W and Q=0VAR, and the truth is P=600W and Q=-24VAR then maybe this is not the way to go, whatever the reason. If I use method 1 the first thing I am pleased about it is that this gives me the sign of the Q. Second thing I can see the result turning inductive if I disconnect C, capacitive if I disconnect R but again all the results are at least 2% off, sometimes up to 20%. I's be happy if the accuracy of the instument would be under 1% or 1 count with the powers. That would be good results.
>For a signal with a single known, steady frequency and a linear >time-invariant load (i.e. if there's no harmonics or mixing products in >the voltage or current) then your delay-and-multiply should work OK. >
I do compensate (slowly) for line frequency variation and as I see the voltage/current samples fly out (which are then plotted) the picture just slowly if at all drifts . So this is working.
>You're getting confused in your apparent vs. real power -- you want to >subtract the real power from the apparent power directly, the left over >"power" is reactive. So after calculating P and S, Q = S - P -- all the >squaring and square rooting is taken care of elsewhere. >
I verified the square root result works for unsigned 32bit numbers. Like all of them. Keep in mind that this is a integer sqrt. So I think this is why method 2 does not work well with small angles.
>Using an FFT to do this job would be like using a cut and thread water >pipes for your house -- it can be done, but you're putting a lot of >effort and expensive machinery into a job that can be done with a hand >tool or two.
Yes, I realize that which is why I said can't do FFT.
> >-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com >
Thanks Tim, heaps of information from you!
>Do you need to implement control loops in software? >"Applied Control Theory for Embedded Systems" was written for you. >See details at http://www.wescottdesign.com/actfes/actfes.html >
Reply by steveu August 21, 20102010-08-21
>Like I said, it boils down to how you want to define reactive power. >You want to define it as a consequence of purely linear reactance, which >means the "apparant - real" calculation is wrong. I want to define it >as anything that's not real (i.e. as a consequence of nonlinear and >reactive elements), which means the "apparent - real" calculation is >exactly correct.
Define it how you want, but for mains power metering the IEC and ANSI spec trump you. :-) Steve
Reply by Tim Wescott August 21, 20102010-08-21
On 08/21/2010 04:48 AM, steveu wrote:
>> On 08/20/2010 11:13 AM, steveu wrote: >>>> Hello. >>>> >>>> >>>> I am sampling the current and voltage simultaniously. Right now I am >>>> calculating reactive power in two ways: >>>> >>>> >>>> 1). delay the current samples by a quarter of a period and then >>>> multiplying: >>>> >>>> Q=i(n+pi/2)*u(n) >>>> >>>> >>>> 2). or using the following procedure: >>>> >>>> P=1/(num. samples)*sum( i(n)*u(n) ) -> active power >>>> >>>> S=Irms*Urms -> apparent power >>>> >>>> Q=sqrt(P^2 - Q^2) -> reactive power >>>> >>>> >>>> Unfortunatelly neither give me good results. Is there a nother way to >>>> compute reactive power? I can't use any complicated FFt algorithm as > the >>>> processor isn't very browny. >>> >>> I presume browny == fast. If you are measuring something slow, I guess > we >>> are talking about measuring mains power consumption. >>> >>> Both your equations are capable of high accuracy in the right >>> circumstances, but fall apart in the wrong ones. You will want to >>> accumulate your signals over a whole number of cycles for stable > results. >>> If you don't, the long term average of your results will be fine, but >>> adjacent readings will jitter. >>> >>> Your first equation will only behave properly if the signal you delay is > a >>> pure sine wave. If you delay a signal by 90 degree at the fundamental, > it >>> will be delayed the wrong amount at all the harmonics. Typically a > mains >>> voltage signal doesn't have a lot of harmonic content, but the current >>> signal does. That means this approach is an OKish approximation in most >>> cases. Note that the delay needs to be pretty accurate to ensure good >>> results across the power factor range. At 0.5PF, just a 0.1 degree > phase >>> error will give you about 0.3% error in the power measurement. >>> >>> Your second equation requires both signals be pure sine waves. >> >> (snip) >> >> Exactly how so? I would say that the second equation removes any such >> restriction at all, which is the exact opposite of what you're saying > here. >> >> Real instantaneous power is, by definition, instantaneous current times >> instantaneous voltage. So if the OP is capturing current and voltage >> adequately* then averaging the instantaneous power would give average >> power quite handily -- regardless of waveforms. > > Yep. That's exactly how every electronic mains power/energy meter works. > >> Similarly, apparent power is, by definition, RMS voltage times RMS >> current. Again assuming adequate capture of current and voltage, >> calculating RMS power is conceptually straightforward (with all due >> respect for the pitfalls). > > Yep. Apparent power is an odd concept, but that's how we define it. > >> What's left is reactive power, and to my mind the only real barrier to >> defining it as what's left after you take real power away from apparent >> power is how one defines "reactive" -- but if you define it as "any >> power that swishes back and forth without doing anything real" then >> you're done. > > Lets say I have a pure voltage waveform and a highly distorted current > waveform. The current harmonics don't correlate with the pure voltage > waveform. The active power is exactly the same as if you had only the > fundamental component of the current signal. However, the RMS current is > altered by these harmonics. Do the pythagoras calculation, and you get a > figure for the reactive power altered by the harmonics. That's not the > correct value. The real reactive power -(i.e. shift the voltage waveform 90 > degree at all frequencies and take the dot product of that with current) is > not affected by those harmonics. The answer from the pythagoras calculation > is wrong. It is, however, quite frequently used as a reactive power > measurement.
Like I said, it boils down to how you want to define reactive power. You want to define it as a consequence of purely linear reactance, which means the "apparant - real" calculation is wrong. I want to define it as anything that's not real (i.e. as a consequence of nonlinear and reactive elements), which means the "apparent - real" calculation is exactly correct. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by Mark August 21, 20102010-08-21
On Aug 20, 11:27&#4294967295;pm, glen herrmannsfeldt <g...@ugcs.caltech.edu>
wrote:
> Mark <makol...@yahoo.com> wrote: > > (snip) > > > RMS power???? > > RMS power exists, defined by the FTC, for audio power amplifiers. > > -- glen
lawyers thinking they can change the laws of physics!! :-) Mark
Reply by steveu August 21, 20102010-08-21
>On 08/20/2010 11:13 AM, steveu wrote: >>> Hello. >>> >>> >>> I am sampling the current and voltage simultaniously. Right now I am >>> calculating reactive power in two ways: >>> >>> >>> 1). delay the current samples by a quarter of a period and then >>> multiplying: >>> >>> Q=i(n+pi/2)*u(n) >>> >>> >>> 2). or using the following procedure: >>> >>> P=1/(num. samples)*sum( i(n)*u(n) ) -> active power >>> >>> S=Irms*Urms -> apparent power >>> >>> Q=sqrt(P^2 - Q^2) -> reactive power >>> >>> >>> Unfortunatelly neither give me good results. Is there a nother way to >>> compute reactive power? I can't use any complicated FFt algorithm as
the
>>> processor isn't very browny. >> >> I presume browny == fast. If you are measuring something slow, I guess
we
>> are talking about measuring mains power consumption. >> >> Both your equations are capable of high accuracy in the right >> circumstances, but fall apart in the wrong ones. You will want to >> accumulate your signals over a whole number of cycles for stable
results.
>> If you don't, the long term average of your results will be fine, but >> adjacent readings will jitter. >> >> Your first equation will only behave properly if the signal you delay is
a
>> pure sine wave. If you delay a signal by 90 degree at the fundamental,
it
>> will be delayed the wrong amount at all the harmonics. Typically a
mains
>> voltage signal doesn't have a lot of harmonic content, but the current >> signal does. That means this approach is an OKish approximation in most >> cases. Note that the delay needs to be pretty accurate to ensure good >> results across the power factor range. At 0.5PF, just a 0.1 degree
phase
>> error will give you about 0.3% error in the power measurement. >> >> Your second equation requires both signals be pure sine waves. > >(snip) > >Exactly how so? I would say that the second equation removes any such >restriction at all, which is the exact opposite of what you're saying
here.
> >Real instantaneous power is, by definition, instantaneous current times >instantaneous voltage. So if the OP is capturing current and voltage >adequately* then averaging the instantaneous power would give average >power quite handily -- regardless of waveforms.
Yep. That's exactly how every electronic mains power/energy meter works.
>Similarly, apparent power is, by definition, RMS voltage times RMS >current. Again assuming adequate capture of current and voltage, >calculating RMS power is conceptually straightforward (with all due >respect for the pitfalls).
Yep. Apparent power is an odd concept, but that's how we define it.
>What's left is reactive power, and to my mind the only real barrier to >defining it as what's left after you take real power away from apparent >power is how one defines "reactive" -- but if you define it as "any >power that swishes back and forth without doing anything real" then >you're done.
Lets say I have a pure voltage waveform and a highly distorted current waveform. The current harmonics don't correlate with the pure voltage waveform. The active power is exactly the same as if you had only the fundamental component of the current signal. However, the RMS current is altered by these harmonics. Do the pythagoras calculation, and you get a figure for the reactive power altered by the harmonics. That's not the correct value. The real reactive power -(i.e. shift the voltage waveform 90 degree at all frequencies and take the dot product of that with current) is not affected by those harmonics. The answer from the pythagoras calculation is wrong. It is, however, quite frequently used as a reactive power measurement. Regards, Steve
Reply by steveu August 21, 20102010-08-21
>steveu <steveu@n_o_s_p_a_m.coppice.org> wrote: >(snip) > >> Your first equation will only behave properly if the signal you delay is
a
>> pure sine wave. If you delay a signal by 90 degree at the fundamental,
it
>> will be delayed the wrong amount at all the harmonics. Typically a
mains
>> voltage signal doesn't have a lot of harmonic content, but the current >> signal does. That means this approach is an OKish approximation in most >> cases. Note that the delay needs to be pretty accurate to ensure good >> results across the power factor range. At 0.5PF, just a 0.1 degree
phase
>> error will give you about 0.3% error in the power measurement. > >There used to be a popular line of voltage regulating transformers >that had a large amount of third harmonic in the output. Enough >in many cases that there was a dip where the peak would normally be. > >Otherwise, yes, the current requirement of many switching power >supplies and discharge lamp ballasts can be very non-linear. > >One non-obvious place this comes in is running lamp ballasts off >the three legs of three-phase wye. Normally the neutral current >should not exceed the largest of the leg currents, but that isn't >the case with the third harmonic. > >-- glen
In industrial areas, in a number of countries, the harmonic content in the voltage waveform off the grid line can reach 15%. Out of the substation the waveform can be quite pure, but by the point of consumption the combination of wiring resistance and the numerous horrible large non-linear loads can lead to that 15% figure. Many active power factor correctors are actually making this worse. They centre the peak of the current waveform coincident with the peak of the voltage waveform, but the current waveform can be very far from sinusoidal. Steve
Reply by glen herrmannsfeldt August 21, 20102010-08-21
robert bristow-johnson <rbj@audioimagination.com> wrote:
(snip, I wrote)

>> RMS power exists, defined by the FTC, for audio power amplifiers.
> so, for that FTC definition, are they squaring the instantaneous > power, averaging that, and square rooting that average to get RMS > power?
> i've always thought the term a misnomer.
I suppose, but like the EPA gas mileage numbers, as long as everyone follows the same rules it works. Since there is no other meaning to RMS power, other than the FTC meaning, no-one can get confused. I believe among others the amplifier has to put out that much power over some period of time. That is, long enough for the heat sinks to get warm and such. Also, it has to be given as per channel. Before the rule some would give the total for all channels. (Reminds me of the airlines "each way with round trip purchase" deals.) Also, the model number isn't allowed to be twice the RMS power per channel, as that might confuse people into believe that is the power rating. (There was one company that gave all the model number one more than twice the power per channel.) -- glen
Reply by robert bristow-johnson August 21, 20102010-08-21
On Aug 20, 11:27&#4294967295;pm, glen herrmannsfeldt <g...@ugcs.caltech.edu>
wrote:
> Mark <makol...@yahoo.com> wrote: > > (snip) > > > RMS power???? > > RMS power exists, defined by the FTC, for audio power amplifiers.
so, for that FTC definition, are they squaring the instantaneous power, averaging that, and square rooting that average to get RMS power? i've always thought the term a misnomer. r b-j