Automatic Power Factor Controller Using 8051 Microcontroller – Complete Student Guide

Fully assembled APFC controller kit for engineering students

🧠 Introduction

An automatic power factor controller using 8051 microcontroller is one of the most important learning projects for electrical and electronics engineering students. Power factor plays a critical role in how efficiently electrical energy is used, especially in systems that involve motors, transformers, and inductive loads.

In real-world electrical installations, low power factor leads to higher current, increased losses, voltage drops, and penalties from electricity boards ⚡. This project helps students understand, measure, and automatically correct power factor using embedded control logic instead of manual calculation.

If you are preparing for final year projects, lab demonstrations, or viva, this project builds strong conceptual clarity while also showing real industrial relevance 🧠.


🎯 Project Overview and Objective

The main objective of this project is to automatically improve power factor by switching capacitor banks based on real-time load conditions.

This project is designed for:

  • Diploma, ITI, BSc, BTech, MTech students
  • Electrical and electronics engineering labs
  • Practical demonstrations and evaluations

What problem does it solve?

Inductive loads such as motors draw reactive power, which reduces power factor. This project detects poor power factor and automatically compensates it using capacitor banks, improving system efficiency and power quality 📈.

👉 Download Project PPT , Synopsis & report

Engineering students can download the complete project documentation below. The ZIP file includes a detailed synopsis and a ready-to-use PPT for seminars, viva, and Presentations.



This article belongs to the Automatic Power Factor Correction (APFC) Project Hub, which presents and compares different implementation approaches used for power factor correction.


Students who wish to implement this design practically can use the Ready-Made Project Kit, suitable for lab demonstrations, evaluations, and final-year submissions.

Video Demonstration :-

Innovative automatic power factor correction project
Automatic power factor controller Project
How to Build an Automatic Power Factor Controller | Electrical Project

🔌 Components Used (Detailed Explanation)

ComponentPurpose in the ProjectWhy This Component Is Used
Current Transformer (CT)Measures the load current flowing through the systemThe CT provides electrical isolation and safely converts high line current into a proportional low-level signal. This current information is essential for calculating apparent power, reactive power, and power factor in real-time ⚡.
Step-Down TransformerSteps down high AC mains voltage to a lower levelSince the microcontroller operates at low voltage (5V), the step-down transformer reduces the mains voltage to a safe level, which is later rectified and regulated for control circuitry 🔋.
8051 Microcontroller (AT89C51)Central control and decision-making unitThe 8051 microcontroller acts as the brain of the APFC system. It reads current inputs, performs power factor calculations, controls relays for capacitor switching, and updates the LCD display 🧠.
Relay ModuleSwitches capacitor banks automaticallyRelays electrically isolate the low-power microcontroller from high-power capacitor banks. They allow automatic connection and disconnection of capacitors based on power factor requirements 🔌.
Capacitor Bank (Multiple Capacitors)Supplies reactive power for correctionCapacitors provide leading reactive power that compensates for lagging reactive power caused by inductive loads. Different capacitor values allow step-wise power factor correction 📈.
Current Sensing UnitSignal conditioning for CT outputThe raw CT signal is conditioned using resistors and filtering components so that it can be safely read by the microcontroller. This ensures accurate and stable current measurement 📊.
Inductive, Capacitive, and Resistive Load SelectorSimulates different load conditionsThis selector allows students to test the system under various load types. Inductive loads create low power factor, resistive loads maintain unity power factor, and capacitive loads help understand over-correction scenarios 🧪.
LCD Display (16×2)Displays electrical parameters and system statusThe LCD shows voltage, current, real power, and power factor values in real time. It also helps during demonstrations, viva, and debugging by providing visual feedback 📟.
Red and Green LEDsVisual indication of power factor statusThe green LED indicates acceptable power factor, while the red LED warns of poor power factor. These indicators make the system intuitive and easy to understand during demos 🚦.
BuzzerAudible alert during correctionThe buzzer provides an audio indication when capacitor banks are switched ON or OFF. This helps students clearly observe correction events during practical demonstrations 🔔.
ResistorsCurrent limiting and biasingResistors are used for LED current limiting, transistor base biasing, and signal conditioning. They protect components and ensure stable operation of the circuit 🔧.
Capacitors (Passive)Filtering and voltage stabilizationThese capacitors smooth rectified DC voltage and reduce noise in the power supply and signal paths, ensuring reliable microcontroller operation 🔋.
Diodes (e.g., 1N4007)Protection and rectificationDiodes are used for AC to DC rectification and as flyback diodes across relay coils to protect transistors and the microcontroller from voltage spikes ⚠️.
Transistors (e.g., BC547)Relay driving and signal amplificationSince microcontroller pins cannot drive relays directly, transistors are used as switching amplifiers to safely control relay coils 💡.

This component combination closely reflects industrial APFC panels, making the learning highly practical 🔌.


🔷 Block Diagram and Working Logic

ALT: automatic power factor controller using 8051 microcontroller block diagram explained

The block diagram explains how signals flow through the system:

  1. Load draws current from the supply
  2. Current transformer senses load current
  3. Microcontroller calculates power factor
  4. Decision logic compares PF with threshold
  5. Relays switch capacitor banks accordingly
  6. LCD and indicators display system status

