Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Hi,

 

I'm very new to this (day 2). I have my emonTxV3 sending data to my Raspberry Pi and then uploading to emonCms. But I have found some calibration issues. 

My voltage is showing as an average of 256v, but when measured by an accurate meter it shows 241v. Obviously I need to calibrate, but all the instructions on the site seem to be for the previous emonTxV2, and how to update the standard sketch for that module.

The new sketch for the V3 is different and I can't see where I would plug in any calibration values. I'm sure people have done this before, so could someone point me in the right direction.

I have to say what I've seen so far of this project is amazing and I can't wait to get everything working smoothly.

Thanks for any help,

Allen

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

? ? ?  If I'm looking at the same emonTxV3_RFM12B_DiscreteSampling.ino as you are, all the settings are in the sketch starting at line 47.

From your numbers, I make Vcal = 268.27 (line 52).

All that's happened there is that instead of the constant being hard-coded into the call to emonLib, it's hard-coded as a constant higher up the sketch so that all the settings constants are grouped together.

AllenConquest's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

I assume you calculated that from the formula on the calibration page: 

New calibration = (correct reading / emonTx reading) * existing calibration

On that page it says you can either modify the Vcal value OR the Vrms value. Which is the better, or should I really adjust both?

I presume I should also calibrate the Ical and phase shift? How is the Ical calculated, as the calibration page seems to imply the default should be 111.1, but it is 85.75996 in the sketch.

Thanks,

Allen

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

I don't understand what you mean by "you can either modify the Vcal value OR the Vrms value. Which is the better, or should I really adjust both?". The Vrms value is used when you are not using the voltage sensor but relying on the declared value or the value you measure once. This is what the comment on line 48 means. So, you adjust the one you are using.

Yes, you do need to calibrate the whole thing, because power is the product of voltage and (the real component of) current. The best way to calibrate the voltage and current constants is against a known accurate meter. The best way to calibrate phase shift is obtain the highest possible power factor when the load is purely resistive (e.g. a fan-less electric heater or water heater). After that, many users have fine-trimmed the calibration over time so that the accumulated energy value tallies with their electricity company's meter, claiming better than 1% agreement.

The calibration page predates the emonTx V3. Knowing the component values, it's possible to work through the maths to calculate the coefficients, and this should be reasonably close to the value you determine on test. A big discrepancy indicates an error or a faulty component somewhere. There's a Building Blocks page that describes the theoretical derivation of the calibration values.

AllenConquest's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

I have updated the Vcal value and now the voltage reading is agreeing with my meter.

What is confusing me at the moment (not too difficult!), is that the Ical value in the sketch is 85.75996 but the online pages about calibration give a default value of 111.1. Of course I might not be comparing the correct values, but when I read the online documentation I sure it implied that 111.1 was the default current calibration.

Do you know why this is different?

I don't have a meter that I can use to measure the current, so I'm not sure I can calibrate anything else. Is there anything else I can do to improve accuracy?

