100 cycle of Ac signal Emon library

Sir,that has been mentioned 50 samples per half cycle inside learn,electricity monitoring ,ac power theory,arduino maths.

The image was made by sampling the mains voltage and current at high frequency, which is exactly what we do on the emontx or Arduino. We make between 50 and 100 measurements every 20 milliseconds. 100 if sampling only current. 50, if sampling voltage and current. We’re limited by the Arduino analog read command and calculation speed.

No, that is the approximate number of samples per whole cycle (at 50 Hz), not per half-cycle.

What image?

That is correct, but I repeat, those are approximate numbers only.

Also, emonLib does not sample continuously. It was designed for use with an Arduino (or emonTx) running on battery power and so it runs for two or three hundred milliseconds (or 30 crossings - 15 cycles) and then reports the values measured during that period. The sketch may then sleep the processor for 10 s to conserve battery life.

Sounds like he’s referring to this one, as it’s the only one on the page he quoted from…
https://learn.openenergymonitor.org/electricity-monitoring/ac-power-theory/arduino-maths

Thank you all of you for reply but i am not getting proper information so please can you provide me calculation ?

As I replied to your other post calcIrms sampling rate slower than expected - #5 by apurva_rana, you can find the theory about the calculations in the ‘Learn’ section of this website. All the calculations are done for you in the emonLib library.

If you are not getting the proper information out, then you are not putting the proper information in. I can assure you that the calculations in the library are correct for an Atmel ATMega 328P. If you are using a different processor, you might need to change one or more things.

Ok Sir , thank you and I am using ATMEGA8 so all values are fluctuating .

You must compare the data sheets for the Mega8 and Mega328P, and note specific differences, you might also find Arduino documentation on the Mega8 helpful.

Then, work through the emonLib code and your sketch, checking that every instruction that relates to the hardware itself is correct.

However, the two are broadly from the same family, so I do not expect major differences. But I would expect I/O references to be different.

If “all values are fluctuating”, then unless the fluctuations are small, it means either that the quantities you are trying to measure really are fluctuating (e.g., the voltage I measure here varies by a few tenths of a volt, often more, each time it is read), or your averaging time - which you specify as the number of samples of half-cycles - is not long enough.

Ok sir, one question regarding low pass filter equation and that is what is alpha value in Emon ?will you please provide calculative information.

Do you mean in emonLib?
The value is approximately 0.001 It was chosen to give a suitable time constant that’s a compromise between adequately removing the 50 Hz ripple and responding reasonably quickly to a change, e.g. when the c.t. is plugged in or unplugged.

The full theory is here.

1 Like

Yes Sir for emonlib and if alpha is 0.001 aprrox and cutoff frequency is 50 Hz then i could not find time constant from Wikipedia equations.

sir ,why 20 crosses and 2000 timeout took ,i know that is for accuracy but it comes from any equation or assumption?because i want to know exact reason about calVI(20,2000).

1. Look at the source code for emonLib and work out exactly what these few lines each side of the filter itself are doing. The comments might help you:

    sampleI = analogRead(inPinI);
	
    // Digital low pass filter extracts the 2.5 V or 1.65 V dc offset, 
	  //  then subtract this - signal is now centered on 0 counts.
    offsetI += (sampleI-offsetI)/1024;
	  filteredI = sampleI - offsetI;

    // Root-mean-square method current
    // 1) sum squared current values

    sumI += filteredI * filteredI;

What is the purpose of those few lines, and what do you want the result of those lines to be? i.e. What does filteredI represent in the real world?

2. Go back to the Wikipedia article and understand what the cut-off frequency is. In emonLib, what is the wanted signal? You should know this from (1) above.
3. What happens to the wanted signal if its frequency is the cut-off frequency?
4. Therefore, what should the cut-off frequency be in relation to the quantity you are trying to measure?

Why not? What does 20 crossings represent in the real world?
What does a timeout of 2000 mean in the real world? Work through this piece of code with paper and pencil and find out what might happen if inPinV has a value within a particular range for a long time? What is the physical meaning of the “particular range” of values? What do I mean by “a long time”? Together, what do those two things mean?

Sir,
I have found out all except 20 cross count please tell me logic behind it or relation with real word.i can not find out.

20 zero crossings = 20 × 10 ms = 200 ms. That is the period of the measurement.

What is SO difficult about that?

If you want a different period, you can choose a value that suits you.

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 ?