You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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..
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.
The text was updated successfully, but these errors were encountered: