Automatic Power Factor Controller Using Pic Microcontroller
Automatic Power Factor Controller Using Pic Microcontroller
microcontroller
Automatic power factor controller project is designed to improve power factor automatically
whenever power factor falls below a certain level. As you know demand of electrical energy is
increasing day by day. More and more inductive loads are being used in industry and domestic
applications. Inductive loads are main reason for low power factor in power system. Therefore
we need to develop a method to improve power factor automatically. Automatic power controller
project provides solution to this problem. Low power factor includes unnecessary burden on
power system and transmission lines. By improving power factor of power system automatically,
power system efficiency can be improved. In this project, power factor correction prototype is
developed using pic microcontroller, relays, potential transformer,current transformer and zero
crossing circuit.
Page Contents [hide]
Capacitor bank
12 volt relays
Liquid crystal display
PIC16F877A microcontroller main heart of APFC project.
LM358 used as zero crossing detector
TMR1H=0;
do
{
if(PORTA.F0 == 1)
T1CON.F0 = 1;
else if(PORTA.F0 == 0 && T1CON.F0 == 1)
{
T1CON.F0 = 0;
break;
}
}while(1);
a = (TMR1L | (TMR1H<<8)) * 2;
TMR1L=0;
TMR1H=0;
do
{
if(PORTA.F0 == 1)
{
T1CON.F0=1;
if(PORTA.F1==1)
{
T1CON.F0=0;
break;
}
}
}while(1);
b = TMR1L | (TMR1H<<8);
tm = (float)b/a;
pf = cos(tm*2*3.14);
x=abs(ceil(pf*100));
return x;
}
void main()
{
char c[]="0.00";
int a,b,d,x,f,e;
float tm,pf;
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
ADCON1 = 0x08; // To configure PORTA pins as digital
TRISA.F0 = 1; // Makes First pin of PORTA as input
TRISA.F1 = 1; //Makes Second pin of PORTA as input
TRISD.F0 = 0; //Makes Fist pin of PORTD as output
TRISD.F1 = 0; //Makes Second pin of PORTD as output
while(1)
{
a = powerFactor();
Delay_us(50);
b = powerFactor();
Delay_us(50);
d = powerFactor();
Delay_us(50);
e = powerFactor();
Delay_us(50);
f = powerFactor();
x = (a+b+d+f+e)/5;
c[3]=x%10 + 0x30;
x=x/10;
c[2]=x%10 + 0x30;
x=x/10;
c[0]=x%10 + 0x30;
Lcd_Out(1,1,"Power Factor");
Lcd_Out(2,1,c);
if(x<90)
{
PORTD.F0 = 1;
PORTD.F0 = 1;
Delay_ms(2000);
}
else
{
PORTD.F0 = 0;
PORTD.F0 = 0;
}
Delay_ms(250);
}
}