Quote Originally Posted by Charles Linquis View Post
If you are going to measure true RMS, and you need cycle-by-cycle measurements, then you need to take about 17 samples per half cycle for really good accuracy.

But I doubt you need answers that fast. You can probably just sample at your heart's content (fairly slowly), as long as you sampling rate is not a multiple or sub-multiple of the line frequency. If you sample at a 13 Hz rate, for example, and sample for 2 or 3 seconds, then you will "grab" the cycle at various parts of the waveform. Square each reading, sum them up and divide by the number of samples. Since you are using a 16F chip (why do people keep using them?), you can't use PBPL to easily deal with the sum of squares you will accumulate.

If you *are not* after an RMS reading, then you should peak-detect the AC with a bridge rectifier, store those peaks in a capacitor, take one reading, divide by two or three and be done with it.

The AC mains have a very low impedance, so true RMS probably isn't necessary to measure line voltage accurately. Current, however, is another matter.
I'm curious - what's the source of these numbers? (17 samples, 13 Hz)

My understanding is that you need to take instantaneous samples at the Nyquist rate (or beyond). You then collect a reasonable number of samples and calculate RMS value from them.

For example, say you want to measure 50Hz true RMS. Then you must sample at at least 100 Hz. (minimum Nyquist rate) At this rate, a reasonably large number of samples can be collected in a sample period of say 1 second (reasonable refresh rate for an LCD display). Stuff 100 samples in memory, square the value measured for each sample, add them all up, divide by 100, take the square root, display the answer. This might be a bit intense for a PIC, but with careful code execution planning should be doable.

Personally, I'd shoot for 1 KHz sample rate and 1,000 samples, on one of the more powerful devices. Here's a good reference for my numbers: http://en.wikipedia.org/wiki/Nyquist...mpling_theorem