Você está na página 1de 46

Department of Electrical and Computer Engineering

North South University

Junior Design Project

Smart Solar Power System

Shakil Mustafa Shanto ID# 1511338643


Mehede Hasan ID #1510099643
Mehedi Hasan Shifat ID#1530500043

Faculty Advisor:

Rummana Rahman

Lecturer
ECE Department
Summer, 2018
Table of content

TABLE OF CONTENT 1

ACKNOWLEDGMENT 2

SMART HYBRID SOLAR SYSTEM 3

BACKGROUND 4

INTRODUCTION 4

SMART SOLAR TRACKER 5

SMART CHARGE CONTROLLER 13

INVERTER 25

EQUIPMENTS WITH COST 34

CONCLUSION 35

APPENDIX I 36

APPENDIX II 40

1|Page
ACKNOWLEDGEMENT

We will like to show our gratitude to our faculty, Rummana Rahman, who gave us an
opportunity to work on this project. Through this project we have gained more
knowledge and a better understanding of Smart Hybrid Solar Inverters. We are really
thankful to our faculty for constantly giving us the motivation to do a good job and
guided us throughout this whole project.

2|Page
SMART HYBRID SOLAR SYSTEM

It has three parts:

1) Smart Solar Tracker

2) Smart Charge Controller

3) Smart Inverter

3|Page
BACKGROUND

Bangladesh being one of the leading progressive countries in the world is lagging
behind in the race of becoming a Smart and Ecofriendly country. The main purpose of
the project is to introduce the very basic concept of Smart Hybrid Solar Inverter in
Bangladesh.

INTRODUCTION
Lack of access to modern energy services is one of the reasons for poverty and low
economic development. Almost 75% of Bangladesh’s 161 million citizens live in rural
areas.
In 2010, the Bangladesh Bureau of Statistics mentioned 90% access in urban areas and
only 42% access in rural areas. The electricity supply is not reliable; supply does not
meet the demand. However, as far as possible, load shedding is scheduled.

In 2013 only an estimated 59.6 %of the Bangladesh population is connected to the
electricity grid. .From 10,213 MW installed electrical generation capacity (public,
private and import), the maximum output delivered was 6,675 MW. However In the
year 2012, household consumption of electricity per capita was about 86 kilowatts per
hour. Considering the places where electricity is not yet accessible our project will be a
good addition for the minimum power to light up bulbs and higher consumption battery
might be able to run a fan as well.

4|Page
FUNCTIONALITY

1) SMART SOLAR TRACKER

In modern solar tracking systems, the solar panels are fixed on a structure that moves
according to the position of the sun.

Let us design a solar tracker using two servo motors, a light sensor consisting of four
LDRs and Arduino UNO board.

The circuit design of solar tracker is simple but setting up the system must be done
carefully.

Four LDRs and Four 100KΩ resistors are connected in a voltage divider fashion and
the output is given to 4 Analog input pins of Arduino.

The PWM inputs of two servos are given from digital pins 9 and 10 of Arduino.

A. Arduino UNO.

Arduino Uno is a microcontroller board based on the ATmega328P. It has 14


digital input/output pins (of which 6 can be used as PWM outputs), 6 analog
inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP
header and a reset button. It contains everything needed to support the
microcontroller; simply connect it to a computer with a USB cable or power it
with an AC-to-DC adapter or battery to get started.

5|Page
Tech Specs of the Arduino UNO.

6|Page
Product Image:

B. MG995 Servo Motor.

MG995 is a powerful servo motor that is capable of spinning and controlling


things that a small hobby servo motor could never accomplish doing. It comes
with a bunch of accessories so you could connect it easily with the outer world,
and it's being controlled like every other servo motor, via PWM.

Tech Specs of MG995

• RPM: 0.20s/60 degrees (4.8V), 0.16s/60 degrees (6V)


• Voltage: 4.8V - 6.6V
• Torque: 9.4kg/cm (4.8V) - 11kg/cm (6V)
• Angle: 60 degrees

7|Page
• Dimensions: 40mm x 20mm x 43mm • Weight: 55g

Product Image:

C. Solar Cell.

A solar cell, or photovoltaic cell, is an electrical device that converts the energy
of light directly into electricity by the photovoltaic effect, which is
a physical and chemical phenomenon. It is a form of photoelectric cell, defined as a
device whose electrical characteristics, such as current, voltage, or resistance, vary
when exposed to light.

. Tech Specs of the Solar Cell used here:

 Maximum Rated output power of 7W at 17V.

 Maximum Output Current 2A

8|Page
Product Image:

List of Apparatus used for Solar Tracker.

1. Arduino UNO

2. MG 995 Servo Motor

3. Solar Cell

4. LDR

5. Resistors (100K)

6. Connecting Wires

9|Page
Working Principle of the Smart Solar Tracker.

LDRs are used as the main light sensors. Two servo motors are fixed to the structure
that holds the solar panel. The program for Arduino is uploaded to the microcontroller.
The working of the project is as follows.

LDRs sense the amount of sunlight falling on them. Four LDRs are divided into top,
bottom, left and right.

For east – west tracking, the analog values from two top LDRs and two bottom LDRs
are compared and if the top set of LDRs receive more light, the vertical servo will move
in that direction. If the bottom LDRs receive more light, the servo moves in that
direction. For angular deflection of the solar panel, the analog values from two left
LDRs and two right LDRs are compared. If the left set of LDRs receive more light than
the right set, the horizontal servo will move in that direction.

If the right set of LDRs receive more light, the servo moves in that direction.

Codes are in appendix i

10 | P a g e
Hardware Picture:

11 | P a g e
12 | P a g e
2) Solar Charge Controller

What is a charge controller?


A solar charge controller regulates the voltage and current coming from your solar
panels which is placed between a solar panel and a battery .It is used to maintain the
proper charging voltage on the batteries. As the input voltage from the solar panel rises,
the charge controller regulates the charge to the batteries preventing any overcharging.
Types of Charge controller:
On/ Off
PWM
MPPT
For this setup we decided to go with the PWM Charge Controller which seems to be a
perfect fit here.

PWM:
Pulse Width Modulation (PWM) is the most effective means to achieve constant voltage
battery charging by adjusting the duty ratio of the switches (MOSFET). In PWM charge
controller, the current from the solar panel tapers according to the battery’s condition
and recharging needs. When a battery voltage reaches the regulation set point, the PWM
algorithm slowly reduces the charging current to avoid heating and gassing of the
battery, yet the charging continues to return the maximum amount of energy to the
battery in the shortest time.
Advantages of using PWM Charge Controller:
Higher Charging efficiency.
Longer battery life.
Reduces battery overheating.
Minimizes stress on battery.

Charge controller function:


The charge controller is designed by taking care of the following points.

13 | P a g e
 Prevent Battery Overcharge: To limit the energy supplied to the battery by the
solar panel when the battery becomes fully charged.
 Prevent Battery Over discharge: To disconnect the battery from electrical loads
when the battery reaches low state of charge.
 Provide Load Control Functions: To automatically connect and disconnect an
electrical load at a specified time. The load will ON when sunset and OFF when
sunrise.
 Monitoring Power and Energy: To monitor the load power and display it.
 Protect from abnormal Condition: To protect the circuit from different abnormal
situation like lightening, over voltage, over current and short circuit etc.
 Indicating and Displaying: To indicate and display the various parameters

Specification of the charge controller:


 Automatic Battery Voltage Selection.
 PWM charging algorithm with auto charge set point according to battery
voltage.
 Display for monitoring the system.
 Protection for load section and supplier section.
 Short circuit and overload protection.
 LED indicator for different state of charging.
Electrical Specification:
 Rated voltage 6v or 12v
 Rated current:8-10A
 Maximum load current 8-10A
 Open circuit voltage 10-12v for 6v system and 12-14.5v for 12v system.

Charging Algorithm:

14 | P a g e
15 | P a g e
Different states of charging:

1. Bulk: At this mode, a preset maximum constant amount of current (amps) is fed into
the battery as no PWM is present. As the battery is being charged up , the voltage of the
battery increases gradually.
2. Absorption: When the battery reaches the bulk charge set voltage, the PWM begins
to hold the voltage constant. This is to avoid over-heating and over-gassing the battery.
This will set the battery to a certain level to reduce its damages properly.
3. Float: When the battery is fully recharged, the charging voltage is reduced to prevent
further heating or gassing of the battery
This is the ideal charging procedure.

