We now review how to compute the power quantities defined earlier — active, reactive, and apparent power — but starting from actual measured data rather than idealized mathematical expressions. We consider two scenarios that represent different “entry points” into the same power triangle. First, we start from raw voltage and current samples acquired at a rate high enough to resolve the within-cycle waveform shape. This is the more general (and more involved) case, typical of research instrumentation and custom data acquisition. Second, we consider the simpler case where cycle-level statistics such as \(V_{rms}\), \(I_{rms}\), and phase angle are already available — the common situation when using a metering IC or commercial power analyzer.
From Sub-Cycle Measurements
Suppose we have discrete samples of voltage and current, \(v[n]\) and \(i[n]\), acquired at a sampling rate \(f_s\) (e.g., several kHz — high enough to capture the waveform shape within each AC cycle). Our goal is to extract the power triangle quantities from these raw samples.
Step 1: Estimate line frequency from voltage zero-crossings
The first task is to identify cycle boundaries. We do this by detecting upward zero-crossings of the voltage signal — instants where \(v[n]\) transitions from negative to positive. Voltage zero-crossings are preferred over current zero-crossings because the voltage waveform is typically much closer to a pure sinusoid (it is set by the grid, not distorted by individual loads), making the crossings sharper and less susceptible to noise.
The time between two consecutive upward zero-crossings gives the period \(T\), and hence the line frequency \(f = 1/T\). In the US grid, we expect \(T \approx 16.67\) ms (\(f \approx 60\) Hz), though the actual value fluctuates slightly. These zero-crossings also define the boundaries of each cycle for the calculations that follow.
Step 2: Compute instantaneous and average (active) power
Instantaneous power at each sample is simply the product:
\[p[n] = v[n] \cdot i[n]\]
The active power (average power) over one complete cycle of \(N\) samples is:
\[P = \frac{1}{N}\sum_{n=0}^{N-1} p[n]\]
It is important to sum over complete cycles — starting and ending at the zero-crossings identified in Step 1. Averaging over a fractional cycle would allow the oscillating component to leak into the estimate, biasing the result.
Step 3: Compute RMS values and apparent power
The RMS voltage and current over the same complete cycle are:
\[V_{rms} = \sqrt{\frac{1}{N}\sum_{n=0}^{N-1} v[n]^2} \qquad I_{rms} = \sqrt{\frac{1}{N}\sum_{n=0}^{N-1} i[n]^2}\]
From these, the apparent power is:
\[S = V_{rms} \cdot I_{rms}\]
Step 4: Estimate the phase difference
The phase angle \(\phi\) between voltage and current can be estimated from the time delay between their respective zero-crossings. If the voltage upward zero-crossing occurs at time \(t_v\) and the nearest current upward zero-crossing occurs at time \(t_i\), then:
\[\phi \approx \omega \cdot (t_v - t_i) = 2\pi f \cdot (t_v - t_i)\]
A positive \(\phi\) (current zero-crossing after voltage) indicates current lagging voltage (inductive load); a negative \(\phi\) indicates current leading (capacitive load). Note that current zero-crossings can be noisier than voltage zero-crossings, especially for loads with significant harmonic distortion, so this estimate may need filtering or averaging over several cycles.
Step 5: Close the power triangle
With active power \(P\) from Step 2 and apparent power \(S\) from Step 3, we can compute the remaining quantities:
\[Q = \sqrt{S^2 - P^2}\]
The sign of \(Q\) is determined by the phase difference from Step 4: positive for inductive (lagging), negative for capacitive (leading). The power factor follows directly:
\[\text{PF} = \frac{P}{S}\]
We now have the complete power triangle — \(P\), \(Q\), \(S\), and \(\text{PF}\) — derived entirely from raw voltage and current samples.
A note on redundancy and uncertainty: Strictly speaking, the power triangle is defined by three quantities (\(P\), \(Q\), \(S\)) linked by the constraint \(S^2 = P^2 + Q^2\), so only two independent estimates are needed to determine the third. In the steps above, we computed \(P\) (from instantaneous power), \(S\) (from RMS values), and \(\phi\) (from zero-crossings) — more information than the triangle requires. In principle, any pair would suffice: \(P\) and \(S\), or \(P\) and \(\phi\), or \(S\) and \(\phi\). However, each of these estimates carries its own measurement uncertainty — from quantization, sensor noise, waveform distortion, and finite sample windows. “Closing” the triangle from different pairs of quantities will generally yield slightly different results for the third. Formally, if we could quantify the uncertainty in each estimate, we could choose the pair that minimizes the propagated uncertainty in the derived quantity. In practice, \(P\) (from the average of \(v[n] \cdot i[n]\)) tends to be the most robust estimate because the sample-by-sample product and averaging operation is relatively insensitive to noise, while the phase angle \(\phi\) from zero-crossing differences tends to be the least reliable, especially for distorted current waveforms.
Practical considerations
All of the above assumes approximately steady-state conditions over the analysis window. In a real building, loads switch on and off, motors ramp up, and the grid voltage fluctuates. Keeping the analysis window short — typically a few cycles (e.g., 3–10 cycles, or roughly 50–170 ms at 60 Hz) — helps ensure that the steady-state assumption holds reasonably well within each window. Longer windows improve noise averaging but risk blurring transient events.