How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

 How is it calculated 1480.

NUMBER OF SAMPLES = 1480 it come from?.
Thank You.
 
#include "EmonLib.h"                   // Include Emon Library
EnergyMonitor ct1;                     // Create an instance

void setup()
{  
  Serial.begin(9600);
  
  ct1.currentTX(1, 115.6);             // CT channel, calibration
}

void loop()
{
  double Irms = ct1.calcIrms(1480);    // Calculate RMS current (1480: no. of samples)
  
  Serial.print(Irms*240.0);	       // Print to serial apparent power
  Serial.print(" ");
  Serial.println(Irms);		       // Print to serial Irms 

 

Robert Wall's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

The sketch reads approximately 106 samples of current in each cycle of mains at 50 Hz. 1480 samples therefore works out at 14 cycles of mains. That will give you a good average reading. You can change the number, but you should get as close as possible to having a whole number of mains cycles, otherwise if you have only part of a cycle on the end, you will introduce an error.

calypso_rae's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

In contrast with the 'current only' sketch, the 'voltage & current' sketch measures for a whole number of cycles.  It actually counts the number of zero-crossings, so for a one second window at 50Hz you would pass the value 100.

Komkanit99's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

 Thank You.       

Robert Wall's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

You can time the code like this:

unsigned long timethen = millis();
double Irms = emon1.calcIrms(1172);  // Calculate Irms only
Serial.print("Time ");Serial.print(millis() - timethen);Serial.print(" ");

This gives you the time to read (in this case) 1172 samples. The time it took was very close to 200 ms (10 cycles at 50 Hz) with an average of 200.033 ms counted over 452 loops. If you wish to time more accurately, you could use micros( ).

A little while ago, Trystan Lea measured 1185 for 10 cycles at 50 Hz.

200 ms  would seem to be a good time to aim for, because 200 ms will also give an integral number of cycles at 60 Hz.

rahuls's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

What will be the calibration for 230 V with same SCT 013-000 transformer? I am using the normal 5V arduino board? And is this SCT CT is having the built in zener diodes? 

 

Thanking you.

Robert Wall's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

rahuls

The system mains voltage does not affect the current calibration constant, you can follow the calculations here where everything is explained (including the 30 A c.t. which has a built-in burden resistor and no zener diodes).

rahuls's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

Respected sir,

The serial print which prints 106 sample values alongwith the rms current?

I need to take average of 106 samples and i need to calculate the apparent power (Only one value on serial port)?

How we can calculate as i used for loop for it but it is showing 106 samples value.

kINDLY REPLY.I am totally stuck at this point

 

calypso_rae's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

Hello rahuls,

Please can you ask your question in a simple way so that I can understand exactly what you are asking.

If you want to measure real power, the best way is to use the standard Voltage and Current sketch.  Then you won't need to worry about how many samples are to be used.

c-r

rahuls's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

Respected sir,
Actually the sketch that is uploaded for current measurement and as per the 1480 samples it will shows the 1480 current and apparent power values in the serial value? So sir if i used 106 sample values then can i take the average of 106 values i.e. of Apparent power values.

Thanking you.

calypso_rae's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

Hi rahuls,

The "Current Only" sketch should give approximately the right answer whatever number of samples you specify.  But if you measure over a whole number of mains cycles, the result will be more stable.

I am still not clear what you are trying to measure.  Is it "real power", as a supply-meter would do, or do you want to measure something else?  Are you measuring voltage as well as current?

(I will only deserve the "respected sir" title if I can solve your problem !!)

Robert Wall's picture

Re: How is it calculated 1480. NUMBER OF SAMPLES 1480 it come from?.

Rahuls,

The way the analogue to digital converter in the processor measures both voltage and current are similar. The signal is changing rapidly, it is approximately a 50 Hz sine wave. Samples of the sine wave are measured and mathematics are done on the numbers. First, a high pass filter is used to remove any d.c. offset. Then:

  1. To calculate real power: Voltage and Current are multiplied together and the result is added to an accumulator and a count kept of the number of additions made. At the end of the measuring period, the total in the accumulator is divided by the count to give the average power. If you do this over a whole number of mains cycles, you will get a more accurate answer than if you stop part way through a cycle. The more whole cycles that you average, the smaller the error will be if you do not stop at exactly the right place.
  2. To calculate rms voltage or current: The voltage (or current) is multiplied by itself and the result is added to an accumulator and a count kept of the number of additions made. At the end of the measuring period, the total in the accumulator is divided by the count to give the average (mean) and then the square root is taken. This gives the rms (root of the mean square) value. Again, if you do this over a whole number of mains cycles, you will get a more accurate answer than if you stop part way through a cycle.

In the current-only sketch, voltage is not measured and so Vrms and Real Power cannot be known. You assume a value for voltage and from that you can only estimate Apparent Power.

In the voltage & current sketch, voltage and current are measured one after the other and the three calculations are done together. At the end, when you have calculated rms current, rms voltage and real power, you can then calculate:

  1. Apparent Power (VA) = Vrms x Irms
  2. Power factor = Real Power / Apparent Power

You do not need to know the 106 individual readings for each mains cycle, and you should not try to look at them because you will slow the processor down and they mean nothing. The only numbers that you should use are the results from your calculations: Vrms, Irms, Real Power, Apparent Power and Power Factor.

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.