By the way, thank you for your responses to what must seem like nonsense coming from a complete novice in this area (I'm learning fast!)

glyn.hudson's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Please could you provide some more info. Where online are you getting the 111.1 cal from? What value have you come up with which works well? Are you using an ac adapter from the shop? Is it UK / euro plug? We will do some testing this week and check the calibration 

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Glyn: Ical, not Vcal is the problem!

Allen: Which current transformer are you using? Is it the blue YHDC SCT-013-000 from the shop? For that one, the theoretical  value for Ical is 90.9 (111.1 relates to a 18 Ω burden resistor in the emonTx V2, yours in the V3 is 22 Ω.) So 85 isn't that far out. You can expect a variation of up to at least 5% due to component tolerances (1% on the burden resistor, 3% on the CT and I think 1% on the voltage regulator).

You'll need to use your electricity meter to calibrate!  Take a look at your meter. If it's a rotating disc, it will say on the front what one revolution of the disc means (or what n revolutions mean). If it's a digital one, it will have a LED that flashes and it will tell you what 1 flash means (or you may need to look up the meter type on the web and read the manual). Then you run with a constant load and time revolutions or flashes (which will give you energy divided by time, equals power) and you relate that to the power the emonTx reads. Then correct Ical and try again!

AllenConquest's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Glyn: I am using the ac adapter from the shop, but my voltage is now calibrated.

Robert: I am using the blue YHDC SCT-013-000 from the shop as the CT. I guess the value in the emonTxV3_RFM12B_DiscreteSampling sketch in git is just whatever value the developer left in there. But it might be nicer if it was the theoretical value of 90.9, unless there is some explanation as to why it is set to such a precise value that is different.

I have a digital electricity meter with an LED on it, so I will do some timings when I can get a steady load on the system (might need to wait until everyone is in bed!)

I had been wondering if using a pulse counter would have been better for getting the power, surely this would not have suffered from calibration issues?

I am also connecting up a solar system in the Type 2 configuration. Will I need to calibrate that separately using the pulses from the generation meter? If that is the case, how can I set different Ical values for each of the CTs? In the previous emonTxV2 sketch you are able to set voltage and current for each CT, but in this newer sketch there seems to be only one setting for all of them (apart from Ical4).

dkeverne's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Hi Allen,  I've just been going through the same thing on my new v3.  My Vcal (changed in the emoxTX V3 Settings section around line 52 in the sketch) is now at 269.66 (original 284.9667) which matches up better with my MM reading, but I've still got more calibration to do later today.  I'll post my final values when I've done some more testing.

Darren

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

I think you two need to share a thread! (For anyone who's missed it: http://openenergymonitor.org/emon/node/3300)

I've just written to Glyn suggesting that there should be 4 Ical's, since when you take the c.t. tolerance into account, to my mind at least the error is unacceptably large if there is a common calibration for the three main c.t's. If you want to do that, you repeat line 50 to give yourself an Ical1, Ical2 and Ical3, you (probably) get rid of line 170 (or repeat that as well, changing it appropriately (and bear in mind once you've inserted some lines above, it won't be 170 any longer!), and then the important bit: you change what was lines 213, 214 & 215 to use Ical1, Ical2 & Ical3 respectively.

I justify that because as I wrote above, the tolerance on the burden resistor is 1%, and the c.t. is 3%. Therefore together you can expect up to 4% from the nominal due to those alone, or possibly 8% difference between channels. You can also expect another 1% I think from the voltage reference but that's common to all 5 channels (including the voltage now). It is clearly necessary, once you have established the calibration for a channel, to keep the same c.t. paired with that channel forever.

However, you don't need to marry the c.t and channel with a particular cable or feed. You can calibrate all 4 inputs simultaneously on the same cable (if there's room so that you can space them an inch or two apart!).

Pulse counter or c.t. is a matter of preference, as much as anything. True, the pulse count is by definition accurate (even if it isn't!) but the data is much more granular and requires you not to miss a pulse. You cannot normally measure exported energy (if you have generation) with a pulse input as the meter won't give pulses when exporting.

 

 

dod's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

My own v3 definitely needs adjusting, the v2 voltage was v229 it is 241 with the v3.

Thanks for the thread, I shall watch !

 

 

dod's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

So this is my current output , why is ct4 so different ?

emonTx V3 Discrete Sampling
OpenEnergyMonitor.org
CT 1-3 Calibration: 90.90
CT 4 Calibration: 16.66
RMS Voltage on AC-AC Adapter input is: ~124V
AC-AC adapter detected - Real Power measurements enabled
assuming powering from AC-AC adapter (jumper closed)
Vcal: 268.00
Phase Shift: 1.70
CT 1 detected
CT 2 detected
CT 3 detected
CT 4 detected
Detected 1 DS18B20..using this for temperature reading
RFM12B Initiated:
Node: 9 Freq: 868Mhz Network: 212
16379 14143 14719 2596 311.35
temperature: 8.30
1507 163 165 31 230.37
temperature: 8.30
1334 15 25 4 228.65
temperature: 8.30

TrystanLea's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

I've just updated the calibration constants for the continuous sampling example to values determined theoretically via component values:

voltage calibration: 276.9

(230V x 13) / (9V x 1.2) = 276.9. Where 13 is the voltage divider reduction factor and 1.2 accounts for 20% increase in voltage adapter output voltage as its not being loaded (open circuit)

and

23kW inputs (1-3) current calibration: 90.9  ( 2000 turn CT / 22 Ohm burden)
4.5kW input (4) current calibration: 16.6  ( 2000 turn CT / 120 Ohm burden)

The result agree's well with my reference meter here.

TrystanLea's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

dod: do you have anything plugged in to CT4? If you put the CT4 clip around the same cable as CT1 does it read the same?

TrystanLea's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

I've updated the emonTxV3_RFM12B_DiscreteSampling sketch on github to use theoretically calculated calibration values and added the ability to tune each CT as suggested by Robert Wall

dod's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Hi, Yes I have all four CT's in use grid,pv1,pv2,EV, I will try the new code.

Thanks

Dave

dkeverne's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Update, after several calculations and fine tuning I've settled for 271.96 as my Vcal, which isn't far off Trystan's theoretical, taking into account component variation.  It tracks the measured values to within .1 V.  I'll get to current calibration next week.

Dod, I see you have a temperature sensor working, could you confirm your pin connections for that, I can't get it to recognise the sensor on my board?

dod's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Mine didn't work first time, so I had to reverse pins 5/6

So I have black on pin 3 white on pin 5 and red on pin 6

 

dod

dkeverne's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Hi, I managed to get some current calibration figures using a 1Kw and 2Kw bar heater.  Numbered my 3 CTs (4th is in the post) as swapping them around also gives a small fluctuation, < 1%.  So from the theoretical 90.9 for CTs1-3 I now have CT1 89.42, CT2 88.96 and CT4 from 16.6 to 16.5.  Not far off the theoretical but they give a much better tracking over higher power readings.

I've also been playing with the continuous sampling sketch.  Very good code, thanks to Robin Emley.  I assume the discrete sketch is just instantaneous sampling every 10 seconds and the continuous one is taking multiple samples per cycle and summing the power, right?  I'll test saving all the samples over a cycle and print them out, which should show a nice sine curve.

I've plugged in the Vcal and Ical recalibration figures to those calculations and that is working well.  I'm getting about 39 samples per cycle and 38uS of available delay from the workload check.  Is that what others have seen as well?  Is the 38uS the time it takes to do the calculation or the time available for other things after the calculation?  I assume it's the latter. It looks like it's testing the delay in every sample of the cycle and prints out what it settled at at the end of the cycle.

I'm gonna have to squint at the code some more as I'd like to get Vrms and Irms out of the calculations, just for interest and comparison...

Cheers, Darren

TrystanLea's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

The discreet sampling example samples over 10 full AC cycles, so 200ms per measurement on each CT. Within this measurement it samples rapidly at about 2500 samples per second. There is then an assumption that the power does not fluctuate significantly in the time it is asleep which is usually good enough for typical household monitoring.

The continuous power monitoring example by Robin is better as it samples continuously and so will not miss anything. The only disadvantage is that you cant put the emontx to sleep between samples and that it doesnt work well if you want to dedicate processor time to other operations like temperature monitoring as well. But if your only interested in power measurement and the emontx is always powered then the continuous sampling approach is the better way to go.

 

dkeverne's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

So discreet does 10 cycles, which is 1/5th of a second, 200ms @ 2500 samples per second, so it does 500 samples every 1/5th of a second?  And it does that every 10 seconds?  So it actually only measures the power for 1/50th of the period?

Just confirming, I'm sure that is fine for rough figures.  I know you can never get 100% accurate unless your actually in-line of the power usage or have infinite samples, which isn't practical ;-)

Have you compared both styles running at the same time on test loads to see how the results differ?  I'd need 2 emonTX's for that.

Cheers

calypso_rae's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

I've also been playing with the continuous sampling sketch.  Very good code, thanks to Robin Emley. 

Thanks, I'm glad it's being of use to you.  Can someone provide a link to this code, it seems to have disappeared from the Github repository.  Or maybe I don't know where to look.

So it actually only measures the power for 1/50th of the period?

That's right, most of the early sketches work in this way.  It allows three channels to be measured, albeit sparsely, using battery power only.   This approach was not suitable for a PV Router application hence my Mk2 code which operates continuously.

The "continuous monitoring" code that I've supplied for emonTx_V3 is a simple extension of my Mk2i PV Router code.  By using low-level commands for the ADC, and integer-based maths, a decent sampling rate can be obtained for several analogue channels.  This sketch uses five such channels (one voltage and four current).  As per its Mk2 ancestry, an energy accumulator  for each of the channels is updated every mains cycle.  This arrangement is not ideal for a straightforward measurement application. 

The alternative arrangement that I posted soon after in a 6-channel version may be better (the code is in a zip-file at the end of the thread).  For maximum speed, the 6-channel version has the ADC in free-running mode; the 5-channel one has the ADC in a timer-based mode which may provide better control of the sampling intervals.

The continuous power monitoring example by Robin is better as it samples continuously and so will not miss anything. The only disadvantage is that you cant put the emontx to sleep between samples and that it doesnt work well if you want to dedicate processor time to other operations like temperature monitoring as well.

Because this code is timer-based, the sampling rate can be reduced in order to create as much spare time as is needed.  Although the ADC is running pretty much flat out, the main processor is only about 50% occupied.  There should be plenty of time for other activities.  Because all the data is are processed in one go, the idle periods (ignoring ISRs) between consecutive blocks of calculations are quite lengthy, maybe 250uS every 520uS. 

 

dkeverne's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

I found it in:

OpenEnergyMonitor/emonTxFirmware/emonTxV3/RFM12B/Examples/emonTxV3_continuous

I shall read the other thread later with interest.  I already had a quick skim and like the ASCII waveform diagram ;-)

Cheers

calypso_rae's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Thanks for that link, I'd not thought to look in the RFM12B folder.  The RF part was a last-minute addition to that code.

Yes, I was pleased when that 6-channel trace appeared.  As it's the Festive Season, maybe it deserves a second viewing :)

>>free RAM = 725
millis() now = 0
recordingMayStartAt 5000
4
3
2
1
0
No of cycles recorded = 1
cycleCount 252,  samplesRecorded 28
|                                  235 0.14                                     |
|                            3   5      .    401                                |
|                       3      5        .       4   01                          |
|                 3 2        5          .         4       1                     |
|            3  2          5            .          4          10                |
|         3   2           5             .           4            1 0            |
|       3    2            5             .            4            1   0         |
|       3     2           5             .           4             1    0        |
|       3      2           5            .           4             1    0        |
|          3     2           5          .         4             1     0         |
|                3    2        5        .       4          1     0              |
|                      3    2     5     .    4        1    0                    |
|                             3  2   5  .  4     1  0                           |
|                                    3 25  1  0                                 |
|                                   41 0.  532                                  |
|                              10 4     .     5   3                             |
|                        10    4        .       5      23                       |
|                   01       4          .         5        2 3                  |
|              0 1         4            .           5          2  3             |
|          0  1           4             .            5           2   3          |
|        0   1            4             .            5           2     3        |
|       0    1            4             .           5            2     3        |
|       0    1             4            .           5           2      3        |
|        0     1             4          .         5          2     3            |
|             0     1          4        .       5       2     3                 |
|                   0    1        4     .    5     2   3                        |
|                          0  1     4   . 5   2  3                              |
|                                0  1  52 3                                     |
 