16 | P a g e
List of Equipment to carry out this setup:
Arduino Uno
16x2 Character LCD
Mosfet (IRF9530)
Transistors (2N3904)
Resistors (10k, 4.7k, 1k, 330 ohm)
Capacitor (100uF,35v)
Diode(IN4007)
Zener Diode 11v (1N4741A)
LEDS(Red and Green)
Fuses (5A) and Fuse Holder
Bread Board.
Connecting Wires.

Circuit Diagram:
Circuit diagram of Charge Controller

17 | P a g e
It has some important section. They are given below:

*Voltage Sensing

The main sensors in the charge controller is voltage sensors which can easily
implemented by using a voltage divider circuit. We have to sense voltage coming from
solar panel and the battery voltage.
As the ARDUINO analog pin input voltage is restricted to 5V, I designed the voltage
divider in such a way that the output voltage from it should be less than 5V.I used a 5W
(Voc=10v) solar panel and a 12v and 8.2Ah SLA battery for storing the power .So I
have to step down both the voltage to lower than 5V.I used R1=10k and R2 =4.7K in
sensing both the voltages (solar panel voltage and battery voltage). The value of R1 and
R2 can be lower one but the problem is that when resistance is low higher current flow
through it as a result large amount of power (P = I^2R) dissipated in the form of heat.
So different resistance value can be chosen but care should be taken to minimize the
power loss across the resistance.

18 | P a g e
ARDUINO CODE:
for(inti=0;i<150;i++)
{ sample1+=analogRead(A0); //read the input voltage from solar panel
sample2+=analogRead(A1); // read the battery voltage
delay(2);
}
sample1=sample1/150;
sample2=sample2/150;
solar_volt=(sample1*4.673* 3.127)/1000;
bat_volt=(sample2*4.673* 3.127)/1000;

*PWM signal generation

19 | P a g e
*MOSFET switching and driver

*Filter and protection

*Display and indication


Load On/Off

A 16X2 char LCD is used for monitoring solar panel voltage and battery voltage. It also
show the % of charge.
When the battery condition is dead it will display: “BATTERY IS DEAD!!" and when
battery is discharged it will display "BAT DISCHARGED...”
LED indication on system condition:
2 LEDS (RED, GREEN) are used for indicating the system condition RED LED will
glow when battery is discharged. Green Led will glow when battery will be fully
charged.

20 | P a g e
Pin Description:
Pin
Function Name
No
1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V – 5.3V) Vcc
3 Contrast adjustment; through a variable resistor VEE
Selects command register when low; and data register Register
4
when high Select
Low to write to the register; High to read from the
5 Read/write
register
Sends data to data pins when a high to low pulse is
6 Enable
given
7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-

21 | P a g e
This is the 16*2 LCD display and pinout.
LCD -> Arduino uno connection

1. VSS -> Arduino GND


2. VDD -> Arduino +5v
3. VO -> Arduino GND pin + Resistor or Potentiometer
4. RS -> Arduino pin 12
5. RW -> Arduino pin 11
6. E -> Arduino pin 10
7. D0 -> Arduino - Not Connected
8. D1 -> Arduino - Not Connected
9. D2 -> Arduino - Not Connected
10. D3 -> Arduino - Not Connected
11. D4 -> Arduino pin 5
12. D5 -> Arduino pin 4
13. D6 -> Arduino pin 3
14. D7 -> Arduino pin 2
15. A -> Arduino Pin 13 + Resistor (Backlight power)
16. K -> Arduino GND (Backlight ground)

22 | P a g e
Here the connection between arduino and the display:

Protection:

Following protection are used:

Over Voltage Protection:

During lightening and thundering over voltage occurs in the system. To protect the
system a zener diode is used.

We used an 11V zener diode as my solar panel open circuit voltage is 10v. When the
voltage is more than 11v, it will provide the ground path to the surges.

23 | P a g e
PV panel reverse current:

During night battery voltage is higher in compare to solar panel voltage(0 V).So power
can be flow in the reverse direction .This avoided by using a diode(D1) after the solar
panel.

