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. Let me add that the i(n) and u(n) ared 12bit, unsigned. Any advice wellcome.

# calculating reactive power from i(t) and u(t)

Started by ●August 20, 2010

Reply by ●August 20, 20102010-08-20

On 08/20/2010 07:14 AM, iggy 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. > > > Let me add that the i(n) and u(n) ared 12bit, unsigned.Define 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. 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. 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. -- 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 ●August 20, 20102010-08-20

>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. 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. 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. :-) 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.>Let me add that the i(n) and u(n) ared 12bit, unsigned. > > >Any advice wellcome.Isn't that a drug company? Steve

Reply by ●August 20, 20102010-08-20

>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 powerOops, I missed something. You have Q and P swapped over here, so you will be taking the root of a negative number. You're making life complex. :-) Steve

Reply by ●August 20, 20102010-08-20

On 08/20/2010 11:15 AM, steveu wrote:>> 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 > > Oops, I missed something. You have Q and P swapped over here, so you will > be taking the root of a negative number. You're making life complex. :-)Worse than that -- look at the last equation. Q = sqrt(P^2 - Q^2) This implies that Q^2 = P^2 - Q^2, or 2 * Q^2 = P^2, or Q = +/- sqrt(2) * P Or maybe it implies a typo... -- 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 ●August 20, 20102010-08-20

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

Reply by ●August 20, 20102010-08-20

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. 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... -- 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 ●August 20, 20102010-08-20

> > 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). > >RMS power???? I would call (in this context) RMS Volts x RMS Amps = average VA's or average apparent power Mark

Reply by ●August 20, 20102010-08-20

On 08/20/2010 06:10 PM, Mark wrote:> >> >> 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). >> >> > > RMS power???? > > I would call (in this context) RMS Volts x RMS Amps = average VA's or > average apparent powerNow how did that slip out? "RMS equivalent power"? Apparent power is probably best, I shoulda stuck to it. -- 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 ●August 21, 20102010-08-21