# RMS Measurement

Discussion created by Ruth Hendrix on Jan 26, 2006

This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.

Posted: Nov 18, 2005, 12:19 p.m.

How can I calculate the RMS value of the AC voltage in assembly code?

I need the technical method which is used in any digital voltmeter project or something like that.

Thanks --

Posted: Nov 18, 2005, 2:49 p.m.

This is very simple on the '08. You find the area under the curve. Simply multiply sample by itself and accumulate per sample. It is just limited by the bandwidth of your signal, and how fast you can perform the math.

To go one step further, use a IFR style filter to hold the dynamic result:

Code:

`RMSSUM = RMSSUM + (NewSample * NewSample) - (RMSSUM>>8);  RMS = SQR(RMSSUM) >> 4; //True because sqr(X/Y) = sqr(X)/sqr(Y)`

RMS Sum will eventually become the (RMS value * 8 ^2), and will be the average of 256 points. You will need a large enough data type to hold the maximum value of ((NewSample * newSample) <<8).

Look to earlier links for efficient square root functions on integers.

Hope this helps!