Auto Load Disconnection:

To avoid deep discharging of battery, auto load disconnection scheme is implemented


through the software. When the battery voltage is falls below a certain voltage (10V)
load is automatically disconnected.

Overcharge protection:

Over charge protection is given to improve the battery life and prevent from overheating
.When the battery voltage is greater than the fully charged voltage(13v) ,it is
disconnected from the solar panel to avoid further charging. This is also implemented
through the software.

Hardware Picture:

24 | P a g e
3) Inverter

An inverter converts the DC voltage to an AC voltage. In most cases, the input DC


voltage is usually lower while the output AC is equal to the grid supply voltage of
either 120 volts, or 240 Volts depending on the country. The inverter may be built as
standalone equipment for applications such as solar power, or to work as a backup
power supply from batteries which are charged separately.

Basic inverter operation

The basic circuits include an oscillator, control circuit, drive circuit for the power
devices, switching devices, and a transformer. The conversion of dc to alternating
voltage is achieved by converting energy stored in the dc source such as the battery, or
from a rectifier output, into an alternating voltage. This is done using switching
devices which are continuously turned on and off, and then stepping up using the
transformer. Although there are some configurations which do not use a transformer,
these are not widely used.

The DC input voltage is switched on and off by the power devices such as
MOSFETs or power transistors and the pulses fed to the primary side of the
transformer. The varying voltage in the primary induces an alternating voltage at
secondary winding. The transformer also works as an amplifier where it increases the
output voltage at a ratio determined by the turn’s ratio. In most cases the output
voltage is raised from the standard 12 volts supplied by the batteries to either 120
Volts or 240 volts AC. The three commonly used Inverter output stages are, a push-
pull with center tap transformer, push-pull half-bridge, or push-pull full bridge. The
push pull with center tap is most popular due to its simplicity and, guaranteed results;
however, it uses a heavier transformer and has a lower efficiency. A simple push pull
DC to AC inverter with center tap transformer circuit is a shown in the figure below.

Inverter output waveforms

The inverters are classified according to their output waveforms with the three
common types being the square wave, the pure sine wave and the modified sine wave.
The square wave is simple and cheaper, however, it has a low power quality compared
to the other two. The modified square wave provides a better power quality (THD~
45%) and is suitable for most electronic equipment. These have rectangular pulses that

25 | P a g e
have dead spots between the positive half cycle and the negative half cycle (THD
about 24%).

Figure: Modified sine waveform

The true sine wave inverter has the best waveform with the lowest THD of about 3%.
However, it is the most expensive and used in applications such as medical
equipment, stereos, laser printers and other applications requiring sinusoidal
waveforms. These are also used in the grid ties inverters and grid connected
equipment. Power-supply efficiency is a critical criterion for today’s cloud-
infrastructure hardware. The efficiency of the chosen power solutions relates to
system power loss and the thermal performance of integrated circuits (ICs), printed
circuit boards (PCBs), and other components, which determines the power-usage
effectiveness of a data center.

26 | P a g e
These concepts will crystal clear the working of MOSFET as a switch and will so justify
the use of MOSFET in inverter circuit as switching component.

Circuit Connections -

When a MOSFET or any transistor is used as a switch, there can be two modes
of switching-
i) Low side switching
ii) High side switching

In both the switching methods, there is only difference of position of the load in
the circuit. In low side switching, the source of the MOSFET is directly connected to
the ground. The load (shown as resistance RL in the circuit diagram) is placed in
between the drain and the power supply.

While assembling these circuits, always use a gate to source resistance (Shown as Rgs
in the circuit diagram) to avoid any external noise at the gate. This resistance also
discharge the parasitic capacitance of the MOSFET. Otherwise, the MOSFET can get
damaged as this parasitic capacitor will keep on charging and exceed the limit of the
gate to source breakdown voltage. Also, do not exceed the input voltage (drain voltage
and gate voltage) of MOSFET greater than its breakdown voltage as it can damage the
MOSFET. A low-value resistor (10E to 500E) should be used at the gate of MOSFET.
This will solve the problem of ringing (parasitic oscillations) and voltage spike in the
MOSFET.
In low side switching, the load resistance is connected at the drain side of the
MOSFET. As the MOSFET is a voltage controlled device, so for turning ON the
MOSFET, the Gate to Source Voltage (Vgs) must be greater than the Gate to Source
Threshold Voltage (Vth). In low side switching, there is no need of a gate driver
circuit. In this switching mode as the source is directly connected to the ground so,

