100 cycle of Ac signal Emon library

Sir , can we take samples of only one cycle of voltage and current to get RMS value of Both voltage and current?

Realistically, no. That is because you will not have exactly one cycle of samples. There is not an exact number of samples per cycle, and you don’t know exactly whether the first sample is immediately after the zero crossing, or whether it is almost one sample period after the zero crossing, therefore you don’t know where the last sample will be in relation to its zero crossing. So you will have an inaccurate measurement. By taking measurements over several cycles, you get an average that is more accurate.

So how many minimum samples we can take in minimum cycle? and according to nyquist rate
sampling frequency 100Hz so why 50 time more sampling rate means 5 Khz ?

1. The Nyquist frequency is the minimum frequency, think what happens if you sample at exactly twice mains frequency and every sample you read happens to land on a zero crossing.

2. Your mains current is not necessarily a nice 50 Hz sine wave. You can apply a Fourier analysis to it and decompose it into 50 Hz fundamental component and all the harmonics, and those will go up to some arbitrarily high frequency.

Ok Sir,but can we take 50 or 60 cycle instead of 100 cycle and if number of samples more (over sampling) then it will suppress the noise or harmonics ?

No, you need to average over MANY cycles in order to have a reliable average.

You want to measure all the harmonic components because they contribute to the total current flowing.

Dear Sir,

Please tell me about sampling rate of analogread() of voltage and current inside of CalVI(20,2000) . is it 100 microsecond or 377 microsecond? As per my understanding that is 377 micro second it means after 377us one sample of voltage and current taken by microcontroller or 377 us is whole loop timming?

If you search the forum for “emonLib sampling rate”, I have posted values for the most recent version of emonLib many times.

Sorry Sir,Although I wrote in my previous message that I understood about
void EnergyMonitor::calcVI(unsigned int crossings, unsigned int timeout) but really I failed to
explain and I have check all your reply regarding all topics but i could not understand some points.
please guide about following parameters

Crystal Frequncy = 16 MHz
ADC prescaler = 128
Sampling frequncy = 16Mhz / 128= 9600 Hz = 104 us.

and why timeout= 2000 that important after voltage adc checking in while (1) loop that also failed to understand.
Also,we got VCAL & ICAL but failed to understand PHASECAL 1.7.

Sir I really do hard work to understand this program please clarify this some points.

The timeout happens when there is no a.c. input.

There’s a page in Learn that explains this. Learn→Electricity Monitoring→Current & Voltage→Advanced: Explanation of the phase correction algorithm→Explanation of the phase correction algorithm

Sir,
I want to know about this timout condition.

while(1) //the while loop…
{
startV = analogRead(inPinV); //using the voltage waveform
if ((startV < (ADC_COUNTS0.55)) && (startV > (ADC_COUNTS0.45))) break; //check its within range
if ((millis()-start)>timeout) break;
}
If adc will not between 460 to 562 then it will go to next condition and wait for 2 sec.

Assuming that the while(st==false) loop goes on for ever, what is the value of startV each time round the loop? What pattern do those values follow?

Following on from that, what does
(startV < (ADC_COUNTS*0.55)) && (startV > (ADC_COUNTS*0.45))
mean in the real world?

So when, in relation to the a.c. mains input, does it break out of the while(st==false) loop?

What does that achieve, in relation to the main measurement loop that follows?

ok sir ,if period of measurement is 200ms than why set 2000 timeout in while loop? i think about 2000 value but i could not solved about value of timeout ,please help me.

sir , I read about PHASECAL on your mentioned link but i want to know exact equation of PHASECAL and also check in datasheet of AVR 465 but i can not figure it out properly. means

z= (PCC/655536)((360fM12813*2)/fclock))

The 2 s timeout is exactly that, a TIMEOUT. It should never get to time out. If it does, something has gone wrong.

That is in emonLib.cpp, line 128

There is a very detailed explanation in AVR465.c, line 269

Note that, because for safety we use a transformer to reduce and isolate the mains voltage, rather than a potential divider, the phase error of that affects the calculation too.

Sir,
i will have to explain emon.lib file to someone else so how i can explain theoretically possible?
please give some hint or solution .

What is the question that you are asking? If something is possible in theory, it means there ought to be a practical solution. If something is possible in practice, it means someone has found and applied that solution.

Sir ,

One more question for phase calibration if i change calibration value according to inductive load so i have to change phasecalibration value when capacitive load connect?

No, you must set the phase calibration as close to 1.00 as possible for a RESISTIVE load, and then never change it.