In the modern era of technology, efficient energy management is crucial for both residential and industrial sectors. One of the key aspects of efficient energy usage is maintaining an optimal power factor. Power factor correction is essential for reducing power losses and improving the efficiency of power systems. This blog will guide you through building an Automatic Power Factor Controller (APFC) using a current transformer, step-down transformer, 8051 microcontroller, relay, and other components. This innovative project is perfect for engineering students and enthusiasts looking to delve into practical applications of power electronics.
Introduction
Power factor is a measure of how effectively electrical power is being used. An ideal power factor is unity (1), but in real-world scenarios, it often falls below this value due to inductive loads. An Automatic Power Factor Controller (APFC) can help in maintaining an optimal power factor by automatically switching capacitor banks on or off as required. This not only improves the efficiency of the power system but also reduces electricity bills and avoids penalties from utility companies. If you want you can directly download the Synopsis , power point presentation and Report directly in a single click from Below:-
Video Demonstration :-
Components Used
To build an Automatic Power Factor Controller, the following components are required:
1. Current Transformer (CT): Used to measure the current flowing through the circuit.
2. Step-Down Transformer: Converts high voltage to a lower voltage suitable for the microcontroller.
3. 8051 Microcontroller: Acts as the brain of the system, processing data and controlling other components.
4. Red and Green LED Indicators: Indicate the status of the power factor correction.
5. Relay: Switches the capacitor banks on and off.
6. Current Sensing Unit: Measures the current and sends the data to the microcontroller.
7. Capacitor Bank (4 capacitors): Used for power factor correction.
8. Inductive, Capacitive, and Resistive Load Selector: Allows the selection of different types of loads for testing.
9. Resistors, Capacitors, Diodes: Various passive components for circuit completion.
Working
The working of an Automatic Power Factor Controller can be understood in the following steps:
Current Measurement: The current transformer measures the current flowing through the load and sends this data to the current sensing unit.
Voltage Step-Down: The step-down transformer reduces the voltage to a level suitable for the microcontroller.
Data Processing: The 8051 microcontroller receives the current and voltage data, calculates the power factor, and determines if correction is needed.
Indicator Status: Based on the power factor, the microcontroller activates the red or green LED indicators. A green LED indicates an optimal power factor, while a red LED indicates a need for correction.
Capacitor Bank Activation: If correction is needed, the microcontroller activates the relay, switching on the required number of capacitors from the capacitor bank to correct the power factor.
Continuous Monitoring: The system continuously monitors the power factor and makes adjustments as necessary.
Block Diagram

Circuit Diagram


