You are on page 1of 74

Microcontroller Based Solar Charger

Microcontroller Based Solar Charger


A PROJECT REPORT
Submitted
In partial fulfillment of the requirements for the award of the degree of
BACHELOR OF TECHNOLOGY
in
ELECTRONICS AND COMMUNICATION ENGINEERING
of
Mahathma Gandhi University ,Kottayam
By
ATHIRA J
ASHLIN DAVID
ANVIN PS
ATHULDEEP N

- 11021431
- 11021430
- 11021429
- 11021432

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING


SREE NARAYANA GURU INSTITUTE OF SCIENCE AND TECHNOLOGY
MANJALY, MANNAM P.O, NORTH PARAVUR -683520.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING


SREE NARAYANA GURU INSTITUTE OF SCIENCE AND TECHNOLOGY
MANJALY, MANNAM P.O, NORTH PARAVUR -683520.

CERTIFICATE

Certified that the mini project report entitled Microcontroller


Based SolarCharger is submitted by ATHIRAJReg No:11021431,
ASHLIN DAVIDReg No:11021430, ANVIN PSReg No:11021429 &
ATHULDEEP.NReg No:11021432 is the bonafide report of the mini project
done by her / him under the guidance of us, in partial fulfillment for the award
of Bachelor of Technology in Electronics and Communication Engineering of
M G University during the year 2014.

Submitted for the practical examination conducted on

Guide

HOD

Internal Examiner

External Examiner

Date:

Date:

Electronics and Communication Engineering Department

SNGIST

iii
Microcontroller Based Solar Charger

ACKNOWLEDGEMENT

I am grateful to the Management of SreeNarayana Guru Institute of Science and


Technology for providing me the facilities for the completion of my task. Firstly I extend my
gratitude to Dr K.S. Divakaran Nair, Director of SreeNarayana Guru Institute of Science
and Technology for his continuous support.
It is my privilege to thank Prof. V.Sureshkumar, Dean of Engineering, SreeNarayana
Guru Institute of Science and Technology for his blessings and encouragement.
I would also like to thank Mr. Rajan N, Head of the Department of Electronics and
Communication Engineering for his inspiration and guidance. May I express my heartfelt
thanks to my guide Mr. Sumesh A.S, for his / her valuable guidance and advice related to
this work.
I thank all the faculty members of Department of Electronics and Communication
Engineering for all the help extended to me and for motivating me. I also extend my gratitude
to technical staff in the Lab, for all their support and help.
I, on this occasion, remember the valuable support and prayers offered by my family
members and friends which were indispensable for the successful.

Electronics and Communication Engineering Department

SNGIST

iv
Microcontroller Based Solar Charger

ABSTRACT

As the sources of conventional energy deplete day by day, resorting to alternative sources of
energy like solar and wind energy has become need of the hour.

Solar-powered lighting systems are already available in rural as well as urban areas. These
include solar lanterns, solar home lighting systems, solar streetlights, solar garden lights and
solar power packs. All of them consist of four components: solar photovoltaic module,
rechargeable battery, solar charge controller and load.

In the solar-powered lighting system, the solar charge controller plays an important role as
the systems overall success depends mainly on it. It is considered as an indispensable link
between the solar panel, battery and load.
The microcontroller-based solar charge controller described here has the following features:

1. Automatic dusk-to-dawn operation of the load


2. Built-in digital voltmeter (0V-20V range)
3. Overcharge protection
4. System status display on LCD
5. Low current consumption
6. Highly efficient design based on microcontroller

Electronics and Communication Engineering Department

SNGIST

v
Microcontroller Based Solar Charger

CONTENTS
SL NO.

TOPIC NAME

PAGE NO.

INTRODUCTION

BLOCK DIAGRAM

11

BLOCK DIAGRAM EXPLANATION

12

MICRO CONTROLLER

13

3.1

PIC 16F877A FEATURES

14

3.2

BLOCK DIAGRAM OF PIC MICRO CONTROLLER

16

3.3

PINOUT DIAGRAM OF PIC MICRO CONTROLLER

17

LCD DISPLAY

25

PIN DESCRIPTION

25

2.1

4
4.1

ELECTRO MECHANICAL RELAYS

27

SOLAR PANELS

30

RECHARGEABLE BATTERY

34

CHARGING&DISCHARGING

34

CIRCUIT DIAGRAM

36

CIRCUIT DIAGRAM EXPLANATION

37

7.1

8
8.1

PROGRAM CODING

38

10

PCB FABRICATION AND SOLDERING

41

11

SOFTWARES USED

47

12

APPENDICES

50

13

ADVANTAGES

72

14

CONCLUSION

73

15

REFERENCE

74

Electronics and Communication Engineering Department

SNGIST

vi
Microcontroller Based Solar Charger

LIST OF TABLES

TABLE
NO:

TABLE NAME

PAGE
NO:

Pin out table of PIC 16F877A.

18

Ports in PIC 16F877A.

19

Specifications of the PIC 16F87X Series.

21

Register bank select.

22

Pin description table of LCD module.

26

Electronics and Communication Engineering Department

SNGIST

vii
Microcontroller Based Solar Charger

LIST OF FIGURES
FIGURE NAME

FIG
NO:

PAGE
NO:

BLOCK DIAGRAM

11

BLOCKDIAGRAMOF PICMICROCONTROLLER

16

PINOUT DIAGRAM OF PIC 16F877

17

16 x 2 LCD PIN DIAGRAM

26

RELAY SCHEMATIC DIAGRAM

28

WORKING OF RELAY CIRCUIT

29

STRUTURE OF SOLAR CELL

33

SOLAR PANEL

33

DIAGRAM OF THE CHARGING OF A SECON DARYCELL BATTERY

34

10

LEAD ACID BATTERY

35

11

CIRCUIT DIAGRAM

36

12

PCB LAYOUT

46

13

PROTEUS INTERFACE WINDOW

48

Electronics and Communication Engineering Department

SNGIST

viii
Microcontroller Based Solar Charger

LIST OF ABBREVIATIONS

1. ROM - Read Only Memory


2. RAM - Random Access Memory
3. PIC - Peripheral Interface Controller
4. IC - Integrated Circuits
5. LCD - Liquid Crystal Display
6. PC - Program Counter
7. IEEE - Institute of Electronics & Electrical Engineers
8. ADC - Analog to Digital Converter
9. CPU - Central Processing Unit
10.I/O - Input/output
11.CMOS - Complementary MOSFET
12.N/C-Normally-closed
13.N/O-Normally-open
14.CMOS - Complementary MOSFET
15.EPROM- Erasable programmable read only memory
16.USART- Universal asynchronous receiver/transmitter

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

CHAPTER: 1

INTRODUCTION
As the sources of conventional energy deplete day by day, resorting to alternative sources of energy like
solar and wind energy has become need of the hour.

Solar-powered lighting systems are already available in rural as well as urban areas. These include solar
lanterns, solar home lighting systems, solar streetlights, solar garden lights and solar power packs. All of
them consist of four components: solar photovoltaic module, rechargeable battery, solar charge controller
and load.

In the solar-powered lighting system, the solar charge controller plays an important role as the systems
overall success depends mainly on it. It is considered as an indispensable link between the solar panel,
battery and load.
The microcontroller-based solar charge controller described here has the following features:

1. Built-in digital voltmeter (0V-20V range)


2. Overcharge protection
3. System status display on LCD
4. Low current consumption
5. Highly efficient design based on microcontroller
LCD module: The system status and battery voltage are displayed on an LCD based on HD44780 controller.
The backlight feature of the LCD makes it readable even in low light conditions. The LCD is used here in 4bit mode to save the microcontrollers port pins. Usually the 8-bitmode of interfacing with a microcontroller
requires eleven pins, but in 4-bit mode the LCD can be interfaced to the microcontroller using only
seven pins.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

10
Solar panel: The solar panel used here is meant to charge a 12V battery and the wattage can range from 3 to
40 watts. The peak unloaded voltage output of the solar panel will be around 19 volts. Higher-wattage
panels can be used with some modifications to the controller unit.

Rechargeable battery: The solar energy is converted into electrical energy and stored in a 12V lead-acid
battery. The ampere-hour capacity ranges from 5 Ah to 100 Ah.
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 (12.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 deenergised state.

Load control: One terminal of the load is connected to the battery through a relay. This relay will control
the load providing. That is if the resistance of load is below 3ohms(high current) then the relay get energised
and cut off the load.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

11

CHAPTER : 2

BLOCK DIAGRAM

Figure1:block diagram.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

12

2.1) BLOCK DIAGRAM EXPLANATION


Here we are using PIC16F877A as the major component. Which will control all actions and provide basic
protection based on the program.
We have a 12V rechargeable battery and a 12V solar panel ,on day time the solar panel will provide 12V
,which will charge the battery and provide 12V constant load.The charging is controlled by the Relay 1.If
the battery is full then the relay get energized. So Relay 1 will provide over charge protection.
The relay switch RL2 is used to protect the battery from over load. When an overload is occurred, the relay
switch RL2 is energised and it disconnects load from battery. The relay will be de-energised when the
overload reset switch is pressed.
The voltage at the battery is continuously displayed on the LCD using the built-in ADC module in the PIC
16F877A. The voltage is divided by 3 by using 3 equal value resistors and 1/3 voltage is send to ADC input.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

13

CHAPTER : 3

MICRO CONTROLLER
A microcontroller is a computer-on-a-chip, or, preferably, a single-chip computer. Micro
suggests that the device is small, and controller tells you that the device might be used to control
objects, processes, or events. Another term to describe a microcontroller is embedded controller,
because the microcontroller and its support circuits are often built into, or embedded in, the devices
they control.

Microcontrollers are found in all kinds of things these days. Any device that measures, stores,
controls, calculates, or displays information is a candidate for putting a microcontroller inside. The
largest single use for microcontrollers is in automobilesjust about every car manufactured today
includes at least one microcontroller for engine control, and often more to control additional systems in
the car. In desktop computers, you can find microcontrollers inside keyboards, modems, printers, and
other peripherals. In test equipment, microcontrollers make it easy to add features such as the ability to
store measurements, to create and store user routines, and to display messages and waveforms.
Consumer products that use microcontrollers include cameras, video recorders, compact-disk players,
and ovens. And these are just a few examples.

A micro controller is similar to the microprocessor inside a personal computer. Examples of


microprocessors include Intels 8086, Motorolas 68000, and Zilogs Z80, ATMEL 89c51. These
microprocessors and microcontrollers contain a central processing unit, or CPU. The CPU executes
instructions that perform the basic logic, math, and data-moving functions of a computer. To make a
complete computer, a microprocessor requires memory for storing data and programs, and input/output
(I/O) interfaces for connecting external devices like keyboards and displays.

In contrast, a micro controller is a single-chip computer because it contains memory and


I/O interfaces in addition to the CPU. Because the amount of memory and interfaces that can fit on a
single chip is limited, microcontrollers tend to be used in smaller systems that require little more than
the microcontroller and a few support components.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

14
PIC micro controllers are low-cost computers-in-a-chip; they allow electronics designers
and hobbyists add intelligence and functions that mimic big computers for almost any electronic
product or project.

The programming of the system is done using a PIC micro controller 16F877. This powerful (200
nanosecond instruction execution) yet easy-to-program (only 35 single word instructions) CMOS
FLASH-based 8-bit micro controller packs Microchip's powerful PIC architecture into a 40-pin
package and is upwards compatible with the PIC16C5X, PIC12CXXX and PIC16C7X devices. It is
has five ports. I.e. port A, port B, port C, port D, port E. The PIC 16F877 has flash memory of 8K and
Data memory of 368 bytes Data EEPROM of 256 bytes.The micro-controller used for our project
isMicrochips PIC16F877A.

3.1)PIC 16F877A- FEATURES

High Performance RISC CPU:


High performance RISC CPU
Only 35 single word instructions to learn
All single cycle instructions except for program branches which are two-cycle
Operating speed: DC - 20 MHz clock input
DC - 200 ns instruction cycle
Up to 8K x 14 words of FLASH Program Memory,
Up to 368 x 8 bytes of Data Memory (RAM)
Interrupt capability (up to 12 sources)
Eight level deep hardware stack
Direct, Indirect and Relative Addressing modes
Processor read access to program memory.

Special Microcontroller Features:


Power-on Reset (POR)
Power-up Timer (PWRT) and
Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

15
Oscillator Start-up Timer (OST)
Watchdog Timer (WDT) with its own on-chip RC
oscillator for reliable operation
Programmable code protection
Power saving SLEEP mode
Selectable oscillator options

Peripheral Features:
Timer0: 8-bit timer/counter with 8-bit prescaler
Timer1: 16-bit timer/counter with prescaler,
can be incremented during SLEEP via external
crystal/clock
Timer2: 8-bit timer/counter with 8-bit period
register, prescaler and postscaler
Two Capture, Compare, PWM modules
- Capture is 16-bit, max. resolution is 12.5 ns
- Compare is 16-bit, max. resolution is 200 ns
- PWM max. resolution is 10-bit

8-bit, up to 8-channel Analog-to-Digital converter


Synchronous Serial Port (SSP) with SPI (Master
mode) and I2C (Slave)
Universal Synchronous Asynchronous Receiver
Transmitter (USART/SCI)
Parallel Slave Port (PSP), 8-bits wide with
external RD, WR and CS controls (40/44-pin only)
Brown-out detection circuitry for
Brown-out Reset (BOR)

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

16

WHY PIC IS USED?

Speed

High Performance RISC CPU

Instruction Set Simplicity

Integration Of Operation Features

Programmable Timer Options

Interrupt Control

EPROM /OTP/ROM options

Inbuilt Modules

Low Power Consumption

Wide Operation Voltage Range :2.5to 6.0 Volt

Programmable Code Protection Mode

Power Saving Sleep Mode

3.2)BlockDiagramof PICMicroController

Figure2: BLOCKDIAGRAMOF PICMICROCONTROLLER


Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

17

3.3)PINOUT DIAGRAM OF PIC 16F877

Figure3:PINOUT DIAGRAM OF PIC 16F877

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

18

PIN NAME

DIP
PIN #

PLCCP
IN #

I/O/O

BUFFER
TYPE

DESCRIPTION

Q
FP

St/cmos

Osc.crystal
i/p. osc.crystal
o/p
Master clear
i/p or program
o/p.
Port A is bi
directional i/p
.

30

Osc/clkin

13

14

TYPE
1

Osc/clkout

14

15

MCLR/Vpp

i/p

St

RA0/AN0

I/O

TTL

RA1/AN1

I/O

TTL

RA2/AN2/VREF-

I/O

TTL

21

RA3/AN3/VREF+

I/O

TTL

22

RA4/TOCK1

I/O

SL

23

RA5/SS/AN4
RB0/INT

7
33

8
36

I/O
I/O

TTL
TTL/ST1

24
8

RB1

34

37

I/O

TTL

RB2

35

38

I/O

TTL

RB3/PGM

36

39

I/O

TTL

RB4

37

41

I/O

TTL

14

RB5

38

42

I/O

TTL

15

RB6/PGC

39

43

I/O

TTL/ST2

16

RB7/PGD

40

44

I/O

TTL/ST2

17

Port B is a bi
directional i/o
port. Port b
can be s/w
pgmed for
pull up on

31
18

19
20

9
10
11

Tbl1:Pin out table of PIC 16F877A

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

19

Input/output ports
PIC16F877 has 5 basic input/output ports. They are usually denoted by PORT A (R A), PORT B (RB), PORT C
(RC), PORT D (RD), and PORT E (RE). These ports are used for input/ output interfacing. In this controller,
PORT A is only 6 bits wide (RA-0 to RA-7), PORT B , PORT C,PORT D are only 8 bits wide (RB-0 to
RB-7,RC-0 to RC-7,RD-0 to RD-7), PORT E has only 3 bit wide (RE-0 to RE-7).

PORT-A

RA-0 to RA-5

6 bit wide

PORT-B

RB-0 to RB-7

8 bit wide

PORT-C

RC-0 to RC-7

8 bit wide

PORT-D

RD-0 to RD-7

8 bit wide

PORT-E

RE-0 to RE-2

3 bit wid

Tbl2 :Ports in PIC 16F877A

All these ports are bi-directional. The direction of the port is controlled by using TRIS(X) registers (TRIS A used
to set the direction of PORT-A, TRIS B used to set the direction for PORT-B, etc.). Setting a TRIS(X) bit 1
will set the corresponding PORT(X) bit as input. Clearing a TRIS(X) bit 0 will set the corresponding PORT(X)
bit as output.
(If we want to set PORT A as an input, just set TRIS(A) bit to logical 1 and want to set PORT B as an output,
just set the PORT B bits to logical 0.)

Other Pins:
o Analog input port (AN0 TO AN7) : these ports are used for interfacing analog inputs.
o TX and RX: These are the USART transmission and reception ports.
o SCK: these pins are used for giving synchronous serial clock input.
o SCL: these pins act as an output for both SPI and I2C modes.
o DT: these are synchronous data terminals.
o CK: synchronous clock input.
o SD0: SPI data output (SPI Mode).
o SD1: SPI Data input (SPI mode).
Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

20
o SDA: data input/output in I2C Mode.
o CCP1 and CCP2: these are capture/compare/PWM modules.
o OSC1: oscillator input/external clock.
o OSC2: oscillator output/clock out.
o MCLR: master clear pin (Active low reset).
o Vpp: programming voltage input.
o THV: High voltage test mode controlling.
o Vref (+/-): reference voltage.
o SS: Slave select for the synchronous serial port.
o T0CK1: clock input to TIMER 0.
o T1OSO: Timer 1 oscillator output.
o T1OS1: Timer 1 oscillator input.
o T1CK1: clock input to Timer 1.
o PGD: Serial programming data.
o PGC: serial programming clock.
o PGM: Low Voltage Programming input.
o INT: external interrupt.
o RD: Read control for parallel slave port.
o CS: Select control for parallel slave.
o PSP0 to PSP7: Parallel slave port.
o VDD: positive supply for logic and input pins.
VSS: Ground reference for logic and input/output pins.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

21
Tbl 4:specifications of the PIC 16F87X Series

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

22

DATA MEMORY &PROGRAM MEMORY


The PIC 16F87x devices have a 13-bit program counter, Capable of addressing
an 8K x 14 program memory space. The PIC 16F877 has 8Kx 14 words of FLASH
program memory. The RESET Vector is at 0000h and the interrupt vector is at 0004h.
Data memory is partition in to multiple banks which contain the general
purpose registers and special function registers. Bits RP1(status <6>) and
RP0(status<5>) are the banks bits.

BANK
RP1:RP0
00
01
10
11

0
1
2
3

Tbl3: Register bank select

Each bank extends up to 7Fh (128bits). The lower location of each banks are
Reserved for the special function registers. About the special function registers are
general purpose registers, implemented as the static RAM. All implemented banks
contain special function registers .Some frequently used special function register from 1
bank may be mirrored in another bank for code reduction and quicker access.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

23

ANALOG TO DIGITAL CONVERTER MODULE (ADC)


The analog to digital converter module has 8 inputs for the 40 pin PIC .The A/D
module has 4 register :
A/D results high register.
A/D results low register
A/D control register 0.
A/D control register 1.
The A/D conversion of the analog input signals in a corresponding 10-bit digital
number.
ADCON0 REGISTER.
R/W-0

R/W-0 R/W-0 R/W-0 R/W-0

ADCS ADCS
1
0

CHS
2

CHS
1

CHS
0

R/W-0

GO/DONE

U-0

------

R/W-0

ADCON

ADCON1 REGISTER
U-0

U-0

R/W-0 U-0

R/W-0

ADF
M

R/W-0

R/W-0

R/W-0

PCF

PCF

PCF

PCF

G3

G2

G1

G0

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

24

USART
This mode is usually used to communicate in 8-bit ASCII code. It has two pins
for transmittion and reception.Transmittion begins whenever data is written to SBUF.
USART is an acronym for universal synchronous asynchronous receiver and
transmitter.
Control Register Of Transmittion (Txsta)
CS
RC

TX
9

TxEN

SYNC

BRGH

TRMT

Tx9D

Control Register Of Reception (Rxsta)


SPE
N

Rx
9

SRE
N

Electronics and Communication Engineering Department

CRE
N

ADDE
N

FER
R

OER
R

SNGIST

Rx9
D

Microcontroller Based Solar Charger

25

CHAPTER: 4

LCD DISPLAY
A liquid-crystal display (LCD) is a flat panel display, electronic visual display, or
video display that uses the light modulating properties of liquid crystals. Liquid crystals
do not emit light directly. LCDs are available to display arbitrary images (as in a
general-purpose computer display) or fixed images which can be displayed or hidden,
such as preset words, digits, and 7-segment displays as in a digital clock. They use the
same basic technology, except that arbitrary images are made up of a large number of
small pixels, while other displays have larger elements.

A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In
this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers,
namely, Command and Data.The command register stores the command instructions
given to the LCD. A command is an instruction given to LCD to do a predefined task
like initializing it, clearing its screen, setting the cursor position, controlling display etc.
The data register stores the data to be displayed on the LCD. The data is the ASCII
value of the character to be displayed on the LCD.

4.1)PINDESCRIPTION
The most commonly used LCDs found in the market today are 1Line,2Line or4 Line LCDs which
have only1 controller and support at most of 80 characters, where as LCD s supporting more than 80
characters make use of 2HD44780 controllers.
Most LCD swith 1 controller has 14 Pins and LCDs with 2 controller has16 Pins (two pinsare
extrainbothforback-lightLEDconnections).Pindescriptionis showninthe tablebelow.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

26

Figure: 4 :16 x 2 LCD Pin diagram


Pin
No:

Function

Name

Ground (0V)

Ground

Supply voltage; 5V (4.7V 5.3V)

Vcc

Contrast adjustment; through a variable resistor

VEE

Selects command register when low; and data register when high

Register Select

Low to write to the register; High to read from the register

Read/write

Sends data to data pins when a high to low pulse is given

Enable

DB0

DB1

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-

Tbl 4: Pin description table of LCD module


Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

27

CHAPTER: 5

ELECTRO MECHANICAL RELAYS


A relay is a switch worked by an electromagnet. It is useful if we want a small current in one
circuit to control another circuit containing a device such as a lamp or electric motor which requires a
large current, or if we wish several different switch contacts to be operated simultaneously.

When the controlling current flows through the coil, the soft iron core is magnetized and
attracts the L-shaped soft iron armature. This rocks on its pivot and opens, closes or changes over, the
electrical contacts in the circuit being controlled it closes the contacts.
The current needed to operate a relay is called the pull-in current and the dropout current in
the coil when the relay just stops working. If the coil resistance R of a relay is 185 and its
operating voltage V is 12V, the pull-in current I is given by:

I = V/R = 12/185 = 65 mA

Relays are electromagnetic switches, which provides contact between two mechanical elements.
Relays have a coil which works on 12V dc power supply and provides DPDT action as an output.
In general relays provide potential free contacts which can be used for universal function like
DC, AC voltage switching and to control bigger electrical switch gears.
The electromechanical relays are

based on the comparison between operating torque/force

and restraining torque/force. The VA burden of such relays are high.


The characteristics of these relays have some limitations.
protective function.

Such relays are used

Each relay can perform only one

for simple and less costly protection purposes. For

important and costly equipment installation static relays are


preferred.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

28

Figure: 5: Relay schematic diagram

Protective relaying is necessary for almost every electrical plant and no part of the power system
is left unprotected.
The choice of protection depends upon several aspects such as

type and rating of the protected equipment.

its importance.

location and cost.

probable abnormal conditions between generators and final


load points.

There are several electrical equipments and machines of various ratings. Each needs
certain adequate protection .The protective relaying senses the abnormal conditions in a part of the
power system and isolates that part from the healthy part of system.The relays used in this project are
compact, self-contained devices which respond to abnormal conditions (relays can distinguish normal
and abnormal conditions).The Relay driver Circuit Works as follows.

A Relay is connected as

shown in the figure 5(a).

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

29

Figure 6: Working Of Relay Circuit

The output of the controller decides Relay operation.

The Relay works only if the Positive and

the Ground is connected to the appropriate terminals of the relay coil. We control the relay by
controlling the ground signal given to the relay using a transistor. The operation is as follows.
When the output of the controller is High, then the transistor conducts, allowing the low potential to
reach one end of the relay, which results in switching of the relay form NC to NO.
When the output is Low, the transistor will not conduct. So ground is not applied to the relay Coil. So
the relay remain in NC position.
Using this Normally open (NO) and Normally Closed (NC) contacts we can switch any supply AC
or DC. The supply to the operated device should be given to the Common of the relay and the
output from the NO is given to the Device. So that
when the relay is switched on the device gets supply and works.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

30

CHAPTER: 6

SOLAR PANEL
6.1 )PHOTO VOLTAIC CELLS (PV CELLS)

There are two basic types of solid silicon, amorphous (having no long range order) and crystalline
(where the atoms are arranged in an ordered three dimensional array). There are various other terms
for the crystalline structure of silicon; poly-crystalline, micro-crystalline, nano-crystalline etc, and
these refer to the size of the crystal "grains" which make up the solid. Solar cells can be, and are
made from each of these types of silicon, the most common being poly-crystalline.

Silicon is a semiconductor. This means that in solid silicon, there are certain bands of energies which
the electrons are allowed to have, and other energies between these bands which are forbidden. These
forbidden energies are called the "band gap". The allowed and orbidden bands of energy are
explained by the theory of quantum mechanics.
At room temperature, pure silicon is a poor electrical conductor. In quantum mechanics, this is
explained by the fact that the Fermi level lies in the forbidden band- gap. To make silicon a better
conductor, it is "doped" with very small amounts of atoms from either group 13 (III) or group 15 (V)
of the periodic table. These "dopant" atoms take the place of the silicon atoms in the crystal lattice, and
bond with their neighboring Si atoms in almost the same way as other Si atoms do. However, because
group 13 atoms have only 3 valence electrons, and group 15 atoms have 5 valence electrons, there is
either one too few, or one too many electrons to satisfy the four covalent bonds around each atom.
Since these extra electrons, or lack of electrons (known as "holes") are not involved in the covalent
bonds of the crystal lattice, they are free to move around within the solid. Silicon which is doped with
group 13 atoms (aluminum, gallium) is known as p-type silicon because the majority charge carriers
(holes) carry a positive charge, whilst silicon doped with group 15 atoms (phosphorus, arsenic) is
known as n-type silicon because the majority charge carriers (electrons) are negative. It should be
noted that both n-type and p-type silicon are electrically neutral,
i.e. they have the same numbers of positive and negative charges, it is just that in n-type silicon,
some of the negative charges are free to move around, while the converse is true for p-type silicon.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

31
A solar cell is a large-area semiconductor p-n junction. To understand the workings of a p-n junction it
is convenient to imagine what happens when a piece of n-type silicon is brought into contact with a
piece of p-type silicon. In practice, however, the p-n junctions of solar cells are not made in this way,
but rather, usually, by diffusing an n- type dopant into one side of a p-type wafer.

If we imagine what happens when a piece of p-type silicon is placed in intimate contact with a
piece of n-type silicon, then what occurs is a diffusion of electrons from the region of high
electron concentration - the n-type side of the junction, into the region of low electron concentration
- p-type side of the junction. When the electrons diffuse across the p-n junction, they recombine
with holes on the p-type side. This diffusion of carriers does not happen indefinitely however,
because of the electric field which is created by the imbalance of charge immediately either side of
the junction which this diffusion creates. Electrons from donor atoms on the n-type side of the junction
are crossing into the p-type side, leaving behind the (extra) positively charged nuclei of the group 15
donor atoms, leaving an excess of positive charge on the n-type side of the junction. At the same
time, these electrons are filling in holes on the p-type side of the junction, becoming involved in
covalent bonds around the group 13 acceptor atoms, making an excess of negative charge on the ptype side of the junction. This imbalance of charge across the p-n junction sets up an electric field
which opposes further diffusion of charge carriers across the junction.

This region where electrons have diffused across the junction is called the depletion region because it
no longer contains any mobile charge carriers. It is also known as the "space charge region". The
electric field which is set up across the p-n junction creates a diode, allowing current to flow in only
one direction across the junction. Electrons may pass from the n-type side into the p-type side, and
holes may pass from the p-type side to the n-type side. But since the sign of the charge on
electrons and holes is opposite, conventional current may only flow in one direction.
Because solar cells are semiconductor devices, they share many of the same processing and
manufacturing techniques as other semiconductor devices such as computer and memory chips.
However, the stringent requirements for cleanliness and quality control of semiconductor fabrication
are a little more relaxed for solar cells. Most large-scale commercial solar cell factories today make
screen printed poly- crystalline silicon solar cells. Single crystalline wafers which are used in the
semiconductor industry can be made in to excellent high efficiency solar cells, but they are
generally considered to be too expensive for large-scale mass production. Poly-crystalline silicon
Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

32
wafers are made by wire-sawing block-cast silicon ingots into very thin (250 to 350 micrometer) slices
or wafers
The wafers are usually lightly p-type doped. To make a solar cell from the wafer, an n-type diffusion
is performed on the front side of the wafer, forming a p-n junction a few hundred nanometres below
the surface. Antireflection coatings, which increase the amount of light coupled into the solar cell,
are typically applied next. Over the past

decade,

silicon

nitride

has

gradually

replaced

titanium dioxide as the antireflection coating of choice because of its excellent surface passivation
qualities (i.e., it prevents carrier recombination at the surface of the solar cell). It is typically applied in
a layer several hundred nanometers thick using plasma-enhanced chemical vapor deposition
(PECVD). The wafer is then metallised, whereby a full area metal contact is made on the back
surface, and a grid-like metal contact made up of fine "fingers" and larger "busbars" is screen-printed
onto the front surface using a silver paste. The rear contact is also formed by screen-printing a metal
paste, typically aluminum. Usually this contact covers the entire rear side of the cell, though in some
cell designs it is printed in a grid pattern. The metal electrodes will then require some kind of heat
treatment or "sintering" to make Ohmic contact with the silicon. After the metal contacts are
made, the solar cells are interconnected in series (and/or parallel) by flat wires or metal ribbons, and
assembled into modules or "solar panels".

Solar panels have a sheet of tempered glass on the front, and a polymer encapsulation on the back.
Some solar cells have textured front surfaces that, like antireflection coatings, serve to increase the
amount of light coupled into the cell. Such surfaces can usually only be formed on single-crystal
silicon, though in recent years methods of forming them on multicrystalline silicon have been
developed
These are also known as solar cells and their assembly is termed as solar panel, let us see the
individual discrete component of solar cell which is shown in below Fig

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

33
Figure 7: STRUTURE
OF SOLAR CELL

PV cells were invented in 1953 by Charles Fariett. A PV cell is used for converting photon into
electron and with sun light incident, electrical energy is generated. The solar-based battery may be
used to directly feed electricity to electronic equipment or for domestic heating. Solar batteries can
also be used for satellites, communication equipment and domestic appliances.

A selenium-or silicon-based solar cell exhibits open-circuit voltage of only 0.5V and short-circuit cell
current of the order of 1milliampere for 6.4cm area of the cell at6458 meter candles. Therefore a
large number of such silicon or selenium solar cells need to be connected in series and parallel to
provide any significant power. A telemetry system required to operate 24 hours a day requires a
solar panel providing 5 watts at 12 volts used for recharging corresponding storage batteries during
daylight hours.

Figure 8: solar panel

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

34

CHAPTER: 7

RECHARGEABLE BATTERY
A rechargeable battery, storage battery, or accumulator is a type of electrical battery. It comprises one or
more electrochemical cells, and is a type of energy accumulator. It is known as a secondary cell because
its electrochemical reactions are electrically reversible. Rechargeable batteries come in many different
shapes and sizes, ranging from button cells to megawatt systems connected to stabilize an electrical
distribution network. Several different combinations of chemicals are commonly used, including: lead
acid, nickel cadmium (NiCd),nickel metal hydride (NiMH), lithium ion (Li-ion), and lithium ion
polymer (Li-ion polymer).
Rechargeable batteries have lower total cost of use and environmental impact than disposable batteries.
Some rechargeable battery types are available in the same sizes as disposable types. Rechargeable batteries
have higher initial cost but can be recharged very cheaply and used many times

7.1)Charging and discharging


During charging, the positive active material is oxidized, producing electrons, and the negative material
is reduced, consuming electrons. These electrons constitute the current flow in the external circuit.
The electrolyte may serve as a simple buffer for internal ion flow between the electrodes, as in lithiumion and nickel-cadmium cells, or it may be an active participant in the electrochemical reaction, as in lead
acid cells.

Figure 9:Diagram of the charging of a secondary cell battery.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

35
The energy used to charge rechargeable batteries usually comes from a battery charger using AC mains
electricity, although some are equipped to use a vehicle's 12-volt DC power outlet. Regardless, to store
energy in a secondary cell, it has to be connected to a DC voltage source. The negative terminal of the cell
has to be connected to the negative terminal of the voltage source and the positive terminal of the voltage
source with the positive terminal of the battery. Further, the voltage output of the source must be higher than
that of the battery, but not much higher: the greater the difference between the power source and the battery's
voltage capacity, the faster the charging process, but also the greater the risk of overcharging and damaging
the battery.
Chargers take from a few minutes to several hours to charge a battery. Slow "dumb" chargers without
voltage- or temperature-sensing capabilities will charge at a low rate, typically taking 14 hours or more to
reach a full charge. Rapid chargers can typically charge cells in two to five hours, depending on the model,
with the fastest taking as little as fifteen minutes. Fast chargers must have multiple ways of detecting when a
cell reaches full charge (change in terminal voltage, temperature, etc.) to stop charging before harmful
overcharging or overheating occurs. The fastest chargers often incorporate cooling fans to keep the cells
from overheating.
Battery charging and discharging rates are often discussed by referencing a "C" rate of current. The C rate is
that which would theoretically fully charge or discharge the battery in one hour. For example, trickle
charging might be performed at C/20 (or a "20 hour" rate), while typical charging and discharging may
occur at C/2 (two hours for full capacity). The available capacity of electrochemical cells varies depending
on the discharge rate.

