Power factor measurment using Arduino

In this project i used arduino and XOR gate to power factor measurement.

What is power factor?
Power factor is a number between 0 and 1 refers to phase shift between voltage phase and current phase in AC appliance.

Power factor measurment using Arduino

How to measure PF with Microcontroller (Arduino)?

To measuring power factor with microcontrollers in first we used Op-Amp to zero cross detection to find the phase shift between current and voltage phase, the op-amp convert the sine wave signal comes from CT and PT with different amplitude to square wave with about 4v amplitude, then we connect these two square wave to XOR gate inputs. 
XOR gate output will be 1 just when the input have different signal so when the load is resistive XOR gate output is 0 because both voltage and current phases start and ends in the same time, but when the load is inductive or capacitive XOR output is 1 because there are phase shaft between voltage and current,

Power factor measurment using Arduino


Hence we can find the power factor by measuring the "ON-time" of XOR output, and put it in the power factor formula :


PF= COS(f*dt*360)

Where:
PF=Power Factor
f= Frequency
dt=Time difference between two phases and/or XOR output ON-time
Circuit:
Here we have two circuits, the first one using Current transformer(CT) and Voltage or potential transformer(PT), the only difference between them is that second circuit with no transformer and no insulation between microcontroller and main voltage so its dangerous if you touch any point in the circuit, but its cheap, small size, light weight and similar to commercial socket power meter.    
Filtering capacitors in this circuit is very important to removing power supply noise( voltage ripple) to insure logic gate works well.

Power factor measurment using Arduino
Power factor measurment using Arduino
Arduino LCD wiring:
Power factor measurment using Arduino

 
Results:

This picture shown voltage and current phases when PF=1


XOR output signal when PF=1



Power factor measurment using Arduino
Power factor measurment using Arduino



Power factor measurment using ArduinoPower factor measurment using Arduino



Power factor measurment using ArduinoPower factor measurment using Arduino



Power factor measurment using Arduino
Power factor measurment using Arduino



NOTES:
1-This project deal with main voltage so its dangerous.
2-However transformers haven't polarity but here transformer winding point(dot) is very important, because if CT and PT dot don't match, the arduino will read low PF even with pure resistive load.

Power factor measurment using Arduino


In this video you can see how this project works:



 
You can improve this project to power factor correction by adding some relay and capacitor and improving the code.


Parts list:
Arduino board
IC 4030 or IC 4070 (XOR gate)
Voltage Transformer 15V or less
Current transformer
Resistor 100K
Resistor 220 ohm
Potentiometer 10K or 100K
Capacitor 47pF (2pcs)
Capacitor 100nF
Capacitor470uF
LCD display 16x2
Diode 1N4148 (4pcs)
LM324 or 741(2pcs)


CODE:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int pin = 13;
float rads = 57.29577951; // 1 radian = approx 57 deg.
float degree = 360;
float frequency = 50;
float nano = 1 * pow (10,-6); // Multiplication factor to convert nano seconds into seconds

// Define floats to contain calculations

float pf;
float angle;
float pf_max = 0;
float angle_max = 0;
int ctr;

void setup()
{
 pinMode(pin, INPUT);
 Serial.begin(9600);
 lcd.begin(16, 2);
}

void loop()
{
 
for (ctr = 0; ctr <= 4; ctr++) // Perform 4 measurements then reset
  {
  // 1st line calculates the phase angle in degrees from differentiated time pulse
  // Function COS uses radians not Degree's hence conversion made by dividing angle / 57.2958
   angle = ((((pulseIn(pin, HIGH)) * nano)* degree)* frequency);
  // pf = cos(angle / rads);
  
   if (angle > angle_max) // Test if the angle is maximum angle
     {
      angle_max = angle; // If maximum record in variable "angle_max"
      pf_max = cos(angle_max / rads); // Calc PF from "angle_max"
     }
   }
   if (angle_max > 360) // If the calculation is higher than 360 do following...
   {
    angle_max = 0; // assign the 0 to "angle_max"
    pf_max = 1; // Assign the Unity PF to "pf_max"
   }
   if (angle_max == 0) // If the calculation is higher than 360 do following...
   {
    angle_max = 0; // assign the 0 to "angle_max"
    pf_max = 1; // Assign the Unity PF to "pf_max"
   }
   Serial.print(angle_max, 2); // Print the result
   Serial.print(",");
   Serial.println(pf_max, 2);
  lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("PF=");
   lcd.setCursor(4,0);
   lcd.print(pf_max);
   lcd.print(" ");
   lcd.setCursor(0,1);
   lcd.print("Ph-Shift=");
   lcd.setCursor(10,1);
   lcd.print(angle_max);
   lcd.print(" ");
  
   //delay(500);
   angle = 0; // Reset variables for next test
   angle_max = 0;
}

Comments

Popular posts from this blog

A2XWY; A2XFY Cables meaning; XLPE cables advantages over PVC cables

Digital Multimeter working principle; DMM working

Wireless voltmeter using Arduino and RF 433MHz receiver and transmitter