# How to 'average' a sine wave of RMS values?

Lock-in amplifiers (Stanford Research Systems 830) display sine wave signals in RMS values SR830 Manual (page 3-3). One can use the internal buffer to rapidly measure a signal, storing up to 16000 points with a measurement rate of 512Hz. These points are RMS values of the original signal, if I'm not mistaken, and often slowly oscillate (due to a small frequency component not completely filtered out by the low pass filter). How does one 'average' these buffered points?

I'm not sure it makes sense to calculate the RMS value of a wave build up from RMS values, but taking the simple average of this wave also feels incorrect.

• You can always take an average and compare it to the rms of the samples, see if it gives funny results. Presumably an average is what you want as the average of a sine wave is zero and will thus effectively remove the low frequency component leaving only the pure DC value. If possible, lowering the sample rate may also have a similar averaging effect. – Sam Jun 5 '16 at 9:02
• You should square the signal, then compute the mean and then calcuate square root. Alternatively, you square the signal, pass trough LPF and then sqroot. – Marko Buršič Jun 5 '16 at 9:35
• If your signal consists of the desired signal + a small unwanted sine wave component, then averaging is the right thing to do. If you can capture the 16000 points into a computer file somehow, maybe get them into an excel spreadsheet, you can test out different processing options and see the effect. – mkeith Jun 5 '16 at 16:31

First of all, you should rephrase your question like: How to get an average value from measurings. The term RMS makes just confusion as it makes no difference if you want to get an average of peak, rms,...whtever values. Simplest method is a moving avearage filter, you need a circular buffer FIFO where you fill the measurings. At each new input, you discard the oldest and compute the new average recursively. https://en.wikipedia.org/wiki/Moving_average

Average = Average + NewestValue/n - OldestValue/n; purge OldestValue from FIFO and insert NewestValue in.

NewValue: xyz;
Average: xyz or float or double;
FIFO: array[0..63] of xyz; //curcular buffer of 64 elements
Pointer: int;

//at init:
FIFO[from 0 to 63]=NewValue;
Average = NewValue;
Pointer = 0;

//at each measuring
Average = Average + NewValue/64 - FIFO[Pointer]/64;
FIFO[Pointer] = NewValue; // purge last and overwrite with new
Pointer= (Pointer + 1) AND 63; //increment pointer with roll over, circular buffer