Sunteți pe pagina 1din 6

KS Project Manual

EFY september 2009

Microcontroller-Based
Solar Charger
A
s the sources of conventional It is considered as an indispensable 9. Low current consumption
energy deplete day by day, link between the solar panel, battery 10. Highly efficient design based on
resorting to alternative sources and load. microcontroller
of energy like solar and wind energy The microcontroller-based solar 11. Suitable for 10-40W solar panels
has become need of the hour. charge controller described here has for 10A load
Solar-powered lighting systems are the following features: The circuit of the solar charge con-
already available in rural as well as ur- 1. Automatic dusk-to-dawn opera- troller is shown in Fig. 1. It comprises
ban areas. These include solar lanterns, tion of the load microcontroller AT89C2051, serial ana-
solar home lighting systems, solar 2. Built-in digital voltmeter (0V-20V logue-to-dig-
streetlights, solar garden lights and range) ital converter
solar power packs. All of them consist 3. Parallel- or shunt-type regula- ADC0831,
of four components: solar photovoltaic tion optocoupler
module, rechargeable battery, solar 4. Overcharge protection MCT2E, reg-
charge controller and load. 5. System status display on LCD ulator 7805,
In the solar-powered lighting sys- 6. Deep-discharge protection MOSFETs
tem, the solar charge controller plays 7. Low battery lock BS170 and IR-
an important role as the system’s 8. Charging current changes to Fig. 2: Pin configurations of
F540N, tran-
overall success depends mainly on it. ‘pulsed’ at full charge BC547, BS170 and IRF540 sistor BC547,

Fig. 1: Circuit of microcontroller-based solar charger


KS Project Manual
EFY september 2009
Parts List
Semiconductors:
IC1 - AT89C2051 microcontroller
IC2 - ADC0831 analogue-to-digital
converter
IC3 - MCT2E optocoupler
IC4 - 7805, 5V regulator
T1 - BC547 npn transistor
T2 - BS170 n-channel MOSFET
T3 - IRF540 n-channel MOSFET
D1 - 6A4 rectifier diode
D2-D4 - 1N4007 rectifier diode
ZD1 - 7.5V zener diode
Resistors (all ¼-watt, ±5% carbon):
R1 - 8.2-kilo-ohm
R2 - 1.2-kilo-ohm
R3, R4, R6-R11 - 10-kilo-ohm
R5 - 20-kilo-ohm
R12 - 330-ohm
Fig. 3: A single-side, actual-size PCB layout for microcontroller-based solar charger
Capacitors:
C1 - 100µF, 63V electrolytic
C2 - 100µF, 16V electrolytic
C3, C7 - 0.1µF ceramic disk
C4, C9 - 10µF, 16V electrolytic
C5, C6 - 33pF ceramic disk
C8 - 0.01µF ceramic disk
Miscellaneous:
S1 - On/off switch
S2 - Push-to-on switch
RL1 - 12V, 1C/O relay
XTAL - 12MHz crystal
LCD - 16×2 line display
Solar panel - 10-40W
F1 - 10A fuse
- 10-pin bergstik SIP
connector (male & female)
Note: 12V Battery and solar panel are not
supplied by Kits ‘n’ Spare

