Im try to make an electrical monitoring unit, im using arduino and emonlib, in calibrating it should reupload the sketch with new value of calibration. any other way to put a calibration value instead of reuploading the sketch? with serial command maybe? or with potentiometer?
»
Re: Calibration without reuploading sketch
It would be possible to write new calibration values via a serial command, but to the best of my knowledge, no sketch exists that has that capability.
The normal and most convenient way is to edit the sketch with the new calibration constants and upload it - that is unless you are using emonCMS, when it is possible to calibrate the power there.
It would also be possible to use potentiometers to tap off a variable voltage from the voltage transformer and the current transformer, but I do not recommend that as the calibration can easily be altered by mistake, and you cannot calibrate the phase correction with a potentiometer.
Re: Calibration without reuploading sketch
As Robert has said, can't you calibrate by using the various processes in emoncms?
For example, despite calibrating my emontx, I still found that it still did not match my utility meter, so I multiplied the input by a calibration amount before logging it to a feed. Now it's still not quite perfect - but not that far away either! Certainly close enough for me.
Paul
Re: Calibration without reuploading sketch
sory, Ive been busy lately,... for this coding :')
this what I have do to solve my problem:
#include "EmonLib.h"
EnergyMonitor emon1;
unsigned long calibI = 111.1;
unsigned long newCalibI;
void setup() {
Serial.begin(9600);
emon1.current(1, calibI);
double Irms = emon1.calcIrms(1480);
Serial.println("Berapa arus terukur sekarang?"); //how electrical current measured now?
Serial.print("Arus terukur oleh emonLib adalah: "); //Current measured by emonlib is:
Serial.println(Irms);
while (Serial.available() == 0) {
}
unsigned long baca = (Serial.parseInt());
newCalibI = calibI * (baca / Irms);
calibI = newCalibI;
emon1.current(1, calibI);
}
void loop() {
double Irms = emon1.calcIrms(1480);
Serial.print(Irms * 230.0);
Serial.print(" ");
Serial.println(Irms);
delay(1000);
}
"omg, how to post a code block?
your calibration value will be requested at first start, after you inputed the calibration value, calculation process will be running at loop function with new calibration value. and it will be back to old value after restart, you can write the value to eeprom if you want
This is not the final code that I use, I have changed emonlib fit my needs, so that the sensor can be viewed online, via icinga.
hopefully the above code can be a little help to anyone who needs
"sory for the indonesian serial output :P
Re: Calibration without reuploading sketch
You should look at using the EEPROM to store your calibration values, because, as you say, when you remove power, calibration will revert to the values in the sketch. This of course is the reason that we always change the calibration constants in the sketch and then reload it. It cannot be changed by accident.
If you have (say) 4 channels of current, a voltage and phase error correction because you are measuring real power, you solution becomes somewhat harder to implement.
Also, can you explain why you are assigning a decimal value to an integer in "unsigned long calibI = 111.1;". This is surely not good practice, even if you intend the calibration constant to be an integer.
Re: Calibration without reuploading sketch
did I missed something to inform you about writing to eeprom? I thought I has inform it at the last line :P
actually, at my last sketch I using 3 voltage sensor and 16x3 current sensor (I using 3 analog mux), and I just need to measuring Vrms and Irms, yet at my last sketch it still need to calibrating especially for phasecal. any suggestion for it?
any better solution about this? at the sample and the emonlib.c the current calibration constant assigned as "double", maybe this is what you mean?. yes, it is my fault, sorry, and thanks for correction.
Re: Calibration without reuploading sketch
You did indeed mention that EEPROM could be used, but I mentioned it again in case someone with less knowledge reads this thread at some time in the future and does not understand that without using EEPROM, the unit must be calibrated each time it is powered up.
To fully calibrate each channel using serial input from the keyboard, you need to input 3 values: voltage calibration (which will be the same for each channel), current calibration and phase calibration. The only realistic way to get phase calibration correct is with an iterative process where either you enter a test values and observe the result, or it steps through values and you choose the best one based on the result (in this case power factor). You must repeat the current and phase calibration procedure for each channel.
Yes, I did mean that you should be using a float or a double for both the initial calibration constant and the value that the user enters.