Você está na página 1de 5

For More Products Visit Our Website:

www.amateurworld.in

Microcontroller Based Solar Charge


Controller Project
What is Solar Charge Controller?
As Wikipedia said A charge controller, charge regulator or battery regulator limits the rate
at which electric current is added to or drawn from electric batteries. It prevents overcharging and
may prevent against overvoltage, which can reduce battery performance or lifespan, and may pose a
safety risk. It may also prevent completely draining ("deep discharging") a battery, or perform
controlled discharges, depending on the battery technology, to protect battery life. The terms
"charge controller" or "charge regulator" may refer to either a stand-alone device, or to control
circuitry integrated within a battery pack, battery-powered device, or battery recharger.
In simple words, Solar Charge controller is a device, which controls the battery charging from
solar cell and also controls the battery drain by load. The simple Solar Charge controller checks the
battery whether it requires charging and if yes it checks the availability of solar power and starts
charging the battery. Whenever controller found that the battery has reached the full charging
voltage lavels, it then stops the charging from solar cell. On the other hand, when it found no solar
power available then it assumes that it is night time and switch on the load. It keeps on the load until
the battery reached to its minimum voltage levels to prevent the battery dip-discharge.
Simultaneously Charge controller also gives the indications like battery dip-discharge, load on,
charging on etc.

What is the function of a microcontroller in Solar Charge Controller?

Measures Solar Cell Voltage.


Measures Battery Voltage.
Decides when to start battery charging.
Decides when to stop battery charging.
Decides when to switch on the load.
Decides when to switch odd the load.
Give indications with the help of led for
o Battery Dip Discharge.
o Battery OK.
o Charging going on.
o Load is On/Off.

Which microcontroller is suitable for the job?


Although any microcontroller with sufficient I/O is suitable for the job but for most suitable
microcontroller to chose, we have to keep in mind the following things.

Page 1 of 5

Should have at least two analog I/O for measurement of Solar and Battery Voltage.
Otherwise we have to add extra AD converter for the job and it will increase the complexity
of the circuits and cost.
Should have at least two digital I/O, capable of switching High Current MOSFET for battery
charging and load.

AMATEUR WORLD

world of amateur electronics

www.amateurworld.in

For More Products Visit Our Website:


www.amateurworld.in

Should have at least three digital I/O capable of driving direct LEDs, otherwise we have to
add extra LED driver for the purpose.
Should have minimum circuit requirements for its self operation to cut down the cost.

Keeping in the mind all above things, we have found AVR and Microchip variants of 8-bit controllers
can do these jobs very well. So we decide to go for ATMEGA8 (which is AVR variant) microcontroller
for this project.
Schematic Diagram of hardware circuits:

Schematic Descriptions:
IC1 is ATMEGA8. For minimum circuits operation it requires only one 10K Resistor (R14) at
reset pin. It has got no crystal as we will use its internal RC Oscillator. L1, L2, L3 are three
LEDs for event indication and as ATMEGA8 can directly drive LEDs we have added only
current limiting resistors of 330 Ohm.
LM7805 (IC2) voltage regulator is there to produce 5V to supply ATMEGA8.
Q3 and Q4, these two small NPN transistors are there to drive two MOSFET, Q1 and Q2
respectively.
SB540 (D1) is a Scotty Diode, which will prevent the battery being drain at night time.
R16 and R15 forms a voltage divider to measure Solar Cell Voltage as because
microcontroller can only measure maximum +5V directly. Zener diode D4 (5V1) is to prevent

Page 2 of 5

AMATEUR WORLD

world of amateur electronics

www.amateurworld.in

For More Products Visit Our Website:


www.amateurworld.in

any accidental over voltage. Similarly there are R8, R9 and D2 for measurement of Battery
Voltage.
We have added two potentiometer R1 and R2 for easy adjustment of Battery High Voltage
(at which charging will stop) and Battery Low Voltage (at which charging will starts and Load
will be off). These two POTS are optional but it adds the flexibility of the system as with
these two POT, user can alter the battery settings at their will.

Software Basic:
As microcontroller software works as sequential basis, it will perform these steps
sequentially.
1.
2.
3.
4.
5.
6.

7.

8.

9.

10.
11.

Power On, RESET


Define Input / Output of the ports
Setup ADC for measurement
Start ADC Module
Measure ADC2, ADC3, ADC4, ADC5. ADC2 for Solar Voltage, ADC3 for Battery High Set,
ADC4 for Battery Low Set and ADC5 for Battery Voltage
If Battery Voltage < Battery High Set and Solar Voltage > Battery Voltage then
a. Switch ON Battery Charging
b. Switch ON Charging LED
c. Switch OFF Load
d. Switch OFF Battery High LED
If Battery Voltage > or = Battery High Set then
a. Switch OFF Battery Charging
b. Switch OFF Charging LED
c. Switch OFF Load
d. Switch ON Battery High LED
If Solar Voltage < Battery Voltage then
a. Switch OFF Battery Charging
b. Switch OFF Charging LED
c. Switch ON Load
If Battery Voltage < or = Battery Low Set then
a. Switch OFF Load
b. Switch ON Battery Low LED
If Battery Voltage > Battery Low Set then
a. Switch OFF battery Low LED
Go to Step 5.

As we have found BASIC language so easy to understand and easy to implement at AVR
microcontroller, we have use it with the help of BASCOM AVR Compiler. Bellow is the complete
code for the project in BASCOM.

Page 3 of 5

AMATEUR WORLD

world of amateur electronics

www.amateurworld.in

For More Products Visit Our Website:


www.amateurworld.in
'MICRO-CONTROLLER BASED SOLAR CHARGE CONTROLLER
'USED CHIP: ATMEGA8L WITH INTERNAL RC OSCILLATOR
'***************************************************************
'
INITIAL SETTINGS
'***************************************************************
$regfile = "m8def.dat"
'REGISTER FILE FOR ATMEGA8
$crystal = 1000000
'OSCILLATOR FRQUENCY=1MHZ
$swstack = 40
'SOFT STACK SIZE
$hwstack = 32
'HARDWARE STACK SIZE
$framesize = 32
'FRAME SIZE
'***************************************************************
' DEFINE INPUT/OUTPUT PORTS
'**************************************************************
Config Portd.2 = Output
Config Portd.3 = Output
Config Portb.1 = Output
Config Portb.2 = Output
Config Portb.3 = Output
'**************************************************************
' DEFINE ALIAS FOR GOOD READEBILITY
'**************************************************************
Charging Alias Portd.3
_load Alias Portd.2
Ch_led Alias Portb.3
Bat_h_led Alias Portb.1
Bat_l_led Alias Portb.2
'***************************************************************
' SETUP ADC MODULE
'***************************************************************
Config Adc = Single , Prescaler = Auto , Reference = Avcc '_2.56_nocap
Start Adc
'***************************************************************
' VARIABLE DECLARATIONS
'***************************************************************
Dim W As Word , W_single As Single
Dim Sol_v As Single , B_high As Single
Dim Bat_v As Single , B_low As Single
Dim Gp1 As Byte , Gp2 As Byte
'***************************************************************
' MAIN PROGRAM LOOP
'***************************************************************
Main:
Gosub Check_adc
If Bat_v < B_high And Sol_v > Bat_v Then
Charging = 1
'CHARGING ON
Ch_led = 0
'CHARGING LED ON
Bat_h_led = 1
'BAT HIGH LED OFF
_load = 0
'LOAD OFF
End If
If Bat_v >= B_high Then
Page 4 of 5

AMATEUR WORLD

world of amateur electronics

www.amateurworld.in

For More Products Visit Our Website:


www.amateurworld.in
Charging = 0
'CHARGING STOPS
Ch_led = 1
'CHARGING LED OFF
Bat_h_led = 0
'BAT HIGH LED ON
Bat_l_led = 1
'BAT LOW LED OFF
Else
Bat_h_led = 1
'BAT HIGH LED OFF
End If
If Sol_v < Bat_v Then
Charging = 0
'CHARGING STOPS
Ch_led = 1
'CHARGING LED OFF
_load = 1
'LOAD ON
End If
If Bat_v <= B_low Then
_load = 0
'LOAD OFF
Bat_l_led = 0
'BAT LOW LED ON
Else
Bat_l_led = 1
'BAT LOW LED OFF
End If
Goto Main
'***************************************************************
' ADC MEASUREMENT SUB RUTINE
'***************************************************************
Check_adc:
For Gp1 = 2 To 5
W_single = 0
For Gp2 = 1 To 200
W = Getadc(gp1)
W_single = W_single + W
Next Gp2
If W_single <> 0 Then
W_single = W_single / 200
Else
W_single = 0
End If
Select Case Gp1
Case 2 : Sol_v = W_single
Case 3 : B_high = W_single
Case 4 : B_low = W_single
Case 5 : Bat_v = W_single
Case Else
End Select
Next Gp1
Return
'****************************************************************
End
'end program

Page 5 of 5

AMATEUR WORLD

world of amateur electronics

www.amateurworld.in

Você também pode gostar