The RMS calculation comes from these relations:

P = Urms^2/R  (for constant R)
P = (U1^2 + U2^2 + ... + Un^2)/R (for instantaneous voltages U1..n in ac)

whence:

Urms = +sqrt((U1^2 + U2^2 + ... + Un^2) / Nsamples_per_second)

(assuming that the samples are equal, otherwise they need to be scaled
in the sum by their lengths).

When R is not constant you obtain the power by multiplying Uinstananeous
and Iinstantaneous in a multiplier obtaining instantaneous power Pi. The
real power is the sum of the Pi divided by the Nsamples over one second.
However there is no such thing as negative power so any negative output
from the multiplier needs to be thrown away before adding (it is the
reflected or reactive power). You can measure and display reflected power
by adding the negative outputs and processing as above.

hope this helps,

Peter

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads