Download - micro controller based solar charger
MICRO CONTROLLER BASED SOLAR
CHARGER
An Industrial Oriented Mini Project Report
Submitted in partial fulfillment of the
Requirements for the Award of the Degree of
Bachelor of Technology
In
Electronics & Communication Engineering
By
CH.RAVITEJA (084N1A0436)
G.VENKATESWARA RAO (084N1A0461)
D.VISHNU VARDHAN (084N1A0465)
B.SUJITHA (084N1A0453)
Under the Guidance of
RAMESH REDDY.M (Assistant Prof)
Department of Electronics & Communication Engineering,
VISVODAYA ENGINEERING COLLEGE, KAVALI
(Affiliated to JNTU, Anantapur)
2008 – 2012
VISVODAYA ENGINEERING COLLEGE, KAVALI
Department of Electronics & Communication Engineering,
CERTIFICATE
This is to certify that the mini project report entitled MICROCONTROLLER
BASED SOLAR CHARGER, being submitted by CH.RAVITEJA (084N1A0436),
G.VENKATESWARA RAO (084N1A0461), D.VISHNU VARDHAN
REDDY(084N1A0465), B.SUJITHA (084N1A0453) , in partial fulfillment of the
requirements for the award of the degree of Bachelor of Technology in Electronics
And Communication Engineering, is a record of bonafide work carried out by them
under my guidance and supervision. The results embodied in this report have not been
submitted to any other university for the award of degree.
Internal Guide Head of the Department
Mr. M. Ramesh Reddy, Mr. V. Narayana Reddy,
Assistant Professor, Associate Professor,
Dept. of ECE, Dept. of ECE,
VEC . VEC.
External Viva Voce conducted on_______________
External Examiner
ACKNOWLEDGEMENTS
We consider it as our privilege to express our gratitude and respect to all those
who guided, inspired and helped us in completion of this mini project. We are
thankful to all whose encouragement and timely help made us to achieve the desired
goal.
We would like to thank our internal Mr.M.Ramesh Reddy, Assistant Professor
for his technical guidance, constant encouragement and support in carrying out our
project at the college.
We express our heart-felt thanks to Mr.V.Narayana Reddy, Associate
Professor and Head of the Dept. of Electronics & Communication Engineering, VEC,
Kavali, for his kind encouragement in completion of the project work and being a
great teacher inspired us to complete our course of action successfully.
We profoundly thank our Principal Dr.M.Sreenivasa Kumar, for his constant
encouragement and support throughout the completion of this project.
We also express our gratitude to the Chairman , D.Vidhyadara Kumar
Reddy Garu for his encouragement and moral support to complete our course.
Finally we would like to thank all the teachers who taught us various subjects
in B.Tech course for the past four years and for giving us sufficient knowledge and
inspiration to evolve ourselves efficient graduates.
We thank one and all who have helped us directly or indirectly in completing
this mini project work successfully and proficiently.
CH.RAVITEJA (084N1A0436)
G.VENKATESWARA RAO (084N1A0461)
D.VISHNU VARDHAN (084N1A0465)
B.SUJITHA (084N1A0453)
i
CONTENTS
TOPICS PG NO
ABSTRACT 1
FIGURES 2
TABLES 3
SYMBOLS & ABBREVATIONS 4
CHAPTER-1
1. INTRODUCTION 5-7
1.1 Motivation 5
1.2 Project Outline 6
1.3 Objectives & Limitations 7
1.3.1 Objectives
1.32 Limitations
CHAPTER-2
2. SOLAR PANELS 8-28
2.1 Photo Voltaic Cells 8
2.1.1 Types Of PV Cells 12
2.1.1.1 Single Crystal 12
2.1.1.2 Poly Crystalline 13
2.1.1.3 Ribbon Silicon 14
2.1.1.4 Amorphous Silicon 15
2.2 Construction Of Silicon Solar Panel 16
2.3 Solar Array 21
2.4 Working Of Solar Cells 24
2.5 PV Cells At a Glance 28
2.5.1 Advantages
2.5.2 Applications
ii
CHAPTER-3
3. PIC MICROCONTROLLERS 32-52
3.1 Core Features 32
3.2 Peripheral Features 33
3.3 Registers 39
3.3.1 Special Function Registers 39
3.3.2 Status Registers 39
3.4 Usart 39
3.4.1 Usart Synchronous Mode 41
3.4.2 Usart Asynchronous Txr 41
3.4.3 Usart Asynchronous Rxr 43
3.5 A/D Converter Module 44
3.6 Interrupts 46
3.7 Instruction Set Summary 47
3.8 Interface With PC 48
3.9 Power Supply Unit 50
3.9.1 Step Down Transformer 50
3.9.2 Rectifier Unit 51
3.9.3 Filtering Unit 51
3.9.4 Voltage Regulators 52
3.9.5 Specifications 52
CHAPTER-4
4. LCD DISPLAY 53-64
4.1 Pin Description 53
4.2 DD Ram 55
4.3 CG Rom 56
iii
CHAPTER-5
5. RELAY 65-67
CHAPTER-6
6. TESTING CIRCUIT 68-80
6.1 Software Dumping Procedure
6.2 Program Used In PIC16F877 81
CHAPTER-7
7.CONCLUSION 81
CHAPTER-8
8.REFERENCES 82
1
ABSTRACT
Our project is a device that will allow a solar panel to efficiently recharge a DC
battery. This is accomplished by operating the solar panel at an optimal power level
regardless of the battery voltage. The controller will vary the voltage across the panel
to find and maintain the maximum power point. The circuitry also monitors the
battery voltage level and charges the battery using pulse width modulation techniques.
The device consists of a boost DC-DC converter, a microcontroller, a current sensing
microchip, a Liquid Crystal Display for data output, and a serial computer interface
for programming and data collection at the initial stage to dump a small c-program
into microcontroller kit PIC16F877.
In detail the sun is the ultimate source of limitless solar energy in the form of light
and heat. Light of the sun is directly converted into electrical energy without any inter
mediate step. When the rays of the sun strike certain light-sensitive material like solar
cell connected to an appropriate circuit, it exhibits a phenomenon called „photovoltaic
effect‟. The photovoltaic effect is the generation of an electrical current in a circuit
containing a photosensitive device when the device is illuminated by visible or
invisible light. In other words, light is directly converted into electricity. The
photovoltaic effect can be achieved by using a variety of materials like silicon,
selenium, cadmium sulphide, germanium, gallium arsenide or amorphous glass.
2
FIGURES
FIG PG.NO
1.GREEN ENERGY GLOBALIZATION 5
2.STRUCTURE OF SOLAR PANEL 11
3.SINGLE CRYSTAL PV CELL 12
4.POLY CRYSTALLINE PV CELL 14
5.RIBBON CRYSTAL PV CELL 14
6.AMARPHOUS SILICON PV CELL 15
7.V-I CHARACTERISTICS OF DESIRED SOLAR CELL 17
8. V-I CHARACTERISTICS OF SOLAR CELL 17
9.SHARED AND UNSHARED V-I REGION 18
10.V-I CHARACTERISTIC WITH RESPECT TO TEMP 19
11.MAX VOLTAGE AND DELIVERED VOLTAGE 20
12.PARALLEL SOLAR CELLS ARRAY 22
14.PERSONAL PHOTOVOLTAIC ARRAY 22
15.ONE & TWO AXIS TRACING SOLAR PANEL 23
16.SOLAR PANEL WORKING 27
17.PIC BLOCK DIAGRAM 33
18.CIRCUIT DIAGRAM OF PIC16F877 34
19.PIN DIAGRAM OF PIC16F877 35
20.PIN OUT DESCRIPTION OF PIC16F877 36
21.TRANSMIT STATUS AND CONTROL REGISTER 40
22.ADCON0 REGISTER (AD 8) 44
23.ADCON1 REGISTER (AD9) 45
24.PIN DIAGRAM MAX232 48
25.MICROCONTROLLER POWER SUPPLY UNIT 50
3
26.LCD HD44780 53
27.DDRAM ADDRESS 1 LINE LCD 55
28.DDRAM ADDRESS 2 LINE LCD 55
29. DDRAM ADDRESS 4 LINE LCD 56
30.LCD CHARACTER MASK 5*8 DOTS 57
31. LCD CHARACTER MASK 5*10 DOTS 58
32.COMMAND & INSTRUCTION SET FOR LCD TYPE 59
33.FLOW CHART FOR LCD INITIALIZATION 62
34.RELAY SCHEMATIC DIAGRAM 66
35.WORKING OF RELAY CIRCUIT 66
36.SOLAR CHARGER TESTING SCHEMATIC CIRCUIT 69
37. KEIL DUMPING SOFTWARE PROGRAM WINDOW 70
TABLES
TABLE PG.NO
1.GLOBALLY RECOGNIZED SOLAR CELL O/P V-I 21
2.PIN DESCRIPTION OF LCD DISPLAY 54
3.PIN DESCRIPTION OF LCD WITH CONTROLLER 1 54
4. PIN DESCRIPTION OF LCD WITH CONTROLLER 2 54
5. COMMAND AND INSTRUCTION OF HD44780 59
6.FREQUENTLY USED COMMANDS & INSTRUCTIONS OF LCD 60
7.POWER SUPPLY CONDITION FOR INTERNAL RESET 61
4
SYMBOLS & ABBREVIATIONS
USART - Universal Synchronous Asynchronous Receiver And Transmitter
RAM - Random Access Memory
ROM - Read Only Memory
RS232 – Recommended Standard
VCC - Supply Voltage
VSS - Ground Potential
PSEN – Program Store Enable
ALE – Address Latch Enable
UART – Universal Asynchronous Receiver Transmitter
USRT – Universal Synchronous Receiver Transmitter
PSP- Parallel Slave Port
EEPROM- Electrically Erasable programmable Read Only Memory
EPROM -Erasable Programmable Read Only Memory
EECON- Electrically Erasable Control Register
TMR-Timer
PWMM-Pulse Width Modulation Mode
MSSP-Master Synchronous Serial Port
POR-Power On Reset
PWRT-Power Up Timer
OST-Oscillator Start Up Timer
SSP-Synchronous Serial Port
PC-Program Counter
ALU-Arithmetic And Logic Unit
CU-Control Unit
5
1. INTRODUCTION
1.1 MOTIVATION
In present globalized world mighty technical innovations lead to growth of human
living standards in such a way that electricity utilization has become his/her
mandatory requirement in order to invent new things or to utilize present technology.
Non conventional power generation is one of the fastest growing sectors. But due to
less natural resources availability and heavy population criteria's power generation is
unable to meet the necessary requirements of people to complete extent, not only that
it's also causing the pollution problems along with resource extinction due to
utilization of natural non-renewable resources. So in order to meet the power
generation scarcity problem along with resource extinction drawbacks we motivated
ourselves to create our project named "MICROCONTROLLER BASED SOLAR
CHARGER" which uses natural renewable solar energy for generating the electricity
in efficient manner thus creating pollution free world termed as "GREEN ENERGY"
power generation concept.
fig 1.1(a): green energy globalization
Also in present living world Globally, all countries are busy developing and
implementing non-conventional power to bridge the electricity demand and power
supply gap.
6
1.2 PROJECT OUTLINE
Solar photovoltaic panels are becoming a more common way to provide electric
power to remote electronic devices. Ease of use and installation, power reliability (the
sun is not expected to stop shining soon), cost competitiveness with replacement of
non-rechargeable batteries, and long lifetime capabilities are all contributing to a
higher demand for solar powered devices. In addition, portable electronic devices,
such as cellular phones, laptop computers, and music playing devices are becoming
more prevalent. Charged batteries are the backbone of these products, and when
individuals are not near traditional electricity, an alternative means of charging must
be present. A solar photovoltaic panel meets this need.
This report outlines the design and performance of a solar electric charge controller
and portable power supply, an extremely portable device which recharges electronic
devices. Along with a solar panel, this device employs microprocessor-based control
which continuously monitors the power output of the solar panel to deliver the
maximum electric power to the batteries. This is called Maximum Power Point
Tracking, and it enables the most efficient battery recharge. Our product also contains
internal rechargeable batteries (at 6-7 Volts). The solar panel actually charges these
internal batteries, and these batteries are used to recharge any external electronic
devices which are attached.
Many solar Maximum Power Point Tracking (MPPT) devices have been designed and
implemented, but ours may be the first to use microprocessor control to continuously
track the maximum power point. Other devices simply calculate the MPP, operate the
circuit at that point, and periodically recalculate the MPP. Our product does
periodically recalculate as well, but continuously updates to ensure maximum power
transfer more consistently. In addition, rechargeable batteries should be charged
differently based on battery state. We implemented a common technique known as
three-stage charging which differentiates charging techniques based on if the battery
is mostly depleted, nearly charged, and fully charged. The goal of our project was to
design and build a cost-effective MPPT circuit and use three-stage charging to
efficiently recharge batteries.
7
1.3 OBJECTIVES AND LIMITATIONS
1.3.1 Objectives
To provide alternative Solar energy solutions for domestic industrial and
commercial establishments in order to mitigate the energy problems in
backward villages of the state.
To develop and deploy village specific electricity generation system and
package based on Solar Technology/ Solar Wind Hybrid Technology.
To provide further standardization and benchmarking of international solar
resource data sets to insure worldwide Intercomparability and acceptance
To provide improved data reliability, availability and accessibility in formats
that address specific user needs
To develop methods that improve the quality and the spatial and temporal
coverage, with customized solar resource products, including reliable solar
radiation forecasts.
1.3.2 Limitations
Large initial setup is required to supply high rating solar energy supplies.
Solar panels are costlier and its bulkiness increases to have large power
supplies of DC.
Solar panels are very delicate and a slight mishandling may lead to destruction
of solar cells which are embedded in solar panels.
8
2. SOLAR PANELS
2.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 forbidden 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-
9
type silicon, some of the negative charges are free to move around, while the converse
is true for p-type silicon.
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 p-
type 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.
10
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 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.
11
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
2.1.(a)
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 at
6458 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.
12
2.1.1 Types Of Photo Voltaic Cells
At the present time, most commercial photovoltaic cells are manufactured from silicon, the
same material from which sand is made. In this case, however, the silicon is extremely pure.
Other, more exotic materials such as gallium arsenide are just beginning to make their way into
the field.
The four general types of silicon photovoltaic cells are:
Single-crystal silicon.
Polycrystalline silicon (also known as multicrystal silicon).
Ribbon silicon.
Amorphous silicon (abbreviated as "aSi," also known as thin film silicon).
2.1.1.1 Single Crystal Silicon
Most photovoltaic cells are single-crystal types. To make them, silicon is purified, melted, and
crystallized into ingots. The ingots are sliced into thin wafers to make individual cells. The cells
have a uniform color, usually blue or black.
13
Typically, most of the cell has a slight positive electrical charge. A thin layer at the top
has a slight negative charge.
The cell is attached to a base called a "backplane." This is usually a layer of metal used
to physically reinforce the cell and to provide an electrical contact at the bottom.
Since the top of the cell must be open to sunlight, a thin grid of metal is applied to the
top instead of a continuous layer. The grid must be thin enough to admit adequate
amounts of sunlight, but wide enough to carry adequate amounts of electrical energy
Light, including sunlight, is sometimes described as particles called "photons." As
sunlight strikes a photovoltaic cell, photons move into the cell.
When a photon strikes an electron, it dislodges it, leaving an empty "hole". The loose
electron moves toward the top layer of the cell. As photons continue to enter the cell,
electrons continue to be dislodged and move upwards
If an electrical path exists outside the cell between the top grid and the backplane of the
cell, a flow of electrons begins. Loose electrons move out the top of the cell and into the
external electrical circuit. Electrons from further back in the circuit move up to fill the
empty electron holes. Most cells produce a voltage of about one-half volt, regardless of
the surface area of the cell. However, the larger the cell, the more current it will
produce.
Current and voltage are affected by the resistance of the circuit the cell is in. The
amount of available light affects current production. The temperature of the cell affects
its voltage. Knowing the electrical performance characteristics of a photovoltaic power
supply is important, and is covered in the next section.
2.1.1.2 Polycrystalline silicon
Polycrystalline cells are manufactured and operate in a similar manner. The difference
is that a lower cost silicon is used. This usually results in slightly lower efficiency, but
polycrystalline cell manufacturers assert that the cost benefits outweigh the efficiency
losses.
14
The surface of polycrystalline cells has a random pattern of crystal borders instead of the
solid color of single crystal cells.
2.1.1.3 Ribbon Silicon
Ribbon-type photovoltaic cells are made by growing a ribbon from the molten silicon
instead of an ingot. These cells operate the same as single and polycrystal cells.
The anti-reflective coating used on most ribbon silicon cells gives them a prismatic
rainbow appearance.
15
2.1.1.4 Amorphous Or Thin Film Silicon
The previous three types of silicon used for photovoltaic cells have a distinct crystal
structure. Amorphous silicon has no such structure. Amorphous silicon is sometimes
abbreviated "aSi" and is also called thin film silicon.
Amorphous silicon units are made by depositing very thin layers of vaporized silicon in
a vacuum onto a support of glass, plastic, or metal.
Amorphous silicon cells are produced in a variety of colors
Since they can be made in sizes up to several square yards, they are made up in long
rectangular "strip cells." These are connected in series to make up "modules." Modules
of all kinds are described.
16
2.2 CONSTRUCTION OF SILICON SOLAR CELL
For almost all applications, the one-half volt produced by a single cell is inadequate.
Therefore, cells are connected together in series to increase the voltage. Several of
these series strings of cells may be connected together in parallel to increase the
current as well.
These interconnected cells and their electrical connections are then sandwiched
between a top layer of glass or clear plastic and a lower level of plastic or plastic and
metal. An outer frame is attached to increase mechanical strength, and to provide a
way to mount the unit. This package is called a "module" or "panel". Typically, a
module is the basic building block of photovoltaic systems.
To insure compatibility with storage batteries or loads, it is necessary to know the
electrical characteristics of photovoltaic modules.
As a reminder, "I" is the abbreviation for current, expressed in amps. "V" is used for
voltage in volts, and "R" is used for resistance in ohms.
A photovoltaic module will produce its maximum current when there is essentially no
resistance in the circuit. This would be a short circuit between its positive and
negative terminals.
This maximum current is called the short circuit current, abbreviated I(sc). When the
module is shorted, the voltage in the circuit is zero.
Conversely, the maximum voltage is produced when there is a break in the circuit.
This is called the open circuit voltage, abbreviated V(oc). Under this condition the
resistance is infinitely high and there is no current, since the circuit is incomplete.
These two extremes in load resistance, and the whole range of conditions in between
them, are depicted on a graph called a I-V (current-voltage) curve. Current, expressed
in amps, is on the vertical Y-axis. Voltage, in volts, is on the horizontal X-axis.
The short circuit current occurs on a point on the curve where the voltage is zero.
The open circuit voltage occurs where the current is zero.
17
The power available from a photovoltaic module at any point along the curve is
expressed in watts. Watts are calculated by multiplying the voltage times the current
(watts = volts x amps, or W = VA).
At the short circuit current point, the power output is zero, since the voltage is zero.
At the open circuit voltage point, the power output is also zero, but this time it is
because the current is zero.
There is a point on the "knee" of the curve where the maximum power output is
located. This point on our example curve is where the voltage is 17 volts, and the
current is 2.5 amps. Therefore the maximum power in watts is 17 volts times 2.5
amps, equaling 42.5 watts.
The power, expressed in watts, at the maximum power point is described as peak,
maximum, or ideal, among other terms. Maximum power is generally abbreviated as
"I (mp)." Various manufacturers call it maximum output power, output, peak power,
rated power, or other terms.
The current-voltage (I-V) curve is based on the module being under standard
conditions of sunlight and module temperature. It assumes there is no shading on the
module.
18
Standard sunlight conditions on a clear day are assumed to be 1000 watts of solar
energy per square meter (1000 W/m2or lkW/m2). This is sometimes called "one sun,"
or a "peak sun." Less than one sun will reduce the current output of the module by a
proportional amount. For example, if only one-half sun (500 W/m2) is available, the
amount of output current is roughly cut in half.
For maximum output, the face of the photovoltaic modules should be pointed as
straight toward the sun as possible
Because photovoltaic cells are electrical semiconductors, partial shading of the
module will cause the shaded cells to heat up. They are now acting as inefficient
conductors instead of electrical generators. Partial shading may ruin shaded cells.
Partial module shading has a serious effect on module power output. For a typical
module, completely shading only one cell can reduce the module output by as much
as 80%. One or more damaged cells in a module can have the same effect as shading.
This is why modules should be completely unshaded during operation. A shadow
across a module can almost stop electricity production. Thin film modules are not as
affected by this problem, but they should still be unshaded.
19
Module temperature affects the output voltage inversely. Higher module temperatures
will reduce the voltage by 0.04 to 0.1 volts for every one Celsius degree rise in
temperature (0.04V/0C to 0.1V/0C). In Fahrenheit degrees, the voltage loss is from
0.022 to 0.056 volts per degree of temperature rise.
This is why modules should not be installed flush against a surface. Air should be
allowed to circulate behind the back of each module so it's temperature does not rise
and reducing its output. An air space of 4-6 inches is usually required to provide
proper ventilation.
The last significant factor which determines the power output of a module is the
resistance of the system to which it is connected. If the module is charging a battery, it
must supply a higher voltage than that of the battery.
If the battery is deeply discharged, the battery voltage is fairly low. The photovoltaic
module can charge the battery with a low voltage, shown as point #1 in Figure 2-20.
As the battery reaches a full charge, the module is forced to deliver a higher voltage,
shown as point #2. The battery voltage drives module voltage.
20
Eventually, the required voltage is higher than the voltage at the module's maximum
power point. At this operating point, the current production is lower than the current
at the maximum power point. The module's power output is also lower.
To a lesser degree, when the operating voltage is lower than that of the maximum
power point, the output power is lower than the maximum. Since the ability of the
module to produce electricity is not being completely used whenever it is operating at
a point fairly far from the maximum power point, photovoltaic modules should be
carefully matched to the system load and storage.
Using a module with a maximum voltage which is too high should be avoided nearly
as much as using one with a maximum voltage which is too low.
The output voltage of a module depends on the number of cells connected in series.
Typical modules use either 30, 32, 33, 36, or 44 cells wired in series.
The modules with 30-32 cells are considered self regulating modules. 36 cell modules
are the most common in the photovoltaic industry. Their slightly higher voltage
rating, 16.7 volts, allows the modules to overcome the reduction in output voltage
when the modules are operating at high temperatures.
21
Globally, following configurations of PV cells are available:
Array voltage
(V)
12 24 36 48
O/P current
(A)
41.67 20.83 13.89 10.42
TABLE 2.2(a): GLOBALLY RECOGNIZED SOLAR CELL O/P V, I
Modules with 33 - 36 cells also have enough surplus voltage to effectively charge
high antimony content deep cycle batteries. However, since these modules can
overcharge batteries, they usually require a charge controller.
Finally, 44 cell modules are available with a rated output voltage of 20.3 volts. These
modules are typically used only when a substantially higher voltage is required.
Another application for 44 cell modules is a system with an extremely long wire run
between the modules and the batteries or load. If the wire is not large enough, it will
cause a significant voltage drop. Higher module voltage can overcome this problem.
It should be noted that this approach is similar to putting a larger engine in a car with
locked brakes to make it move faster. It is almost always more cost effective to use an
adequate wire size, rather than to overcome voltage drop problems with more costly
44 cell modules.
2.3 SOLAR ARRAYS
In many applications the power available from one module is inadequate for the load.
Individual modules can be connected in series, parallel, or both to increase either
output voltage or current. This also increases the output power.
When modules are connected in parallel, the current increases. For example, three
modules which produce 15 volts and 3 amps each, connected in parallel, will produce
15 volts and 9 amps.
22
If the system includes a battery storage system, a reverse flow of current from the
batteries through the photovoltaic array can occur at night. This flow will drain power
from the batteries.
A portable array may be as small as a one square foot module easily carried by one
person to recharge batteries for communications or flashlights. They can be mounted
on vehicles to maintain the engine battery during long periods of inactivity. Larger
ones can be installed on trailers or truck beds to provide a portable power supply for
field operations.
23
Arrays that track, or follow the sun across the sky, can follow the sun in one axis or in
two. Tracking arrays perform best in areas with very clear climates. This is because
following the sun yields significantly greater amounts of energy when the sun's
energy is predominantly direct. Direct radiation comes straight from the sun, rather
than the entire sky.
Normally, one axis trackers follow the sun from the east to the west throughout the
day. The angle between the modules and the ground does not change. The modules
face in the "compass" direction of the sun, but may not point exactly up at the sun at
all times.
Two axis trackers change both their east-west direction and the angle from the ground
during the day. The modules face straight at the sun all through the day. Two axis
trackers are considerably more complicated than one axis types.
24
2.4 WORKING OF SOLAR CELLS
The answer to the question of how do you produce electricity from solar energy is
fairly easy to understand once you have a slight knowledge of the subject.
Before you are able to produce electricity through solar energy, there needs to be
some form of solar cell or panel.
The solar panels are made of a semi-conductive material, the most common material
is silicon.
The semi-conductive material contains electrons which are quite happy just sitting
there.
When photons (contained within the suns rays) hit the solar cells, the electrons absorb
this solar energy, transforming them into conduction electrons.
If the energy of these photons is great enough, then the electrons are able to become
free, and carry an electric charge through a circuit to the destination.
Any electrons that do not receive enough energy simply warm up, which heats your
cell or panel, resulting in lowering the efficiency of the cell.
The lowering in efficiency is down to two main factors and they are; that the cell is
not working to its full potential (e.g. some electrons may be lost), the second factor is
when the electrons release heat, the panel also becomes warm, interfering with other
aspects of the solar cells.
The more solar cells contained in a solar panel, or solar array, means the more output
you will receive.
Quality cells are also a major factor in efficiency. If you purchase more expensive
natural energy technologies, you are more likely to have a more efficient cell.
Another factor which affects solar panel efficiency is location. Obviously nearer the
equator, you will receive a slightly better output with a given cell, but solar cells
25
should always be facing the direction of the sun, and have no objects blocking the
sun's rays.
So there we have a basic understand of how you produce solar electricity from using
energy within the sun's rays.
Whether on a solar-powered calculator or an international space station, solar panels
generate electricity using the same principles of electronics as chemical batteries or
standard electrical outlets. With solar panels, it's all about the free flow of electrons
through a circuit.
To understand how solar panels generate electrical power, it might help to take a
quick trip back to high school chemistry class. The basic element of solar panels is the
same element that helped create the computer revolution -- pure silicon. When silicon
is stripped of all impurities, it makes a ideal neutral platform for the transmission of
electrons. Silicon also has some atomic-level properties which make it even more
attractive for the creation of solar panels.
Silicon atoms have room for eight electrons in their outer bands, but only carry four in
their natural state. This means there is room for four more electrons. If one silicon
atom contacts another silicon atom, each receives the other atom's four electrons. This
creates a strong bond, but there is no positive or negative charge because the eight
electrons satisfy the atoms' needs. Silicon atoms can combine for years to result in a
large piece of pure silicon. This material is used to form the plates of solar panels.
Here's where science enters the picture. Two plates of pure silicon would not generate
electricity in solar panels, because they have no positive or negative charge. Solar
panels are created by combining silicon with other elements that do have positive or
negative charges.
Phosphorus, for example, has five electrons to offer to other atoms. If silicon and
phosphorus are combined chemically, the result is a stable eight electrons with an
additional free electron along for the ride. It can\'t leave, because it is bonded to the
other phosphorus atoms, but it isn't needed by the silicon. Therefore, this new
silicon/phosphorus plate is considered to be negatively charged.
26
In order for electricity to flow, a positive charge must also be created. This is
achieved in solar panels by combining silicon with an element such as boron, which
only has three electrons to offer. A silicon/boron plate still has one spot left for
another electron. This means the plate has a positive charge. The two plates are
sandwiched together in solar panels, with conductive wires running between them.
With the two plates in place, it's now time to bring in the 'solar' aspect of solar panels.
Natural sunlight sends out many different particles of energy, but the one we're most
interested in is called a photon. A photon essentially acts like a moving hammer.
When the negative plates of solar cells are pointed at a proper angle to the sun,
photons bombard the silicon/phosphorus atoms.
Eventually, the 9th electron, which wants to be free anyway, is knocked off the outer
ring. This electron doesn't remain free for long, since the positive silicon/boron plate
draws it into the open spot on its own outer band. As the sun's photons break off more
electrons, electricity is generated. The electricity generated by one solar cell is not
very impressive, but when all of the conductive wires draw the free electrons away
from the plates, there is enough electricity to power low amperage motors or other
electronics. Whatever electrons are not used or lost to the air are returned to the
negative plate and the entire process begins again.
One of the main problems with using solar panels is the small amount of electricity
they generate compared to their size. A calculator might only require a single solar
cell, but a solar-powered car would require several thousand. If the angle of the solar
panels is changed even slightly, the efficiency can drop 50 percent.
Some power from solar panels can be stored in chemical batteries, but there usually
isn't much excess power in the first place. The same sunlight that provides photons
also provides more destructive ultraviolet and infrared waves, which eventually cause
the panels to degrade physically. The panels must also be exposed to destructive
weather elements, which can also seriously affect efficiency.
solar cells works on the concept of PN junction where when light incidents on the
solar cell then the heat energy or the photonic energy which was present in the
27
photons which were located in the solar rays was converted into electrical energy by
means of PN junction of semiconductor principle where the majority carriers of P and
N material Crosses the junction as a result movement of these charge carriers causes
current flow which can be extracted from the either side of the solar cell in the form
of DC output with + and - terminals. Thus the DC Output obtained can be given to
any digital circuits or it can be converted into AC by using the INVERTER and can
be utilized for house hold purposes. Many sources also refer to solar panels as
photovoltaic cells, which references the importance of light (photos) in the generation
of electrical voltage. The challenge for future scientists will be to create more efficient
solar panels are small enough for practical applications and powerful enough to create
excess energy for times when sunlight is not available.
28
2.5 PV CELLS AT GLANCE
2.5.1 Advantages
Salient and low maintenance
Solid states with no moving parts
High-quality powers
Life times of 20 to30 years
Flexible and reliable
Modular and expandable
2.5.2 Applications
Coast guard navigation
Off-grid and grid- connected homes
Rail road signaling
Satellites and space station
Out door lightning‟s
Telecommunication and water pumping, etc.
29
3. PIC MICRO CONTROLLER
Embedded System Plays a major role in day to day advancement and achievements.
This simple article provides what is an embedded system and its applications.
An embedded system is a large or small computer system that is built into a product, a
piece of equipment or another computer system, and that performs some task useful to
the product, equipment or system. It is a computer system that is programmed to
perform a particular task. This task may be very simple or very complex; that is not a
relevant distinction. "But" you say, " all computers are programmed to perform
tasks!" True, however an embedded system is programmed to perform its task from
the time it is powered up until it is shut down. Its programming cannot be changed
except in ways that its original programmer intended.
This leads to the notion of an embedded system as a component. Just like a logic gate
or other electronic component, an embedded systems has a single task to perform.
Again, the task may be extremely complex or extremely simple, but in either case the
task is performed by a computer system programmed appropriately. An embedded
system is a component of a larger system of some sort. Indeed, embedded systems
may be nested within other embedded systems to arbitrary depth. Generally, the
"higher level" embedded system is the more complex one, but this is not necessarily
the case.
An example of nested embedded systems might be a walking, or legged, robot. Each
motor on each joint of each leg might be controlled by its own embedded system that
implements some form of motor control strategy such as pulse width modulation or
stepper motor control as appropriate, and acquires sensory input (probably joint
angles and forces). In a multi-legged robot, these low-level embedded systems could
be controlled by a higher-level embedded system that issues commands for each leg
to implement the desired robot motion. Thus, these two levels of embedded system
implement a motion control platform, to which commands are sent by a yet higher-
level system that performs robot path planning and computes the overall motion for
30
the robot. This system may not be at the top of the embedded system hierarchy; it is
entirely possible that a still-higher level system controls the path planner. In this
example, we see a hierarchy of four levels of nested embedded systems. Embedded
systems come in a tremendous variety of "sizes and flavors". An embedded system
may be as small as a single 8-pin integrated circuit that performs the functions of a
few logic gates, or may be as large as a system with 256 megabytes of memory, a
small disc (20 gigabytes or so), a Pentium processor and a host of intelligent
peripherals. The range of physical and "computing" sizes is huge, but all embedded
systems have these features:
they perform a very well-defined task for the product, equipment or
system in which they are found
they do not permit user interaction with their operation except where
such interaction may be the task of the embedded system, and
they are considered to be a component of the (usually much larger)
product, equipment or system.
Examples of Pic Microcontroller Based embedded systems include:
keyboard and other controllers for computers, CD players and
consumer electronics,
timing and control electronics in microwave ovens, coffee makers,
controllers for vacuum cleaners and washing machines for sensing dirt
loads,
control of the dashboard, ignition, fuel injection, suspension stiffness
and environmental temperature and noise in automobiles,
parking meter controllers,
elevator, environmental and security systems in buildings,
internal operation of medical instrumentation such as infusion pumps,
pulse oximeters,
disc controllers for computer systems,
control of data communications routers for wide-band
communications,
and many more.
31
Other than the normal Microcontrollers PIC Family supports more features, so we
have chosen PIC 16F877 as the main controller. The Main features and Peripherals
features are discussed below.
The PIC Microcontroller board consists of circuits necessary to operate a
Microcontroller with PC interface. The board contains provisions for interfacing 8
analog inputs and 23 Digital level signals. The Description of the circuit is given
below.
Analog inputs:
Pin no 2 to 10 can be used to connect any analog signals of range 0-5v.
Digital signals:
As mentioned in the circuit the pin outs from the port is taken to a 26 pin FRC
connector through which we can connect our Digital level signals 0 or 5 volts.
Clock:
The PIC16F877 can be operated in Four Different oscillator modes. The user can
program two configuration bits FOSC1 and FOSC0 to select one of these four modes.
*LP - Low Power crystal
*XT - crystal / resonator
*HS - High speed crystal/resonator
*RC - Resistor capacitor
The clock we have used is 10 MHZ which full under HS category.
MCLR/VPP:
This is master clear input pin to the IC. A logic low signal will generate a reset signal
to the microcontroller. So we have tied this pin to VCC for the proper operation of the
microcontroller.
32
TXD and RXD:
TO communicate with the outside world the microcontroller has an inbuilt USART.
The O/P and I/P line from the USART is taken and given to a MAX232 IC for having
communication with the PC. Since we have used comport for interfacing the
microcontroller.
VCC and Ground:
Pin no 32, 11 are tied to VCC and pin no 31, 12 are grounded to provide power supply
to the chip.
3.1 CORE FEATURES
• 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 14 sources)
• Direct, indirect and relative addressing modes
• Power-on Reset (POR)
• Power-up Timer (PWRT) and
Oscillator Start-up Timer (OST)
• Processor read/write access to program memory
• Wide operating voltage range: 2.0V to 5.5V
• Low-power consumption:
- < 0.6 mA typical @ 3V, 4 MHz
- < 1 µA typical standby current
33
3.2 PERIPHERAL FEATURES
• Timer0: 8-bit timer/counter with 8-bit prescaler
• Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP
• Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
• 10-bit multi-channel Analog-to-Digital converter
• Synchronous Serial Port (SSP) wi
• 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)
Figure 3.2(a) - Block Diagram of PIC Micro Controller
34
Figure 3.2(b) - Circuit Diagram of PIC16F877
35
Fig 3.2(c): PIC16f877 Pin Diagram
There are three memory blocks in each of the PIC16F87X MCUs. The Program
Memory and Data Memory have separate buses so that concurrent
access can occur and is detailed in this section.
The PIC16F87X devices have a 13-bit program counter capable of addressing an 8K
x 14 program memory space. The PIC16F877/876 devices have 8K x 14 words of
FLASH program memory. 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.
36
Fig 3.2(d): PIC16f877 Pin Out Description
37
Fig 3.2(e): PIC16f877 Pin Out Description
38
The PIC16F87X devices have a 13-bit program counter capable of addressing an 8K
x 14 program memory space. The PIC16F877/876 devices have 8K x 14 words of
FLASH program memory. 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.
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. 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.
For byte-oriented instructions, ‟f‟ represents a file register designator and ‟d‟
represents a destination designator. The file register designator specifies which file
register is to be used by the instruction. The destination designator specifies where the
result of the operation is to be placed. If ‟d‟ is zero, the result is placed in the W
register. If ‟d‟ is one, the result is placed in the file register specified in the
instruction. For bit-oriented instructions, ‟b‟ represents a bit field designator which
selects the number of the bit affected by the operation, while ‟f‟ represents the address
of the file in which the bit is located.
For literal and control operations, ‟k‟ represents an eight or eleven bit constant or
literal value. All instructions are executed within one single instruction cycle, unless a
conditional test is true or the program counter is changed as a result of an instruction.
In this case, the execution takes two instruction cycles with the second cycle executed
as a NOP. One instruction cycle consists of four oscillator periods. Thus, for an
oscillator frequency of 4 MHz, the normal instruction execution time is 1 µs. If a
conditional test is true, or the program counter is changed as a result of an instruction,
the instruction execution time is 2 µs.
39
3.3 REGISTERS
3.3.1 Special Function Registers
The Special Function Registers are registers used by the CPU and peripheral modules
for controlling the desired operation of the device. These registers are implemented as
static RAM. The Special Function Registers can be classified into two sets: core
(CPU) and peripheral. Those registers associated with the core functions are described
in detail in this section. Those related to the operation of the peripheral features are
described in detail in the peripheral features section.
3.3.2 Status Registers
The STATUS register contains the arithmetic status of the ALU, the RESET status
and the bank select bits for data memory.The STATUS register can be the destination
for any instruction, as with any other register. If the STATUS register is the
destination for an instruction that affects the Z, DC or C bits, then the write to these
three bits is disabled. These bits are set or cleared according to the device logic.
Furthermore, the TO and PD bits are not writable, therefore, the result of an
instruction with the STATUS register as destination may be different than intended.
For example, CLRF STATUS will clear the upper threebits and set the Z bit. This
leaves the STATUS register as 000u u1uu (where u = unchanged).It is recommended,
therefore, that only BCF, BSF,SWAPF and MOVWF instructions are used to alter the
STATUS register, because these instructions do not affect the Z, C or DC bits from
the STATUS register.
3.4 ADDRESSABLE UNIVERSAL SYNCHRONOUS
ASYNCHRONOUS RECEIVER TRANSMITTER (USART)
The Universal Synchronous Asynchronous Receiver Transmitter (USART) module is
one of the two serial I/O modules. (USART is also known as a Serial
Communications Interface or SCI.) The USART can be configured as a full duplex
asynchronous system that can communicate with peripheral devices such as CRT
terminals and personal computers, or it can be configured as a half duplex
synchronous system that can communicate with peripheral devices such as A/D or
40
D/A integrated circuits, serial EEPROMs etc. The USART can be configured in the
following modes:
• Asynchronous (full duplex)
• Synchronous - Master (half duplex)
• Synchronous - Slave (half duplex)
Bit SPEN (RCSTA<7>) and bits TRISC<7:6> have to be set in order to configure
pins RC6/TX/CK and RC7/RX/DT as the Universal Synchronous Asynchronous
Receiver Transmitter. The USART module also has a multi-processor communication
capability using 9-bit address detection.
Figure 3.4(a) - Transmit status and Control register (address 98h)
bit 7 CSRC: Clock Source Select bit
Asynchronous mode: Don‟t care
Synchronous mode:
1 = Master mode (clock generated internally from BRG)
0 = Slave mode (clock from external source)
bit 6 TX9: 9-bit Transmit Enable bit
1 = Selects 9-bit transmission
0 = Selects 8-bit transmission
bit 5 TXEN: Transmit Enable bit
1 = Transmit enabled
0 = Transmit disabled
bit 4 SYNC: USART Mode Select bit
1 = Synchronous mode
0 = Asynchronous mode
bit 2 BRGH: High Baud Rate Select bit
Asynchronous mode:
1 = High speed
41
0 = Low speed
Synchronous mode: Unused in this mode
bit 1 TRMT: Transmit Shift Register Status bit
1 = TSR empty
0 = TSR full
bit 0 TX9D: 9th bit of Transmit Data, can be parity bit
3.4.1 Usart Asynchronous Mode
In this mode, the USART uses standard non-return-to zero (NRZ) format (one
START bit, eight or nine data bits, and one STOP bit). The most common data format
is 8-bits. An on-chip, dedicated, 8-bit baud rate generator can be used to derive
standard baud rate frequencies from the oscillator. The USART transmits and receives
the LSb first. The transmitter and receiver are functionally independent, but use the
same data format and baud rate. The baud rate generator produces a clock, either x16
or x64 of the bit shift rate, depending on bit BRGH (TXSTA<2>). Parity is not
supported by the hardware, but can be implemented in software (and stored as the
ninth data bit).
Asynchronous mode is stopped during SLEEP. Asynchronous mode is selected by
clearing bit SYNC (TXSTA<4>). The USART Asynchronous module consists of the
following important elements:
• Baud Rate Generator
• Sampling Circuit
• Asynchronous Transmitter
• Asynchronous Receiver
3.4.2 Usart Asynchronous Transmitter
The heart of the transmitter is the transmit (serial) shift register (TSR). The shift
register obtains its data from the read/write transmit buffer, TXREG. The TXREG
register is loaded with data in software. The TSR register is not loaded until the STOP
bit has been transmitted from the previous load. As soon as the STOP bit is
transmitted, the TSR is loaded with new data from the TXREG register (if available).
Once the TXREG register transfers the data to the TSR register (occurs in one TCY),
42
the TXREG register is empty and flag bit TXIF (PIR1<4>) is set. This interrupt can
be enabled/disabled by setting/clearing enable bit TXIE (PIE1<4>). Flag bit TXIF
will be set, regardless of the state of enable bit TXIE and cannot be cleared in
software. It will reset only when new data is loaded into the TXREG register. While
flag bit TXIF indicates the status of the TXREG register, another bit TRMT
(TXSTA<1>) shows the status of the TSR register.
Status bit TRMT is a read only bit, which is set when the TSR register is empty. No
interrupt logic is tied to this bit, so the user has to poll this bit in order to determine if
the TSR register is empty. Transmission is enabled by setting enable bit TXEN
(TXSTA<5>). The actual transmission will not occur until the TXREG register has
been loaded with data and the baud rate generator (BRG) has produced a shift clock.
The transmission can also be started by first loading the TXREG register and then
setting enable bit TXEN. Normally, when transmission is first started, the TSR
register is empty. At that point, transfer to the TXREG register will result in an
immediate transfer to TSR, resulting in an empty TXREG. A back-to-back transfer is
thus possible Clearing enable bit TXEN during a transmission will cause the
transmission to be aborted and will reset the transmitter.
As a result, the RC6/TX/CK pin will revert to hi-impedance.In order to select 9-bit
transmission, transmit bit TX9 (TXSTA<6>) should be set and the ninth bit should be
written to TX9D (TXSTA<0>). The ninth bit must be written before writing the 8-bit
data to the TXREG register. This is because a data write to the TXREG register can
result in an immediate transfer of the data to the TSR register (if the TSR is empty). In
such a case, an incorrect ninth data bit may be loaded in the TSR register.
When setting up an Asynchronous Transmission, follow these steps:
1. Initialize the SPBRG register for the appropriate baud rate. If a high speed
baud rate is desired, set bit BRGH.
2. Enable the asynchronous serial port by clearing bit SYNC and setting bit
SPEN.
3. If interrupts are desired, then set enable bit TXIE.
4. If 9-bit transmission is desired, then set transmit bit TX9.
43
5. Enable the transmission by setting bit TXEN, which will also set bit TXIF.
6. If 9-bit transmission is selected, the ninth bit should be loaded in bit
TX9D.
7. Load data to the TXREG register (starts transmission).
8. If using interrupts, ensure that GIE and PEIE (bits 7 and 6) of the INTCON
register are set.
3.4.3 Usart Asynchronous Receiver
The data is received on the RC7/RX/DT pin and drives the data recovery block. The
data recovery block is actually a high speed shifter, operating at x16 times the baud
rate; whereas, the main receive serial shifter operates at the bit rate or at FOSC. Once
Asynchronous mode is selected, reception is enabled by setting bit CREN
(RCSTA<4>). The heart of the receiver is the receive (serial) shift register (RSR).
After sampling the STOP bit, the received data in the RSR is transferred to the
RCREG register (if it is empty). If the transfer is complete, flag bit RCIF (PIR1<5>)
is set. The actual interrupt can be enabled/disabled by setting/clearing enable bit RCIE
(PIE1<5>). Flag bit RCIF is a read only bit, which is cleared by the hardware. It is
cleared when the RCREG register has been read and is empty.
If the RCREG register is still full, the overrun error bit OERR (RCSTA<1>) will be
set. The word in the RSR will be lost. The RCREG register can be read twice to
retrieve the two bytes in the FIFO. Overrun bit OERR has to be cleared in software.
This is done by resetting the receiver logic (CREN is cleared and then set). If bit
OERR is set, transfers from the RSR register to the RCREG register are inhibited, and
no further data will be received. It is therefore, essential to clear error bit OERR if it is
set. Framing error bit FERR (RCSTA<2>) is set if a STOP bit is detected as clear. Bit
FERR and the 9th receive bit are buffered the same way as the receive data. Reading
the RCREG will load bits RX9D and FERR with new values, therefore, it is essential
for the user to read the RCSTA register before reading the RCREG register in order
not to lose the old FERR and RX9D information.
44
3.5 ANALOG-TO-DIGITAL CONVERTER (A/D) MODULE
The Analog-to-Digital (A/D) Converter module has five inputs for the 28-pin devices
and eight for the other devices. The A/D conversion of the analog input signal results
in a corresponding 10-bit digital number. The A/D converter has a unique feature of
being able to operate while the device is in SLEEP mode. To operate in SLEEP, the
A/D clock must be derived from the A/D‟s internal RC oscillator. The A/D module
has four registers. These registers are:
• A/D Result High Register (ADRESH)
• A/D Result Low Register (ADRESL)
• A/D Control Register0 (ADCON0)
• A/D Control Register1 (ADCON1)
The ADCON0 register, shown in Figure 11, controls the operation of the A/D module.
The ADCON1 register, shown in Figure 12, configures the functions of the port pins.
The port pins can be configured as analog inputs (RA3 can also be the voltage
reference), or as digital I/O. Additional information on using the A/D module can be
found in the PIC micro™ Mid-Range MCU Family Reference Manual (DS33023).
Figure 11- ADCON0 Register (address: 1fh)
bit 7-6 ADCS1:ADCS0: A/D Conversion Clock Select bits
00 = FOSC/2
01 = FOSC/8
10 = FOSC/32
11 = FRC (clock derived from the internal A/D module RC oscillator)
bit 5-3 CHS2:CHS0: Analog Channel Select bits
000 = channel 0, (RA0/AN0)
001 = channel 1, (RA1/AN1)
45
010 = channel 2, (RA2/AN2)
011 = channel 3, (RA3/AN3)
100 = channel 4, (RA5/AN4)
101 = channel 5, (RE0/AN5)(1)
110 = channel 6, (RE1/AN6)(1)
111 = channel 7, (RE2/AN7)(1)
bit 2 GO/DONE: A/D Conversion Status bit
If ADON = 1:
1 = A/D conversion in progress (setting this bit starts the A/D conversion)
0 = A/D conversion not in progress (this bit is automatically cleared by hardware
when the A/D conversion is complete)
bit 1 Unimplemented: Read as '0'
bit 0 ADON: A/D On bit
1 = A/D converter module is operating
0 = A/D converter module is shut-off and consumes no operating current
Figure 12- ADCON1 Register (address 9fh)
bit 7 ADFM: A/D Result Format Select bit
1 = Right justified. 6 Most Significant bits of ADRESH are read as „0‟.
0 = Left justified. 6 Least Significant bits of ADRESL are read as „0‟.
bit 6-4 Unimplemented: Read as '0'
bit 3-0 PCFG3:PCFG0: A/D Port Configuration Control bits:
These steps should be followed for doing an A/D Conversion:
1. Configure the A/D module:
• Configure analog pins/voltage reference and digital I/O (ADCON1)
• Select A/D input channel (ADCON0)
• Select A/D conversion clock (ADCON0)
• Turn on A/D module (ADCON0)
46
2. Configure A/D interrupt (if desired):
• Clear ADIF bit
• Set ADIE bit
• Set PEIE bit
• Set GIE bit
3. Wait the required acquisition time.
4. Start conversion:
• Set GO/DONE bit (ADCON0)
5. Wait for A/D conversion to complete, by either:
• Polling for the GO/DONE bit to be cleared (with interrupts enabled); OR
• Waiting for the A/D interrupt
6. Read A/D result register pair (ADRESH:ADRESL), clear bit ADIF if required.
7. For the next conversion, go to step 1 or step 2, as required. The A/D conversion
time per bit is defined as TAD. A minimum wait of 2TAD is required before the next
acquisition starts.
3.6 INTERRUPTS
The PIC16F87X family has up to 14 sources of interrupt. The interrupt control
register (INTCON) records individual interrupt requests in flag bits. It also has
individual and global interrupt enable bits. A global interrupt enable bit, GIE
(INTCON<7>) enables (if set) all unmasked interrupts, or disables (if cleared) all
interrupts. When bit GIE is enabled, and an interrupt‟s flag bit and mask bit are set,
the interrupt will vector immediately. Individual interrupts can be disabled through
their corresponding enable bits in various registers. Individual interrupt bits are set,
regardless of the status of the GIE bit.
The GIE bit is cleared on RESET. The “return from interrupt” instruction, RETFIE,
exits the interrupt routine, as well as sets the GIE bit, which re-enables interrupts. The
RB0/INT pin interrupt, the RB port change interrupt, and the TMR0 overflow
interrupt flags are contained in the INTCON register. The peripheral interrupt flags
are contained in the special function registers, PIR1 and PIR2. The corresponding
interrupt enable bits are contained in special function registers, PIE1 and PIE2, and
the peripheral interrupt enable bit is contained in special function register INTCON.
47
When an interrupt is responded to, the GIE bit is cleared to disable any further
interrupt, the return address is pushed onto the stack and the PC is loaded with 0004h.
Once in the Interrupt Service Routine, the source(s) of the interrupt can be determined
by polling the interrupt flag bits. The interrupt flag bit(s) must be cleared in software
before re-enabling interrupts to avoid recursive interrupts. For external interrupt
events, such as the INT pin or PORTB change interrupt, the interrupt latency will be
three or four instruction cycles. The exact latency depends when the interrupt event
occurs. The latency is the same for one or two-cycle instructions. Individual interrupt
flag bits are set, regardless of the status of their corresponding mask bit, PEIE bit, or
GIE bit.
Note: Individual interrupt flag bits are set, regardless of the status of their
corresponding mask bit, or the GIE bit.
3.7 INSTRUCTION SET SUMMARY
Each PIC16F87X instruction is a 14-bit word, divided into an OPCODE which
specifies the instruction type and one or more operands which further specify the
operation of the instruction. The PIC16F87X instruction set summary in byte-
oriented, bit-oriented, and literal and control operations.
For byte-oriented instructions, ‟f‟ represents a file register designator and„d‟
represents a destination designator. The file register designator specifies which file
register is to be used by the instruction. The destination designator specifies where the
result of the operation is to be placed. If „d‟ is zero, the result is placed in the W
register. I'd‟ is one, the result is placed in the file register specified in the instruction.
For bit-oriented instructions, ‟b‟ represents a bit field designator which selects the
number of the bit affected by the operation, while ‟f‟ represents the address of the file
in which the bit is located.
48
For literal and control operations, ‟k‟ represents an eight or eleven bit constant or
literal value. All instructions are executed within one single instruction cycle, unless a
conditional test is true or the program counter is changed as a result of an instruction.
In this case, the execution takes two instruction cycles with the second cycle executed
as a NOP. One instruction cycle consists of four oscillator periods. Thus, for an
oscillator frequency of 4 MHz, the normal instruction execution time is 1 µs. If a
conditional test is true, or the program counter is changed as a result of an instruction,
the instruction execution time is 2µs.
3.8 INTERFACE WITH PC
Even if all the parameters are processed through a PIC Microcontroller the display
unit used will be a Seven segment Display or an LCD Display. Using this device we
cannot make Parameter more effective. In order to make the Parameter more
effectively illustrated on Screen we can go for PC instead of LCD Displays. So to
Interface a PC with our Microcontroller unit we need a RS232 interface. Here we
have used MAX232 as a serial interface chip.
Figure 13- Pin Diagram of MAX232
49
The MAX232 power supply section has 2 charge pumps the first uses external
capacitors C1 to double the +5V input to +10V with input impedance of
approximately 200. The second charge pump uses external capacitor to invert +10V
to –10V with an overall output impedance of 45.
The best circuit uses 22F capacitors for C1 and C4 but the value is not critical.
Normally these capacitors are low cost aluminum electrolyte capacitors or tantalum if
size is critical. Increasing the value of C1 and C2 to 47F will lower the output
impedance of +5V to+10V doubled by about 5 and +10V to -10V inverter by about
10. Increasing the value of C3 and C4 lowers the ripple on the power supplies
thereby lowering the 16KHz ripple on the RS232 output. The value of C1 and C4 can
be lowered to 1F in systems where size is critical at the expense of an additional
20 impedance +10V output and 40 additional impedance at –10V input.
Each of the two transmitters is a CMOS inverter powered by + 10V internally
generated supply. The input is TTL and CMOS compatible with a logic threshold of
about 26% of Vcc. The input if an unused transmitter section can be left unconnected:
an internal 400K pull up resistor connected between the transistor input and Vcc
will pull the input high forming the unused transistor output low.
The open circuit output voltage swing is guaranteed to meet the RS232 specification
+ 5v output swing under the worst of both transmitter driving the 3K Minimum load
impedance, the Vcc input at 4.5V and maximum allowable ambient temperature
typical voltage with 5K and Vcc= +.9 v
The slow rate at output is limited to less than 30V/s and the powered done output
impedance will be a minimum of 300 with +2V applied to the output with Vcc
=0V.The outputs are short circuit protected and can be short circuited to ground
indefinitely.
The two receivers fully conform to RS232 specifications. They‟re input impedance is
between 3K either with or without 5V power applied and their switching threshold
is within the +3V of RS232 specification. To ensure compatibility with either RS232
50
IIP or TTl\CMOS input. The MAX232 receivers have VIL of 0.8V and VIH of 2.4V
the receivers have 0.5V of hysterisis to improve noise rejection.
The TTL\CMOS compatible output of receiver will be low whenever the RS232 input
is greater than 2.4V. The receiver output will be high when input is floating or driven
between +0.8V and –30V.
3.9 POWER SUPPLY UNIT
As we all know any invention of latest technology cannot be activated without the
source of power. So it this fast moving world we deliberately need a proper power
source which will be apt for a particular requirement. All the electronic components
starting from diode to Intel IC‟s only work with a DC supply ranging from -+5v to
-+12v.
Figure 3.9(a) : Power Supply Unit For The Microcontroller
We are utilizing for the same, the cheapest and commonly available energy source of
230v-50Hz and stepping down, rectifying, filtering and regulating the voltage. This
will be dealt briefly in the forth-coming sections.
3.9.1 Step Down Transformer
When AC is applied to the primary winding of the power transformer it can either be
stepped down or up depending on the value of DC needed. In our circuit the
transformer of 230v/15-0-15v is used to perform the step down operation where a
230V AC appears as 15V AC across the secondary winding. One alteration of input
causes the top of the transformer to be positive and the bottom negative. The next
alteration will temporarily cause the reverse. The current rating of the transformer
51
used in our project is 2A. Apart from stepping down AC voltages, it gives isolation
between the power source and power supply circuitries.
3.9.2 Rectifier Unit
In the power supply unit, rectification is normally achieved using a solid state diode.
Diode has the property that will let the electron flow easily in one direction at proper
biasing condition. As AC is applied to the diode, electrons only flow when the anode
and cathode is negative. Reversing the polarity of voltage will not permit electron
flow.
A commonly used circuit for supplying large amounts of DC power is the bridge
rectifier. A bridge rectifier of four diodes (4*IN4007) are used to achieve full wave
rectification. Two diodes will conduct during the negative cycle and the other two will
conduct during the positive half cycle. The DC voltage appearing across the output
terminals of the bridge rectifier will be somewhat lass than 90% of the applied rms
value. Normally one alteration of the input voltage will reverse the polarities.
Opposite ends of the transformer will therefore always be 180 deg out of phase with
each other.
For a positive cycle, two diodes are connected to the positive voltage at the top
winding and only one diode conducts. At the same time one of the other two diodes
conducts for the negative voltage that is applied from the bottom winding due to the
forward bias for that diode. In this circuit due to positive half cycleD1 & D2 will
conduct to give 10.8v pulsating DC. The DC output has a ripple frequency of 100Hz.
Since each altercation produces a resulting output pulse, frequency = 2*50 Hz. The
output obtained is not a pure DC and therefore filtration has to be done.
3.9.3 FILTERING UNIT
Filter circuits which are usually capacitors acting as a surge arrester always follow the
rectifier unit. This capacitor is also called as a decoupling capacitor or a bypassing
capacitor, is used not only to „short‟ the ripple with frequency of 120Hz to ground but
also to leave the frequency of the DC to appear at the output. A load resistor R1 is
52
connected so that a reference to the ground is maintained. C1R1 is for bypassing
ripples. C2R2 is used as a low pass filter, i.e. it passes only low frequency signals and
bypasses high frequency signals. The load resistor should be 1% to 2.5% of the load.
1000f/25v : for the reduction of ripples from the pulsating.
10f/25v : for maintaining the stability of the voltage at the load side.
O, 1 : for bypassing the high frequency disturbances.
3.9.4 Voltage Regulators
The voltage regulators play an important role in any power supply unit. The primary
purpose of a regulator is to aid the rectifier and filter circuit in providing a constant
DC voltage to the device. Power supplies without regulators have an inherent problem
of changing DC voltage values due to variations in the load or due to fluctuations in
the AC liner voltage. With a regulator connected to the DC output, the voltage can be
maintained within a close tolerant region of the desired output. IC7812 and 7912 is
used in this project for providing +12v and –12v DC supply.
3.9.5 Specifications
Resistors R1 and R2 maintain line load regulation.
At the secondary side of the transformer,
Applied voltage = 15v
Conducting drop across the diodes = 2*0.6= 1.2v.
Without capacitor:
Vavg = (15-1.2)v = 13.8c pulsating DC
Frequency = 100Hz
With capacitor:
V=Vavg *1.414(form factor) = 19.51v.
Frequency = 0Hz
With 7812 voltage regulator:
V0= +12v
53
4. LCD DISPLAY
The most commonly used Character based LCDs are based on Hitachi's HD44780
controller or other which are compatible with HD44580. In this tutorial, we will
discuss about character based LCDs, their interfacing with various microcontrollers,
various interfaces (8-bit/4-bit), programming, special stuff and tricks you can do with
these simple looking LCDs which can give a new look to your application.
4.1 PIN DESCRIPTION
The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4
Line LCDs which have only 1 controller and support at most of 80 characters,
whereas LCDs supporting more than 80 characters make use of 2 HD44780
controllers.
Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two
pins are extra in both for back-light LED connections). Pin description is shown in the
table below.
FIG 4.1(a): Character LCD type HD44780 Pin diagram
54
Pin No. Name Description
Pin no. 1 VSS Power supply(GND)
Pin no. 2 VCC Power supply (+5V)
Pin no. 3 VEE Contrast adjust
Pin no. 4 RS 0 = Instruction input
1 = Data input
Pin no. 5 R/W 0 = Write to LCD module
1 = Read from LCD module
Pin no. 6 EN Enable signal
Pin no. 7 D0 Data bus line 0 (LSB)
Pin no. 8 D1 Data bus line 1
Pin no. 9 D2 Data bus line 2
Pin no. 10 D3 Data bus line 3
Pin no. 11 D4 Data bus line 4
Pin no. 12 D5 Data bus line 5
Pin no. 13 D6 Data bus line 6
Pin no. 14 D7 Data bus line 7 (MSB)
TABLE 4.1(a): Pin description Of LCD Display
Pin no. 8 D1 Data bus line 1
Pin no. 9 D2 Data bus line 2
Pin no. 10 D3 Data bus line 3
Pin no. 11 D4 Data bus line 4
Pin no. 12 D5 Data bus line 5
Pin no. 13 D6 Data bus line 6
Pin no. 14 D7 Data bus line 7 (MSB)
TABLE 4.1(b): Pin description Of LCD Display with controller 1
Pin No. Name Description
Pin no. 1 D7 Data bus line 7 (MSB)
Pin no. 2 D6 Data bus line 6
Pin no. 3 D5 Data bus line 5
Pin no. 4 D4 Data bus line 4
Pin no. 5 D3 Data bus line 3
Pin no. 6 D2 Data bus line 2
Pin no. 7 D1 Data bus line 1
Pin no. 8 D0 Data bus line 0 (LSB)
Pin no. 9 EN1 Enable signal for row 0 and 1 (1stcontroller)
Pin no. 10 R/W 0 = Write to LCD module
1 = Read from LCD module
Pin no. 11 RS 0 = Instruction input
55
1 = Data input
Pin no. 12 VEE Contrast adjust
Pin no. 13 VSS Power supply (GND)
Pin no. 14 VCC Power supply (+5V)
Pin no. 15 EN2 Enable signal for row 2 and 3 (2nd
controller)
Pin no. 16 NC Not Connected
TABLE 4.1(b): Pin description Of LCD Display with controller 2
Usually these days you will find single controller LCD modules are used more in the
market. So in the tutorial we will discuss more about the single controller LCD, the
operation and everything else is same for the double controller too. Lets take a look at
the basic information which is there in every LCD.
4.2 DDRAM - Display Data RAM
Display data RAM (DDRAM) stores display data represented in 8-bit character codes.
Its extended capacity is 80 X 8 bits, or 80 characters. The area in display data ram
(DDRAM) that is not used for display can be used as general data RAM. So whatever
you send on the DDRAM is actually displayed on the LCD. For LCDs like 1x16, only
16 characters are visible, so whatever you write after 16 chars is written in DDRAM
but is not visible to the user.
Figures below will show you the DDRAM addresses of 1 Line, 2 Line and 4 Line
LCDs.
Figure 4.2(a): DDRAM Address for 1 Line LCD
Figure 4.2(b) : DDRAM Address for 2 Line LCD
56
Figure 4.2(c): DDRAM Address for 4 Line LCD
4.3 CGROM - Character Generator ROM
Now you might be thinking that when you send an ascii value to DDRAM, how the
character is displayed on LCD? so the answer is CGROM. The character generator
ROM generates 5 x 8 dot or 5 x 10 dot character patterns from 8-bit character codes
(see Figure 5 and Figure 6 for more details). It can generate 208 5 x 8 dot character
patterns and 32 5 x 10 dot character patterns. User defined character patterns are also
available by mask-programmed ROM.
As you can see in both the code maps, the character code from 0x00 to 0x07 is
occupied by the CGRAM characters or the user defined characters. If user want to
display the fourth custom character then the code to display it is 0x03 i.e. when user
send 0x03 code to the LCD DDRAM then the fourth user created character will be
displayed.
As clear from the name, CGRAM area is used to create custom characters in LCD. In
the character generator RAM, the user can rewrite character patterns by program. For
5 x 8 dots, eight character patterns can be written, and for 5 x 10 dots, four character
patterns can be written. Later in this tutorial i will explain how to use CGRAM area to
make custom character and also making animations to give nice effects to your
application.
57
Figure 4.3 (a) : LCD characters code map for 5x8 dots
Busy Flag is an status indicator flag for LCD. When we send a command or data to
the LCD for processing, this flag is set (i.e BF =1) and as soon as the instruction is
executed successfully this flag is cleared (BF = 0). This is helpful in producing and
exact delay, To read Busy Flag, the condition RS = 0 and R/W = 1 must be met and
The MSB of the LCD data bus (D7) act as busy flag. When BF = 1 means LCD is
busy and will not accept next command or data and BF = 0 means LCD is ready for
next.
There are two 8-bit registers in HD44780 controller Instruction and Data register.
Instruction register corresponds to the register where you send commands to LCD e.g
LCD shift command, LCD clear, LCD address etc. and Data register is used for
58
storing data which is to be displayed on LCD. when send the enable signal of the
LCD is asserted, the data on the pins is latched in to the data register and data is then
moved automatically to the DDRAM and hence is displayed on the LCD.
Figure 4.3(b) : LCD characters code map for 5x10 dots
Data Register is not only used for sending data to DDRAM but also for CGRAM, the
address where you want to send the data, is decided by the instruction you send to
LCD. We will discuss more on LCD instruction set further in this tutorial.
Only the instruction register (IR) and the data register (DR) of the LCD can be
controlled by the MCU. Before starting the internal operation of the LCD, control
information is temporarily stored into these registers to allow interfacing with various
MCUs, which operate at different speeds, or various peripheral control devices. The
59
internal operation of the LCD is determined by signals sent from the MCU. These
signals, which include register selection signal (RS), read/write signal (R/W), and the
data bus (DB0 to DB7), make up the LCD instructions (Table 3). There are four
categories of instructions that:
Designate LCD functions, such as display format, data length, etc.
Set internal RAM addresses
Perform data transfer with internal RAM
Perform miscellaneous functions
60
Table 4.3 (a) : Command and Instruction set for LCD type HD44780
Although looking at the table you can make your own commands and test them.
Below is a brief list of commands which are used frequently while working on LCD.
No. Instruction Hex Decimal 1 Function Set: 8-bit, 1 Line, 5x7 Dots 0x30 48
2 Function Set: 8-bit, 2 Line, 5x7 Dots 0x38 56
3 Function Set: 4-bit, 1 Line, 5x7 Dots 0x20 32
4 Function Set: 4-bit, 2 Line, 5x7 Dots 0x28 40
5 Entry Mode 0x06 6
6
Display off cursor off
(clearing display without clearing DDRAM
content)
0x08 8
7 Display on Cursor on 0x0E 14
8 Display on Cursor off 0x0C 12
9 Display on Cursor blinking 0x0F 15
10 Shift entire display left 0x18 24
12 Shift entire display right 0x1C 30
13 Move cursor left by one character 0x10 16
14 Move cursor right by one character 0x14 20
15 Clear Display (also clear DDRAM content) 0x01 1
16 Set DDRAM address or coursor position on
display 0x80+add* 128+add*
17 Set CGRAM address or set pointer to CGRAM
location 0x40+add** 64+add**
Table 4.3 (b): Frequently used commands and instructions for LCD
* DDRAM address given in LCD basics section see Figure 2,3,4
** CGRAM address from 0x00 to 0x3F, 0x00 to 0x07 for char1 and so on.
Before using the LCD for display purpose, LCD has to be initialized either by the
internal reset circuit or sending set of commands to initialize the LCD. It is the user
who has to decide whether an LCD has to be initialized by instructions or by internal
reset circuit. we will discuss both ways of initialization one by one.
61
An internal reset circuit automatically initializes the HD44780U when the power is
turned on. The following instructions are executed during the initialization. The busy
flag (BF) is kept in the busy state until the initialization ends (BF = 1). The busy state
lasts for 10 ms after VCC rises to 4.5 V.
As mentioned in the Note, there are certain conditions that has to be met, if user want
to use initialization by internal reset circuit. These conditions are shown in the Table 5
below.
Table 4.3(c): Power Supply condition for Internal Reset circuit
Initializing LCD with instructions is really simple. Given below is a flowchart that
describes the step to follow, to initialize the LCD.
Move data to LCD port
select data register
select write operation
send enable signal
wait for LCD to process the data
Now we are ready with sending data and sending command to LCD.
62
Figure 4.4(a) : Flow chart for LCD initialization
Reading data from the LCD is done in the same way, but control line R/W has to be
high. When we send a high to the LCD, it will reset and wait for instructions. Typical
instructions sent to LCD display after a reset are: turning on a display, turning on a
cursor and writing characters from left to right. When the LCD is initialized, it is
ready to continue receiving data or instructions. If it receives a character, it will write
it on the display and move the cursor one space to the right. The Cursor marks the
next location where a character will be written. When we want to write a string of
characters, first we need to set up the starting address, and then send one character at a
63
time. Characters that can be shown on the display are stored in data display (DD)
RAM. The size of DDRAM is 80 bytes.
Before we access DD RAM after defining a special character, the program must set
the DD RAM address. Writing and reading data from any LCD memory is done from
the last address which was set up using set-address instruction. Once the address of
DD RAM is set, a new written character will be displayed at the appropriate place on
the screen. Until now we discussed the operation of writing and reading to an LCD as
if it were an ordinary memory. But this is not so. The LCD controller needs 40 to 120
microseconds (uS) for writing and reading. Other operations can take up to 5 mS.
During that time, the microcontroller cannot access the LCD, so a program needs to
know when the LCD is busy. We can solve this in two ways.
One way is to check the BUSY bit found on data line D7. This is not the best method
because LCD's can get stuck, and program will then stay forever in a loop checking
the BUSY bit. The other way is to introduce a delay in the program. The delay has to
be long enough for the LCD to finish the operation in process. Instructions for writing
to and reading from an LCD memory are shown in the previous table.
At the beginning we mentioned that we needed 11 I/O lines to communicate with an
LCD. However, we can communicate with an LCD through a 4-bit data bus. Thus we
can reduce the total number of communication lines to seven. The wiring for
connection via a 4-bit data bus is shown in the diagram below. In this example we use
an LCD display with 2x16 characters, labeled LM16X212 by Japanese maker
SHARP. The message 'character' is written in the first row: and two special characters
'~' and '}' are displayed. In the second row we have produced the word
'mikroElektronika'.
When working with a microcontroller the numbers are presented in a binary form. As
such, they cannot be displayed on a display. That's why it is necessary to change the
numbers from a binary system into a decimal system so they can be easily understood.
For printing the variables lcdbyte and lcdword we have used the macros digbyte and
digword which convert the numbers from binary system into a decimal system and
64
print the result on LCD. Main program has the purpose of demonstrating use of LCD
display. At the start it's necessary to declare variables LCDbuf, LCDtemp, Digtemp,
Dig1, Dig2, and Dig3 used by the macros for LCD support. It is also necessary to
state the port of microcontroller that LCD is connected to. Program initializes the
LCD and demonstrates printing text and 8-bit variable temp.
65
5.ELECTROMECHANICAL 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. Each relay can perform
only one protective function. Such relays are used for simple and less costly
protection purposes. For important and costly equipment installation static relays are
preferred.
66
FIG 5(a): 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).
67
The Relay driver Circuit Works as follows. A Relay is connected as shown in the
figure 5(a).
Figure 5(a): 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.
68
6.TESTING CIRCUIT
Basically, there are two methods of controlling the charging current: series regulation
and parallel (shunt) regulation. A series regulator is inserted between the solar panel
and the battery. The series type of regulation „wastes‟ a lot of energy while charging
the battery as the control circuitry is always active and series regulator requires the
input voltage to be 3-4 volts higher than the output voltage. The current and voltage
output of a solar panel is governed by the angle of incidence of light, which keeps
varying.
Parallel regulation, is preferred in solar field. In parallel regulation, the control
circuitry allows the charging current (even in MA) to flow into the battery and stop
the charging once the battery is fully charged. At, this stage, the charging current is
wasted by converting into heat (current is passed through low value, high-wattage
resister); this part of the regulation dissipate a lot of heat.
In this project, we have used parallel regulation but instead of wasting the charging
current as heat, we have made it pulsed and applied to the battery to keep the battery
topped-up.
After power-on, the microcontrollers read the battery voltage with the help of the
ADC and display the values on LCD. It monitors the input signal from the dusk-to-
dawn sensor and activates the load or charging relay RL1 accordingly. The digital
voltmeter works up to 20V. As Vref of the ADC is converted to Vcc (5V), the input
voltage to the ADC connect exceed +5V. A potential divider is used at pin 2 of the
ADC (IC2) using resisters R5, R6 & R7 to scale down the voltage from ADC output
is multiplied four times and displayed on the LCD as battery voltage.
When the solar panel voltage is present, the duck-to-down sensor provides a signal to
the microcontroller, which the displays „charging‟ message on the LCD. During
charging, the battery voltage is continuously monitored. When the voltage reaches
14.0V, the microcontroller interrupts the charging current by energizing the relay,
which is connected to the MOSFET BS170 (T2) , and start a 5-minute times. During
this stage, The LCD shows “battery full.”
69
After 5-minutes, the relay reconnects the panel to the battery. This way, the charging
current is pulsed at the intervals of five minutes and the cycle repeats until the panel
voltage is present.
FIG 6(a): solar charger testing schematic circuit
When the panel voltage falls below the zener diode (ZD1) voltage of the dusk-to-
dawn sensor, the microcontroller senses this and activates the load by switching on
MOSFET T3 via optocoupler IC3 and “load on” message is displayed.
In this mode, the microcontroller monitors for low battery. When the battery voltage
drops below 10 volts, the microcontroller turns off the load by switching off
MOSFET T3 and “Battery Low-Load Off” message is displayed.
Normally, when the load is switched off, the battery voltage tends to rise back and the
load oscillates between „on‟ and „off‟ states. To avoid this, the microcontroller
employs a hysteresis control by intering into a „lock‟ mode during low-battery state
and comes out of the lock mode when the duck-to-dawn sensor receives the panel
70
voltage (the next morning). During lock mode, the microcontroller keeps converting
the ADC value and displays the battery voltage on the LCD.
6.1 SOURCE CODE
1. Click on the Keil uVision Icon on DeskTop
2. The following fig will appear
FIG: 6.1 (a): Keil Dumping Software Program Window
3. Click on the Project menu from the title bar
4. Then Click on New Project
71
5. Save the Project by typing suitable project name with no extension in u r
own folder sited in either C:\ or D:\
6. Then Click on Save button above.
7. Select the component for u r project. i.e. Atmel……
8. Click on the + Symbol beside of Atmel
72
9. Select AT89C51 as shown below
10. Then Click on “OK”
11. The Following fig will appear
73
12. Then Click either YES or NO………mostly “NO”
13. Now your project is ready to USE
14. Now double click on the Target1, you would get another option “Source
group 1” as shown in next page.
15. Click on the file option from menu bar and select “new”
74
16. The next screen will be as shown in next page, and just maximize it by
double clicking on its blue boarder.
17. Now start writing program in either in “C” or “ASM”
18. For a program written in Assembly, then save it with extension “. asm”
and for “C” based program save it with extension “ .C”
75
19. Now right click on Source group 1 and click on “Add files to Group
Source”
20. Now you will get another window, on which by default “C” files will
appear.
76
21. Now select as per your file extension given while saving the file
22. Click only one time on option “ADD”
23. Now Press function key F7 to compile. Any error will appear if so happen.
24. If the file contains no error, then press Control+F5 simultaneously.
25. The new window is as follows
77
26. Then Click “OK”
27. Now Click on the Peripherals from menu bar, and check your required port
as shown in fig below
28. Drag the port a side and click in the program file.
78
29. Now keep Pressing function key “F11” slowly and observe.
30. You are running your program successfully
6.2 Program Used In PIC16F877
// With LCD Display #include <pic.h> #include <math.h> #include <stdlib.h> #include <stdio.h> #include <delay4.c> #include <lcdportd.h> #defineRelay RC0 int Printval; char Ostr[5]; float Volt,Volt1; void main() { TRISA = 0xff; TRISB = 0xff; TRISC = 0x80; TRISD = 0x00; TRISE = 0x00;
79
ADCON0 = 0x81; ADCON1 = 0x82; PORTD = 0x00; PORTE = 0x00; LCD_init(); DelayMs(200); LCD_SendCmd(0x80); Relay = 0; do { ADCON0 = 0x81; DelayUs(50); ADGO = 1; while(ADGO) continue; Volt = (float)((ADRESH * 256)+ADRESL); Volt = Volt / 101.0; LCD_SendCmd(0x80); LCD_puts("SV:"); sprintf(Ostr,"%3d",(int)(Volt * 10)); LCD_SendData(Ostr[0]); LCD_SendData(Ostr[1]); LCD_SendData('.'); LCD_SendData(Ostr[2]); LCD_SendData('V'); ADCON0 = 0x89; DelayUs(50); ADGO = 1; while(ADGO) continue; Volt1 = (float)((ADRESH * 256)+ADRESL); Volt1 = Volt1 / 102.0; LCD_SendCmd(0xc0); LCD_puts("BV:"); sprintf(Ostr,"%3d",(int)(Volt1 * 10)); LCD_SendData(Ostr[0]); LCD_SendData(Ostr[1]); LCD_SendData('.'); LCD_SendData(Ostr[2]); LCD_SendData('V'); LCD_SendCmd(0x89); if(Volt > 6.0) { Relay = 1; LCD_puts("Chrgng "); } else { Relay = 0; LCD_puts("Nt Chrg"); } LCD_SendCmd(0xc9);
80
if(Volt1 < 4.0) { LCD_puts("Lo Volt"); } else { LCD_puts("Volt OK"); } DelayMs(200); }while(1); }
81
7.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.
Presently, solar systems are developing 2%. By the end of 2010, the growth rate may
increase to 7%.
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.
The key point is "Start Using Solar Power And Save Earth From Destruction"
82
8.REFERENCES
Solar Electricity Engineering of Photovoltaic System – by Lorezo E.
Solar Energy – by Maxwell J.F & McGown J.G
System Identification – by Solderstron T. & Stoica P.
Power Electronics – by Bhimbra P.S
Electronics and Circuits - by Allen Mottershead
Basic Electronics – by Miami A.K
www.electronicsforu.com
www.wikipedia.com
www.atmel.com