#include <math.h>
#define SAMPLING_NUMBER 35
unsigned int get_RMS(void)
{
static unsigned int Count = 0, SUM = 0;
unsigned int Value = 0;
unsigned int rms = 0;
if( Count < SAMPLING_NUMBER )
{
Value = Read_AD_Value();
SUM += Value * Value;
Count++;
}
if( Count >= 35 )
{
rms = (unsigned int )sqrt( SUM / SAMPLING_NUMBER );
Count = 0;
SUM = 0;
}