AllenConquest's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

I finally got my solar PV system working today and got some readings coming from the emonTxV3.  However, the inverter was should 242w, but my monitoring was showing 112w. That would give me 

112/242 * 90.9 = 42.069

This seems very low. Has anyone else experienced something like this?

The CT clip is round a very narrow cable that comes from the inverter, could that affect the reading?

glyn.hudson's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

That does not sound right at all. Are you using an AC-AC adapter to power the emonTx V3? Also are you using the latest firmware on github? https://github.com/openenergymonitor/emonTxFirmware/tree/master/emonTxV3/RFM12B/emonTxV3_RFM12B_DiscreteSampling

When you start up the emonTx V3 if you have a USB to UART cable connected it will serial print on 9600 baud the calibration values currently in the code. 

glyn.hudson's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Ah, just seen your other post: http://openenergymonitor.org/emon/node/3330. I've just replyed 

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

calibración de tensión: 276.9
(230V x 13) / (9V x 1,2) = 276,9. Donde 13 es el factor de reducción de divisor de tensión y 1.2 representa 20% de aumento en la tensión de salida del adaptador de tensión, ya que no está cargado (circuito abierto)

 

Saludos Amigos estoy intentando realizar un prototipo básico con un TC y un adaptador de AC-AC,, estoy tratando de calibrar de acuerdo a las condiciones en la que estoy trabajando (Vref=5V, tensión de la red 120V +-10%, y).

