How to Calibrate PHASECALL

I've try to change value PHASECALL In the function EnergyMonitor. it start from 0.9 increase. but i didnt see real power and power factor value change.  whereas the difference real power of my system between multimeter about 11 W.

Can anyone explain it to me in simple terms?

Thanks.

 

Robert Wall's picture

Re: How to Calibrate PHASECALL

PHASECAL is an adjustment to correct the errors in the input sensors. You adjust the value so that, with a purely resistive load, you have power factor = 1.00

The method is here: http://openenergymonitor.org/emon/modules/emontx/firmware/calibration

If your test load is 11 W, I think it is very unlikely that you will see any difference, as the true current will be masked by electrical noise.

shaulagara's picture

Re: How to Calibrate PHASECALL

How normally the range of work to read power??

i've try to change the constant of PHASECALL from 0.9 - 2 but the value of power didnt change, so far i know it should have changed.

electrical noise?? you mean THD?

how about THD? In the function EnergyMonitor there is no filter. I'm also still confused this section.

Can you explain it to me in simple terms?

thanks in advance.

Robert Wall's picture

Re: How to Calibrate PHASECALL

"How normally the range of work to read power??"  Sorry, but I do not understand what you are asking.

"electrical noise?? you mean THD?"  No, I mean electrical noise from the digital part of the processor.  It causes the input to change randomly by two or three counts even with nothing connected. You read that as a "current" of maybe 200 mA and a  "power" of maybe a few tens of watts maximum. This is not real current nor is it real power. That is normal and you can do nothing about it. To set PHASECAL, you need a much larger load than that - say 500 W - so that the true current is much larger than the "noise current". When you do that, you should see the power factor change as you change PHASECAL.

The real power calculation in emonLib will correctly calculate the power even when the current and voltage waves are distorted - provided there is no significant power in the harmonics above the 25th.

shaulagara's picture

Re: How to Calibrate PHASECALL

i mean large load that can be read correctly? >500, <500 ??

im sorry i dont use emonLib.h library. my code use in the book "arduino projects to save the world"

I'm  confused when the current and voltage waves are distorted. because there is no filter.

from this code, if i change constan of PHASECALL, the real power doesnt change.

this is the code :

#include <LiquidCrystal.h>
LiquidCrystal lcd(3, 5, 6, 7, 8, 9);

const int voltageSensor = A0;
const int currentSensor = A1;

const int numberOfSamples = 3000;

// Calibration constants
const float AC_WALL_VOLTAGE = 220.0;
const float AC_ADAPTER_VOLTAGE = 6.37;
const float AC_VOLTAGE_DIV_VOUT = 1.12;
const float CT_RATIO = 30;

// Calibration coefficients
const float VCAL = 1.0;
const float ICAL = 1.0;
const float PHASECAL = 1.0;
// Calculated ratio constants, modified by VCAL/ICAL
const float AC_ADAPTER_RATIO = AC_WALL_VOLTAGE / AC_ADAPTER_VOLTAGE;
const float AC_VOLTAGE_DIV_RATIO = AC_ADAPTER_VOLTAGE / AC_VOLTAGE_DIV_VOUT;
const float V_RATIO = AC_ADAPTER_RATIO * AC_VOLTAGE_DIV_RATIO * 5/1024 * VCAL;
const float I_RATIO = CT_RATIO * 5 / 1024 * ICAL;

// Sample variables
int lastSampleV, lastSampleI, sampleV, sampleI;

// Filter variables
float lastFilteredV, lastFilteredI, filteredV, filteredI;

// Power sample totals
float sumI, sumV, sumP;

// Phase calibrated instantaneous voltage
float calibratedV;

// Calculated power variables
float realPower, apparentPower, powerFactor, voltageRMS, currentRMS;
unsigned long last_kWhTime, kWhTime;
float kilowattHour = 0.0;

void setup() {
lcd.begin(16,2);
}

void loop() {
calculatePower();
displayPower();
}