Figure:10 lead acid battery

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

36

CHAPTER : 8

CIRCUIT DIAGRAM

Figure:CIRCUIT DIAGRAM

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

37

8.1)CIRCUIT DIAGRAM EXPLANATION


Here we are using PIC16F877Aas the major component. Which will control all actions and provide basic
protection based on the program.
The current produced by the solar panel is flowing to the battery through a relay switch RL1. When the
battery is fully charged RL1 will be energised and disconnects the solar panel from battery .The relay switch
RL2 is used to protect the battery from over load. When an overload is occurred, the relay switch RL2 is
energised and it disconnects load from battery.

The relay will be de-energised when the overload reset switch is pressed. The voltage at the battery is
continuously displayed on the LCD using the built-in ADC module in the PIC 16F877A. The voltage is
divided by 3 by using 3 equal value resistors and 1/3 voltage is send to ADC input. The analogue voltage is
converted into digital and it is displayed on LCD after multiplying with 3. The reference voltage for the
ADC conversion is taken from the VDD supply.

The rated current of the power supply is chosen as 3A. At full load, the load voltage will be 9.6V
(full load resistance = V/I = 12V/3A = 4Ohm. Therefore Load voltage = 12 x 4/5 = 9.6V using voltage
divider rule) it is divided by 3 using resistive network and given to ADC channel 2(AN2). The voltage is
continuously measured by the pic. If over load occurs, the voltage at load reduces. It is detected by the pic
and energises relay switch 2 and disconnects load from over current.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

38

CHAPTER: 9

PROGRAM CODING

sbit LCD_RS at RB0_bit;


sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;


sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
float b;
float a;
char txt[10];
void main()
{
trisa=0xff;

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

39
trisc=0xff;
trisd=0x00;
Lcd_Init();
Lcd_Cmd(_LCD_CURSOR_OFF);
delay_ms(200);
ADC_Init();
delay_ms(200);
while(1)
{
a=.00488*ADC_Read(0)*3;
FloatToStr(a, txt);
strcat(txt,"V");
Lcd_Out(1,2,"SOLAR CHARGER");
Lcd_Out(2,4,txt);
//Lcd_Out(2,6,"v");
delay_ms(300);
if(a>12)
portd.f7=0;
else
portd.f7=1;
b=.0048*ADC_Read(1);
/*Lcd_Out(1,1,"load");
FloatToStr(b, txt);
Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

40
Lcd_Out(2,1,txt);
delay_ms(1000);*/
if(b<3)
{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,4,"OVER LOAD");
portd.f6=1;
while(portc.f0==1);
portd.f6=0;
}
else
portd.f6=0;}}

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

41

CHAPTER : 10

PCB FABRICATION AND SOLDERING


Printed Circuit Board (PCB) is piece of art. The performance of an electronic
circuit depends on the design and layout of the PCB. A PCB mechanically supports and
connects components by conductive pathways, etched from copper sheets laminated on to
insulated substrate. PCB are used to rotate electrical currents and signals through copper tracts
which are firmly bonded to an insulating base.
PCB fabrication involves following steps:
1.

Drawing the layout of the PCB in the paper. The track layout of the electronic circuit

should be made in such manner that the paths are in easy routes. It is then transferred to a Mylar
sheet. The sheet is then touched with black ink.
2.

The solder side of the Mylar sheet is placed on the shiny side of the five-star sheet and

is placed in a frame. Then it is exposed to sunlight with Mylar sheet facing the sunlight.
3.

The exposed five-star sheet is put in hydrogen peroxide solution. Then it is put in hot

ater and shook till unexposed region becomes transparent.


4.

This is put in cold water and then the rough side is stuck onto the silk screen. This is

then pressed and dried well.


5.

The plastic sheet of the five-star sheet is removed leaving the pattern on the screen.

6.

A copper clad sheet is cut to the size and cleaned. This is placed under screen.

7.

As it resistant ink if spread on the screen so that a pattern of tracks and a pad is

obtained on a copper clad sheet. It is then dried.


8. The dried sheet is then etched using ferric chloride solution
9.

(32Baume) till all the unwanted copper is etched away. Swish the board to keep the each

fluid moving. Lift the PCB and check whether all the unwanted copper is removed. Etching is
done by immersing the marked copper clad in ferric chloride solution. After that the etched
Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

42
sheet is dried.The unwanted resist ink is removed using sodium hydroxide solution Holes are
then dried.

PCB PARAMETERS
Copper thickness- 72mil (1mm=39.37mils)
Track width- 60 mil
Clearance - 60 mil
Pad width- 86mil
Pad height - 86 mil
Pad shape- oval
Pad hole size- 25mil
On board- Through
Hole size- .9mm(36mil)
Base - paper phenolic, hylam
PCB Quality- FRC

SOLDERING
Soldering is the process of joining metals by using lower melting point to weld or alloy with
joining surface.

SOLDER:
Solder is the joining material that melts below 427 degree connections between
components.The popularly used solders are alloys of tin(Sn) and lead(Pb) that melts below the
melting point if tin.
Types:
1.

Rosin core: - 60/40 Sn/Pb solders are the most common types used for electronics

assembly. These solders are available in various diameters and are most appropriate for small
electronics work(0.02-0.05|| dia is recommended)

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

43
2.

Lead free :- Lead free solders are used as more environmental-friendly substitutes for

leaded solder, but they are typically not as easy to use mainly because of their higher melting
point and poorer wetting properties.
3.

Silver:- Silver solders are typically used for low resistance connections but they have

a higher melting point and are expensive than Sn/Pb solders.


4.

Acid-core:- acid-core solders should not be used for electronics.They are intended for

plumbing of non-electronics assembly work. The acid-core flux will cause corrosion of circuitry
and can damage components.
5.Other special solders:- various melting point eutectics: these

6.special solders are typically used for non-electronic assembly of difficult to construct
mechanical items that must be assembled in a particular sequence .

FLUX
In order to make the surface accept the solder readily ,the components terminals should be free
oxides and other obstructing films .the lead should be cleaned chemically or by abrasion using
blades or knives. Small amount of lead coating can be done on the portion of the leads using
soldering iron .this process is called thinning. Zinc chloride or ammonium chloride separately or
in combination is mostly used as fluxes. These are available in petroleum jelly as paste flux. The
desirable properties of flux are:It should provide a liquid cover over the materials and exclude air gap up to the soldering
temperature. It should dissolve any oxide on the metal surface. It should be easily replaced from
the metal by the molten soldering operation.Residue should be removable after completing
soldering operation.The most common flux used in hand soldering of electronic components is
rosin, a combination of mild organic acids extracted from pine tree.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

44

SOLDERING IRON
It is a tool used to melt the solder and apply it at the joints in the circuit. it
operates in 230V supply. The iron at the tip gets heated while few minutes. 50W and 25W
soldering irons are commonly used for soldering of electronics circuit.

SOLDERING STEPS
1.

Make the layout of the component in the circuit. Plug in the chord of the soldering

irons the main to get heated.


2.

Straighten and clean the component leads using a blade or knife.

3.

Mount the components on the PCB by bending the leads of the components. Use nose

pliers.
4.

Apply flux on the joints and solder the joints. Solder must be in minimum time to

avoid dry soldering and heating up of the components.


5.Wash the residue using water and brush.
6.Solder joints should be inspected when completed to determine if they have been properly
made.

CHARACTERISTICS OF A GOOD SOLDER JOINTS:


A. Shiny surface
B. Good, smooth fillet

CHARACTERISTICS OF A POOR SOLDER JOINTS:


1.

Dull or crystallized surface: This is an indicator of a cold solder joint. Cold solder joint

result from moving the component after soldering has been removed, but before the solder has
hardened. Cold solder joints may work at first, but will eventually fail.
2.

Air Pocket: Air pocket (voids) result from incomplete wetting of surface, allowing air

to be in contact with the connecting metals. This will cause oxidation of the joints & eventual
Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

45
failure. Blow holes can occur due to vaporization of moisture on the surface of the board &
existing through the molten solder. Boards should be clean & dry, prior to soldering. Ethanol
(100%) can be used as a moisture chaser if boards are wet prior to soldering.
3. Dimples: Dimples in the surface do not always indicate a serious problem, but they should be
avoided since they are precursors to voids.
4. Floaters: Black spots-Floating in the soldering fillet should be avoided, because they indicate
contamination & potential for failure as in the case of voids. These black spots usually results
from overheated (burnt) Rosin or other contaminants such as burnt wire insulation. Maintaining
a clean tip will help to avoid these problems.
5.Balls:A solder balls instead of a fillet can occur if the trace was heated but the leads were
not(vice versa).This prevents proper wetting of both surfaces & result in solder being attached to
only one surface(component of trace).
6. Excess solder: Excess solder usage can cover up other potential problems & should be
avoided. It can lead to solder bridges. In addition, spherical solder joints can result from the
application of too much solder

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

46

PCB LAYOUT

Figure: PCB LAYOUT

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

47

CHAPTER : 11

SOFTWARES USED

PROTHEUS
Proteus is a software for microprocessor simulation, schematic capture, and printed circuit board (PCB)
design. It is developed by Labcenter Electronics.The XGameStation Micro Edition was designed using
Labcenter's Proteus schematic entry and PCB layout tools
Proteus PCB design combines the ISIS schematic capture and ARES PCB layout programs to provide a
powerful, integrated and easy to use suite of tools for professional PCB Design.All Proteus PCB design
products include an integrated shape based autorouter and a basic SPICE simulation capability as standard.
More advanced routing modes are included in Proteus PCB Design Level 2 and higher whilst simulation
capabilities can be enhanced by purchasing the Advanced Simulation option and/or micro-controller
simulation capabilities.

System components

ISIS Schematic Capture - a tool for entering designs.

PROSPICE Mixed mode SPICE simulation - industry standard SPICE3F5 simulator combined with a
digital simulator.

ARES PCB Layout - PCB design system with automatic component placer, rip-up and retry auto-router
and interactive design rule checking.

VSM - Virtual System Modelling lets cosimulate embedded software for popular micro-controllers
alongside hardware design.

System Benefits Integrated package with common user interface and fully context sensitive help.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

48

Figure: PROTEUS INTERFACE WINDOW

MIKRO C
MikroC is a full-featured ANSI C compiler that is available for six different microcontroller architectures (in
this case, for PIC 12/16/18). It features an intuitive IDE, a powerful compiler with advanced SSA
optimizations, lots of hardware and software libraries, and additional tools that will help you in your work.
The compiler comes with a comprehensive Help file (700 pages) and lots of ready-to-use examples designed
to get you started in no time.
Each compiler license includes free upgrades and tech support for the lifetime of the product. The software
features a Live Update service so you can get new features and improvements instantly.
The mikroC PRO for PIC compiler supports 504 PIC microcontrollers. Newly released PIC microcontrollers
will be supported by new versions of the compiler software that is updated regularly.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

