Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RMS computation improvement suggestion #19

Open
bcaro opened this issue Sep 13, 2015 · 2 comments
Open

RMS computation improvement suggestion #19

bcaro opened this issue Sep 13, 2015 · 2 comments

Comments

@bcaro
Copy link

bcaro commented Sep 13, 2015

I used this very interesting library.

I have some suggestions for calcIrms():
1 - Before entering into the for loop, some variables have to be initialized:
sampleI = analogRead(inPinI); // very important for a signal with DC component
// the first sample create a high RMS
filteredI=0; // not so important but better
for (int n = 0; n < NUMBER_OF_SAMPLES; n++)

2 - The first order filter is sensitive to sampling period
if the speed of computation changes ( the frequency of the microcontroller changes from 2MHz -> 16 MHz) the cutt-off frequency changes also by a factor 8. This is because the sampling rate is not fixed and varies with the computation time. Perhaps it will be difficult to impove that, but it is important to know this effect.

3 - The gain of the filter is not equal to 1 at high frequency
but it should be in order to not affect the RMS.
The filter should be equal to:

define CUTT_OFF 0.996

filteredI =CUTT_OFF_(lastFilteredI+CUTT_OFF_(sampleI-lastSampleI));
With 0.996, the error is equal to 0.4 %, but if we want a higher cut-off frequency the error increases, because CUTT_OFF is lower.

I hope it will help.

@srinivasan251992
Copy link

what is the significance of using 0.996

@Barabba11
Copy link

Hi, thanks for this library. Can you kindly tell how it works? Will it take the processor busy for some time to "catch" a full sinewave and from it make calculations? Looks to me the only chance. I would like to know if during measurement I can't do something else, and for how much time, thank you.
At least with this library I don't have to add hardware like AC/DC rectifier and it seems already precise..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants