Академический Документы
Профессиональный Документы
Культура Документы
Introduction
1
1.1 Introduction
Electric power or energy has become an ultimate necessity nowadays; in today’s life
we can’t imagine life without electricity. By looking on the importance of electricity,
it is very important to discuss the means to use it efficiently so that the user feels at
ease.
Electrical system basically consists of two major components and those include
voltage and current. Electrical power can be actually defined as the product of applied
voltage and electrical current at any instant.
P ( t ) =v ( t ) . i( t)
Since, most modern electrical system is based on alternating current theory so for a
sinusoidal flow of current at any instant
Where, ω actually defines a full period of a sinusoidal wave, θi∧θv are their phase
angles and Vm∧ℑare their peak amplitudes .
2
1.2 What is Power Factor?
Power factor is actually the ratio of real i.e. working power and apparent power.
Power factor measurement actually includes phase angle delay between voltage and
current wave form.
PF=cos (θ)
The concept of power factor can be made clearer using the power triangle as the
distribution system is composed of active (useful) and reactive (non-useful) power.
So, according to a power triangle
3
And
kW
Power factor=
kVA
The main concern about power factor is based upon the fact that we are not able to
utilize the full electrical power being transmitted to us. Low power factor means that
you are wasting your power instead of making use of it. Low power factor means that
current waveform is either lagging or leading by some angle to voltage waveform.
The more the angle between the two waveforms it means the more energy you are
wasting.
There is another way of looking at this that the less the power factor is the higher the
current needed in order to perform the same amount of power factor. Low power
factor in transmission line means that you have to increase the size of the conductor in
order to transmit the same amount of real power at constant voltage as it has to carry
large current. Similarly, with the increase in current the I 2 R losses of the line
increases.
Hence, the graph explains that the consumption of current is doubled when power
factor is decreased to half.
4
So, higher power factor can actually help in increasing the efficiency of your
electrical system as well as it may help in increasing the life span of your electrical
systems.
As the power factor decreases means the phase delay between the voltage and current
waveform increases which alternatively have an impact on the active and reactive
components of the current.
Considering a delay of about 30 degrees between the two we have active component
of the current as I∗cos 30=0.866 I and reactive component asI∗sin 30=0.5 I .
Similarly, if we consider a delay of about 60 degrees between the two we have active
component of the current as I∗cos 60=0.5 I and reactive component as
I∗sin 60=0.866 I. As, the delay increases active component of the current decreases
but the reactive component of the current increases and similarly, as the delay
decreases active component of the current increases but the reactive component of the
current decreases. So, actually power factor has great impact on kW and kVA
consumptions.
Another major concern is that when power factor falls below specific level, electrical
companies charge accordingly. So, you actually have to pay for the energy you don’t
utilize. So, improvements in power factor means that you only have to pay for the
energy utilized.
5
Fig 1.4 Power consumption comparison due to power factor
6
Chapter 2
Literature Review
7
2.1 Different Nature of Loads
The major of concern of power factor is with large industries and in electrical
distribution panels as they have to deal with much larger loads than the home
appliances used in local areas where the compensation of power factor is mostly of no
concern or say of very little concern that it can be ignored. So, in real world there are
three different kinds of loads that are resistive, inductive and capacitive. All these
loads show different behavior towards the distortion of power factor.
In general resistive loads are considered to show unity power factor behavior.
Although the resistive loads have very limited existence in nature but they have no
impact on the distortion of current and voltage waveforms i.e. the phase delay
between the two is considered to be zero ideally in resistive loads.
Fig 2.1 Current and voltage waveforms behavior due to Resistive load
Since, the phase delay between the two waves is zero as shown in Fig 3.
So, θ=0
hence, cos (0)=1
So, resistive loads have unity power factor so there is no reason to deal with these
loads in terms of power factor hence no compensation is required in such loads.
8
2.1.2 Inductive load
Any kind of load that has coil in it is generally considered to be inductive. Examples
of inductive load are motors, solenoids, contactor coils, compressors, speakers, relays,
transformers, inductors.
Before understanding the inductive loads it is necessary to understand the basic
phenomena of induction. Electromagnetic induction is the phenomena in which
an electromotive force is produced across an electrical conductor because of a
changing magnetic field.
In general inductive loads are considered to show lagging power factor behavior.
Most modern world has inductive nature of loads. When an inductive load is
introduced in an electrical system it starts to draw reactive power in demand for the
magnetizing current along with active power. So an inductive motor even at no load
shows 25 to 30 % of the full load current. All inductive system has similar behavior to
electric current. It actually distorts the current and voltage waveform. In inductive
loads the current lags the voltage by some angle θ which in case of resistive loads is
generally considered to be zero but for induction loads it is has some value so in such
kind of loads the power factor is always less than one due to the consumption of
reactive power.
9
Fig 2.2 Current and voltage waveforms behavior due to Inductive load
The above graph shows a behavior of partial inductive loads as in general the
inductive loads shows a poor power factor between 0.6 and 0.8. Hence, because of
such poor power factor the demand of magnetizing current increases and with that the
consumption of reactive power increases as the power factor falls below. So, the less
the power factor the more the current will flow through a machine ultimately at some
point the machine starts to resist it to a high extent and it will start to heat up thus
making the efficiency of its work too low that finally the machine will not be of any
use.
Fig 2.3 Induction motor showing consumption of active and reactive power
10
The figure clearly describes that how an induction motor draws active power along
with reactive power to finally make up apparent power.
But an ideal inductive load does not exhibit such kind of behavior. An ideal inductive
load leads the power to drop to drop to zero. So in an ideal inductive load the voltage
and current waveforms are 90 o apart from each other and hence an infinite amount of
current starts to flow through the electrical system. In an ideal inductive load there is
no active power consumption but the reactive power is fully consumed.
kW 0
Power factor= = =0
kVA 1
Since, the consumption of active power for ideal inductive load is 0 and that of
reactive power is 100%.
So, in case of inductive loads or say lagging power factor there is a severe need to
improve power factor as close to unity as possible in order for the electrical systems
to increase their efficiency thus making the system more and more perfect.
Although the most loads in real worlds are inductive and contribution of capacitive
loads are quite much smaller than the contribution of inductive loads. But still it is
necessary to understand these loads in order to overcome the problem of leading
power factor which generally does not occur but IT generators and AC power supplies
may exhibit capacitive nature and hence may leads towards the problem of leading
power factor. In order to understand it let’s consider the problem exhibition in IT
generators.
The generator controls its output voltage by constantly measuring it and adjusting the
current fed to the spinning electromagnet. If a load is suddenly applied to the
11
generator and the voltage drops, the regulator acts to slightly increase the
electromagnet current to maintain the desired output voltage. When the load has some
out-of-phase current, this current gives rise to a magnetic field within the generator
rotor that either adds to or partially cancels the magnetic field of the spinning
electromagnet. If the load has a leading out-of-phase current this actually adds to the
electromagnet field, and the regulator must reduce the excitation current to the
electromagnet to compensate. The voltage regulator has a limiting capacity of
maintaining the output voltage as the leading excitation current increases until a point
appears where the regulator stop delivering supply current. At this point the leading
out of phase current will be able to supply current to whole field and starts to produce
instability in output voltage. At this point the safety systems will shut down the whole
generation systems.
So, as in nature the power factor distortion is because of two currents. One is the
excitation current while the other one is because of harmonics current. But this
problem of leading power factor is neither because of lagging reactive currents neither
because of harmonics current. Its reason is actually leading reactive currents that start
to supply making the actual source or supply of no use and causing problems.
The phase difference between voltage and current in leading power factor can be
shown by waveforms as
12
Fig 2.5 Current and voltage waveforms behavior due to capacitive load
As, the cos (θ) is generally able to define the power because of the difference between
the two waveforms but it does not decide whether it is leading or lagging so for an
ideal capacitive effect can be described to exhibit a power factor of zero as
Usually in transmission lines this problem occurs for a very small or no load because
of the line capacitance. So, in such cases receiving end voltage starts to increase as
compared to sending end voltage and hence the problem known as Ferranti effect
appears in transmission lines. Voltage rise due to leading power factor may give rise
to eddy current losses and hysteresis loss and may cause electrical stress on the
capacitor banks added in transmission lines.
Due to the increase in current due to leading power factor the line power losses
increases. There also rises heating issues in transformers due to increased current.
So, as in most cases the problem of leading power factor is ignored but there is a
crucial need for the detection and improvement of leading power factor as it makes
huge electrical stresses to the transmission line and backup generators.
The compensation of resistive loads that usually have almost zero contribution in the
real world is not necessary but the compensation of leading and lagging power factor
as described in previous sections is necessary as their respective loads behavior can
13
cause serious problems. So, the before compensation the study for the methodology
for the compensation is a necessary requirement in order to implement it according to
the nature of loads.
Passive Compensation
Active Compensation
14
the systems. Capacitive compensation can be fixed or
either switched.
15
factor is improved using this methodology.
So, their applications and use become limited because of all these points and capacitor
bank make an advantage as most of these points are not of concern while adding
capacitor bank.
Phase advancers are used to improve the power factor of induction motors.
The low power factor of an induction motor is due to the fact that its stator
winding draws exciting current which lags be-hind the supply voltage by 90
degrees. If the exciting ampere turns can be provided from some other AC
16
source, then the stator winding will be relieved of exciting current and the
power factor of the motor can be improved. This job is accomplished by the
phase advancer which is simply an AC exciter. The phase advancer is
mounted on the same shaft as the main motor and is connected in the rotor
circuit of the motor. It provides exciting ampere turns to the rotor circuit at
slip frequency. By providing more ampere turns than required, the induction
motor can be made to operate on leading power factor like an over-excited
synchronous motor.
The leading power factor as described is generally ignored in most practical works but
necessary actions are required in order to overcome this problem.
18
Chapter 3
Hardware Design
19
Having dealt with the theoretical concepts and background of all the research work
that has been conducted now we come down to the hardware specifications of our
project. In this chapter we will explain to you about the components that have been
used and why they were effective in performing the required tasks. We will show
PCB designs and layouts to make you familiar with the internal workings of the
project.
3.1 Introduction
The hardware for the Automatic Power Factor Correction was designed in such a way
that individual boards performed separate functions, its hardware was broken down
into several logical chunks and the respective PCB’s were designed and fabricated
accordingly. This also meant that the user could easily understand the functioning of
each part and make a whole clear picture in his mind of how things are proceeding
logically.
20
3.1.1 Power Supply
In our project we needed three types of dc voltage levels. First of all we needed
positive 5V supply to power our microcontroller and current sensor. Then we needed
a positive 12V and negative 12V supply to give biasing to operational amplifiers used
in sine to square conversion. Positive 12V supply was also needed to power up relays.
All the power supplies and related designs were changed during project building due
to current limitation SIMCOM required 2A of current during SMS sending. Instead
any designed power supply we used a SMPS 5v and 2A.
For a 12V supply we have used 18V transformer which will provide an input of 18V
to rectifier stage after stepping down 220V A.C. The rectifier stage will provide
pulsating DC which will be further smoothed by filtering capacitors. The filtering
capacitors are chosen according to datasheet recommendations (Reference Fig. 2 in
Appendix A). 6V will be dropped in to LM7812 whose maximum current handling
capacity is. So, for the maximum current rating the power dissipation across IC will
be 6W and IC LM7812 has the capacity to withstand this dissipation but for
protection it is better to attach a heat sink along with it.
21
3.1.1.3 Negative 12V Supply
For a negative 12V supply we have used a center tap 18V transformer which will
provide an input of 18V to rectifier stage after stepping down 220V A.C. The rectifier
stage will provide pulsating DC which will be further smoothed by filtering
capacitors. The filtering capacitors are chosen according to datasheet
recommendations (Reference Fig. 3 in Appendix A). 6V will be dropped in to
LM7912 whose maximum current handling capacity is 1A. So, for the maximum
current rating the power dissipation across IC will be 6W and IC LM7912 has the
capacity to withstand this dissipation but for protection it is better to attach a heat sink
along with it.
3.1.2 AC Transformers
In most of the cases where we have to measure or process the mains voltage we need
to step it down to a specified level so that we can easily work with it without any
danger so for that purpose mostly a potential transformer is used. The current in the
primary of potential transformer will be able to create a varying magnetic flux on the
secondary of the transformer which will induce voltage on the transformer with
respect to the number of turns given on primary and secondary side. So for the
measurement purpose it is necessary to induce step downed voltage according to our
requirement.
For the purpose of measurement in our project the potential transformer is connected
in parallel to our load.
22
We have designed 5V and 2A step down transformer.
42
Number of turn per volt = =3.349turn/ volt
12.54
Primary
For 10W power with 220V input, the current rating should be of 45mA as
P 10W
I= = =0.045 A
V 220 V
So, according to AWG standard wire gauge should be of 30. (Reference Table 1 in
Appendix A).
Secondary
For keeping the power constant at 10W and for a 5V step down requirement the
output current should be 2A.
P 10 W
I= = =2 A
V 5V
So, according to AWG standard wire gauge should be 18. (Reference Table 1 in
Appendix A).
23
Fig 3.3 Current Transformer
A current transformer is similar to potential transformer but generally used for the
measurement purposes in order to measure the relative current of the load instead of
voltages but this relative current is converted to voltages using resistor of a specified
value and then it is fed in voltage form to further circuitries.
The current transformer is usually connected in series to load. We must ensure that
the current transformer is always in parallel with burden resistance and it should never
be an open circuit otherwise huge amount of voltage can be induced on secondary
side of a current transformer.
S=0.85 kVA
S=VI
Primary
So,
S 850 VA
I= = =3.86 A
V 220 V
Secondary
Ip∗Rb
Eo=
Tr
5∗Rb
4=
1000
so , Rb=0.8 k Ω
24
As, the maximum input current is 3.86A and available transformer was of 5A so we
have selected it with the ratings of 5A to 5mA.
25
Fig 3.4 Working of zero cross detector
An operational amplifier got his name from ancient times when it was generally used
to perform all arithmetical operations.
LM741 is the most common operational amplifier used in today’s world. This is an
operational amplifier which means it works based on the difference between two
inputs. Although ideally it is considered when there is no difference between the two
inputs there should be no voltage at the output but in practical a DC offset appears
across the output. So to nullify such effects two offset null pins are embedded in
LM741. The input can be applied based on your applications to either of inverting or
non-inverting input. We have used non-inverting configurations as in our case both
the configurations work fine.
Arduino Uno
The microcontroller we used in our project is Atmel 328 (Arduino Uno). The basic
purpose of giving it priority upon other controllers is its small size with number of
necessity pins required by us including two external interrupts used to detect the
difference between voltage and current zero crossings using the output of zero cross
26
detector as the input of external interrupts of microcontroller and 2 out of 6 ADC
channels are required for the measurement of incoming AC voltage and current
amplitude according to load.
We have used LCD of 16x2 in order to display voltage, current and power factor each
in separate row. There are 8 pins means 8 bits available for data but we have used
only 4 bits. The potentiometer is connected with it in order to control its brightness so
that the text on it is available.
27
3.1.7 Bridge Rectifier
As, the voltage from bridge rectifier is a value higher than the voltage value
that can be fed to microcontroller so it is necessary for protection that it has to
catered using some mean so we used a potential divider in order to compensate
the voltage level. So we designed a voltage divider by using both the resistors
of same value in a configuration shown in fig. 14 so that every voltage level
that is the output of bridge rectifier should be divided in to half before it can be
28
fed to microcontroller as its input for further procedure based on
microcontroller algorithm.
As, the compensation was required in two cases i.e. lagging and leading both but there
was no compensation required in resistive case. So, there will be two kinds of
circuitries to be designed accordingly.
The switching circuitries of lagging load is designed in such a way that the load
remains in contact with the AC source in parallel. So, in order to do so AC phase is
connected to normally open of the relay and AC neutral is connected to one of the
terminals of the AC capacitor while the second terminal of the capacitor is connected
to the common terminal of the relay. For the operation of relay coil the normal
circuits are unable to provide sufficient current so to make the coil to perform its
operation it is necessary to provide the sufficient current by some means. Usually a
bipolar junction transistor will be able to provide this current from emitter to
collector. When sufficient power is applied at the base of the transistor the relay
connected to the collector of the transistor will be able to provide sufficient current to
the coil of the relay to energize and perform its electromagnetic operation to switch its
terminal. But we have used a 4 relays driver Module.
29
Fig 3.10 4xRelay Module
The common terminal which is actually the common emitter of all the bipolar
junction transistors is connected to 12V while a pulse is applied to the input (base of
the transistor) of the driver IC through a microcontroller which then further drives its
respective output (collector of the transistor).
The switching circuitries of leading load is designed in such a way that the load
remains in contact with the AC source in series. So, in order to do so AC phase is
connected to one of the terminals of load while AC neutral is connected the common
terminal of the relay. The load will be able to complete its path in two ways. First
when it is connected to the normally closed path of the relay bypassing the inductive
banks while the second through inductive banks which are further connected to the
normally open path of the relay. When sufficient current is provided at the INPUT of
the Relay module through a microcontroller pulse it allows the relay to energize its
coil in order to switch its contact between normally closed path to normally open path
and hence making the flow of current through capacitive loads ad inductive banks
combination instead of just allowing the flow of current through the load.
30
3.1.10 Compensation Calculation for Leading & Lagging Load
I=358mA
θ=53.13
V=238V
S=VI*
S=VI∠ θ
S=51.12+68.16j
So
Pav =51.12W
Q 1=68.18 VAR
θ=8.10
S=VI*
S=VI∠ θ
S=84.35+12.00j
Pav =84.35W
Q2=12.00 VAR
Q 1−Q 2=56.16VAR
E2
Q=
X
So,
31
X=1008
1
X=
2 πfC
1
C=
2 πXf
Hence
C=3.13uF
I=373mA
θ=45.57
V=238V
S=VI*
S=VI∠ θ
S=62.14+63.3j
So
Pav =62.14W
Q1=68.18 VA
θ=8.10
S=VI*
S=VI∠ θ
S=87.8+12.5j
32
Pav =87.8W
Q 2=12.5 VAR
Q 1−Q2=50.8VAR
E2
Q=
X
So,
X=1115
1
X=
2 πfC
1
C=
2 πXf
Hence
C=2.85uF
I=234mA
θ=36.86
V=238V
S=VI*
S=VI∠ θ
S=44.5+33.4j
So
Pav =44.5W
33
Q 1=33.4 VA
θ=8.10
S=VI*
S=VI∠ θ
S=55.13+7.8j
Pav =55.13W
Q2=7.8 VAR
Q 1−Q 2=25.6VAR
E2
Q=
X
So,
X=2212
1
X=
2 πfC
1
C=
2 πXf
Hence
C=1.43uF
34
3.1.11 Sim900A Module
Dimensions: 24x24x3mm
Weight: 3.4g
35
Control via AT commands (GSM 07.07 ,07.05 and SIMCOM enhanced AT
Commands)
SIM application toolkit
Supply voltage range : 3.2 ... 4.8V
Low power consumption: 1.0mA(sleep mode)
Operation temperature: -40°C to +85 °C
Interfaces
o Interface to external SIM 3V/ 1.8V
o Analog audio interface
o RTC backup
o SPI interface (option)
o Serial interface
o Antenna pad
o I2C
o GPIO
o PWM
o ADC
This Module interface with the Arduino with SPI (we are using Software Serial). To
communicate and configure this module we are using AT commands in Arduino and
sending them to SIMCOM over TX/RX lanes. This module will get the info about the
Power factor break down and it will send a message to the defined user. After the
correction of the power factor another message will be send to the same user that the
power factor is now correct. This module is configured in sms sending mode only for
this project.
3.1.11.2 Working
After uploading the Code in the Arduino there is a 1 min loop, a predefined loop time for
sim900a to register itself to the mobile network. After that a function is called and run all the
SIM900A configurations code line e.g. configure the SIMCOM to SMS mode only, set the user
mobile number and send a message to confirm all the setting are done correctly. If any
power factor issue appears another function will be called and low power factor related
36
message will be sent to the same user. After the correction is done another function will call
and inform the user that the power factor is corrected.
3.2 SCHEMATICS
37
3.3 PCB LAYOUTS
38
Fig 3.29 Zero Cross Detectors Hardware
39
Fig 3.32 Current Sensor ACS712
40
Fig. 3.34 Both Lagging & Leading Load
41
Chapter 4
Software Implementation
42
4.1 Software Logic
The basic implementation of logic has been done on Arduino IDE software. In our
code firstly we are measuring our current and voltage values at supply end using ADC
channels. Voltage measuring is quite simple just note the ADC output and multiply it
with the some transfer functions of our design parameters, for current measure the
ADC value using sampling technique and obtain max and min value of ADC and we
subtract max value with min value to have the difference then from that difference we
measure the current.
We have supplied our output of zero cross detector of current and voltage to the
external interrupts. 1st rising edge of current and voltage decides the power factor of
leading or lagging. 1st rising edge start the timer and other rising edge stops the timer
and from that time difference we calculate the Cos (ϴ).
This Cos (ϴ) decides you power factor and how much compensation is required. After
that we have some ranges of power factor drop, according to load and power factor
we power up the switch in switching circuit to perform the compensation.
43
4.2 Software Logic Flow Chart
44
4.4 Software Logic of SIM900A
The software logic for sim900A is written in the Arduino code has it’s on board
cannot be program directly, instead it can be configured. The pre-written program of
sim900A allow us to configure the sim900a module with AT commands combination.
Arduino starts with its configuration settings. Sim900A module is set in the SMS
mode. User cell phone is then configure in it in international mobile number format.
During normal routine program, whenever power factor is dropped an alert is
generated and trigger the sim900a function to send the user a sms to inform that
power factor is reduce from its threshold. A power factor correction sub routine is
also call and correct this bad power factor and again call the sim900a to inform that
corrections have been made. All the configuration are send to the sim900a through
SPI (using a software serial). Sim900a support baud rate from 9600 to 115200.
Initializing
Receiving
Configuration
Setup User
Phone Number
Send SMS as
notification to
user
Fig 4.2 SIM900A Flow Diagram
45
Conclusion:
Our project basically deals with both lagging power factor that is generally dealt in
practical along with leading power factor. There are practical limitations of this
project that capacitors and inductors of every rating are not available in market so we
had a great difficulty to improve power factor as a result our results were not very
accurate. Overall we had a great idea now that how power factor its compensation and
monitoring works.
46
Chapter 5
References
47
APPENDIX
APPENDIX A)
Reference Table 1
48
Reference Fig. 1
Reference Fig. 2
Reference Fig. 3
49
Reference Fig. 4
Reference Fig. 5
50
Reference Fig. 6
APPENDIX B)
#include "ACS712.h"
51
// with the arduino pin number it is connected to
float theta = 0;
float theta_temp = 0;
float rad = 0;
float PF = 0;
float RF = 0;
float F_PF = 0;
int PulseRead = 2;
int R1 = A2;
int R2 = A3;
int R3 = A4;
int L1 = A5;
int L2 = 5;
int relay_count = 0;
int inductor_count = 0;
int Cin = 3;
int Vin = 4;
52
volatile byte PF_LL =0;
float Real_Power = 0;
void setup() {
Serial.begin(9600);
sim.begin(9600);
Serial.println("Setup stared");
53
// Lead or Lag identification reference siganl
///////relay outputs///////
lcd.clear();
lcd.home();
//lcd.print(theta);
54
lcd.setCursor(0, 1);
lcd.print(i);
lcd.print(" secs");
delay(1000);
simConfig();
sei();
EICRA |= B00001100;
EIMSK |= B00000010;
//lcd.clear();
//lcd.home();
//lcd.print("LCD is");
// lcd.print(theta);
//lcd.setCursor(0, 1);
//lcd.print("ONNN");
//lcd.print(PF);
//delay(2000);
// GetPulse();
Serial.println("Setup Ended");
55
}
void loop() {
Serial.println("Loop stared");
// delay(100);
// cli();
Serial.println(Amps_RMS);
read_Volts();
Serial.println(Volts_RMS);
// {
// }
// if (theta < 0)
// {
// }
// if (theta_error < 0)
// {
// }
theta = abs(theta);
57
float R_power = Amps_RMS * Volts_RMS * RF; // reactive power = power*sin(PF)
lcd.clear();
lcd.home();
lcd.print("theta = ");
lcd.print(theta);
lcd.setCursor(0, 1);
lcd.print("PF = ");
lcd.print(PF);
delay(1000);
displayinfo(A_power,R_power);
// sei();
58
Serial.println("Loop Ended");
Serial.println("");
Serial.println("");
Serial.println("");
Serial.println("");
Serial.println("");
Serial.println("");
High_peak = 0; //We first assume that our high peak is equal to 0 and low peak is
1024, yes inverted
Low_peak = 1024;
float ACS_Value = analogRead(Cout); //We read a single value from the module
59
if(ACS_Value > High_peak) //If that value is higher than the high peak
(at first is 0)
if(ACS_Value < Low_peak) //If that value is lower than the low peak (at
first is 1024)
Low_peak = ACS_Value; //The low peak will change from 1024 to that
value found
60
High_peak = 0; //We first assume that our high peak is equal to 0 and low peak is
1024, yes inverted
Low_peak = 1024;
float ACS_Value = analogRead(Vout); //We read a single value from the module
if(ACS_Value > High_peak) //If that value is higher than the high peak
(at first is 0)
if(ACS_Value < Low_peak) //If that value is lower than the low peak (at
first is 1024)
Low_peak = ACS_Value; //The low peak will change from 1024 to that
value found
61
} //We keep looping until we take all samples and at the
end we will have the high/low peaks values
float A = A_power;
float R = R_power;
lcd.clear();
lcd.home();
lcd.setCursor(0, 1);
delay(1200);
lcd.clear();
lcd.home();
lcd.setCursor(0, 1);
delay(1200);
62
lcd.clear();
lcd.home();
lcd.setCursor(0, 1);
delay(1200);
void simConfig()
lcd.home();
lcd.print("Configuring Sim");
lcd.setCursor(0, 1);
lcd.print("Module Wait....");
delay(1000);
//lcd.print("AT");
63
sim.println("AT+CMGS=\"+923086116331\""); // Set Mobile Number to Send
SMS
lcd.clear();
lcd.home();
lcd.print("configure 100%");
lcd.setCursor(0, 1);
lcd.print("Notification ");
delay(1000);
lcd.clear();
lcd.home();
lcd.setCursor(0, 1);
delay(1000);
void PFLowAlert()
64
// 2. display msg on LCD power factor is below limit
PFCorrection();
lcd.clear();
lcd.home();
lcd.setCursor(0, 1);
delay(1200);
relay_count = 1;
inductor_count = 0;
else if ((PF < 0.90) && (relay_count == 1) && (PF_LL <= 1)) {
inductor_count = 0;
relay_count = 2;
65
}
else if ((PF < 0.90) && (relay_count == 2) && (PF_LL <= 1)) {
relay_count = 3;
inductor_count = 0;
inductor_count = 1;
relay_count = 0;
digitalWrite(L2, HIGH);
66
digitalWrite (R3, LOW);
inductor_count = 2;
relay_count = 0;
lcd.clear();
lcd.home();
lcd.setCursor(0, 1);
delay(1200);
void PFCorrection()
delay(100);
67
delay(100);
void PFCorrectionAlert()
//////As the PF is Corrected and new Values are shown on LCD, its time to send an
sms to mobile
delay(100);
delay(100);
void GetPulse()
duration_sum = 0;
68
//PF_LL = 0;
i--;
duration_sum = duration_sum;
else {
if (LeadLag > 5) {if (PF_LL > 5){PF_LL = 5;} else PF_LL = PF_LL + 1;}
duration = duration_sum / 5;
69
ISR (INT1_vect)
LeadLag = 5;
////// intrupting the Current pulse and checking voltage pulse if its already there or
not
*********************************************************
* End of the Program *
*********************************************************
70