Source Voltage, Vs = 0 V
Considering gate to source threshold voltage, Vth = 4 V
So, for turning on the MOSFET, gate to source voltage (Vgs) should be greater than
gate to source threshold voltage (Vth).
Vgs = Vg –Vs > Vth

27 | P a g e
Vgs = Vg – 0 > 4V
Vg = 4V

Therefore for turning ON the MOSFET, the gate voltage should be equal to 4 V. Since
the applied voltage is usually 5V, this makes the low side switching process easy to
implement without using any external circuitry.

Power loss in switching MOSFET

In MOSFETs using either a trench or lateral architecture, there is a distinct


relationship between on-resistance and capacitance. But it is important to remember
that the ratio of RDS(ON) per unit area compared to capacitance per unit area is
different for each, and each approach offers distinct advantages. Since trench
MOSFETs exhibit relatively low RDS(ON), designers can compensate for increased
switching losses by using a larger transistor. At the same time, switching losses for a
given on-resistance in a MOSFET using a lateral architecture can be less than half of
those exhibited by a comparable trench MOSFET, allowing them to offset the higher
conduction loss that their higher on-resistance generates. Two factors contribute to
switching loss: turn-on loss (see Figure 1), or the energy used to charge drain-source
capacitance (also referred to as output capacitance, Coss); and crossover loss, or the
energy lost during turn-on and turn-off transitions. Both of these factors play an
increasingly important role in applications at lower power levels.

28 | P a g e
Conduction power loss in MOSFET
Conduction losses are simple--the integration of E drop * I while conducting.
Switching losses occur when the device has substantial voltage and current
simultaneously--they occur during turn-on and turn-off transitions--mostly during
turn-off when the current is likely to be highest. Speed of turn-off is vital and that is
why a high current gate drive is essential. During the gate voltage transitions, there is
a period of time where the miller capacitance effect tends to hold the gate voltage in
the active region for a period of time--during this brief period, most switching losses
occur. Switching frequency also plays an important part--the higher the frequency,
the higher the losses. Proper application of a polarized snubber circuit can divert the
current long enough to assist turn off and reduce the switching loss.
Input information:
D - Duty cycle
ton - turn on time
f - Switching frequency
Vin(dc) - input DC voltage
Rds(ON) - drain to source on-state resistance

29 | P a g e
Conduction energy losses can be obtained by
t t
on  on 
E v ( t ) i ( t ) dt R i ( t )2 dt [3]
cond ds d ds ( ON) d
0 0
where, vds(t) is the on-state voltage drop and id(t) is the drain current waveform
after turn on. Then conduction power losses:

P
cond= E cond f

Experimentally, the turn-off losses may be calculated via a high speed oscillography
of current and voltage at this point and integrating the power calculated over several
points. Computer algorithms that do this are complex and take a great deal of effort to
make accurate.

30 | P a g e
HIGH SIDE SWITCHING

There are two common methods for driving the MOSFET in high side switching -

1) Dual power supply - This method is very simple but it needs two power source. In
this method, the voltage is applied at drain and gate of MOSFET by separate power
supplies. So that higher voltage can be provided at the gate compared to drain of the
MOSFET. This way the MOSFET can be turned ON.
2) Using Bootstrap circuit - In this method a single power source is needed, using
some capacitor in the circuit. This way double or higher voltage is obtained at the
gate terminal compared to the drain of the MOSFET. The capacitor in the circuit is
called Bootstrap capacitor as it boost up the gate signal to a higher voltage. So by the
help of the bootstrap circuit, the MOSFET can be turned ON in high side switching

31 | P a g e
Fig: Inverter Circuit

Warning: Due to technical requirements components may contain dangerous


substances. If a failure of such components can reasonably be expected to cause
the failure of that life-support device or system, or to affect the safety or
effectiveness of that device or system. Life-support devices or systems are
intended to be implanted in the human body, or to support and/or maintain and
sustain and/or protect human life. If they fail, it is reasonable to assume that the
health of the user or other persons may be endangered.