49
The compiler is designed to be smart and efficient, so you can rely on it to do the hard work. It features four
levels of optimizations that can reduce your code size up to 20 percent. Standard header files are included
that make it easy to port your code from other C compilers.

MikroC PRO for PIC C Compiler Features


Single-click Debugging
mikroC PRO for PIC has native support for the mikroICD In-Circuit Debugger feature of the fast USB
2.0 mikroProg-PIC programmer (in both on-board and standalone versions). mikroICD is a separate DLL
module which supports Step-over, Step-Into, Step-Out, Run, and Run-to-Cursor debugging operations. Also,
the debugger supports standard and advanced breakpoints.
Faster, better, more productive
mikroC PRO for PIC comes equipped with fully functional software tools that can boost your efficiency and
do the job for you, so you can be more productive in your work: LCD Custom Character Tool, GLCD
Bitmap Editor, Seven-Segment Editor, UART Terminal, UDP Terminal, HID Terminal, ASCII Chart,
Active Comments Editor, Advanced Statistics and more.

Electronics and Communication Engineering Department

SNGIST

Microcontroller Based Solar Charger

50

APPENDICES
1)

PIC16F87XA
Data Sheet
28/40/44-Pin Enhanced Flash
Microcontrollers

www.nitropdf.com

Microcontroller Based Solar Charger

51

PIC16F87XA
28/40/44-Pin Enhanced Flash Microcontrollers
Devices Included in this Data Sheet:
PIC16F873A
PIC16F874A

Analog Features:
10-bit, up to 8-channel Analog-to-Digital
Converter (A/D)
Brown-out Reset (BOR)
Analog Comparator module with:
- Two analog comparators
- Programmable on-chip voltage reference
(VREF) module
- Programmable input multiplexing from device
inputs and internal voltage reference
- Comparator outputs are externally accessible

PIC16F876A
PIC16F877A

High-Performance RISC CPU:


Only 35 single-word instructions to learn
All single-cycle instructions except for program
branches, which are two-cycle
Operating speed: DC 20 MHz clock input
DC 200 ns instruction cycle
Up to 8K x 14 words of Flash Program Memory,
Up to 368 x 8 bytes of Data Memory (RAM),
Up to 256 x 8 bytes of EEPROM Data Memory
Pinout compatible to other 28-pin or 40/44-pin
PIC16CXXX and PIC16FXXX microcontrollers

Special Microcontroller Features:


100,000 erase/write cycle Enhanced Flash
program memory typical
1,000,000 erase/write cycle Data EEPROM
memory typical
Data EEPROM Retention > 40 years
Self-reprogrammable under software control
In-Circuit Serial Programming (ICSP)
via two pins
Single-supply 5V In-Circuit Serial Programming
Watchdog Timer (WDT) with its own on-chip RC
oscillator for reliable operation
Programmable code protection
Power saving Sleep mode
Selectable oscillator options
In-Circuit Debug (ICD) via two pins

Peripheral Features:
Timer0: 8-bit timer/counter with 8-bit prescaler
Timer1: 16-bit timer/counter with prescaler,
can be incremented during Sleep via external
crystal/clock
Timer2: 8-bit timer/counter with 8-bit period
register, prescaler and postscaler
Two Capture, Compare, PWM modules
- Capture is 16-bit, max. resolution is 12.5 ns
- Compare is 16-bit, max. resolution is 200 ns
- PWM max. resolution is 10-bit
Synchronous Serial Port (SSP) with SPI
(Master mode) and I2C (Master/Slave)
Universal Synchronous Asynchronous Receiver
Transmitter (USART/SCI) with 9-bit address
detection
Parallel Slave Port (PSP) 8 bits wide with
external RD, WR and CS controls (40/44-pin only)
Brown-out detection circuitry for
Brown-out Reset (BOR)

CMOS Technology:
Low-power, high-speed Flash/EEPROM
technology
Fully static design
Wide operating voltage range (2.0V to 5.5V)
Commercial and Industrial temperature ranges
Low-power consumption

Program Memory

Device

MSSP
Data
EEPROM
10-bit
CCP
Timers
# Single Word SRAM (Bytes) I/O A/D (ch) (PWM)
Master USART 8/16-bit Comparators
Bytes
SPI
Instructions (Bytes)
I 2C

PIC16F873A 7.2K

4096

192

128

22

Yes

Yes

Yes

2/1

PIC16F874A 7.2K

4096

192

128

33

Yes

Yes

Yes

2/1

PIC16F876A 14.3K

8192

368

256

22

Yes

Yes

Yes

2/1

PIC16F877A 14.3K

8192

368

256

33

Yes

Yes

Yes

2/1

www.nitropdf.com

Microcontroller Based Solar Charger

52

PIC16F87XA
Pin Diagrams
28-Pin PDIP, SOIC, SSOP
28
27
26
25
24
23
22
21
20
19
18
17
16
15

RA1/AN1
RA0/AN0
MCLR/VPP
RB7/PGD
RB6/PGC
RB5
RB4

RB7/PGD
RB6/PGC
RB5
RB4
RB3/PGM
RB2
RB1
RB0/INT
VDD
VSS
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA

.......

RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC3/SCK/SCL
RC2/CCP1
RC1/T1OSI/CCP2
RC0/T1OSO/T1CKI

44-Pin QFN

---p

PIC16F874A
PIC16F877A

33
32
31
30
29
28
27
26
25
24
23

12
13
14
15
16
17
18
19
20
21
22

1
2
3
4
5
6
7
8
9
10
11

----~
~

OSC2/CLKO
OSC1/CLKI
VSS
VSS
VDD
VDD
RE2/CS/AN7
RE1/WR/AN6
RE0/RD/AN5
RA5/AN4/SS/C2OUT
RA4/T0CKI/C1OUT

.......

.....

11I1111ll~

RB3/PGM
NC
RB4
RB5
RB6/PGC
RB7/PGD
MCLR/VPP
RA0/AN0
RA1/AN1
RA2/AN2/VREF-/CVREF
RA3/AN3/VREF+

.....
....

44
43
42
41
40
39
38
37
36
35
34

lUllIllll1
RC7/RX/DT
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7
VSS
VDD
VDD
RB0/INT
RB1
RB2

.......
.......
.......

1
2
3
4
5
6
7

PIC16F873A
PIC16F876A

21
20
19
18
17
16
15

RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL
RC4/SDI/SDA
RC5/SDO
RC6/TX/CK

RA2/AN2/VREF-/CVREF
RA3/AN3/VREF+
RA4/T0CKI/C1OUT
RA5/AN4/SS/C2OUT
VSS
OSC1/CLKI
OSC2/CLKO

28
27
26
25
24
23
22

28-Pin QFN

8
9
10
11
12
13
14

PIC16F873A/876A

1
2
3
4
5
6
7
8
9
10
11
12
13
14

MCLR/VPP
RA0/AN0
RA1/AN1
RA2/AN2/VREF-/CVREF
RA3/AN3/VREF+
RA4/T0CKI/C1OUT
RA5/AN4/SS/C2OUT
VSS
OSC1/CLKI
OSC2/CLKO
RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL

www.nitropdf.com

._-......
....
~

RB3/PGM
RB2
RB1
RB0/INT
VDD
VSS
RC7/RX/DT

Microcontroller Based Solar Charger

53

PIC16F87XA
Pin Diagrams (Continued)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

RA5/AN4/SS/C2OUT
RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7
VDD
VSS
OSC1/CLKI
OSC2/CLKO
RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL
RD0/PSP0
RD1/PSP1

RB7/PGD
RB6/PGC
RB5
RB4
RB3/PGM
RB2
RB1
RB0/INT
VDD
VSS
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3
RD2/PSP2

40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21

RA3/AN3/VREF+
RA2/AN2/VREF-/CVREF
RA1/AN1
RA0/AN0
MCLR/VPP
NC
RB7/PGD
RB6/PGC
RB5
RB4
NC

MCLR/VPP
RA0/AN0
RA1/AN1
RA2/AN2/VREF-/CVREF
RA3/AN3/VREF+
RA4/T0CKI/C1OUT

PIC16F874A/877A

40-Pin PDIP

PIC16F874A
PIC16F877A

33
32
31
30
29
28
27
26
25
24
23

12
13
14
15
16
17
18
19
20
21
22

1
2
3
4
5
6
7
8
9
10
11

NC
RC0/T1OSO/T1CKI
OSC2/CLKO
OSC1/CLKI
VSS
VDD
RE2/CS/AN7
RE1/WR/AN6
RE0/RD/AN5
RA5/AN4/SS/C2OUT
RA4/T0CKI/C1OUT

,_'.
-

NC
NC
RB4
RB5
RB6/PGC
RB7/PGD
MCLR/VPP
RA0/AN0
RA1/AN1
RA2/AN2/VREF-/CVREF
RA3/AN3/VREF+

44
43
42
41
40
39
38
37
36
35
34

44-Pin TQFP

RC7/RX/DT
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7
VSS
VDD
RB0/INT
RB1
RB2
RB3/PGM

PIC16F874A
PIC16F877A

39
38
37
36
35
34
33
32
31
30
29

18
19
20
21
22
23
24
25
26
27
28

7
8
9
10
11
12
13
14
15
16
17

RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL
RD0/PSP0
RD1/PSP1
RD2/PSP2
RD3/PSP3
RC4/SDI/SDA
RC5/SDO
RC6/TX/CK
NC

RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC3/SCK/SCL
RC2/CCP1
RC1/T1OSI/CCP2
NC

RA4/T0CKI/C1OUT
RA5/AN4/SS/C2OUT
RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7
VDD
VSS
OSC1/CLKI
OSC2/CLKO
RC0/T1OSO/T1CK1
NC

6
5
4
3
2
1
44
43
42
41
40

44-Pin PLCC

www.nitropdf.com

RB3/PGM
RB2
RB1
RB0/INT
VDD
VSS
RD7/PSP7
RD6/PSP6
RD5/PSP5
RD4/PSP4
RC7/RX/DT

Microcontroller Based Solar Charger

54

PIC16F87XA
FIGURE 1-2:

PIC16F874A/877A BLOCK DIAGRAM


13
Flash
Program
Memory

Program
Bus

PORTA
RA0/AN0
RA1/AN1
RA2/AN2/VREF-/CVREF
RA3/AN3/VREF+
RA4/T0CK I/C1OUT
RA5/AN4/SS/C2OUT

RAM
File
Registers

8 Level Stack
(13-bit)

14

Data Bus

Program Counter

RAM Addr(1)

PORTB

Addr MUX

Instruction reg
Direct Addr

Indirec t
Addr

-x
-x

FSR reg

-x

-x

Status reg
8

RB0/INT
RB1
RB2
RB3/PGM
RB4
RB5
RB6/PGC
RB7/PGD

PORTC
3

Power-up
Timer
Instruction
Decode &
Control
Timing
Generation
OSC1/CLKI
OSC2/CLKO

Oscillator
Start-up Timer
Power-on
Reset
Watchdog
Timer
Brown-out
Reset

RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL
RC4/SDI/SDA
RC5/SDO
RC6/TX/CK
RC7/RX/DT

MUX

ALU
8
W reg

PORTD
RD0/PSP0
RD1/PSP1
RD2/PSP2
RD3/PSP3
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7

In-Circuit
Debugger
Low-Voltage
Programming

PORTE
MCLR

RE0/RD/AN5

VDD, VSS

RE1/WR/AN6
RE2/CS/AN7

Timer0

Timer1

Timer2

10-bit A/D

Data EEPROM

CCP1,2

Synchronous
Serial Port

USART

Parallel
Slave Port

Comparator

Voltage
Reference

Device

Program Flash

Data Memory

Data EEPROM

PIC16F874A

4K words

192 Bytes

128 Bytes

PIC16F877A

8K words

368 Bytes

256 Bytes

Note 1: Higher order bits are from the Status register.

www.nitropdf.com

Microcontroller Based Solar Charger

55

PIC16F87XA
TABLE 1-3:

PIC16F874A/877A PINOUT DESCRIPTION

Pin Name
OSC1/CLKI
OSC1

PDIP
Pin#
13

PLCC TQFP
Pin# Pin#
14

30

QFN
Pin#

I/O/P
Type

32
I

CLKI

OSC2/CLKO
OSC2

14

15

31

33

Buffer
Type

ST/CMOS(4) Oscillator crystal or external clock input.


Oscillator crystal input or external clock source
input. ST buffer when configured in RC mode;
otherwise CMOS.
External clock source input. Always associated
with pin function OSC1 (see OSC1/CLKI,
OSC2/CLKO pins).

Oscillator crystal or clock output.


Oscillator crystal output.
Connects to crystal or resonator in Crystal
Oscillator mode.
In RC mode, OSC2 pin outputs CLKO, which
has 1/4 the frequency of OSC1 and denotes the
instruction cycle rate.

ST

Master Clear (input) or programming voltage (output).


Master Clear (Reset) input. This pin is an active
low Reset to the device.
Programming voltage input.

CLKO

MCLR/VPP
MCLR

18

18
I

VPP

Description

PORTA is a bidirectional I/O port.


RA0/AN0
RA0
AN0

RA1/AN1
RA1
AN1

RA2/AN2/VREF-/CVREF
RA2
AN2
VREFCVREF

RA3/AN3/VREF+
RA3
AN3
VREF+

RA4/T0CKI/C1OUT
RA4

19

19
I/O
I

20

20

TTL

21

21

Digital I/O.
Analog input 1.
TTL
Digital I/O.
Analog input 2.
A/D reference voltage (Low) input.
Comparator VREF output.

I/O
I
I
O
6

22

22

TTL
Digital I/O.
Analog input 3.
A/D reference voltage (High) input.

I/O
I
I
7

23

23

ST
I/O

Digital I/O Open-drain when configured as


output.
Timer0 external clock input.
Comparator 1 output.

I
O

RA5/AN4/SS/C2OUT
RA5
AN4
SS
C2OUT

Note 1:
2:
3:

Digital I/O.
Analog input 0.

I/O
I

T0CKI
C1OUT

Legend:

TTL

24

24

TTL
I/O
I
I
O

Digital I/O.
Analog input 4.
SPI slave select input.
Comparator 2 output.

I = input
O = output
I/O = input/output
P = power
= Not used
TTL = TTL input
ST = Schmitt Trigger input
This buffer is a Schmitt Trigger input when configured as the external interrupt.
This buffer is a Schmitt Trigger input when used in Serial Programming mode.
This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.

www.nitropdf.com

Microcontroller Based Solar Charger

56

PIC16F87XA
TABLE 1-3:
Pin Name

PIC16F874A/877A PINOUT DESCRIPTION (CONTINUED)


PDIP
Pin#

PLCC TQFP
Pin# Pin#

QFN
Pin#

I/O/P
Type

Buffer
Type

Description
PORTB is a bidirectional I/O port. PORTB can be
software programmed for internal weak pull-up on all
inputs.

RB1

34

37

RB2

35

38

RB3/PGM
RB3
PGM

36

39

RB4

37

41

14

14

I/O

TTL TTL

Digital I/O.

RB5

38

42

15

15

I/O

TTL/ST(2)

Digital I/O.

RB6/PGC
RB6
PGC

39

43

16

16
I/O
I

TTL/ST(2)

Digital I/O.
In-circuit debugger and ICSP programming clock.

RB7/PGD
RB7
PGD

40

Note 1:
2:
3:

TTL/ST(1)

33

Legend:

36

RB0/INT
RB0
INT

I/O
I

Digital I/O.
External interrupt.

10

I/O

TTL

Digital I/O.

10

11

I/O

TTL

Digital I/O.

11

12

TTL
I/O
I

44

17

Digital I/O.
Low-voltage ICSP programming enable pin.

17
I/O
I/O

Digital I/O.
In-circuit debugger and ICSP programming data.

I = input
O = output
I/O = input/output
P = power
= Not used
TTL = TTL input
ST = Schmitt Trigger input
This buffer is a Schmitt Trigger input when configured as the external interrupt.
This buffer is a Schmitt Trigger input when used in Serial Programming mode.
This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.

www.nitropdf.com

Microcontroller Based Solar Charger

57

PIC16F87XA
TABLE 1-3:
Pin Name

PIC16F874A/877A PINOUT DESCRIPTION (CONTINUED)


PDIP
Pin#

PLCC TQFP
Pin# Pin#

QFN
Pin#

I/O/P
Type

Buffer
Type

Description
PORTC is a bidirectional I/O port.

RC0/T1OSO/T1CKI
RC0
T1OSO
T1CKI

15

RC1/T1OSI/CCP2
RC1
T1OSI
CCP2

16

RC2/CCP1
RC2
CCP1

17

RC3/SCK/SCL
RC3
SCK

18

16

32

34
I/O
O
I

18

35

35

ST

19

36

36

Digital I/O.
Timer1 oscillator input.
Capture2 input, Compare2 output, PWM2 output.
ST

I/O
I/O
20

37

37

Digital I/O.
Capture1 input, Compare1 output, PWM1 output.
ST

I/O
I/O

Digital I/O.
Synchronous serial clock input/output for SPI
mode.
Synchronous serial clock input/output for I2C
mode.

I/O

RC4/SDI/SDA
RC4
SDI
SDA

23

RC5/SDO
RC5
SDO

24

RC6/TX/CK
RC6
TX
CK

25

RC7/RX/DT
RC7
RX
DT

26

Note 1:
2:
3:

Digital I/O.
Timer1 oscillator output.
Timer1 external clock input.

I/O
I
I/O

SCL

Legend:

ST

25

42

42

ST
I/O
I
I/O

26

43

43

Digital I/O.
SPI data in.
I2C data I/O.
ST

I/O
O
27

44

44

Digital I/O.
SPI data out.
ST

I/O
O
I/O
29

Digital I/O.
USART asynchronous transmit.
USART1 synchronous clock.
ST

I/O
I
I/O

Digital I/O.
USART asynchronous receive.
USART synchronous data.

I = input
O = output
I/O = input/output
P = power
= Not used
TTL = TTL input
ST = Schmitt Trigger input
This buffer is a Schmitt Trigger input when configured as the external interrupt.
This buffer is a Schmitt Trigger input when used in Serial Programming mode.
This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.

www.nitropdf.com

Microcontroller Based Solar Charger

58

PIC16F87XA
TABLE 1-3:
Pin Name

PIC16F874A/877A PINOUT DESCRIPTION (CONTINUED)


PDIP
Pin#

PLCC TQFP
Pin# Pin#

QFN
Pin#

I/O/P
Type

Buffer
Type

Description
PORTD is a bidirectional I/O port or Parallel Slave
Port when interfacing to a microprocessor bus.

RD0/PSP0
RD0
PSP0

19

RD1/PSP1
RD1
PSP1

20

RD2/PSP2
RD2
PSP2

21

RD3/PSP3
RD3
PSP3

22

RD4/PSP4
RD4
PSP4

27

RD5/PSP5
RD5
PSP5

28

RD6/PSP6
RD6
PSP6

29

RD7/PSP7
RD7
PSP7

30

RE0/RD/AN5
RE0
RD
AN5

RE1/WR/AN6
RE1
WR
AN6

RE2/CS/AN7
RE2
CS
AN7

10

21

38

ST/TTL(3)

38

Digital I/O.
Parallel Slave Port data.

I/O
I/O
22

39

ST/TTL(3)

39

Digital I/O.
Parallel Slave Port data.

I/O
I/O
23

40

ST/TTL(3)

40

Digital I/O.
Parallel Slave Port data.

I/O
I/O
24

41

ST/TTL(3)

41

Digital I/O.
Parallel Slave Port data.

I/O
I/O
30

ST/TTL(3)

Digital I/O.
Parallel Slave Port data.

I/O
I/O
31

ST/TTL(3)

Digital I/O.
Parallel Slave Port data.

I/O
I/O
32

ST/TTL(3)

Digital I/O.
Parallel Slave Port data.

I/O
I/O
33

ST/TTL(3)

Digital I/O.
Parallel Slave Port data.

I/O
I/O

PORTE is a bidirectional I/O port.


9

25

ST/TTL(3)

25
I/O
I
I

10

26

ST/TTL(3)

26
I/O
I
I

11

27

Digital I/O.
Read control for Parallel Slave Port.
Analog input 5.

27

ST/TTL(3)

I/O
I
I

Digital I/O.
Write control for Parallel Slave Port.
Analog input 6.
Digital I/O.
Chip select control for Parallel Slave Port.
Analog input 7.

VSS

12, 31 13, 34

6, 29

6, 30,
31

Ground reference for logic and I/O pins.

VDD

11, 32 12, 35

7, 28

7, 8,
28, 29

Positive supply for logic and I/O pins.

13

These pins are not internally connected. These pins


should be left unconnected.

NC
Legend:
Note 1:
2:
3:

1, 17, 12,13,
28, 40 33, 34

I = input
O = output
I/O = input/output
P = power
= Not used
TTL = TTL input
ST = Schmitt Trigger input
This buffer is a Schmitt Trigger input when configured as the external interrupt.
This buffer is a Schmitt Trigger input when used in Serial Programming mode.
This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.

www.nitropdf.com

Microcontroller Based Solar Charger

59

PIC16F87XA
2.0

MEMORY ORGANIZATION

There are three memory blocks in each of the


PIC16F87XA devices. The program memory and data
memory have separate buses so that concurrent
access can occur and is detailed in this section. The
EEPROM data memory block is detailed in Section 3.0
Data EEPROM and Flash Program Memory.
Additional information on device memory may be found
in the PICmicro Mid-Range MCU Family Reference
Manual (DS33023).

FIGURE 2-1:

PIC16F876A/877A
PROGRAM MEMORY MAP
AND STACK

2.1

Program Memory Organization

The PIC16F87XA devices have a 13-bit program


counter capable of addressing an 8K word x 14 bit
program memory space. The PIC16F876A/877A
devices have 8K words x 14 bits of Flash program
memory, while PIC16F873A/874A devices have
4K words x 14 bits. Accessing a location above the
physically implemented address will cause a
wraparound.
The Reset vector is at 0000h and the interrupt vector is
at 0004h.

FIGURE 2-2:

PIC16F873A/874A
PROGRAM MEMORY MAP
AND STACK
PC<12:0>