Fig. 4: Component layout for the PCB readable even in low light conditions.
The LCD is used here in 4-bit mode to
LCD and a few discrete components. Serial ADC. The microcontroller save the microcontroller’s port pins.
Component description is given be- monitors the battery voltage with the Usually the 8-bit mode of interfacing
low. help of an analogue-to-digital con- with a microcontroller requires eleven
Microcontroller. Microcontroller verter. The ADC0831 is an 8-bit succes- pins, but in 4-bit mode the LCD can be
AT89C2051 is the heart of the circuit. sive approximation analogue-to-digital interfaced to the microcontroller using
It is a low-voltage, high-performance, converter with a serial I/O and very only seven pins.
8-bit microcontroller that features 2 kB low conversion time of typically 32 µs. Solar panel. The solar panel used
of Flash, 128 bytes of RAM, 15 input/ The differential analogue voltage input here is meant to charge a 12V battery
output (I/O) lines, two 16-bit timers/ allows increase of the common-mode and the wattage can range from 10
counters, a five-vector two-level inter- rejection and offsetting of the analogue to 40 watts. The peak unloaded volt-
rupt architecture, a full-duplex serial zero input voltage. In addition, the age output of the solar panel will be
port, a precision analogue comparator, voltage reference input can be adjusted around 19 volts. Higher-wattage panels
on-chip oscillator and clock circuitry. to allow encoding of any smaller ana- can be used with some modifications to
A 12MHz crystal is used for providing logue voltage span to the full eight bits the controller unit. Solar panel can be
the basic clock frequency. All I/O pins of resolution. It is available in an 8-pin purchased from A.K. Electronics, Delhi
are reset to ‘1’ as soon as RST pin goes PDIP package and can be interfaced (Ph: 011-41406775/76).
high. Holding RST pin high for two to the microcontroller with only three Rechargeable battery. The solar en-
machine cycles, while the oscillator is wires. ergy is converted into electrical energy
running, resets the device. Power-on LCD module. The system status and and stored in a 12V lead-acid battery.
reset is derived from resistor R1 and battery voltage are displayed on an The ampere-hour capacity ranges from
capacitor C4. Switch S2 is used for LCD based on HD44780 controller. The 5 Ah to 100 Ah.
manual reset. backlight feature of the LCD makes it Dusk-to-dawn sensor. Normally, in
KS Project Manual
EFY september 2009
a solar-photovoltaic-based installation—
for example, solar home lighting system,
solar lantern or solar streetlight—the
load (the light) is switched on at dusk
(evening) and switched off at dawn
(morning). During daytime, the load is
disconnected from the battery and the
battery is recharged with current from
the solar panel. The microcontroller
needs to know the presence of the solar
panel voltage to decide whether the
load is to be connected to or discon-
nected from the battery, or whether the
battery should be in charging mode
or discharging mode. A simple sensor
circuit is built using a potential divider
formed around resistors R8 and R9,
zener diode ZD1 and transistor T1 for
the presence of panel voltage.
Charge control. Relay RL1 connects
the solar panel to the battery through
diode D1. Under normal conditions, it
allows the charging current from the
panel to flow into the battery. When
the battery is at full charge (14.0V), the
charging current becomes ‘pulsed.’ To
keep the overall current consumption
of the solar controller low, normally-
closed (N/C) contacts of the relay are
used and the relay is normally in de-
energised state.
Load control. One terminal of Fig. 5: Flow-chart of the source program
the load is connected to the battery
through fuse F1 and another terminal Parallel regulation is preferred in works up to 20V. As Vref of the ADC
of the load to an n-channel power solar field. In parallel regulation, the is connected to VCC (5V), the input volt-
MOSFET T3. MOFETs are voltage- control circuitry allows the charging age to the ADC cannot exceed +5V. A
driven devices that require virtually no current (even in mA) to flow into the potential divider is used at pin 2 of
drive current. The load current should battery and stop charging once the bat- the ADC (IC2) using resistors R5, R6
be limited to 10A. One additional tery is fully charged. At this stage, the and R7 to scale down the voltage from
MOSFET is connected in parallel for charging current is wasted by convert- 0V-20V to 0V-05V. The ADC output is
more than 10A load current. ing into heat (current is passed through multiplied four times and displayed on
low-value, high-wattage resistor); this the LCD as battery voltage.
Circuit description part of the regulation dissipates a lot When the solar panel voltage is
Basically, there are two methods of of heat. present, the dusk-to-dawn sensor
controlling the charging current: series In this project, we have used paral- provides a signal to the microcontrol-
regulation and parallel (shunt) regula- lel regulation technique but instead ler, which then displays ‘charging’
tion. A series regulator is inserted be- of wasting the charging current as message on the LCD. During charging,
tween the solar panel and the battery. heat, we have made it pulsed and ap- the battery voltage is continuously
The series type of regulation ‘wastes’ plied to the battery to keep the battery monitored. When the voltage reaches
a lot of energy while charging the bat- topped-up. 14.0V, the microcontroller interrupts
tery as the control circuitry is always After power-on, the microcontroller the charging current by energising the
active and series regulator requires reads the battery voltage with the help relay, which is connected to MOSFET
the input voltage to be 3-4 volts higher of the ADC and displays the values on BS170 (T2), and starts a 5-minute timer.
than the output voltage. The current the LCD. It monitors the input signal During this stage, the LCD shows “bat-
and voltage output of a solar panel is from the dusk-to-dawn sensor and tery full.”
governed by the angle of incidence of activates the load or charging relay After five minutes, the relay recon-
light, which keeps varying. RL1 accordingly. The digital voltmeter nects the panel to the battery. This
KS Project Manual
EFY september 2009
way, the charging current is pulsed at microcontroller keeps converting the tery status is also displayed on line 2
the intervals of five minutes and the ADC value and displays the battery of the LCD.
cycle repeats until the panel voltage voltage on the LCD. EFY note. 1. If the unit is switched
is present. on without the solar panel connected,
When the panel voltage falls below Construction and testing the “Battery Low—Load Off” mes-
the zener diode (ZD1) voltage of the Pin configurations of transistor BC547, sage is displayed irrespective of the
dusk-to-dawn sensor, the microcon- MOSFET BS170 and MOSFET IRF540 battery voltage. The display changes
troller senses this and activates the are shown in Fig. 2. An actual-size, to “charging” as soon as the panel is
load by switching on MOSFET T3 via single-side PCB for the microcontrol- connected.
optocoupler IC3 and “load on” mes- ler-based solar charger is shown in 2. There will be slight variation in
sage is displayed. Fig. 3 and its component layout in the voltage displayed because of the
In this mode, the microcontroller Fig. 4. Wire the circuit on the PCB. tolerance levels of potential-divider
monitors for low battery. When the Prior to inserting the programmed resistors in the ADC section and Vref
battery voltage drops below 10 volts, microcontroller into the PCB, check of the ADC being directly connected to
the microcontroller turns off the load for soldering mistakes like shorts, VCC (the output of 7805 has an accuracy
by switching off MOSFET T3 and and for proper connections using a of 2-5 per cent) instead of dedicated
“battery low—load off” message is multimeter. Mount power MOSFET temperature-compensated voltage
displayed. IRF540N on a suitable heat-sink. Be- reference.
Normally, when the load is fore switching on the controller unit,
switched off, the battery voltage connect the leads of the battery, load Software
tends to rise back and the load oscil- and solar panel at appropriate places The source program for the project
lates between ‘on’ and ‘off’ states. on the board. is written in Assembly language and
To avoid this, the microcontroller Switch on the unit and the mes- assembled using Metalink’s ASM51
employs a hysteresis control by en- sage “Solar Charge Controller–EFY” assembler, which is freely available on
tering into a ‘lock’ mode during low- is displayed on the LCD for two sec- the Internet for download. It is well
battery state and comes out of the onds. The system status messages are commented for easy understanding
lock mode when the dusk-to-dawn displayed on line 1 of the LCD and the and works as per the flow-chart shown
sensor receives the panel voltage (the battery voltage is displayed on line 2. in Fig. 5. The hex file ‘solar.hex’ is to be
next morning). During lock mode, the A small graphic representing the bat- burnt into the microcontroller.

