I wanted to brush up on the theory before I jump to the implementation. So back to basic circuit analysis.
In a steady state system, the voltage and current as a function of time consists of
where is is the phase angle of the voltage and current respectively
The instantaneous power is defined as
Using some trigonometry, (3) reduces to
(4) shows that the instantaneous power has a constant or DC component and a time-variant component and illustrated below. (v=1, i=1, )
Note the average component “the DC offset” and the frequency of the instantaneous power is two times that of the voltage or current.
We can compute the average power by integrating (4) over one period. We get
If one substitutes (4) into (5), (5) reduces to in a purely resistive circuit and assuming a sinusoidal waveform.
In the power measurement solution for home, one can assume purely resistive loads and sinusoidal voltages and currents. That will come at the price of accuracy. The reality loads such as computers, UPS, etc. introduce inductance and capacitance which create loads that are neither purely resistive nor purely reactive. Furthermore, the current and voltage profiles are not clean sine waves.
Recall that the average power absorbed by a purely resistive load using a sinusoidal source was . Note that if the source was a DC, then What if the source is not a sinusoidal wave? Is there an equivalent constant current that can be computed that delivers the same average power to a purely resistive load (R)? .e.g. solving for we get
Plug in in a sinusoidal current like into (6) we get the infamous
Given this view of the RMS current, one can write the average power as
In the North-American 120 volt system, the 120 is the RMS voltage and
For non-sinusoidal functions, more complex integration needs to occur. Fortunately, in the implementation, there are some assumptions we can make to approximate the integration that makes the math much simpler. Nevertheless, an understanding of the math is needed to bend the rules.
One last component needs to be addressed and that is the power factor. Equation (7) contains two components. The product of is known as the Apparent Power (S) and the as the Power Factor.
In an purely resistive circuit, since
The reference implementation shall compute the average power, Irms and Vrms. Using (7), one can compute the power factor. e.g.
The power factor angle = The reactive power can be computed by the relation where Q is the reactive power in vars. Solve for Q and we can now compute all power related components.
Now you may ask why the Power Factor Angle? We don’t even reference it? Well, you could use to compute the reactive power. What it does give me is sense of the types of loads I have in the house. A value closer to 0, implies I am operating in a resistive load. If you look at the power factor angle of a variable speed drill, at low speeds the angle would be far from zero. At full RPM the angle would approach zero. Why this is the case is because how variable speed drills work. That is a separate discussion.
Next I want to model the math using a tool to help me make some assumptions for my reference implementation.