void calculatePower() {
for (int i = 0; i < numberOfSamples; i++) {
// Used for voltage offset removal
lastSampleV = sampleV;
lastSampleI = sampleI;

// Read voltage and current values
sampleV = analogRead(voltageSensor);
sampleI = analogRead(currentSensor);

// Used for voltage offset removal
lastFilteredV = filteredV;
lastFilteredI = filteredI;

// Digital high pass filters to remove 2.5V DC offset
filteredV = 0.996 * (lastFilteredV + sampleV - lastSampleV);
filteredI = 0.996 * (lastFilteredI + sampleI - lastSampleI);

// Phase calibration
calibratedV = lastFilteredV + PHASECAL * (filteredV - lastFilteredV);

// Root-mean-square voltage
sumV += calibratedV * calibratedV;

// Root-mean-square current
sumI += filteredI * filteredI;

// Instantaneous Power
sumP += abs(calibratedV * filteredI);

}

// Calculation of the root of the mean of the voltage and current squared (rms)
// Calibration coeficients applied
voltageRMS = V_RATIO * sqrt(sumV / numberOfSamples);
currentRMS = I_RATIO * sqrt(sumI / numberOfSamples);

// Calculate power values
realPower = V_RATIO * I_RATIO * sumP / numberOfSamples;
apparentPower = voltageRMS * currentRMS;
powerFactor = realPower / apparentPower;

// Calculate running total kilowatt hours
// This value will reset in 50 days
last_kWhTime = kWhTime;
kWhTime = millis();

// Convert watts into kilowatts and multiply by the time since the last reading in ms
kilowattHour += (realPower / 1000) * ((kWhTime - last_kWhTime) / 3600000.0);

// Reset sample totals
sumV = 0;
sumI = 0;
sumP = 0;
}
void displayPower() {
lcd.clear();
lcd.print(realPower, 0);
lcd.print("w ");
lcd.print(apparentPower, 0);
lcd.print("va ");
lcd.print(powerFactor * 100, 0);
lcd.print("%");
lcd.setCursor(0,1);
lcd.print(voltageRMS, 0);
lcd.print("v ");
lcd.print(currentRMS, 1);
lcd.print("a ");
lcd.print(kilowattHour, 4);
}

Robert Wall's picture

Re: How to Calibrate PHASECALL

That code looks as if it has been copied from here and altered for your book. Sorry, but I don't have the time to debug someone else's code. The author of the book is the person best placed to provide you with support.

Try this sketch. You will need emonLib. It will not drive a local display, and if you do not have the radio module, you will need to remove that from the sketch or it will hang.

[Edit]
I can see a mistake in the code. The power calculation is incorrect. It appears to be a deliberate change and if you have not changed the code out of the book, you'll need to ask the authors of the book why they have changed it from the original on this site. If it is their change, I think their understanding of electrical theory is suspect.

shaulagara's picture

Re: How to Calibrate PHASECALL

the power calculation is incorrect??

what do you mean? which part is wrong?? can you explain it? I've contacted the author but not yet replied.

im sorry, I forgot to remove the serial begin. I just changed Calibration coefficients and constans.

so this code will correctly calculate the power even when the current and voltage waves are distorted?? i didnt get it.

 

calypso_rae's picture

Re: How to Calibrate PHASECALL

shaulagara, I've just posted a set of results on a different thread which show a voltage and current waveform that are nicely in phase.   That's because the current is passing through a resistive load (a 2 kW heater), and the voltage transformer is not introducing much phase shift. 

PhaseCal is a software technique that introduces a phase shift in the voltage waveform.  When measuring a resistive load, phase shift has very little effect on Real Power.  I posted a video some months ago in which I introduced a phaseCal value of 5, and it made very little difference to the circuit's performance.

 

shaulagara's picture

Re: How to Calibrate PHASECALL

calypso_rae,

so in order to have a large effect on the real power I have tried in capacitive or inductive loads?

What's the title of the thread that you post video???

calypso_rae's picture

Re: How to Calibrate PHASECALL

All the videos that I've posted are listed on my Summary Page.

The particular one that I mentioned is at  http://www.youtube.com/watch?v=v8ifoUJvcXY 

Comment viewing options

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