### Computing AC voltage & phase difference(HELP)

Hey everyone! I've connected the input based on this link from the building blocks: http://openenergymonitor.org/emon/buildingblocks/measuring-voltage-with-an-acac-power-adapter

I'm able to read the value from the arduino and I know you have to compute the values based on this link: http://playground.arduino.cc/Main/DirectMathVoltmeter

1) The value from analog input on the arduino needs to divide 1023 then *5 and afterwards I have to divide back the Resistors 1 & 2 to get the values before the voltage dividing. What comes after that? What about the transformer AC-AC power adapter? Shouldn't I need another math to step back up the values to get the final measurement?

2) I've looked at this link:http://openenergymonitor.org/emon/buildingblocks/arduino-sketch-voltage-and-current

and I want to ask if it is the measurement of the phase difference of the two inputs current & voltage?

Here is my code:

const int analogIn0 = A0;
const int analogIn1 = A1;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
int RawCurrentValue= 0;
int RawVoltageValue= 0;
int ACSoffset = 2500;
int Denominator = 0;
float AcVoltage = 0;
float Voltage0 = 0;
float Voltage1 = 0;
float Amps = 0;

void setup(){
Serial.begin(9600);
}

void loop(){

Denominator = (10000)/(130000);

Voltage0 = (RawCurrentValue / 1023.0) * 5000;
Voltage1 = (RawVoltageValue / 1023.0) * 5000;
AcVoltage = (Voltage1 / Denominator ) ;
Amps = ((Voltage0 - ACSoffset) / mVperAmp);

Serial.print(Amps);
Serial.print(", ");
Serial.println(AcVoltage);

}

If it is, how do I do the measurement on this code?

### Re: Computing AC voltage & phase difference(HELP)

The "Building Blocks" pages are just that - the essential first steps. I suggest you download and study emonLib - that is a set of fully developed methods, one is used in the sketch that you link to, and that will in fact give you - indirectly - the phase difference between current and voltage. I say 'indirectly' because what calcVI does is it calculates real power, rms voltage and rms current. Multiply the last two together and you have apparent power, and the ratio of real power to apparent power is power factor. Provided that both current and voltage are pure sinusoids, power factor = cos(φ). If one or both are not pure sinuoids, phase angle only has a meaning for the individual harmonics that make up the complex wave. I think the angle φ is what you're asking for.

## Comment viewing options

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