Si  tengo una variación del 20%  sin carga y la salida nominal es de 9V , el porcentaje sería 1.8 y no 1.2, o estoy interpretando mal... Otra duda que tengo es, que hacer con la constante de calibración, que operación debo realizar para obtener los valores, similares o en el mejor de los casos iguales a los de mi multímetro.

La verdad soy nuevo en esto, me parece que es una pregunta muy básica, pero si me pueden ayudar les quedo infinitamente agradecido, y si tienen un código para estudiarlo y entenderlo mucho mejor...

Gracias...!!

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Your AC-AC adapter gives you ~ 11 V out for 120 V in, therefore if you use the calibration constant that is correct for a 240 V supply, it will say your supply is twice the voltage that you have in reality. Therefore you must use a voltage calibration constant that is approximately 140 ( 276.9 -> 140). You measure the voltage and change the "140" so that your prototype reads the same as your meter.

"Si  tengo una variación del 20%  sin carga y la salida nominal es de 9V , el porcentaje sería 1.8 y no 1.2, o estoy interpretando mal..."

I am sorry, but you are misinterpreting it. The voltage for small transformers is given at the rated load - 9 V - and the voltage rises by ~20% on no-load ( 11 / 9 = 1.22). For a distribution transformer owned by the power company, it is the no-load voltage that is 'normal' and the transformer regulation is the drop in voltage at full load.

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Gracias por contestar,  estoy trabajando en esto y cada vez me surgen mas dudas, disculpas  pero la verdad no me quedan claras algunas cosas, si me pueden ayudar con lo siguiente. 

Tengo un Transformador de tensión en el cual el fabricante indica (110V AC / 12V AC) pero la tensión en mi país es de 120V AC  ±10% , es decir  en el peor de los casos sería 132V AC he  realizado la medición y obtengo a la salida del adaptador 15Vrms a esto le debo añadir el 20% debido a que no existe carga, quedandome 18Vrms = 25.46Vpico esto lo e utilizado para calcular el valor de la resistencia del divisor de tensión, tomando en cuenta que estoy trabajando con un aruino Mega 2560R3 y utilizo la referencia de 5V, finalmente los valores de resistencia son 100K y 10K, teniendo como máximo 2.3 Vpico.  A  partir de esto tengo las siguientes preguntas concretas.

1) Revisé el siguiente link  http://openenergymonitor.org/emon/buildingblocks/ct-and-ac-power-adaptor-installation-and-calibration-theory  . Y la pregunta es ¿Por qué se utiliza un solo valor de tensión (230V) sin tomar en cuenta la variación que esta puede tener?. 

Si aplico la fórmula  "voltage constant = 230 × 11 / (9 × 1.20) = 234.26"  en las condiciones que estoy trabajando tendría lo siguiente. 

2) Voltage Constant = 110 x 11 / (12 x 1.2) = 84.03  Donde 110 es el voltage que indica el fabricante. ¿Esto es correcto con mis condiciones? o debo poner el valor de voltage real que tengo en la red (120V).  

3) No comprendo la lógica de esta constante de calibración . ¿Por qué se utiliza esta fórmula?.  

4) ¿Qué función tiene la siguiente línea de código de la librería "EmonLib" ?