32 | P a g e
Hardware Picture:

33 | P a g e
EQUIPMENTS WITH COST

Equipment’s Quantity Price (TK)


Arduino 2 800
Charge Controller 200
components
Solar Tracker 200
components
Solar Panel 1 600
Battery 1 1200
Inverter components 700
Transformer 1 350
DC geared Motor 1 350
Bread board 2 200
Frame 1 1200
Wires 350
Box and Tapes 100
Others 250
Total 6300

34 | P a g e
Conclusion: Solar energy is an excellent source of directly useable energy and it
creates other aspects of energy resources such as biomass, wave energy, wind, and
hydropower. Most of the Earth's surface receives sufficient solar energy to permit
low-grade heating of water and buildings, although there are large variations with
latitude and season. At low latitudes, simple mirror devices can concentrate solar
energy sufficiently for cooking and even for driving steam turbines. The energy of
light shifts electrons in some semiconducting materials. This photovoltaic effect is
capable of large-scale electricity generation. However, the present low efficiency of
solar PV cells demands very large areas to supply electricity demands. Our project
can be used in a wide range of variety and moreover making most of renewable
energy with keeping necessary maintenance steps.

35 | P a g e
Appendix i

Solar Tracker Code:


#include <Servo.h>
//defining Servos
Servo servohori;
int servoh = 0;
int servohLimitHigh = 160;
int servohLimitLow = 20;

Servo servoverti;
int servov = 0;
int servovLimitHigh = 160;
int servovLimitLow = 20;
//Assigning LDRs
int ldrtopl = 2; //top left LDR green
int ldrtopr = 1; //top right LDR yellow
int ldrbotl = 3; // bottom left LDR blue
int ldrbotr = 0 ; // bottom right LDR orange

void setup ()
{
servohori.attach(10);
servohori.write(0);
servoverti.attach(9);

36 | P a g e
servoverti.write(0);
delay(500);
}

void loop()
{
servoh = servohori.read();
servov = servoverti.read();
//capturing analog values of each LDR
int topl = analogRead(ldrtopl);
int topr = analogRead(ldrtopr);
int botl = analogRead(ldrbotl);
int botr = analogRead(ldrbotr);
// calculating average
int avgtop = (topl + topr) / 2; //average of top LDRs
int avgbot = (botl + botr) / 2; //average of bottom LDRs
int avgleft = (topl + botl) / 2; //average of left LDRs
int avgright = (topr + botr) / 2; //average of right LDRs

if (avgtop < avgbot)


{
servoverti.write(servov +1);
if (servov > servovLimitHigh)
{
servov = servovLimitHigh;

37 | P a g e
}
delay(10);
}
else if (avgbot < avgtop)
{
servoverti.write(servov -1);
if (servov < servovLimitLow)
{
servov = servovLimitLow;
}
delay(10);
}
else
{
servoverti.write(servov);
}

if (avgleft > avgright)


{
servohori.write(servoh +1);
if (servoh > servohLimitHigh)
{
servoh = servohLimitHigh;
}
delay(10);

38 | P a g e
}
else if (avgright > avgleft)
{
servohori.write(servoh -1);
if (servoh < servohLimitLow)
{
servoh = servohLimitLow;
}
delay(10);
}
else
{
servohori.write(servoh);
}
delay(50);
}

39 | P a g e
Appendix ii
code for charge controller:

#include <LiquidCrystal.h>
float solar_volt =0; // variable for solar panel voltage
float bat_volt=0; // variable for battery voltage
float sample1=0; // reading from Arduino pin A0
float sample2=0; // reading from Arduino pin A1
int pwm=6; // pwm out put to mosfet
int load=9; //load is connected to pin-9
int charged_percent =0;
LiquidCrystal lcd(12,11, 10, 5, 4, 3, 2);
int backLight = 13; // pin 13 will control the backlight
int RED=7; // To indicate discharged condition of battery
int GREEN=8; // for charging and battery fully charged

