# Discrete Time Equivalents

Earlier I spoke about modeling the math to simulate the calculations that I will be using in my home grown energy monitoring system. I think I have a good enough grasp on the math to come up with the algorithm to use in the software. Specifically, the computation of RMS values and average power.

$P_{avg} = \frac{1}{N}\sum_{n=1}^{N}v_ni_n \approx \frac {1}{T}\int^{to+T}_{to}p(t)dt \qquad(1)$ $X_{rms}= \sqrt{\frac{1}{N}\sum_{n=1}^{N}x^2_n} \approx \sqrt{\frac {1}{T}\int^{to+T}_{to}x^2(t)dt} \qquad(2)$

The simulation implemented both these and the integration functions to compare results. We are dealing with low frequency power line signals of 60hz which in theory we need to sample at 120 times per second. The reality is that there will be higher frequency components such as harmonics and we would need to sample at a higher rate capture those effect and ensure we can compute true RMS values.

Don Lancaster’s Tech Musings provides an excellent summary about measuring power s and pitfalls in trying to measure it.

I think I have enough theory and now ready to start building something.