double V_RATIO = VCAL *((SUPPLYVOLTAGE/1000.0) / 1023.0);         Donde  VCAL = Voltage constant
 Vrms = V_RATIO * sqrt(sumV / numberOfSamples); 

GRACIAS..!!

 

 

 

 

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Mil disculpas, yo pensé por un momento realizar  otros cálculos muy diferentes a los que están aquí  Lo que pensaba realizar  es lo siguiente:

1) Realice unas medidas con mi multímetro el cual indica que tiene un error de 1%, y los resultados fueron:

VInt =108Vrms Vout= 12.3 Vrms
VInt=121.7Vrms Vout=13.87
VInt=130Vrms  Vout=14.7 Vrms 
VInt=132Vrms  Vout=15 Vrms

2) Como la señal de entrada al ADC del arduino tiene una relación de VintArduino= (1 / 11) (VOutAdaptador). Tomando como ejemplo  la medida  VInt=130Vrms  Vout=14.7 Vrms. Tendríamos 

3) VintArduino= (1 / 11) (14.7)=1.34V  que corresponde a la muestra 274 del ACD del microprocesador, Entonces lo que se busca es una constante de calibración que nos de el valor real (130Vrms), Se tendría la siguiente ecuación:

4) VoltageConstant = 274 / 130 = 2.1  es decir que mediante software se debe dividir cada muestra entre 2.1 para obtener el valor real (130V).

Esto tomando en cuenta que la relación del voltaje de salida del adaptador es lineal con respecto a la entrada. 

Revisé el link anterior y la constante de calibración es muy diferente, y no logro Interpretar su procedimiento

 "voltage constant = 230 × 11 / (9 × 1.20) = 234.26" 

¿Que procedimiento realizan una vez calculada la constante  de voltaje (234.26)?. 

Se que no debe haber mucha dificultad para maestros como ustedes, pero yo estoy empezando a trabajar en esto y se me hace complicado.

 

 

Gracias  nuevamente por su ayuda..!!

 

 

 

 

 

 

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

I also found it complicated when I started! It is difficult, but it is possible to work through the mathematics to obtain the voltage constant.

1) Revisé el siguiente link  http://openenergymonitor.org/emon/buildingblocks/ct-and-ac-power-adaptor... . Y la pregunta es ¿Por qué se utiliza un solo valor de tensión (230V) sin tomar en cuenta la variación que esta puede tener?.

In the formula

"voltage constant = 230 × 11 / (9 × 1.20) = 234.26"

"230" is the stated supply voltage for the adapter, and "(9 × 1.20)" is the output voltage at that supply voltage. You can use any supply voltage provided you know the output voltage that goes with it.

"11" is the inverse of the ratio of the voltage divider in the input circuit.

Now the real question is: Is 100 kΩ and 10 kΩ the correct voltage divider?
Your maximum supply voltage is 132 V and at that voltage, you have 15 V from the adapter. Your ADC in the Arduino can accept 5 V peak-to-peak = 1.767 V rms, so that is safe, because you get only 1.36 V from the divider. You could use 82 kΩ and 10 kΩ in the voltage divider; then your calibration constant would be:

132 V × ( (82 k + 10 k) / 10 k )  / ( 15 V ) = 80.96

and you still have ~ 7% available to allow for component tolerances.

4) ¿Qué función tiene la siguiente línea de código de la librería "EmonLib" ?

double V_RATIO = VCAL *((SUPPLYVOLTAGE/1000.0) / 1023.0);         Donde  VCAL = Voltage constant
Vrms = V_RATIO * sqrt(sumV / numberOfSamples);

Two things are happening here. (1) The first line is taking the voltage calibration constant (VCAL) and "correcting" it by measuring the actual analogue reference voltage ( = VCC ) at the top of the emonLib method calcVI( ), which it calls SUPPLYVOLTAGE. This is the reason that the Arduino VCC does not appear in the formula.

2) the second line is completing the rms calculation and applying the calibration. It is taking the average of the sum of V2 and then taking the square root, multiplying by the number we just calculated that is the adjusted calibration constant and giving the answer in Volts rms.

 

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

