Saturday, August 18, 2018

Arduino calculate the capacitor value for PFC

Calculation of capacitor value for PFC using Arduino

By this Arduino project you can find out the capacitor value needed for PFC (Power Factor Correction) using arduino without any mathematical process.



Following image show you the value given by arduino and the value given by the PFC app. that available for Android in google play for free. both give me the same value.

Arduino calculate the capacitor value for PFC

Then i connect a capacitor with value given by arduino and the PF become unity

Arduino calculate the capacitor value for PFC

When no load connected

Arduino calculate the capacitor value for PFC

When the load is resistive

Arduino calculate the capacitor value for PFC

Parts list:
Arduino board
Energy meter module Pzem-004t 
LCD 16x2 with I2C adapter board
Connecting wires


Wiring:

Arduino calculate the capacitor value for PFC


Video:







Code:

#include "math.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h> // Arduino IDE <1.6.6
#include <PZEM004T.h>
LiquidCrystal_I2C lcd(0x27,16,2);
PZEM004T pzem(2,3);  // (RX,TX) connect to TX,RX of PZEM


IPAddress ip(192,168,1,1);



void setup() {


  Serial.begin(9600);


  pzem.setAddress(ip);


  pinMode(9, OUTPUT);

}

void loop(){


 float v = pzem.voltage(ip);


  if (v < 0.0) v = 0.0;


  Serial.print(v);Serial.print("V; ");



  float i = pzem.current(ip);


  if (i < 0.0) i = 0.0;
 

  Serial.print(i);Serial.print("A; ");




  float p = pzem.power(ip);



   if (p < 0.0) p = 0.0;


  Serial.print(p);Serial.print("W; ");


 float Cap = ((((i)*sqrt(1-(((p)/(v*i))*((p)/(v*i)))))/(v*314))*1000000);

 float PF = ((p)/(v*i));

  Serial.print(Cap);Serial.print("uF ");

  Serial.print("PF= ");Serial.print((p)/(v*i));

 if (PF > 0.99){
      lcd.init();
      lcd.backlight();
      lcd.setCursor(0,0);
      lcd.print("Resistive Load");
      lcd.setCursor(0,1);
      lcd.print("No Cap. Needed");

  }
 
  else  if (PF < 0.99){

  Serial.println();
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Cap. Should Be =");
  lcd.setCursor(3,1);
  lcd.print(Cap);
  lcd.setCursor(8,1);
  lcd.print("uF");

  }

  if (i == 0.00){
      lcd.init();
      lcd.backlight();
      lcd.setCursor(4,0);
      lcd.print("No Load");
      
  }
}