johnnysmith911
Newbie level 5
I'm using a sliding RMS mechanism to compute RMS of a signal, i.e. with a window size of N, I add the squared value of the new sample x to the running total while deducting the squared value of the x(n - N) sample and then performing a square root to get the RMS value.
This method works fine when a cycle's worth data in the signal under question lines up exactly with the length of the window. For ex,
Let the window length N = 512, frequency of the signal = 100 Hz & sampling frequency = 51200 Hz.
With the above settings, every set of 512 samples would have a cycle's worth data of the signal & the computation works fine.
Now, the issue begins when the frequency of the signal deviates from 100Hz giving more or less number of samples in the same 512 samples window which throws off the accuracy of the sliding RMS algorithm.
This happens because the division by 512 to get the RMS, is no longer valid due to the fact that this particular cycle of the signal is getting complete before the end of the 512 samples window. However, the running squared total would already have the contributions from the previous samples which were divided by 512 while the samples of this cycle would require a different window length.
Is there a way to compensate for the addition/lack of samples due to the frequency drifts while using this technique?
This method works fine when a cycle's worth data in the signal under question lines up exactly with the length of the window. For ex,
Let the window length N = 512, frequency of the signal = 100 Hz & sampling frequency = 51200 Hz.
With the above settings, every set of 512 samples would have a cycle's worth data of the signal & the computation works fine.
Now, the issue begins when the frequency of the signal deviates from 100Hz giving more or less number of samples in the same 512 samples window which throws off the accuracy of the sliding RMS algorithm.
This happens because the division by 512 to get the RMS, is no longer valid due to the fact that this particular cycle of the signal is getting complete before the end of the 512 samples window. However, the running squared total would already have the contributions from the previous samples which were divided by 512 while the samples of this cycle would require a different window length.
Is there a way to compensate for the addition/lack of samples due to the frequency drifts while using this technique?