"Your maximum supply voltage is 132 V and at that voltage, you have 15 V from the adapter. Your ADC in the Arduino can accept 5 V peak-to-peak = 1.767 V rms, so that is safe, because you get only 1.36 V from the divider. You could use 82 kΩ and 10 kΩ in the voltage divider; then your calibration constant would be.....

Pero  adicional a los  15 V tengo que sumarle la variación del 20% debido a que no existe carga lo que me daría 18 V = 25.46 V pico-pico,  y tomé en cuenta  el caso en que la señal de referencia del arduino fuera 4.8V  ya que planeo ponerle una batería que sirve cuando no haya servicio eléctrico y esta hace que varíe la referencia. Haciendo los cálculos y si selecciono una resistencia fija R2=100k  obtengo  R1=10.4k  aproximadamente  a 10k ... Es correcto esto? o ¿Cuando se toma en cuenta la variación del 20% a la salida del adaptador?

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

No, you measured the adapter with no load (only your multimeter) so there is no need to add another 20%.

You only need to allow for transformer regulation when you use the full-load voltage that the manufacturer of the adapter gives: i.e. if the manufacturer states that it is for 120 V supply and gives 9 V and it is rated at 6 VA, then you get 9 V out when the load is 666 mA, and the voltage rises as the load reduces.

If you measure the same adapter at 132 V supply and you get 15 V out on no load, then those are the numbers you should use, because your circuit does not put a significant load on the adapter.

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Thank you very much!!

With this explanation I guess I'll calibrated voltage, then start with the current sensor and I need help.

In the library "EmonLib" algorithm is not performed to detect that wavelength is Missoni is "zero" (512) as it does in the voltage.

boolean st=false;                            

unsigned long start = millis();

  while(st==false)                            
  {
     startV = analogRead(inPinV);              
     if ((startV < 550) && (startV > 440)) st=true;
     if ((millis()-start)>timeout) st = true;
  }

Why not do the same with variable current?
Thanks was very helpful comments...!!!xfa

calypso_rae's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

The standard sketch for measuring voltage and current waits until the ADC value for voltage is near the zero-crossing point.   This technique is possible because mains voltage should always be present.

For the current only sketch, it would be difficult to detect the start of a mains cycle if no current was flowing through the CT.  I presume that's why this "synchronous start" stage is omitted.  Instead, the measurement process starts straight away.  By choosing a suitable number of samples, it should be possible to measure the current for a whole number of mains cycles, which achieves much the same effect.  

(Hope this is right - from memory)

 

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

That is right - but there is no need to start sampling at or near zero in particular, it is only necessary to have as nearly as possible an integer number of whole cycles. So the exact point on the wave at which we start does not matter, as long as we finish at about the same place.

And there is no need to do the same with current, because emonLib measures samples of voltage and current alternately - approximately 50 pairs per cycle at 50 Hz.

 

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Sorry, but the more I study, the more ignorant I become, I'm tried to interpret the entire library "EmonLib", here applies a high pass filter to remove the DC component (offset), can be you  skip this algorithm by hardware if a full wave rectifier is used as to calculate effective values ​​has the same effect, since the formula is squared .....

 

What implications would need to make this change?

Another option would be to use a half-wave rectifier, would have the same effect is compensated by multiplying 1 / sqr (2). and would avoid double drop diode voltage (occurring in the full-wave).

This is it correct?.

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

You cannot use a rectifier. If you do, you no longer have any information about the phase of the current in relation to the voltage, therefore you cannot determine the direction of power flow. In addition, if you include a rectifier, you will introduce non-linearity as the diodes begin to conduct.

I do not understand why you want to do that. All the rectification that is necessary is done in the software. As you say, provided you are measuring only power, you need only one high-pass filter. But if you need an output of both voltage and current, then you must have a high pass filter in each.

One more point: EmonLib is proven and it works.

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

 

"One more point: EmonLib is proven and it works".

 

works well, I'm know.
My idea is to fully understand how it works, now you can not run a full wave rectifier.