PC<12:0>

13

CALL, RETURN
RETFIE, RETLW

13

CALL, RETURN
RETFIE, RETLW

Stack Level 1

Stack Level 1

Stack Level 2

Stack Level 2

Stack Level 8

Stack Level 8

Reset Vector

0000h

Interrupt Vector

0004h

Reset Vector

0000h

Interrupt Vector

0004h
0005h

0005h
Page 0
07FFh
0800h

On-Chip
Program
Memory

Page 1
On-Chip
Program
Memory

Page 0
07FFh
0800h
Page 1

0FFFh

0FFFh

1000h

1000h

Page 2
17FFh
1800h
Page 3
1FFFh

www.nitropdf.com

1FFFh

Microcontroller Based Solar Charger

60

PIC16F87XA
2.2

Data Memory Organization

The data memory is partitioned into multiple banks


which contain the General Purpose Registers and the
Special Function Registers. Bits RP1 (Status<6>) and
RP0 (Status<5>) are the bank select bits.
RP1:RP0

Bank

00

01

10

11

Each bank extends up to 7Fh (128 bytes). The lower


locations of each bank are reserved for the Special
Function Registers. Above the Special Function Registers are General Purpose Registers, implemented as
static RAM. All implemented banks contain Special
Function Registers. Some frequently used Special
Function Registers from one bank may be mirrored in
another bank for code reduction and quicker access.
Note:

2.2.1

The EEPROM data memory description can


be found in Section 3.0 Data EEPROM
and Flash Program Memory of this data
sheet.

GENERAL PURPOSE REGISTER


FILE

The register file can be accessed either directly, or


indirectly, through the File Select Register (FSR).

www.nitropdf.com

Microcontroller Based Solar Charger

61

PIC16F87XA
FIGURE 2-3:

PIC16F876A/877A REGISTER FILE MAP


File
Address

Indirect addr.(*)
TMR0
PCL
STATUS
FSR
PORTA
PORTB
PORTC
PORTD(1)
PORTE(1)
PCLATH
INTCON
PIR1
PIR2
TMR1L
TMR1H
T1CON
TMR2
T2CON
SSPBUF
SSPCON
CCPR1L
CCPR1H
CCP1CON
RCSTA
TXREG
RCREG
CCPR2L
CCPR2H
CCP2CON
ADRESH
ADCON0

00h
01h
02h
03h
04h
05h
06h
07h
08h
09h
0Ah
0Bh
0Ch
0Dh
0Eh
0Fh
10h
11h
12h
13h
14h
15h
16h
17h
18h
19h
1Ah
1Bh
1Ch
1Dh
1Eh
1Fh

File
Address
Indirect addr.(*)
OPTION_REG
PCL
STATUS
FSR
TRISA
TRISB
TRISC
TRISD(1)
TRISE(1)
PCLATH
INTCON
PIE1
PIE2
PCON

SSPCON2
PR2
SSPADD
SSPSTAT

TXSTA
SPBRG

CMCON
CVRCON
ADRESL
ADCON1

20h

General
Purpose
Register

*
Note 1:
2:

TMR0
PCL
STATUS
FSR
PORTB

PCLATH
INTCON
EEDATA
EEADR
EEDATH
EEADRH

General
Purpose
Register
16 Bytes

100h
101h
102h
103h
104h
105h
106h
107h
108h
109h
10Ah
10Bh
10Ch
10Dh
10Eh
10Fh
110h
111h
112h
113h
114h
115h
116h
117h
118h
119h
11Ah
11Bh
11Ch
11Dh
11Eh
11Fh

Indirect addr.(*)
OPTION_REG
PCL
STATUS
FSR
TRISB

PCLATH
INTCON
EECON1
EECON2
Reserved(2)
Reserved(2)

General
Purpose
Register
16 Bytes

120h
General
Purpose
Register

General
Purpose
Register

80 Bytes

80 Bytes

80 Bytes

Bank 1

EFh
F0h

accesses
70h-7Fh

16Fh
170h

accesses
70h - 7Fh

17Fh

FFh
Bank 2

Unimplemented data memory locations, read as 0.


Not a physical register.
These registers are not implemented on the PIC16F876A.
These registers are reserved; maintain these registers clear.

www.nitropdf.com

180h
181h
182h
183h
184h
185h
186h
187h
188h
189h
18Ah
18Bh
18Ch
18Dh
18Eh
18Fh
190h
191h
192h
193h
194h
195h
196h
197h
198h
199h
19Ah
19Bh
19Ch
19Dh
19Eh
19Fh
1A0h

General
Purpose
Register

accesses
70h-7Fh
7Fh

Indirect addr.(*)

A0h

96 Bytes

Bank 0

80h
81h
82h
83h
84h
85h
86h
87h
88h
89h
8Ah
8Bh
8Ch
8Dh
8Eh
8Fh
90h
91h
92h
93h
94h
95h
96h
97h
98h
99h
9Ah
9Bh
9Ch
9Dh
9Eh
9Fh

File
Address

File
Address

1EFh
1F0h
1FFh

Bank 3

Microcontroller Based Solar Charger

62

2)
www.fairchildsemi.com

MC78XX/LM78XX/MC78XXA

3-Terminal 1A Positive Voltage Regulator


Features

Description

The MC78XX/LM78XX/MC78XXA series of three


terminal positive regulators are available in the
TO-220/D-PAK package and with several fixed output
voltages, making them useful in a wide range of
applications. Each type employs internal current limiting,
thermal shut down and safe operating area protection,
making it essentially indestructible. If adequate heat sinking
is provided, they can deliver over 1A output current.
Although designed primarily as fixed voltage regulators,
these devices can be used with external components to
obtain adjustable voltages and currents.

Output Current up to 1A
Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V
Thermal Overload Protection
Short Circuit Protection
Output Transistor Safe Operating Area Protection

TO-220

1
D-PAK

1
1. Input 2. GND 3. Output

Internal Block Digram

IN PUT

OUT

SERIES

1
CURRENT
GENERATOR

PASS
ELEMENT

SOA
PROTECTION

PUT

.3

..

:-

I
STARTING
CIRCUIT

t---

REFERENCE
VOLTAGE

t-P-

ERROR
AMPLIFIER

THERMAL
PROTECTION

f----

:
GND

-...
2

Rev. 1.0.1
2001 Fairchild Semiconductor Corporation

www.nitropdf.com

Microcontroller Based Solar Charger

63

MC78XX/LM78XX/MC78XXA

Absolute Maximum Ratings


Parameter

Symbol

Value

Unit

VI
VI

35
40

V
V

RJC

Input Voltage (for VO = 5V to 18V)


(for VO = 24V)
Thermal Resistance Junction-Cases (TO-220)

C/W

oC/W

Thermal Resistance Junction-Air (TO-220)

RJA

65

Operating Temperature Range

TOPR

0 ~ +125

-65 ~ +150

Storage Temperature Range

TSTG

C
C

Electrical Characteristics (MC7805/LM7805)


(Refer to test circuit ,0C < TJ < 125C, IO = 500mA, VI = 10V, CI= 0.33F, CO= 0.1F, unless otherwise specified)
Parameter

Output Voltage

Symbol

VO

Conditions

MC7805/LM7805
Min.

Typ.

Max.

TJ =+25 oC

4.8

5.0

5.2

5.0mA Io 1.0A, PO 15W


VI = 7V to 20V

4.75

5.0

5.25

VO = 7V to 25V

4.0

100

VI = 8V to 12V

1.6

50

IO = 5.0mA to1.5A

100

IO =250mA to
750mA

50

Unit

Line Regulation (Note1)

Regline

TJ=+25 oC

Load Regulation (Note1)

Regload

TJ=+25 oC

IQ

TJ =+25 oC

5.0

8.0

IO = 5mA to 1.0A

0.03

0.5

VI= 7V to 25V

0.3

1.3

IO= 5mA

-0.8

mV/ oC

42

V/Vo

62

73

dB

IO = 1A, TJ =+25 oC

f = 1KHz

15

230

mA

2.2

Quiescent Current
Quiescent Current Change
Output Voltage Drift

IQ
VO/T

Output Noise Voltage

VN

f = 10Hz to 100KHz, TA=+25 oC

Ripple Rejection

RR

f = 120Hz
VO = 8V to 18V

Dropout Voltage

VDrop

Output Resistance
Short Circuit Current
Peak Current

rO
ISC

VI = 35V, TA =+25

IPK

oC

TJ =+25 C

mV

mV
mA
mA

Note:
1. Load and line regulation are specified at constant junction temperature. Changes in Vo due to heating effects must be taken
into account separately. Pulse testing with low duty is used.

www.nitropdf.com

Microcontroller Based Solar Charger

64
MC78XX/LM78XX/MC78XXA

Typical Applications

V,

Input

MC78XX/LM78XX
KA78XX

Output

::=CI

Co :~
O.l~F

O.33~F