void setup()
{
TCCR0B = TCCR0B & 0b11111000 | 0x05;
Serial.begin(9600);
pinMode(pwm,OUTPUT);
pinMode(load,OUTPUT);
pinMode(RED,OUTPUT);
pinMode(GREEN,OUTPUT);
digitalWrite(pwm,LOW);

40 | P a g e
digitalWrite(load,LOW);
digitalWrite(RED,LOW);
digitalWrite(RED,LOW);
pinMode(backLight, OUTPUT);
analogWrite(backLight, 150);
lcd.begin(16,2);
lcd.clear();
}

void loop()
{
lcd.setCursor(16,1);
lcd.print(" ");

for(int i=0;i<150;i++)
{
sample1+=analogRead(A0);
sample2+=analogRead(A1);
delay(2);
}
sample1=sample1/150;
sample2=sample2/150;
// actual volt/divider output=3.127
//2.43 is eqv to 520 ADC

41 | P a g e
// 1 is eqv to .004673
solar_volt=(sample1*4.673* 3.127)/1000;
bat_volt=(sample2*4.673* 3.127)/1000;
Serial.print("solar input voltage :");
Serial.println(solar_volt);
Serial.print("battery voltage :");
Serial.println(bat_volt);

if((solar_volt > bat_volt)&& ( bat_volt <= 13.5 ))


{
analogWrite(pwm,242.25); // @ 95% duty // boost charging// most of the charging done
here
Serial.print("pwm duty cycle is :");
Serial.println("95%");
}
else if((solar_volt > bat_volt)&&(bat_volt > 11.5)&& (bat_volt <= 13.5))
{
analogWrite(pwm,25.5); // 10% duty // float charging
Serial.print("pwm duty cycle is :");
Serial.println("10%");
}
// // shut down when battery is fully charged or when sunlight is not enough
else if ((bat_volt > 13.5) or (solar_volt < bat_volt))
{

42 | P a g e
analogWrite(pwm,0);
Serial.print("pwm duty cycle is :");
Serial.println("0%");
digitalWrite(GREEN,LOW); // green LED will off as no charging is done during this
time
}

charged_percent=bat_volt*10;
charged_percent=map(bat_volt*10, 60 , 72, 0, 100);

lcd.setCursor(0,0); // set the cursor at 1st col and 1st row


lcd.print("SOL:");
lcd.print(solar_volt);
lcd.print(" BAT:");
lcd.print(bat_volt);
lcd.setCursor(1,1); // set the cursor at 1st col and 2nd row
// LCD will show the %charged during charging period only
if ((bat_volt > 11) && (bat_volt <=13.5))
{
lcd.print(charged_percent);
lcd.print("% Charged ");
}
// LCD will alart when battery is dead by displaying the message "BATTERY IS
DEAD!!"
else if (bat_volt < 10)

43 | P a g e
{
lcd.print("BATTERY IS DEAD!!");
}

if ((solar_volt < 3 ) && (bat_volt > 13.5))


// when there is no sunlight(night) and battery is charged,
//load will switched on automatically
{
digitalWrite(load,LOW); // for relay digitalWrite(load,HIGH);
}
///load will be disconnected during day time(solar_volt > 6) or when battery is
discharged condition
if ((bat_volt < 12 )or (solar_volt > 17))
{

digitalWrite(load,HIGH); // for relay digitalWrite(load,LOW);


// prevent battery from complete discharging

if ( solar_volt > bat_volt && bat_volt <12.5)


{
///Green LED will blink continiously indicating charging is going on
digitalWrite(GREEN,HIGH);
delay(5);

44 | P a g e
digitalWrite(GREEN,LOW);
delay(5);
}
// Red LED will glow when battery is discharged
// also display in LCD
if (bat_volt < 13.5 && bat_volt >11)
// seecond restriction is given for indicating battery is dead
// if you omit the (bat_volt <10) when ever battery is dead also display bat discharged
{
digitalWrite(RED,HIGH); // indicating battery is discharged
lcd.setCursor(1,1);
lcd.print("BAT DISCHARGED..");
}
// Red LED will OFF when battery is not discharged
if (bat_volt > 11)
{
digitalWrite(RED,LOW);
}
//Green LED will glow when battery is fully charged
if(bat_volt >=13.5)
{
digitalWrite(GREEN,HIGH);
}
}
***The End***

45 | P a g e

Você também pode gostar