solar.asm
$MOD51 LBF BIT FLAGS.1 ; LOW BATT FLAG LCALL CMD
; LCD 4-BIT MODE CONNECTIONS CSEG MOV DPTR,#MSG1
RS EQU P1.7 ;LCD REGISTER SELECT HERE: CLR A
LINE ORG 0000H MOVC A,@A+DPTR
EN EQU P1.6 ;LCD ENABLE LINE JMP MAIN JZ NEXT
DB4 EQU P1.5 ; MOV BUF,A
DB5 EQU P1.4 ; ORG 000BH ;Timer Interrupt0 LCALL DAT
DB6 EQU P1.3 ; JMP COUNTDOWN INC DPTR
DB7 EQU P1.2 ; MAIN: MOV SP,#50H SJMP HERE
; ADC0831 CONNECTIONS MOV P3,#0FFH NEXT: MOV BUF,#0C0H
CS EQU P3.0 MOV P1,#0FFH LCALL CMD
CLK EQU P3.1 CLR CHG_RL MOV DPTR,#MSG2
DO EQU P3.2 CLR LD_RL HERE1: CLR A
;INPUT & OUTPUT LCALL PWR_DELAY MOVC A,@A+DPTR
LCALL INIT JZ OVER
DYI EQU P3.4 ; SOLAR PANEL VOLTAGE SETB CLK MOV BUF,A
SENSOR SETB DO LCALL DAT
CHG_RL EQU P3.5 ; CHARGING CONTROL SETB CS INC DPTR
RELAY SETB DYI SJMP HERE1
LD_RL EQU P3.7 ; LOAD CONTROL RELAY MOV VAL1,#00H OVER: LCALL ONE_SEC_DELAY
DSEG MOV VAL2,#00H LCALL ONE_SEC_DELAY
MOV VAL3,#00H LCALL CLEAR
ORG 0020H MOV FLAGS,#00H MOV BUF,#0C0H
LOADCHAR: MOV BUF,#40H LCALL CMD
VAL1: DS 1 LCALL CMD MOV DPTR,#MSG7
VAL2: DS 1 MOV DPTR,#RCHAR HERE2: CLR A
VAL3: DS 1 REP: CLR A MOVC A,@A+DPTR
ADC_VAL: DS 1 MOVC A,@A+DPTR JZ CONVERT
BUF: DS 1 JZ SCREEN1 MOV BUF,A
CNT1: DS 1 MOV BUF,A LCALL DAT
CNT2: DS 1 LCALL DAT INC DPTR
IMG: DS 1 INC DPTR SJMP HERE2
FLAGS: DS 1 SJMP REP CONVERT:LCALL DDELAY
OCF BIT FLAGS.0 ; OVER CHARGE FLAG SCREEN1: MOV BUF,#80H CLR CS ; INITIATE CONVERSION
KS Project Manual
EFY september 2009
SETB CLK LOAD OFF MSG MOV R4,B
CLR CLK ; FIRST CLOCK MOV IMG,#03H ADD A,#2
SETB CLK LCALL SENDSTAT2LCD ADD A,R5
CLR CLK ; SECOND CLOCK LJMP CONVERT MOV B,#10
MOV A,#00H ; CLEAR A SENDVAL2LCD: MOV BUF,#0C7H DIV AB
MOV R5,#08H ; 8 CLOCK PULSES LCALL CMD MOV R5,B
AGAIN: MOV C,DO MOV A,VAL1 CJNE R6,#00D,ADD_IT
RLC A ORL A,#30H SJMP CONTINUE
SETB CLK MOV BUF,A ADD_IT: ADD A,R6
CLR CLK LCALL DAT CONTINUE: MOV R6,A
DJNZ R5,AGAIN MOV A,VAL2 DJNZ R1,HIGH_BYTE
SETB CS ORL A,#30H MOV B, #10D
MOV ADC_VAL,A MOV BUF,A MOV A,R6
MOV B,#79D LCALL DAT DIV AB
MUL AB ; PRODUCT IN AB MOV BUF,#’.’ MOV R6,B
MOV R1,B ; HIGH BYTE IN B LCALL DAT MOV R7,A
MOV R2,A ; LOW BYTE IN A MOV A,VAL3 ENDD: RET
LCALL HEX2BCD ORL A,#30H ONE_SEC_DELAY: MOV R0,#10D ; One second
MOV VAL1,R7 MOV BUF,A delay routine
MOV VAL2,R6 LCALL DAT RZ3: MOV R1,#100D
MOV VAL3,R5 RET RZ1: MOV R2,#250D
LCALL SENDVAL2LCD SENDSTAT2LCD: MOV BUF,#080H RZ2: NOP
CHECK: JNB LBF,CHECK2 ; SEE IF ANY LCALL CMD NOP
FLAGS ARE SET ,i,e LOW BATT FLAG OR BATT HERE3: CLR A DJNZ R2,RZ2
FULL FLAG MOVC A,@A+DPTR DJNZ R1,RZ1
JB DYI,CONVERT JZ PICT DJNZ R0,RZ3
CHECK2: JNB OCF,PROCEED MOV BUF,A RET
JB DYI,NIGHT LCALL DAT PWR_DELAY: ; 15 mSec DELAY FOR LCD TO
SJMP CONVERT INC DPTR INTIALIZE AFTER POWER-ON
PROCEED: JB DYI,NIGHT SJMP HERE3 MOV R4,#100D
CLR LD_RL ; OFF LOAD PICT: MOV BUF,#0CEH H2: MOV R3,#250D
CLR LBF ; CLEAR LOW BATT FLAG LCALL CMD H1: DJNZ R3,H1
MOV A,VAL2 ; SEE IF BATT.IS FULL MOV BUF,IMG DJNZ R4,H2
XRL A,#04H LCALL DAT RET
JZ FULLCHG BACK: RET ;******LCD SUBROUTINES********
CLR CHG_RL ; CONNECT BATT. TO ;******************************** CMD: PUSH ACC ; SAVE ACCUMULATOR
PANEL ; TIMER0 ISR (5 MINUTES TIMER) SETB EN
MOV DPTR,#MSG4 ; DISPLAY CHARGING ;******************************** CLR RS ; SELECT SEND COMMAND
MSG COUNTDOWN: CLR TR0 MOV A,BUF ; PUT DATA BYTE IN ACC
MOV IMG,#00H MOV TH0,#03CH MOV C, ACC.4 ; LOAD HIGH NIBBLE ON
LCALL SENDSTAT2LCD MOV TL0,#0B0H DATA BUS
LJMP CONVERT SETB TR0 MOV DB4,C ; ONE BIT AT A TIME
FULLCHG: SETB OCF ;SET OVERCHARGE DJNZ CNT1,BACK2 USING...
FLAG MOV CNT1,#200D MOV C, ACC.5 ; BIT MOVE OPERATOINS
SETB CHG_RL ;DISCONNECT BATT.FROM DJNZ CNT2,BACK2 MOV DB5,C
PANEL CLR TR0 ; OFF 5 MIN TIMER MOV C, ACC.6
MOV TH0,#03CH ;START 5 MIN TIMER CLR ET0 MOV DB6,C
HERE CLR OCF ; CLEAR OVER CHARGE FLAG MOV C, ACC.7
MOV TL0,#0B0H ;DISCONNECT BATT FROM CLR CHG_RL ; RE-CONNECT BATT TO MOV DB7,C
PANEL PANEL CLR EN
MOV CNT1,#200D BACK2: RETI NOP
MOV CNT2,#30D Hex2BCD: MOV R3,#00D SETB EN ; PULSE THE ENABLE LINE
SETB ET0 MOV R4,#00D MOV C, ACC.0 ; SIMILARLY, LOAD LOW
SETB TR0 MOV R5,#00D NIBBLE
SETB EA MOV R6,#00D MOV DB4,C
MOV DPTR,#MSG5 ; DISPLAY BATT.FULL MOV R7,#00D MOV C, ACC.1
MSG ACALL H2B MOV DB5,C
MOV IMG,#01H RET MOV C, ACC.2
LCALL SENDSTAT2LCD H2B: MOV B,#10D MOV DB6,C
LJMP CONVERT MOV A,R2 MOV C, ACC.3
NIGHT: CLR CHG_RL ; RECONNECT BATT. DIV AB MOV DB7,C
TO PANEL MOV R3,B ; CLR EN
CLR TR0 ; STOP TIMER0 INCASE ITS MOV B,#10 ; R7,R6,R5,R4,R3 NOP
RUNNING DIV AB SETB EN ; PULSE THE ENABLE LINE
CLR OCF ; CLEAR OVER CHARGE FLAG MOV R4,B LCALL MSDELAY
SETB LD_RL ; CONNECT LOAD TO BATT. MOV R5,A POP ACC
MOV A,VAL1 CJNE R1,#00H,HIGH_BYTE ; CHECK FOR RET
XRL A,#00H HIGH BYTE ; ******LCD SUBROUTINES*******
JZ LOWBAT SJMP ENDD DAT: PUSH ACC ; SAVE ACCUMULATOR
MOV DPTR,#MSG3 ; DISPLAY LOAD ON HIGH_BYTE: MOV A,#6 SETB EN
MSG ADD A,R3 SETB RS ; SELECT SEND DATA
MOV IMG,#02H MOV B,#10 MOV A, BUF ; PUT DATA BYTE IN ACC
LCALL SENDSTAT2LCD DIV AB MOV C, ACC.4 ; LOAD HIGH NIBBLE ON
LJMP CONVERT MOV R3,B DATA BUS
LOWBAT: SETB LBF ADD A,#5 MOV DB4,C ; ONE BIT AT A TIME
CLR LD_RL ; DISCONNECT LOAD FROM ADD A,R4 USING...
BATT. MOV B,#10 MOV C, ACC.5 ; BIT MOVE OPERATOINS
MOV DPTR,#MSG6 ; DISPLAY BAT.OW AND DIV AB MOV DB5,C
KS Project Manual
EFY september 2009
MOV C, ACC.6 DJNZ R5,QT2 LCALL CMD ; INCREMENT CURSOR RIGHT,
MOV DB6,C RET NO SHIFT
MOV C, ACC.7 ;******LCD SUBROUTINES******* RET
MOV DB7,C MSDELAY: MOV R5,#26D
CLR EN QT22: MOV R6,#50D ORG 0320H
NOP QT11: DJNZ R6,QT11 MSG1: DB ‘ SOLAR CHARGE ‘,00H
SETB EN ; PULSE THE ENABLE LINE DJNZ R5,QT22 MSG2: DB ‘ CONTROLLER-EFY ‘,00H
MOV C, ACC.0 ; SIMILARLY, LOAD LOW RET MSG3: DB ‘ LOAD ON ‘,00H
NIBBLE ;******LCD SUBROUTINES******* MSG4: DB ‘ CHARGING ‘,00H
MOV DB4,C INIT: MOV BUF,#30H ; FUNCTION MSG5: DB ‘ BATTERY FULL ‘,00H
MOV C, ACC.1 SET - DATA BITS, LINES, FONTS MSG6: DB ‘BAT.LOW-LOAD OFF’,00H
MOV DB5,C LCALL CMD MSG7: DB ‘Volts: ‘,00H
MOV C, ACC.2 ACALL DDELAY ;INITIAL DELAY 4.1MSEC ORG 0400H
MOV DB6,C MOV BUF,#30H ; FUNCTION SET - RCHAR: DB 04D,31D,17D,31D,17D,31D,
MOV C, ACC.3 DATA BITS, LINES, FONTS 17D,31D ; CHARGING
MOV DB7,C LCALL CMD DB 04D,31D,31D,31D,31D,31D,
CLR EN ACALL DDELAY ;INITIAL DELAY 4.1MSEC 31D,31D ; FULL
NOP MOV BUF,#30H ; FUNCTION SET - DATA DB 31D,31D,14D,04D,04D,14D,
SETB EN ; PULSE THE ENABLE LINENOP BITS, LINES, FONTS 31D,31D ; LOAD
LCALL MSDELAY LCALL CMD DB 04D,31D,17D,17D,17D,17D,
POP ACC ACALL DDELAY ;INITIAL DELAY 4.1MSEC 17D,31D ; LOW BATT
RET MOV BUF,#28H ;2 LINES 5X7, 4-BIT DB 31D,31D,31D,31D,31D,31D,
;******LCD SUBROUTINES****** MODE 31D,31D
CLEAR: MOV BUF,#01H LCALL CMD DB 31D,31D,31D,31D,31D,31D,
LCALL CMD MOV BUF,#0CH ; DISPLAY ON 31D,31D
RET LCALL CMD DB 31D,31D,31D,31D,31D,31D,
;******LCD SUBROUTINES******* MOV BUF,#01H ; CLEAR DISPLAY, HOME 31D,31D
DDELAY: MOV R5,#41D ; 4.1 mS DELAY CURSOR DB 031D,31D,31D,31D,31D,31D,
QT2: MOV R6,#50D LCALL CMD 31D,31D,00H
QT1: DJNZ R6,QT1 MOV BUF,#06H ; SET ENTRY MODE END 

S-ar putea să vă placă și