Automatic Power Factor Controller Using Pic Microcontroller
Automatic Power Factor Controller Using Pic 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, transformer, current transformer and zero crossing circuit.
PIC16F877A microcontroller calculate power factor and take necessary actions based on power
factor. relay driver IC UNL2003 is connected with microcontroller and which is used to drive
relays. Microcontroller sends high signal to relay driver IC whenever power factors falls less than
0.9. ULN2003 turn on relays which in return connects capacitor banks with the load. First of all the
phase difference between voltage and current waveforms are measured and then power factor is
calculated. In case of low power factor capacitors are added to improve it.
Step 1 of automatic power factor controller Alternating voltage of 220 volts is applied to
the input of a step down voltage transformer. The output of step down transformer is connected
to the diode which act as a rectifier and clips negative part of the sinusoidal waveform as
microcontroller cannot detect negative cycle of the waveform.
Microcontrollers cannot operate upon voltages which are greater than 5 volts. If
microcontroller is made to be operated upon the voltage greater than 5 volts, it will burn out
and damage immediately. For microcontroller to be operated upon the circuits of high voltages
we have to make use of step down transformers. Alternating voltage has to be step down such
that peak value of voltage is less than 5 volts.
Two different methods are usually used to convert 220 volts alternating voltage in to low
voltage of 5 volts alternating voltage.
Potential Transformer.
Difference amplifier.
The proposed work uses transformer to step down voltage.The process of electromagnetic
induction is used by the transformer to transfer electrical energy from one circuit to another
circuit or within same circuit. Time varying magnetic fields in a conductor produces force for
electromagnetic induction. Transformers can be used to step up a voltage or step down a voltage
depending upon its composition for the use in different electrical circuits.
In primary windings of a transformer, varying current produces a magnetic flux which is
varying and this travels to the secondary of the transformers winding. This produces a varying
magnetic field which in turn produces electromotive force in secondary windings because of
electromagnetic induction. Faradays law can be used to understand the phenomenon.To reduce
electrical voltages a special type of transformers is used known as step down transformer. In
step down transformer the voltage in primary windings is greater than secondary windings.
Such a type of transformer is used for example for converting 220 volts in to 110 volts.
Step down transformer can be used for isolation in electrical circuits, for power distribution to
convert electrical voltage from one level to the other and many other control and power
applications. Step down transformers use principle of electromagnetic induction between coils
for conversion of voltages.Step down transfer are consists of two coils of wire which are
insulated. The coils are made to wind upon the core. The core composition is of iron. A
transformer has two coils. Primary coil has turns which are greater in number than number of
turns in secondary. When a voltage is applied at primary side of the transformer, the core is
magnetized as it is made up of iron. This induces voltage in secondary coil of the transformer.
The primary side of transformer is called as input side and secondary side of the transformer is
known as output of the transformer.
The voltage which is step down in a transformer depends upon the number of turns in primary
and secondary side of the transformer.An example can be given as:If there are 100 turns in
primary coil of the transformer and 50 turns in secondary side then voltage ratio will be 2:1.
Step down transformer can be also known as voltage ratio device.
Step 2 of automatic power factor controller:-
Same input signal is connected to the step down current transformer.A step down current
transformer is used to convert high current in to low current for the use of different electrical
circuits. The amount of current which is step down depends on the number of turns in primary
coil and number of turns in secondary coil and also on the step down ratio.
If current transformer has ratio of 1000:10, then it means that such a step down transformer
can convert current of 1000 amperes to 10 amperes. Step down transformers can be used in
circuits where circuits are required to be operate on low currents and available currents are high
in value. For example if a relay is to be operated or a microcontroller is to be operated in a
circuit. One has to use intelligent techniques to step down the current value for the use of
circuits and for this purpose step down transformers can be used.In proposed work a
microcontroller is used that is why we have to step down the value of current for the
microcontroller and step down current transformer or potential transformer can be used for this
purpose.
Zero crossing detection is used to detect sine wave zero crossing from positive half cycle to
negative half cycle or negative half cycle to positive half cycle. Zero crossing of two waves
must be detected to measure the phase difference between two waves. Zero crossing detector
circuit basically converts the sinusoid wave to square wave.The outputs from step down current
and voltage transformers are fed in to zero crossing detector circuit which convert the sinusoid
waveform in to square waveform to be used by microcontroller.
Op-amp is used as a comparator for the purpose of zero crossing detector circuit. Two analogue
voltage levels are compared with one another using Op-amp circuit and output depends upon
the comparison of these voltage levels. The voltage which is higher in magnitude appears at
the output.
In zero crossing detector circuit one input (inverting) of Op-amp is set at zero reference and
second input (non-inverting) is fed with sinusoidal wave to be converted in to square wave.
Whenever the sinusoidal signal has value greater than zero reference, the output of Op-amp
has positive value. As soon as the sinusoidal signal falls below zero reference, the output of
op-amp falls to zero. In this way zero crossing detector circuit converts a sinusoidal signal to a
square waveform.
The LM358 operational amplifier is equivalent to half of the LM324. Such amplifiers are
preferable over usual operational amplifiers for several applications. Such type of amplifiers
can operate upon low voltages such as only 3.0 volts and also high voltages up to 32 volts. The
input which is common mode includes negative power supply, therefore it eliminates the
necessity of external biasing components for many applications. Output voltage includes
negative part of the supply voltage.
The paper utilizes and applies PIC microcontroller. The microcontroller is a cheaper solution
for computational work in portable devices like this. PIC microcontroller is an advance
microcontroller with many advance features low power utilization, high performance, high
frequency, multiple special functions and vast memory space.
PIC 18F family has a RISC architecture with standard on chip features like RAM,
ROM, ADC, Timers, Interrupts, I/O ports, EEPROM and USART. The PIC 18F devices have
diverse interrupt sources and interrupt priority customization as well. It consists timer
interrupts, serial interrupts, external interrupts, peripheral interrupts, watch dog timer interrupt.
It has a 10- bit ADC with 13 channels. With the use of external interrupt or timer interrupt the
high pulse time can be calculated and thus the phase angle can also be calculated. Since the
PIC has multiple oscillator and clock frequency options, the controller can be operated faster
and slower depending on the application. With such advance features and low cost, PIC is the
best option for this project. The data collected from the zero detectors can be logged in the
EEPROM as a record as well. External peripherals and POM extension help to diversify the
features. The USART allows serial communication to pass on the data to the computer or the
wireless systems that work on serial protocol. The microcontroller consists of 4 timers with
each having interrupt as well. The calculation for phase angle through such a powerful
controller is the ideal choice.
The output from the zero crossing detectors are now fed to the pins of PIC of microcontroller
separately which uses its internal timers to measure the time duration of signals in which their
value is high or 1.Timer is a register which counts from 0 to 255 and then start from 0 again.
0, 1, 2, 3, 4255.0,1, 2, 3etc. Timers are available in all PIC microcontrollers and when
timer overflows it generates interrupt. Timer can use external clock or external clock to
calculate time and it depends upon programmer how to use it.
Timer 0
Timer 1
Timer 2
Watch Dog Timer
TIMER0 is 8 bit timer and has prescalar of 8 bit. This timer can run 2 to 256 times slower than
normal. TIMER1 is 16 bit timer and has two 8 bit registers having 1:1 and 1:8 prescalar and
also has some other useful features. TIMER2 is an 8 bit timer having prescalar of 1:1 to 1:16
and postscalar of 1:1 to 1:16. It also has a period register. It can be used to control motors with
PWM.
The time difference between two waves can be easily measured using external interrupts.
Whenever interrupt is received on the pin of microcontroller, timer starts and as soon as another
external interrupt is received time stops counting. One interrupt is generated with the help of
current signal and other interrupt will be generated with the help voltage signal zero crossing.
Timer value will be stored for further use. This variable value is basically a time difference
between two waves. For good results take 20-30 values and then calculate their average.
In proposed work software program works in a similar manner such that as soon as the output
of one zero crossing detector becomes high the timer start incrementing from 0 to 255 and then
starts from 0 again. Timer continue to measure time period until the output of second zero
crossing detector becomes high. By using simple and basic calculations of timer and its
prescalar, the time difference at which the outputs of zero crossing detectors become high can
be calculated easily.
Microcontroller then uses its abilities and program to calculate the phase angle and phase
difference between two waveforms. Time difference between two waveforms can yield phase
difference easily using following formula.Time difference = average values of timer /1000
In above equation 1000 is used to convert time into seconds because half of the sine wave is
about 10us and there will 1000 counts per second.
= time difference * 2
The pins of microcontroller are connected to the relay IC and then to relays.When a low voltage
circuit is used to derive a load which is connected to high voltage an IC is used which is known
as Relay driver IC. A relay coil require more current as compared to other devices. Integrated
circuits such as Op-amp circuits cannot supply such larger currents to derive relays. Relays are
unique in properties and have taken the place of solid state switches and are stronger than solid
state devices. Relays have high current capacities. They are capable to stand ESD and can also
drive circuit isolation. There are many ways to drive relays. Some of the Relay Driver ICs are
as follows:
First time the relays were used in telegraph circuits in long distances as amplifiers. They repeat
the signals which are coming in to the circuits and again transmit it to another circuit. Relays
were also used in computers to perform different algebraic and logical operations and also in
telephone exchanges.
Electromagnetic relay is simply consists of a coil which is wrapped around an iron core. An
iron core is a source of providing low reluctance path to pass magnetic flux. Relay also includes
moveable iron armature and one or more contacts. The armature is connected to the yoke and
is mechanically connected to the contacts of the relays. A spring is used to place the contacts
in place so that whenever relay is de-energized there is an air gap in magnetic circuits.In this
work relays are used to connect and disconnect capacitors in the circuits.
Microcontroller program calculates the phase difference between two sinusoid waves and then
power factor using this information and displays on LCD. Liquid Crystal Display screen is
very basic module and is used very commonly in various circuits for display purpose. It finds
a wide range of applications. LCD display is preferred over LED display and seven segment
display. LCDs are easily programmable, economical and can easily display characters,
animations and so on.162 LCD has 2 lines and each line can display 16 characters. In this
LCD 57 pixel matrix is used to display each character. LCD has two registers which are
named as command and data.
A command is an instruction which is fed to LCD, commands are used to execute some tasks
which are predefined already such as initialize LCD, clear its screen, controlling display and
brightness and setting cursor position etc. Command register stores such predefined
instructions.Data register in LCD stores data which is to be displayed on screen. The data is in
the ASCII form of the character which is to be displayed.
There are total of 16 pins in LCD display details are given in following table.
Pin
No Function Name
5 Low to write to the register; High to read from the register Read/write
6 Sends data to data pins when a high to low pulse is given Enable
7 DB0
8 DB1
9 DB2
10 DB3
11 DB4
12 DB5
13 DB6
To display values on LCD hex values are converted in to decimal and then each decimal value
is converted to respective ASCII code and finally send to LCD display.
If the power factor is less than a prescribed value then microcontroller generate command to
turn on the relay. Turning on relay will add capacitor in to the circuit which will help to improve
power factor. Capacitors add reactive load in the circuit which will help to increase power
factor. Number of capacitors which are to be added depends upon the power factor of the
circuit. As soon as the power factor drops from a specific value, the relay will act to add
capacitor to the circuit. If power factor value drops a little to the prescribed value then one
capacitor is added. In case of power factor drops much more than prescribed value then second
capacitor is also added and the system goes on this way. The circuit will continue to add
capacitor in parallel to the load until a good value of power factor is achieved.
CODE EXPLANATION of automatic power
factor controller
The software programs which is used in automatic power factor controller work to improve
power factor consists of following steps.
STEP 1:-
STEP 2:-
Configure one port for the LCD display. Assign pins as output and input as required.
STEP 3:-
STEP 4:-
STEP 5:-
When the second interrupt is received the timer stops and its value is stored in a variable.
STEP 6:-
Use this timer value to calculate the phase difference between two waves.
STEP 7:-
Perform calculations to get phase angle of the signal and finally calculate the power factor.
STEP 8:-
STEP 9:-
Use this power factor value to decide whether the capacitors are to be added in circuit or not.
Use relays to add capacitors in the circuits.
STEP 10:-
Power factor is basically the result of reactive loads, especially inductive load because they are
frequently found in the form of motors. Such type of loads cause an offset between voltage and
current. The inductor cause the current to lag voltage and capacitor cause the opposite.
Power factor below 0.95 is not acceptable. If the load is inductive, a capacitive load is
introduced. The voltage and current waveforms are passed through the zero cross detector. The
difference between the zero crossing of the current and voltage waveforms is calculated using
the timer of the microcontroller. This value then allows the microcontroller to decide how much
capacitors/inductors to add in the main circuitry. If the phase angle is positive, a combination
of capacitors are added in the circuit until the power factor is above 0.95. If the phase angle is
negative and inductor is added to compensate the power factor until it is reached to the desired
value.
If the power factor is not above 0.95, the losses will be prominent and this will cause the system
to drain more power than required. This project just deals in positive phase angle i.e. the system
only adds capacitive loads to the main circuit. Since the microcontroller used has a relatively
smaller stack, the inductive addition could not be accomplished, but this can be done by using
microcontroller with bigger stack. The system has multiple capacitors that are added to
circuitry one after the other until the required power factor is not reached. This technique is
frequently used in water pumps and ceiling fans which have pre-calculated and factory installed
capacitors with the motors.
Due to low power factor the full load of the true power is not delivered. Such systems are dead
investment as they waste a lot of energy finally causing losses to the company. If the power
factor decreases, the voltage drop in the transmission lines increase. For such systems power
generation companies install boosters. If the power factor is locally improved, such expensive
are of no need. When motors are operated in varying speed, variable frequency drives are also
a good solution but for this as well you need to detect the phase angle and power factor.
The proposed work has input supply of sinusoidal waveform. The voltage waveform and
current waveforms both are passed through the zero crossing detector circuits. These zero
crossing detector circuits convert sinusoidal waveforms in to square waveforms using LM358
IC thats an op-amp IC. LM358 uses a zero voltage signal as reference signal and then
compares this signal to the signal to be converted in to square waveform. The microcontroller
PIC is programmed such that its timers are made to be operated upon interrupts received. When
interrupt form zero crossing detector circuit connected to voltage input wave is received timer
starts its function of measuring time. As soon as the interrupt from second zero crossing
detector is received the timer stops its function and its value is stored in a variable. The value
of this variable is then used to calculate the phase difference between two waves. This phase
difference then provides power factor of the system. The power factor of the system is then
compared to the desired value of the power factor thats set to be 0.95 for the current work. If
the systems power factor value come out to be less than 0.95 then the microcontroller sends
command to add capacitors in to the system until power factor becomes equal to 0.95. If the
power factor increase from a specified value then inductor may be added to decrease it.
This system uses 162 LCD. 4 things are displayed on the LCD:
Power Factor.
Frequency
AC Voltage.
AC Current.