🔌 Circuit Connections of APFC using 8051 Microcontroller
Let’s break down the circuit into smaller sections so it’s easy to understand. This project mainly includes a microcontroller, LCD display, relays, simulated CT input, LEDs, and a buzzer.
🧠 1. Microcontroller (AT89C51 / 8051)
- Port 0 (P0.0 to P0.7): These pins are connected to the data pins (D0 to D7) of the 16×2 LCD display.
- Port 2:
- P2.7 (RS): Controls LCD Register Select.
- P2.6 (RW): LCD Read/Write (usually tied to GND to keep in Write mode).
- P2.5 (EN): LCD Enable pin.
- P2.4 to P2.1: Connected to relays that switch ON capacitor banks (1 kVAR, 2 kVAR, and 3 kVAR).
- P2.0: Connected to a relay that controls the load connection.
- Port 3:
- P3.0: Green LED – indicates good power factor.
- P3.1: Red LED – shows poor power factor.
- P3.2: Buzzer – sounds during correction process.
- Port 1:
- P1.0: Push button or switch used to simulate load type (resistive or inductive).
- P1.1: Takes input from a potentiometer to simulate CT (current transformer) values.
📺 2. LCD Display (16×2)
- D0–D7: Connected to P0.0–P0.7 of the microcontroller.
- RS, RW, EN: Connected to P2.7, P2.6, and P2.5 respectively.
- VSS and VDD: Connected to GND and +5V power supply.
- VEE (contrast): Connected to the middle terminal of a 10k potentiometer.
🔄 3. Simulated CT (Current Transformer)
Instead of using an actual CT sensor, we use a 10k potentiometer connected to P1.1 to vary the current input manually. In real-time use, a CT would be connected through a signal conditioner and ADC.
⚙️ 4. Relay Connections
- Each relay is controlled using an NPN transistor (e.g., BC547).
- The base of the transistor is connected through a 1kΩ resistor to a microcontroller pin (P2.0–P2.4).
- Relay coil is connected between +12V and the transistor collector.
- A diode (like 1N4007) is placed across each relay coil to protect from voltage spikes when switching.
🔊 5. LEDs and Buzzer
- Green LED (P3.0): Lights up when power factor is good.
- Red LED (P3.1): Turns on when power factor is poor.
- Buzzer (P3.2): Gives an alert sound during power factor correction.
- LEDs are connected through 220Ω resistors to limit the current.
🔁 Working of the APFC Circuit
⚡ Step 1: Power On
- When the system is powered on, the LCD shows a welcome message like “Power Factor Controller”.
- All relays and indicators are set to their initial states.
🔘 Step 2: Load Selection
- A switch connected to P1.0 lets you choose the type of load:
- If the switch is ON (logic HIGH) → Load is resistive (like heaters or bulbs). Power factor is already good, so no correction needed.
- If the switch is OFF (logic LOW) → Load is inductive (like motors). This causes low power factor, so correction is required.
📉 Step 3: Reading Current
- The potentiometer connected to P1.1 acts like a current transformer input.
- Based on the voltage from this input, the microcontroller calculates the current value.
- Then it calculates:
- Apparent Power (VA) = Voltage × Current
- Real Power (Watts) = Apparent Power × PF
- Reactive Power (VAR) = √(VA² – Real Power²)
- Power Factor (PF) = Real Power ÷ Apparent Power
🔄 Step 4: Automatic Correction
- If the power factor is low, the microcontroller turns ON capacitor banks one by one using relays:
- If more than 3 kVAR is needed, turn on Relay 3.
- For 2 kVAR, turn on Relay 2.
- For 1 kVAR, turn on Relay 1.
- The buzzer beeps during this correction to notify action.
- Once the PF reaches acceptable levels (≥ 0.95), it turns on the green LED.
🖥️ Step 5: LCD Display
- The LCD keeps updating in real-time:
- Top Line: Shows Voltage and Current
- Bottom Line: Shows Real Power and Power Factor
🧾 Required Components List
Component | Quantity | Description |
---|---|---|
8051 Microcontroller (AT89C51) | 1 | Main controller for logic and display |
16×2 LCD Display | 1 | To display power factor and power values |
Relays (5V or 12V) | 4 | Switches for load and capacitor banks |
Capacitor Banks | 3 | Used for improving power factor (1, 2, 3 kVAR) |
NPN Transistors (BC547) | 4 | Used to drive the relay coils |
Diodes (1N4007) | 4 | Flyback protection for relays |
Potentiometer (10k) | 2 | One for LCD contrast, one to simulate current input |
LEDs (Green, Red) | 1 each | Indicators for system status |
Buzzer | 1 | Alert during correction process |
Push Button | 1 | To switch between resistive and inductive loads |
Resistors (1k, 220Ω) | As needed | For LEDs and transistor base pins |
5V & 12V Power Supply | 1 each | For microcontroller and relays respectively |
Program / Code of the Project :-
#include<reg51.h>
#include<math.h> // Added for power factor calculations
#define dataport P0
#define key P3
sbit rs = P2^7;
sbit rw = P2^6;
sbit en = P2^5;
sbit relay = P2^0; // Main load relay
sbit relay1 = P2^1; // Capacitor bank 1 (1 kVAR)
sbit relay2 = P2^2; // Capacitor bank 2 (2 kVAR)
sbit relay3 = P2^3; // Capacitor bank 3 (3 kVAR)
sbit relay4 = P2^4; // Reserved for future expansion
sbit sw = P1^0; // Toggle switch for load selection
sbit green = P3^0; // Green LED (good PF)
sbit red = P3^1; // Red LED (bad PF)
sbit buzzer = P3^2; // Buzzer for alarm
sbit ct_input = P1^1; // Simulated CT input (connect to potentiometer in hardware)
// Global variables for simulated measurements
unsigned int voltage = 220; // Simulated voltage (220V)
unsigned int current_raw = 0; // Raw CT reading
float current = 0; // Calculated current
float apparent_power = 0; // VA
float real_power = 0; // W
float reactive_power = 0; // VAR
float power_factor = 0; // PF
unsigned int phase_angle = 0; // Degrees
void delay(unsigned int msec) //Time delay function
{
int i,j;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
void lcd_cmd(unsigned char item) //Function to send command to LCD
{
dataport = item;
rs= 0;
rw=0;
en=1;
delay(1);
en=0;
return;
}
void lcd_data(unsigned char item) // Function to send data to LCD
{
dataport = item;
rs= 1;
rw=0;
en=1;
delay(1);
en=0;
return;
}
void lcd_data_string(unsigned char *str) // Function to send string to LCD
{
int i=0;
while(str[i]!='\0')
{
lcd_data(str[i]);
i++;
}
return;
}
void lcd(unsigned char str[10]) // Function to send string to LCD
{
lcd_cmd(0x38);
lcd_cmd(0x0e);
lcd_data_string(str);
}
// Function to read simulated CT input (replace with actual ADC in hardware)
unsigned int read_ct_input()
{
// In real implementation, this would read from ADC
// For simulation, we'll use a fixed pattern that changes with time
static unsigned int simulated_value = 100;
simulated_value += 5;
if(simulated_value > 200) simulated_value = 100;
return simulated_value;
}
// Function to calculate power parameters
void calculate_power_parameters(int load_type)
{
// Read simulated current
current_raw = read_ct_input();
// Convert raw reading to current (simulated)
current = current_raw / 10.0; // Scaling factor
// Calculate apparent power
apparent_power = voltage * current;
// Calculate real and reactive power based on load type
if(load_type == 0) // Resistive load
{
real_power = apparent_power;
reactive_power = 0;
power_factor = 1.0;
phase_angle = 0;
}
else // Inductive load
{
// Simulate varying power factor for inductive load
static float pf_variation = 0.5;
pf_variation += 0.05;
if(pf_variation > 0.7) pf_variation = 0.5;
power_factor = pf_variation;
phase_angle = (unsigned int)(acos(power_factor) * 180 / 3.1415);
real_power = apparent_power * power_factor;
reactive_power = sqrt(apparent_power*apparent_power - real_power*real_power);
}
}
// Function to display power parameters on LCD
void display_power_parameters()
{
char lcd_buffer[16];
// Line 1: Voltage and Current
lcd_cmd(0x80);
sprintf(lcd_buffer, "V:%3dV I:%4.1fA", voltage, current);
lcd_data_string(lcd_buffer);
// Line 2: Power and PF
lcd_cmd(0xC0);
sprintf(lcd_buffer, "P:%4.0fW PF:%1.2f", real_power, power_factor);
lcd_data_string(lcd_buffer);
delay(500);
}
// Function to automatically correct power factor
void auto_correct_pf()
{
// Only correct if PF is below threshold
if(power_factor < 0.95)
{
float required_correction = reactive_power / 1000; // in kVAR
// Determine which capacitors to switch based on required correction
if(required_correction > 3.0 && relay3 == 1)
{
relay3 = 0; // Switch 3 kVAR capacitor
buzzer = 0; // Brief buzzer beep
delay(100);
buzzer = 1;
}
else if(required_correction > 2.0 && relay2 == 1)
{
relay2 = 0; // Switch 2 kVAR capacitor
buzzer = 0;
delay(100);
buzzer = 1;
}
else if(required_correction > 1.0 && relay1 == 1)
{
relay1 = 0; // Switch 1 kVAR capacitor
buzzer = 0;
delay(100);
buzzer = 1;
}
// Recalculate power parameters after correction
calculate_power_parameters(1);
// Update display
lcd_cmd(0x01);
display_power_parameters();
// If PF is now good, turn on green LED
if(power_factor >= 0.95)
{
green = 1;
red = 0;
}
else
{
green = 0;
red = 1;
}
}
else
{
green = 1;
red = 0;
}
}
void main()
{
red = green = 0;
buzzer = 1;
// Initialize all relays to off
relay = relay1 = relay2 = relay3 = relay4 = 1;
// Initialize LCD
lcd_cmd(0x01);
lcd_cmd(0x38);
lcd_cmd(0x0C);
// Show welcome message
lcd_cmd(0x01);
lcd_cmd(0x80);
lcd("Power Factor");
lcd_cmd(0xC0);
lcd(" Controller");
delay(350);
delay(350);
delay(350);
while(1)
{
if(sw == 1) // Resistive load
{
relay = 0; // Turn on resistive load
relay1 = 1; // Turn off all capacitors
relay2 = 1;
relay3 = 1;
relay4 = 1;
// Calculate power parameters
calculate_power_parameters(0);
// Display parameters
lcd_cmd(0x01);
display_power_parameters();
// Good PF indication
green = 1;
red = 0;
while(sw == 1);
}
else // Inductive load
{
relay = 1; // Turn off resistive load
relay1 = 1; // Start with all capacitors off
relay2 = 1;
relay3 = 1;
relay4 = 1;
// Calculate initial power parameters
calculate_power_parameters(1);
// Display initial parameters
lcd_cmd(0x01);
display_power_parameters();
// Bad PF indication
green = 0;
red = 1;
// Automatic correction sequence
delay(1000); // Wait before starting correction
// Perform automatic correction
auto_correct_pf();
// Keep monitoring and correcting while in inductive mode
while(sw == 0)
{
// Simulate small load variations
calculate_power_parameters(1);
display_power_parameters();
auto_correct_pf();
delay(1000);
}
}
}
}
Code Explanation:-
🔧 1. Purpose of the Project
The main goal is to maintain the Power Factor (PF) near 1.0 by switching capacitor banks automatically in an inductive load situation.
- If the PF drops below 0.95, capacitors are added to correct it.
- Uses relay-controlled capacitors (1, 2, and 3 kVAR) to compensate for reactive power.
- A CT input is simulated for current measurement.
- Uses LCD display to show voltage, current, power, and PF.
- Green and red LEDs indicate good/bad PF, and buzzer gives feedback.
⚙️ 2. Hardware Components (Pin Mapping)
Pin | Description |
---|---|
P0 | LCD Data port |
P2.7–P2.5 | LCD Control (RS, RW, EN) |
P2.0–P2.4 | Main Relay and Capacitor Relays |
P3.0 | Green LED |
P3.1 | Red LED |
P3.2 | Buzzer |
P1.0 | Load type switch |
P1.1 | CT input (simulated) |
🔁 3. Working Logic (Main Loop)
🟢 a. On Startup:
- Turns off all relays.
- Initializes the LCD.
- Displays “Power Factor Controller” welcome message.
🟡 b. Load Selection:
- The system uses a switch
sw = P1.0
to detect the type of load: ✅ Ifsw == 1
: Resistive Load- Relay is ON (resistive load connected).
- Capacitor banks are OFF.
- Power factor = 1.0 (ideal).
- Green LED ON.
- Red LED OFF.
- Power parameters are calculated and displayed.
sw == 0
: Inductive Load- Resistive load relay is OFF.
- Capacitor banks are OFF initially.
- Simulates low PF (0.5 to 0.7) with reactive power.
- Red LED ON.
- Green LED OFF.
- Displays the PF, voltage, and power.
- Then calls
auto_correct_pf()
to correct the power factor.
🧠 4. Important Functions Explained
📌 read_ct_input()
- Simulates reading from a current transformer (CT) using a counter (in real case: ADC).
- Returns a value between 100–200.
📌 calculate_power_parameters(int load_type)
- Reads the current from CT simulation.
- Calculates:
- Apparent Power (VA) = Voltage × Current
- Real Power (W) = Apparent × Power Factor
- Reactive Power (VAR) = √(VA² – W²)
- PF = 1 for resistive, varies for inductive (0.5–0.7)
- Phase angle = acos(PF) in degrees
📌 display_power_parameters()
- Sends 2 lines to the LCD:
- Line 1: Voltage & Current
- Line 2: Real Power & Power Factor
📌 auto_correct_pf()
- Checks if PF is less than 0.95.
- Calculates how much reactive power (in kVAR) is needed to fix it.
- Turns ON relays of capacitor banks in this priority:
- First 3kVAR → Then 2kVAR → Then 1kVAR
- Buzzes briefly when any relay switches.
- Recalculates and updates the display after correction.
- Sets LED indicators based on the new PF.
🔄 5. Continuous Monitoring
- If inductive load is active:
- System keeps recalculating and correcting every 1 second.
- Keeps the PF ≥ 0.95 by dynamically switching capacitors ON/OFF.
📊 Example Simulation:
Case | Current (CT) | PF | Reactive Power | Action |
---|---|---|---|---|
1 | 12A | 0.6 | ~211 VAR | Switch 1kVAR ON |
2 | 15A | 0.55 | ~280 VAR | Switch 2kVAR ON |
3 | 18A | 0.5 | ~360 VAR | Switch 3kVAR ON |
✅ Visual Indicators
- Green LED ON → PF is good (≥ 0.95)
- Red LED ON → PF is poor (< 0.95)
- Buzzer Beep → Capacitor bank is switched
🧠 Summary of Logic:
plaintextCopyEdit[ Start ]
↓
[ Show Welcome ]
↓
[ Check Load Type ]
↓
Resistive? → Maintain Good PF (no correction)
↓
Inductive?
↓
→ Simulate poor PF
→ Show readings
→ Auto-correct using capacitor banks
→ Recalculate PF
→ Update LEDs and LCD
↓
Repeat Every 1s
Applications
The Automatic Power Factor Controller has a wide range of applications:
Industrial Plants: For maintaining optimal power factor in large machinery and equipment.
Commercial Buildings: To reduce electricity bills by improving power factor.
Residential Homes: For energy-efficient power usage.
Power Distribution Systems: To minimize power losses and improve system efficiency.
Renewable Energy Systems: For efficient power management in solar and wind energy systems.
Advantages
Energy Efficiency: Reduces power losses and improves overall system efficiency.
Cost Savings: Lowers electricity bills and avoids penalties from utility companies.
Automatic Operation: Does not require manual intervention for power factor correction.
Improved Equipment Life: Reduces strain on electrical equipment, extending their lifespan.
Easy Integration: Can be integrated into existing power systems with minimal modifications.
Disadvantages
Initial Cost: The setup cost can be high due to the components required.
Complexity: Requires a good understanding of power electronics and microcontroller programming.
Maintenance: Periodic maintenance may be needed to ensure accurate operation.
Space Requirement: The capacitor bank and other components require adequate space for installation.
Future Scope
The future scope of Automatic Power Factor Controllers includes:
Smart Grid Integration: Enhancing APFC systems to work seamlessly with smart grids for better energy management.
IoT Connectivity: Adding IoT features for remote monitoring and control via smartphones and computers.
AI Integration: Using artificial intelligence to predict and optimize power factor correction dynamically.
Scalability: Developing scalable solutions for larger industrial applications.
Energy Storage Systems: Integrating with energy storage systems for enhanced efficiency and reliability.
✅ Summary
This APFC system using an 8051 microcontroller helps improve the power factor automatically by switching capacitor banks based on real-time power calculations. It simulates load behavior using a switch and current input through a potentiometer. The system gives clear visual (LEDs, LCD) and audio (buzzer) feedback, making it both informative and efficient.
Conclusion
Building an Automatic Power Factor Controller is an innovative project that offers numerous benefits for efficient energy management. By using a combination of current transformers, microcontrollers, and capacitor banks, you can create a system that automatically maintains an optimal power factor, reducing power losses and saving costs. This project not only serves as a practical application of engineering principles but also contributes to sustainable energy usage.
For those looking to delve deeper into power electronics and control systems, this project is a perfect starting point. By continuously improving and integrating new technologies, the future of Automatic Power Factor Controllers looks promising, with potential applications in various fields. Start your journey towards efficient energy management today by building your own Automatic Power Factor Controller.
By following this guide, you can create a highly efficient system that not only meets the current demands but also paves the way for future innovations in power factor correction and energy management.