You are not authorized to post comments.

AC Power Theory 2

This page covers the mathematics behind calculating real power, apparent power, power factor, RMS voltage and RMS current from instantaneous Voltage and Current measurements of single phase AC electricity. Discreet time equations are detailed since the calculations are carried out in the Arduino in the digital domain. There are also code examples of the equations.

This page is based on Atmel's AVR465 appnote page 12-15 which can be found here

Real power

Real power (also known as active power) is defined as the power used by a device to produce useful work.

Mathematically it is the definite integral of voltage, u(t), times current, i(t), as follows:

 

Equation 1. Real Power Definition.

U - Root-Mean-Square (RMS) voltage.

I - Root-Mean-Square (RMS) current.

cos(φ) - Power factor.

The discrete time equivalent is:

 

Equation 2. Real Power Definition in Discrete Time.

u(n) - sampled instance of u(t)

i(n) - sampled instance of i(t)

N - number of samples.

Real power is calculated simply as the average of N voltage-current products. It can be shown that this method is valid for both sinusoidal and distorted waveforms.

Code example of equation 2:

for (n=0) to (numberOfSamples-1) loop

{

//instV and instI calculation from raw ADC input goes here.

instP = instV * instI;

sumP += instP;

}

realPower = sumP / numberOfSamples;

RMS Voltage and Current Measurement

An RMS value is defined as the square root of the mean value of the squares of the instantaneous values of a periodically varying quantity, averaged over one complete cycle. The discrete time equation for calculating voltage RMS is as follows:

 

Equation 3. Voltage RMS Calculation in Discrete Time Domain.

Current RMS is calculated using the same equation, only substituting voltage samples, u(n), for current samples, i(n).

Code example of equation 3:

for (n=0) to (numberOfSamples-1) loop

{

//instV calculation from raw ADC input goes here.

sqV = instV * instV;

sumV += sqV;

}

Vrms = sqrt(sumV / numberOfSamples);

Substitute V for I for current.

Apparent Power and Power Factor

Apparent power is calculated, as follows:

Apparent power = RMS Voltage x RMS current

and the power factor:

Power Factor = Real Power / Apparent Power

Bringing it all together

The following program is used in the basic energy monitor to carry out all the measurements above:

for (n=0) to (numberOfSamples-1) loop

{

//instV and instI calculation from raw ADC input goes here.

sqV = instV * instV;

sumV += sqV;

sqI = instI * instI;

sumI += sqI;

instP = instV * instI;

sumP +=instP;

}

Vrms = sqrt(sumV / numberOfSamples);

Irms = sqrt(sumI / numberOfSamples);

realPower = sumP / numberOfSamples;

apparentPower = Vrms * Irms;

powerFactor = realPower / apparentPower;

For a more in detail look at the measurement code have a look at the Arduino Sketch here.

umdl's picture

hello there I am from Nepal

hello there

I am from Nepal and trying to implement this in three phase system. I have some queries.

i> Is arduino capable to sample 6 parameters ( 3 voltage and 3 currents). I just found that 24 samples per cycle (for 50 hz) will be good enough for accuracy( theoritically).

ii> "for (n=0) to (numberOfSamples-1) loop"... How to determine exaxt number of samples in real coding?

iii> In real life voltage doesn't change but what abt current which really swings( from few mA to 10s of ampere)?? Do I need extra circuitry as in AVR465.?

Please help me out.

Thanks,

Umdl 

Terry's picture

Should "Irms = sqrt(sumV /

Should "Irms = sqrt(sumV / numberOfSamples);" actually be "Irms = sqrt(sumI / numberOfSamples);"? Otherwise as written Vrms and Irms are equal? Most likely this is just a typo, but I wouldn't want someone to rely on the wrong equation.

TrystanLea's picture

 Thanks Terry, yes your quite

 Thanks Terry, yes your quite right, didnt see that, will change it now