This flow helps students visualize how measurement → decision → correction happens automatically 🧠.

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.

Circuit Diagram

8051 microcontroller Section with Audio Visual Indicators
Relay circuit with Darlington pair configuration as a driver.

🔌 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

The Automatic Power Factor Controller continuously monitors the load condition and automatically corrects the power factor by switching capacitor banks whenever required. The complete working is explained step by step below 👇


⚡ Step 1: Power ON and System Initialization

When the system is powered ON, the 8051 microcontroller initializes all peripherals.
The LCD displays a welcome message such as “Power Factor Controller”, and all relays, LEDs, and the buzzer are set to their default OFF state.

This ensures the system starts from a safe and known condition before measurement begins.


🔘 Step 2: Load Selection

A switch connected to P1.0 allows selection of the load type:

  • Switch ON (Logic HIGH)Resistive Load
    Examples: bulbs, heaters
    Power factor is already close to unity, so no correction is required.
  • Switch OFF (Logic LOW)Inductive Load
    Examples: motors, coils
    Inductive loads reduce power factor, so correction becomes necessary.

This step helps students clearly understand how different loads affect power factor 🧠.


📉 Step 3: Current Measurement and Power Calculation

A potentiometer connected to P1.1 is used to simulate the current transformer (CT) input.

Based on this input, the microcontroller calculates:

  • Apparent Power (VA) = Voltage × Current
  • Real Power (W) = Apparent Power × Power Factor
  • Reactive Power (VAR) = √(VA² − W²)
  • Power Factor (PF) = Real Power ÷ Apparent Power

These calculations form the core logic of the APFC system and are critical for correction decisions ⚡.


🔄 Step 4: Automatic Power Factor Correction

If the calculated power factor is below the preset threshold (typically 0.95), the microcontroller activates the relay-controlled capacitor banks step by step:

  • If high correction is required → 3 kVAR capacitor ON
  • For moderate correction → 2 kVAR capacitor ON
  • For fine correction → 1 kVAR capacitor ON

Each time a capacitor is switched, the buzzer briefly sounds to indicate correction activity 🔔.

Once the power factor reaches an acceptable level, the green LED turns ON, indicating successful correction.


🖥️ Step 5: Real-Time LCD Display

The LCD continuously updates the system parameters:

  • Top Line: Voltage and Current
  • Bottom Line: Real Power and Power Factor

This live display makes the project extremely useful for demonstration, viva, and lab experiments 📟.


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:-

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.

Hardware Components (Pin Mapping)

PinDescription
P0LCD Data port
P2.7–P2.5LCD Control (RS, RW, EN)
P2.0–P2.4Main Relay and Capacitor Relays
P3.0Green LED
P3.1Red LED
P3.2Buzzer
P1.0Load type switch
P1.1CT input (simulated)

🏭 Applications

  • Electrical engineering laboratories
  • Industrial power factor improvement systems
  • Energy management studies
  • Technical exhibitions and competitions
  • Research and advanced learning projects

✅ Advantages

Industry-relevant logic and design

Strong conceptual clarity for power factor correction

Real-time embedded system exposure

Suitable for viva and evaluation

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 and Enhancements

Smart grid and industrial automation integration

IoT-based monitoring dashboards 🌐

GSM or WiFi alerts for power quality

AI-based predictive correction 🤖

✅ 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.

🔗 Internal Resource Links

🛒 Want a Fully Assembled Version of This Project?

If you are a student who wants to focus on understanding, demonstration, and viva instead of hardware troubleshooting, you can directly use the fully assembled automatic power factor controller project available on Circuits Bazaar.

❓ Frequently Asked Questions

Q1. What is an automatic power factor controller using 8051 microcontroller?

A. An automatic power factor controller using 8051 microcontroller is an embedded system that continuously monitors electrical load conditions and improves power factor by switching capacitor banks automatically. It helps reduce reactive power, minimize energy losses, and improve system efficiency. This project is widely used for academic learning, lab demonstrations, and industrial understanding ⚡.

Q2. Why is power factor correction important in electrical systems?

A. Power factor correction is important because a low power factor causes higher current flow, increased copper losses, voltage drops, and penalties from electricity boards. By improving power factor, electrical systems operate more efficiently, equipment life improves, and energy costs are reduced 📉.

Q3. Is this automatic power factor controller project suitable for final year students?

A. Yes, this project is highly suitable for final year engineering, diploma, and ITI students. It covers core concepts like power electronics, embedded systems, control logic, and industrial power systems, making it ideal for evaluation, viva, and practical demonstrations 🧠.

Q4. Does this project support practical demonstration and viva explanation?

A. Absolutely. The project includes clear LCD output, LED indicators, and buzzer alerts that visually demonstrate power factor conditions and correction steps. This makes it easy for students to explain the working principle confidently during viva and lab assessments 📟.

Q5. Can this power factor controller project be upgraded further?

A. Yes. The project can be enhanced with IoT modules, GSM alerts, cloud monitoring, or AI-based predictive correction. Such upgrades align the project with smart grid concepts and modern industrial automation practices 🌐.