I'm starting and so I came all these doubts.
Thanks for the help.!

 

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Help, I have problems playing back the program, you say that it takes about 50 samples per cycle pairs. Where does he get this value?.

According to my analysis, the samples are subject to sampling period of the ADC of Arduino (100uS), if I set the variable

"timeout = 2000" 

Sampling would be for two seconds, which corresponds to 120 cycles (60 Hz). What if the other side to the "crossings" Variable I assign a value of 20?. Not fit something in there ...The variable value should be 240 crossings. and must always have a logical relationship with the timeout variable.

Now there is another issue, as this sampling voltage and current time between samples is another 400uS, you'll take 41.67 samples per cycle, now in 2 seconds would have approximately 5000 samples.

Is this correct?.

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Timeout is totally different. It should never end the sampling loop. It is there to prevent the program waiting forever in an infinite loop if there is no input. CrossCount should always terminate the measurement loop.

The default "crossings" (or wavelengths - which is not true, it is half-wavelengths) is 20, which at 50 Hz is 10 cycles in 0.2 s. If you leave crossings at 20, at 60 Hz you will sample for 0.166 s.  Sampling for 0.2 s every 5 s was chosen to give a good battery life when using battery power. If you want to sample for 0.2 s, "crossings" should be 24.

As you say, the number of samples is defined by the rate at which the ADC converts inputs and the time taken by the program to do the mathematics. It works out be a little more than 2500 sample pairs per second. So you are almost correct, in 2 s you will have a little more than 5000 sample pairs. On a 60 Hz supply, I think you should see maybe one or two more, about 42 or 43 sample pairs per cycle.

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

"If you want to sample for 0.2 s, "crossings" should be 24."

What effect has increased or decreased if the " crossings = 40 " or "  crossings = 5" cycles ?. Have any negative effect?.

What would be the optimal value for crossings?

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

For how long do you want to measure?  And how frequently?  0.2 s every 5 s is good if your electricity demand is not changing rapidly.

If you want, Diverting surplus PV Power: PLL will measure power continuously - you do not need to use the energy diverting function if you do not need it.

There is a 60 Hz version available (3 c.t's - by Dan Woodie: http://openenergymonitor.org/emon/node/2624
and http://openenergymonitor.org/emon/node/2679)

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

What I seek is actually measuring energy consumption continuously (Real Time), ie the load increases at some point turn to observe the increase of energy ..... I think these changes (increased load ) do not occur very often, but if I must occur sensing that change.

I'm think it would be fine in 5s 0.2s for my application.

I'm will review the code of Dan, I will definitely take time entendenderlo.
Thanks for the help.

 

calypso_rae's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Two sketches of mine which measure Real Power continuously and support the RFM12B are available:

This code measures real power on four channels, it is intended for single-phase use with the emonTx V3.  The ADC sampling regime uses a hardware timer. 

The code on this thread (in NZ_project.zip) has the ADC in free-running mode for greatest speed.  It was written to monitor 2 phases of a 3-phase supply, but could easily be modified to measure power on all three phases.

As far as I can see, both of these sketches should be able to measure real power in a 60Hz environment without requiring any changes.  The first sketch also accumulates energy, so "50" should be changed to "60" in each of the following lines:

          tx_data.msgNumber = msgNumber++; // increment
          tx_data.power_CT1 = energyInBucket_long_CT1 * (powerCal_CT1/50);
          tx_data.power_CT2 = energyInBucket_long_CT2 * (powerCal_CT2/50);
          tx_data.power_CT3 = energyInBucket_long_CT3 * (powerCal_CT3/50);
          tx_data.power_CT4 = energyInBucket_long_CT4 * (powerCal_CT4/50);
 

Robert Wall's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Thanks Robin. I was looking for those last night and couldn't find them, and hoped you'd chip in. They're now in my private FAQ list.

José's picture

Re: Calibration of emonTxV3 and emonTxV3_RFM12B DiscreteSampling sketch

Thanks calypso_rae, no doubt this will help me a lot going to interpret the code and make the corresponding changes, I think I will take some time, since the code and EmonLib different from the library, which was the one with reference.

Comment viewing options

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