(,7

Figure 5. DC Parameters

V,

MC78XX/LM78XX
KA78XX
~~~----------~Vo
Output

o---~---t

Input

Figure 6. Load Regulation

V,

5.10

,...

......

Input

MC78XX/LM78XX

KA78XX

-r-O.33~F

Vo

Output

i~ RL

"
470~F

120Hz

+.

Figure 7. Ripple Rejection

Input

Output

KA78XX
V,O-----r----1MC78XX/LM78XX
C,

Co

Figure 8. Fixed Output Regulator

21

www.nitropdf.com

Microcontroller Based Solar Charger

65

MC78XX/LM78XX/MC78XXA

KA78XX
MC78XX/LM78XX

Input

Output

v;

V,
Al

CI

10 2

Vxx

Co

ll'o

10

VXX +
R1

10

Figure 9. Constant Current Regulator


Notes:
(1) To specify an output voltage. substitute voltage value for "XX." A common ground is required between the input and the
Output voltage. The input voltage must remain typically 2.0V above the output voltage even during the low point on the input
ripple voltage.
(2) CI is required if regulator is located an appreciable distance from power Supply filter.
(3) CO improves stability and transient response.

Output

Input
MC78XX/LM78XX
KA78XX

V,

VO
2

CI

R1

1!Q

Co

R2

I RI 5IQ
VO = VXX(1+R2/R1)+IQR2
Figure 10. Circuit for Increasing Output Voltage

Input
V,

CI

Output

MC7805
LM7805

LM741
Co

IRI 5 IQ
VO = VXX(1+R2/R1)+IQR2
Figure 11. Adjustable Output Regulator (7 to 30V)

22

www.nitropdf.com

Microcontroller Based Solar Charger

66
MC78XX/LM78XX/MC78XXA

Mechanical Dimensions
Package

TO-220
4.50 0.20
2.80 0.10
(3.00)

+0.10

1.30 0.05

18.95MAX.

(3.70)

3.60 0.10

15.90 0.20

1.30 0.10

(8.70)

(1.46)

9.20 0.20

(1.70)

9.90 0.20

(45
1.52 0.10

0.80 0.10
2.54TYP
[2.54 0.20]

10.08 0.30

(1.00)

13.08 0.20

1.27 0.10

+0.10

0.50 0.05

2.40 0.20

2.54TYP
[2.54 0.20]

10.00 0.20

25

www.nitropdf.com

Microcontroller Based Solar Charger

67

MC78XX/LM78XX/MC78XXA

Mechancal Dimensions (Continued)


Package

D-PAK

MIN0.55

0.91 0.10
0.89 0.10

0.76 0.10

0.50 0.10
1.02 0.20

2.30TYP
[2.300.20]

(3.05)

(2XR0.25)

(0.10)
0.76 0.10

www.nitropdf.com

(1.00)

6.60 0.20
(5.34)
(5.04)
(1.50)

(0.70)

2.30 0.20

(0.90)

6.10 0.20

2.70 0.20

0.50 0.10

2.70 0.20

2.30TYP
[2.300.20]

(0.50)

6.10 0.20

MAX0.96

(4.34)

9.50 0.30

0.80 0.20

0.60 0.20

(0.50)

2.30 0.10

9.50 0.30

5.34 0.30

0.70 0.20

6.60 0.20

Microcontroller Based Solar Charger

68

3)

BC107
BC108
BC109

MECHANICAL DATA
Dimensions in mm (inches)

GENERAL PURPOSE
SMALL SIGNAL
NPN BIPOLAR TRANSISTOR

5.84 (0.230)
5.31 (0.209)

12.7 (0.500)
min.

5.33 (0.210)
4.32 (0.170)

4.95 (0.195)
4.52 (0.178)

0.48 (0.019)
0.41 (0.016)
dia.

FEATURES
SILICON NPN
HERMETICALLY SEALED TO18

2.54 (0.100)
Nom.

SCREENING OPTIONS AVAILABLE


3

1
2

TO18 METAL PACKAGE


Underside View
PIN 1 Emitter

PIN 2 Base

PIN 3 Collector

ABSOLUTE MAXIMUM RATINGS (TA = 25C unless otherwise stated)


VCBO
VCEO

Collector Base Continuous Voltage

BC017

50V

BC108, BC109

30V

Collector Emitter Continuous Voltage With Zero Base Current BC107

45V

BC108, BC109
VCES

VEBO

20V

Collector Emitter Continuous Voltage With Base Shortcircuited to Emitter

Emitter Base Continuous Voltage Reverse Voltage

BC107

50V

BC108, BC109

30V

BC107

6V

BC108, BC109

5V

IC

Continuous Collector Current

100mA

ICM

Peak Collector Current

200mA

Ptot

Power Dissipation @ Tamb = 25C

300mW

Tamb

Ambient Operating Temperature Range

-65 to +175C

Tstg

Storage Temperature Range

-65 to +175C

Semelab plc.

Telephone +44(0)1455 556565. Fax +44(0)1455 552612. e-mail sales@semelab.co.uk


Website http://www.semelab.co.uk www.nitropdf.com

3/99

Microcontroller Based Solar Charger

69

BC107
BC108
BC109
ELECTRICAL CHARACTERISTICS (TA = 25C unless otherwise stated)
Parameter

Typ.

Max. Unit

BC107

15

VCB = 25V

BC108, BC109

15

Collector-Emitter Leakage Current

VCB = 45V

BC107

@Tamb =125C

VCB = 25V

BC108, BC109

Emitter Cut-off Current

VEB = 4V

IC = 0

VCE = 5V

IC = 2mA

Group A

BC107, BC108

110

220

Group B

All Types

180

460

Group C

BC108, BC109

380

800

BC107

110

460

BC108

110

800

BC109

180

800

Collector-Base Leakage Current

ICBO(1)

h21E

Min.

VCB = 45V

ICBO(1)

IEBO

Test Conditions

Static Forward Current Transfer Ratio

nA
A
A

VBE

Base Emitter Breakdown

VCE = 5V

IC = 2mA

0.7

VBE(sat)(1)

Base Emitter Saturation Voltage

IB = 0.5mA

IC = 10mA

0.83

VCE(sat)(1)

Collector Emitter Saturation Voltage

IB = 0.5mA

IC = 10mA

0.25

fT

Transition Frequency

VCE = 5V

IC = 10mA

f = 100MHz
VCE = 5V

Noise Factor

MHz

150

IC = 0.2mA

R = 2k f =1kHz F=200Hz
BC109

BC107, BC108

10

dB

VCE = 5V IC = 2mA f =100kHz


BC107, BC108

125

260

Small Signal Forward Current Transfer Group B

All Types

240

500

Ratio

BC108, BC109

450

900

BC107

125

500

BC108

125

900

BC109

240

900

Group A
h21e

Group C

VCE = 5V IC = 2mA f = 1kHz


h11e

Common Emitter Input Impedance

Group A

BC107, BC108

1.6

4.5

Group B

All Types

3.2

8.5

Group C

BC108, BC109

6.0

15

VCE = 5V IC = 2mA f = 1kHz


h22e

Common Emitter Output Admittance

C22b

Common Base Output Capacitance

Rth(j-amb)

Thermal Resistance: Junction to

Group A

BC107, BC108

30

Group B

All Types

60

Group C

BC108, BC109

110

VCB = 10V

f = 1MHz

Ambient

Semelab plc.

Telephone +44(0)1455 556565. Fax +44(0)1455 552612. e-mail sales@semelab.co.uk


Website http://www.semelab.co.uk www.nitropdf.com

pF

500

C/W
3/99

Microcontroller Based Solar Charger

4)

ft

RAT

70

1N4001 - 1N4007

1.0A RECTIFIER
Please click here to visit our online spice models database.

Features

Diffused Junction
High Current Capability and Low Forward Voltage Drop
Surge Overload Rating to 30A Peak
Low Reverse Leakage Current
Lead Free Finish, RoHS Compliant (Note 3)

Mechanical Data

Case: DO-41
Case Material: Molded Plastic. UL Flammability Classification
Rating 94V-0
Moisture Sensitivity: Level 1 per J-STD-020D
Terminals: Finish - Bright Tin. Plated Leads Solderable per
MIL-STD-202, Method 208
Polarity: Cathode Band
Mounting Position: Any
Ordering Information: See Page 2
Marking: Type Number
Weight: 0.30 grams (approximate)

DO-41 Plastic
Min
Max
A
25.40

B
4.06
5.21
C
0.71
0.864
D
2.00
2.72
All Dimensions in mm

Dim

Maximum Ratings and Electrical Characteristics @TA = 25C unless otherwise specified
Single phase, half wave, 60Hz, resistive or inductive load.
For capacitive load, derate current by 20%.
Characteristic
Symbol
VRRM
Peak Repetitive Reverse Voltage
Working Peak Reverse Voltage
VRWM
DC Blocking Voltage
VR
RMS Reverse Voltage
VR(RMS)
Average Rectified Output Current (Note 1) @ TA = 75C
IO
Non-Repetitive Peak Forward Surge Current 8.3ms
IFSM
single half sine-wave superimposed on rated load
Forward Voltage @ IF = 1.0A
VFM
Peak Reverse Current @TA = 25C
IRM
at Rated DC Blocking Voltage @ TA = 100C
Typical Junction Capacitance (Note 2)
Cj
Typical Thermal Resistance Junction to Ambient
RJA
Maximum DC Blocking Voltage Temperature
TA
Operating and Storage Temperature Range
TJ, TSTG
Notes:

1N4001 1N4002 1N4003 1N4004 1N4005 1N4006 1N4007

Unit

50

100

200

400

600

800

1000

35

70

140

280
1.0

420

560

700

V
A

30

1.0
5.0
50

15

A
8

100
+150
-65 to +150

pF
K/W
C
C

1. Leads maintained at ambient temperature at a distance of 9.5mm from the case.


2. Measured at 1.0 MHz and applied reverse voltage of 4.0V DC.
3. EU Directive 2002/95/EC (RoHS). All applicable RoHS exemptions applied, see EU Directive 2002/95/EC Annex Notes.

DS28002 Rev. 8 - 2

1 of 3

www.nitropdf.com
www.diodes.com

1N4001-1N4007
Diodes Incorporated

Microcontroller Based Solar Charger

ft

RAT

IF, INSTANTANEOUS FORWARD CURRENT (A)

I(AV), AVERAGE FORWARD RECTIFIED CURRENT (A)

71

1.0

0.8

0.6

0.4

0.2

0
40

60

80

100

120

140

160

10

1.0

0.1

Tj, = 25oC
Pulse Width = 300 s
2% Duty Cycle

0.01
0.6

180

TA, AMBIENT TEMPERATURE (C)


Fig. 1 Forward Current Derating Curve

0.8

1.0

1.2

1.4

1.6

VF, INSTANTANEOUS FORWARD VOLTAGE (V)


Fig. 2 Typical Forward Characteristics

50

100
f = 1MHz

40
Cj, CAPACITANCE (pF)

IFSM, PEAK FORWARD SURGE CURRENT (A)

Tj = 25C

30

20

1N4001 - 1N4004

10

1N4005 - 1N4007

10

1.0

1.0

10

1.0

100

10

100

VR, REVERSE VOLTAGE (V)


Fig. 4 Typical Junction Capacitance

NUMBER OF CYCLES AT 60 Hz
Fig. 3 Max Non-Repetitive Peak Fwd Surge Current

Ordering Information (Note 4)


Device
1N4001-B
1N4001-T
1N4002-B
1N4002-T
1N4003-B
1N4003-T
1N4004-B
1N4004-T
1N4005-B
1N4005-T
1N4006-B
1N4006-T
1N4007-B
1N4007-T
Notes:

Packaging
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic
DO-41 Plastic

Shipping
1K/Bulk
5K/Tape & Reel, 13-inch
1K/Bulk
5K/Tape & Reel, 13-inch
1K/Bulk
5K/Tape & Reel, 13-inch
1K/Bulk
5K/Tape & Reel, 13-inch
1K/Bulk
5K/Tape & Reel, 13-inch
1K/Bulk
5K/Tape & Reel, 13-inch
1K/Bulk
5K/Tape & Reel, 13-inch

4. For packaging details, visit our website at http://www.diodes.com/datasheets/ap02008.pdf.

DS28002 Rev. 8 - 2

2 of 3

www.nitropdf.com
www.diodes.com

1N4001-1N4007
Diodes Incorporated

72
Microcontroller Based Solar Charger

ADVANTAGES
No noise
Easy to install
Simple to operate
Pollution free working
Low maintenance cost
Generating panel has a long life

Electronics and Communication Engineering Department

SNGIST

73
Microcontroller Based Solar Charger

CONCLUSION

In future, India will have to depend on renewable energy. The only source available around
us is sunlight, and we can easily convert sunlight energy into electrical energy by using PV
cells to meet our requirement.
However to extend use of solar power energy to industrial and commercial areas, the price
of PV cells need to be brought down through low-cost manufacturing techniques.
By using the solar energy power generation technology the usage of non-conventional
resources can be minimized which not only reduces the resource extinction but helps widely
in reducing the environmental pollution.
By Generating Power Through Solar Energy The Cost Of Electricity Can Be
Minimized And Occasionally Can Be Provided With Free Of Cost.
Electricity Can Be Supplied Even To Remote Areas With Out The usage Of
Transmission Lines.

Electronics and Communication Engineering Department

SNGIST

74
Microcontroller Based Solar Charger

REFERENCE

PIC Microcontroller Text by Muhammad Ali Mazidi.


www.electronicscomponents.com
http://www.electronicsforu.com/
http://www.alldatasheet.com/

Electronics and Communication Engineering Department

SNGIST

You might also like