Project Thesis (13!07!2018)
Project Thesis (13!07!2018)
Project Thesis (13!07!2018)
Submitted by
SYED MUHAMMAD SAMI SHAH 14PWELE4586
YASIR NAWAZ 14PWELE4590
MUHAMMAD ASIM 14PWELE4452
Supervisor
Submitted by
SYED MUHAMMAD SAMI SHAH
YASIR NAWAZ
MUHAMMAD ASIM
Supervisor
DISSERTATION
Submitted by
Syed Muhammad Sami Shah (14PWELE4586)
Yasir Nawaz (14PWELE4590)
Muhammad Asim (14PWELE4452)
_______________________ _______________________
ENGR. UZMA NAWAZ PROF. DR. WAQAR SHAH
Project Supervisor Chairman
I hereby declare that I am the sole author of this thesis. This is a true copy of the thesis, including
any required final revisions, as accepted by my examiners. It is further declared, that I have
fulfilled all the requirements in line with the Quality Assurance guidelines of the Pakistan
engineering council.
Abstract
Smart meter is an advanced energy meter that measures usage of electrical energy providing
extra information compared to a conventional energy meter. Smart meters Integration into grid
includes operation of a variety of techniques and software, depending on the features that the
situation demands. Smart Meters design depends upon the needs of company and customers.
Different features can be added to the Smart Meter. Appropriate choice and implementation of
communication channels are required for the deployment Smart Meters that satisfy the security
standards of smart grid communication. These problems and challenges are included in
designing, deployment, utilization, and maintenance of the smart meter infrastructure.
Additionally, many other applications and advantages of smart meter, in the sight of future
electricity market are conferred in detail. The importance of introduction of Smart Meters in
developing countries is included.
First of all, we would like to thank almighty ALLAH for giving us the strength to complete this
project. Foremost, we would like to express our sincere gratitude to our advisor Engr.Uzma
Nawaz for his continuous support of his patience, motivation, enthusiasm and immense
knowledge’s guidance helped us in all the time of research and writing this thesis. We could not
have imagined having a better advisor and mentor for our project study. Last but not the least; we
would like to thank our family, our parents and friends for supporting us spiritually throughout
our education.
Table of Contents
APPROVAL SHEET ................................................................................................................ ii
AUTHOR'S DECLARATION ................................................................................................. ii
Abstract .................................................................................................................................... iii
Acknowledgements .................................................................................................................. iv
Table of Contents ...................................................................................................................... v
List of Figures ........................................................................................................................ viii
List of Tables ........................................................................................................................... ix
CHAPTER 1 ........................................................................................................................... 10
INTRODUCTION .................................................................................................................. 10
1.1 Background ................................................................................................................... 10
1.2 Literature Review .......................................................................................................... 12
1.3 Objective of Project ....................................................................................................... 12
1.4 Scope of Project ............................................................................................................ 12
1.5 Outline of Thesis ........................................................................................................... 12
CHAPTER 2…...…………………………………………………………………………….14
REVIEW OF SOLAR ENERGY AND COMPONENTS ...................................................... 14
2.1 Solar Cell ....................................................................................................................... 14
2.1.1 How Solar Panels Work Converting Sunlight into Electricity ............................... 15
2.1.2 Internal structure of solar cell ................................................................................. 16
2.1.3 The basic steps in the operation of a solar cell are: ................................................ 17
2.2 Applications .................................................................................................................. 17
2.3 Efficiency ...................................................................................................................... 18
2.4 Cost................................................................................................................................ 18
2.5 Relay.............................................................................................................................. 19
2.5.1 Relay construction and working principle .............................................................. 19
2.5.2 On condition ........................................................................................................... 20
2.5.3 Off condition........................................................................................................... 21
2.6 LCD ............................................................................................................................... 21
2.6.1 Applications of LCD .............................................................................................. 21
2.6.2 Interface of LCD with micro controller .................................................................. 22
2.6.3 Command/Instruction Register ............................................................................... 22
2.6.4 Data Register .......................................................................................................... 22
2.6.5 Displaying Character On Screen ............................................................................ 22
2.14 Graphic LCD ............................................................................................................... 23
2.14.1 Pin Diagram: ......................................................................................................... 26
2.14.2 Pin Description: .................................................................................................... 26
CHAPTER 3 ........................................................................................................................... 27
PIC MICROCONTROLLER AND ITS DESCRIPTION ...................................................... 27
3.1 Instruction Sets in PIC .................................................................................................. 27
3.2 Memory ......................................................................................................................... 29
3.2.1 Flash memory ......................................................................................................... 29
3.3 Registers ........................................................................................................................ 29
3.4 Interrupts ....................................................................................................................... 30
3.5 Bus ................................................................................................................................. 30
3.5.1 Data bus .................................................................................................................. 30
3.5.2 Address bus............................................................................................................. 30
3.6 Overview of PIC 16F877 .............................................................................................. 32
3.7 Features of PIC16F877.................................................................................................. 33
3.7.1 General Features ..................................................................................................... 33
3.7.2 Peripheral Features ................................................................................................. 34
3.7.3 Key Features ........................................................................................................... 35
3.7.4 Analog Features ...................................................................................................... 35
3.7.5 Special Features ...................................................................................................... 35
3.8 Pin Diagrams ................................................................................................................. 36
3.8.1 Input/output ports ................................................................................................... 39
CHAPTER 4 ........................................................................................................................... 41
PHYSICAL MODELING AND HARDWARE IMPLEMENTATION PROCESS .............. 41
4.1 Block Diagram .............................................................................................................. 41
4.2 Circuit Diagram ............................................................................................................. 42
4.3 Hardware Implementation ............................................................................................. 43
CHAPTER 5 ........................................................................................................................... 45
CONCLUSION ....................................................................................................................... 45
5.1 Conclusion:.................................................................................................................... 45
5.2 Future Work Recommendation: .................................................................................... 45
Appendix I .............................................................................................................................. 47
References: .............................................................................................................................. 49
List of Figures
Figure 1.1: Net Metering......................................................................................................... 10
Figure 2.1: Solar Cell .............................................................................................................. 15
Figure 2.2:Solar Cell ............................................................................................................... 15
Figure 2.3: Working Principle of Solar Cell ........................................................................... 16
Figure 2.4: Internal Structure of Solar Cell ............................................................................ 17
Figure 2.5: Design of Relay .................................................................................................... 20
Figure 2.6: ON Condition of Relay......................................................................................... 21
Figure 2.7: LCD ...................................................................................................................... 22
Figure 2.8: Circuit Diagram .................................................................................................... 23
Figure 2.10: Graphic LCD ...................................................................................................... 24
Figure 2.11: Pin Diagram of graphic LCD ............................................................................. 26
Figure 3.1: PIC Structure ........................................................................................................ 28
Figure 3.2: PIC 16F877........................................................................................................... 33
Figure 3.3: Pin Diagrams of PIC 16F877 chip ....................................................................... 37
Figure 3.4: PIC Microcontroller used in project ..................................................................... 38
Figure 4.1: Block Diagram ..................................................................................................... 42
Figure 4.2: Circuit Diagram .................................................................................................... 43
Figure 4.3: Whole Circuit ....................................................................................................... 44
List of Tables
DC Direct Current
AC Alternating Current
C. T Current Transformer
P. T potential Transformer
IC Integrated Circuit
INTRODUCTION
1.1 Background
“The electricity policy for the consumers who owns renewable energy facilities (such as solar
power) is net metering, which facilitate the use of electricity whenever needed while contribute
in the production to grid.” In the Philippines, according to the Renewable Energy Act of 2008 the
Net Metering is the first policy which has been fully implemented. The flow of electricity from
power generation through High Voltage Transmission (HVT) and Distribution utilities to the
end-user who can now install a renewable energy source and can sent the not required electricity
back into the distribution grid and earn revenue for this export, is depicted in the picture below.
Net metering is the notion which records net energy between export of produced energy and
import of Distribution company’s energy for a billing month. On the other hand, the meter
developed with the feature of recording both the import and export values other than parameters
notified by CEA metering regulations and APTRANSCO (Transmission Company)/Distribution
company’s procedures in trend, will also be permissible for incoming net energy for the billing
period.
The electricity is generated by directing the Sunlight on the solar photovoltaic (SPV)
modules. Multiple devices are created as an applications of the SPV modules connected with the
designed power taming units for compliance of the electricity requirements Grid connected roof
top solar PV system: Recently PV systems has become the attractive and viable source of power
generation.
Utility scale plants are being introduced worldwide with promotional mechanisms which are
set up on ground surface as well as the roof-top area of the buildings can also be used for setting
up solar PV power plants, and thus using the free land area efficiently. The generated electricity
of SPV systems can also be exported to the distribution or transmission grid after integrating to
suit grid incorporation.
These roof-top solar PV systems are easy to install and maintain, having life span of 25 years,
are segmental in nature, whose capacity can be boosted in future to meet the high demand of
electricity.
The PV panels will be installed on the rooftop of the building. The output generated by the
panels (DC electricity) is connected to the power conditioning unit / inverter which converts this
DC output to AC. Whereas the inverter’s output will be connected to the control panel or
distribution board of the building to employ the power. The inverter is synchronized with grid
and is also connected to the backup power source, to yield smooth power to power the loads with
first priority of the solar power usage. If the power generated by the solar cells is more than load
requirement then the excess power is automatically directed to the grid. For the greater capacity
systems linking through step up transformer and switch yard may be required to feed the power
to grid.
Operation and Maintenance Requirements: In the systems there are no moving parts and
requires slight care. As the dust can affect the ability of the system thus it will require a slight
periodic cleaning.
The grid linked with the roof top solar PV system would be able to fulfill partially/ full need
of power for the large-scale buildings. Some of the benefits of roof top SPV systems are
mentioned below:
In many years, number of Engineers have worked on Smart energy metering system. Some of
their work includes technologies like the touch based AMR system, which is an automatic meter
reading system, among others Shwehdi et al. presented the Digital Tele wattmeter system which
is an example of a microcontroller based meter; the meter was realized to transmit data on a
monthly basis through a dedicated a pair of modems and a telephone line, to a remote central
office. Kaoy et al. designed and implemented a Bluetooth energy meter where several meters
which were near, communicated wirelessly with a master PC. The major setback for this kind of
system was the distance coverage because Bluetooth technology works effectively at small
range. Stanescu et al. presented a design and implementation of SMS based control for
monitoring systems. The system has three modules involving sensing unit, The SMS, for
monitoring the complex applications and for status reporting such as power failure respectively.
In this system the billing system issues for electricity board usage were not considered. Sharma
et al. suggested a method to utilize telecommunication system for automated transmission of data
to facilitate bill generation at the server end and to the customer through SMS or Email
The objective of our project is to develop a system named (Dual way Metering System) as a
name indicate this system can supply the power to both the sides, for example from end
consumers to WAPDA and WAPDA to End consumers.
The system will allow the end consumer to generate the power to fulfill the requirement of its
own load, where in case of excess unit system will fed the power to WAPDA site.
1. In case the inability of the solar to generate any power then consumer will be able to use the
WAPDA as a primary source.
2. In case the solar power generated is greater than consumer’s load consumption, then the
excessive units can be sold to WAPDA.
3. If the selling to the WAPDA greater and consumption is less from WAPDA, then WAPDA
will pay back or the net bill will come in negative.
4. If the selling to the WAPDA is less and consumption from WAPDA is more, then consumer
will pay to WAPDA but in net bill the selling units will be subtracted.
To achieve the objective of this project, many scopes had been defined, those includes using, C
language to program PIC Microcontroller, building hardware for the system. and interfacing
the hardware to PIC microcontroller and different electronics components like LCD, Relay,
Current transfer (CT’s), Voltage Transformers (VT’s) etc.
This thesis comprises of five chapters. The first chapter discuss the objective of the
project, chapter 2 includes literature review related to the project that had been done, in chapter 3
discussion on PIC Microcontroller and on its interface is done, whereas in chapter 4 the
methodology for the project implementation is discussed and the last chapter discusses the the
conclusion of this project and future work.
CHAPTER 2
A photovoltaic cell (also called a solar cell) which converts the light energy directly into
electrical energy by using photovoltaic effect. It is a kind of photoelectric cell (which means its
electrical characteristics such as current, voltage, or resistance, vary when light is strike upon it)
which can generate and support an electric current without being attached to any external voltage
source, when exposed to light.
Photovoltaic is the field of research and technology concerned with the practical application
of photovoltaic cells in the production of electricity from light, though it is often used
specifically to refer to the generation of electricity from sunlight. Cells can be labelled
as photovoltaic even when the source of light is not essentially sunlight (artificial light such as
lamplight, etc.). In such situations the cell is sometimes used as a photo detector (infrared
detectors), which detects the light or any other electromagnetic radiation in the near visible
range, or measuring light intensity.
In contrast, a solar thermal collector collects heat for either direct heating or indirect
electrical power generation by absorbing sunlight. On the other hand, "Photo electrolytic cell"
(photo electrochemical cell), refers either a type of photovoltaic cell (like that developed by A.E.
Becquerel and modern dye-sensitized solar cells) or a device that splits water directly into
hydrogen and oxygen using only solar illumination.
Figure 2.1: Solar Cell
The solar cells are made from two very thin silicon wafers that are approximately 1 mm
thick. One wafer has a positive charge whereas the other caries a negative charge. When exposed
to the rays of sun called photons, an electron activity is generated. which is then captured by a
grid of very fine finger-like "metal electrical contacts" distributed across the panel. Through a
junction box at the back of the solar panels, this activity is passed and then appears as DC
electricity. The DC energy produced by the solar panels must be captured in battery to be stored.
Else it would be lost.
The solar panel is collectively made of individual solar cells. These panels collectively generates
the solar Array. The function of solar cell is like that of large semiconductor and use a large-area
p-n junction diode. These p-n junction diodes convert the energy from sunlight into usable
electrical energy whenever these solar cells are exposed to sunlight. The solar energy generated
from photons strikes the solar panels surface that allows electrons to be bumped out of their
orbits and are released. And then the electric fields in the solar cells attract these free electrons in
a directional current in which the "metal contacts" in the individual solar cells (which are all
'connected' within the panel) and thus this GENERATE ELECTRICITY! This is the way solar
panels work.
The sunlight is directly converted into electricity by an electronic device called solar cell.
When Light shines on the solar cell produces both a current and a voltage in order to generate
electrical energy. This process requires two things
Firstly, a material in which the electrons are raised to a higher energy state by the
absorption of light.
Secondly, the movement of this higher energy electrons into an external circuit from
the solar cell.
The electron then disintegrates its energy in the external circuit and returns to the solar cell.
For photovoltaic energy conversion, a large diversity of materials and processes can potentially
satisfy its needs, but in practice nearly all photovoltaic energy conversion uses semiconductor
materials in the form of a p-n junction.
2.2 Applications
Solar cell is an encapsulated and electrically connected module. The semiconductor wafers of
photovoltaic cells are protected from abrasion and effect due to wind-driven debris, rain, hail,
etc. by the thin sheet of glass which is on the front side of the module, which allows the sunlight
to pass into it. In module the solar cells are connected in series, creative an additive voltage. The
cells connected in parallel will produce a higher current; though very important problems exist
with cells connected parallelly. For example, the effect of shadow can close down the weaker
(less illuminated) parallel string (a number cells connected in series) cause the substantial power
loss and can even damage the weaker string due to excessive reverse bias applied by their
illuminated partners to the shadowed cells. The strings of the cells connected in series should be
handled independently and should not be connected parallelly as much as possible. And should
be save using special paralleling circuits. Though an Array with desired peak DC voltage and
loading current capacity can be created by interconnecting the modules, independent MPPTs
(maximum power point trackers) usage provides a better solution. To reduce the power loss
because of shadowing in the arrays of connected cells in series/parallel, shunt diodes can be used
in the absence of paralleling circuits.
To make use of energy generated by solar cells , the electricity is often transfer to the grid
using inverters (grid-connected photovoltaic systems); the energy not required immediately is
stored in batteries in stand alone systems. Solar panels can also be used to recharge or power
portable devices.
2.3 Efficiency
Solar cells efficiency may be broken down into thermodynamic efficiency, reflectance
efficiency, conductive efficiency, and charge carrier separation efficiency. The product of each
of these individual efficiencies, contribute to the overall efficiency of the solar cells
These parameters can’t be measured directly , thus instead some other parameters are measured:
integrated quantum efficiency, thermodynamic efficiency, quantum efficiency, fill factor, and
VOC ratio. A portion of the quantum efficiency under "external quantum efficiency" are the
Reflectance losses. Recombination losses make up a portion of the VOC ratio, quantum
efficiency, and fill factor. Resistive losses are mostly categorized under fill factor, but it also
makes up slight portions of the quantum efficiency, VOC ratio.
‘The ratio of the maximum obtainable power to the product of the short circuit current and open
voltage is know as fill factor. Also its a key parameter in evaluating the performance of solar
cells. Commercial typical solar cells have a fill factor > 0.70 to 0.72. While a fill factor usually
between 0.4 to 0.7 are Grade B cells. Cells those have high fill factor have low equivalent and
high shunt resistance,so the current produced by low cells are dissipated in internal losses.
.
2.4 Cost
The cost of a sunlight based cell is given per unit of pinnacle electrical power. Assembling costs
essentially incorporate the cost of vitality required for fabricate. Sun oriented specific feed-in
tariffs vary around the world, and even state by state inside different nations. Such feed-in
tariffs can be very viable in empowering the improvement of sunlight based power ventures.
High-effectiveness sun based cells are important to diminish the cost of sun oriented vitality.
Huge numbers of the expenses of a sun based power plant are corresponding to the region of the
plant; a higher effectiveness cell may diminish territory and plant cost, regardless of whether the
cells themselves are all the more exorbitant. Productivity's of uncovered cells, to be helpful in
assessing sun oriented power plant financial aspects, must be assessed under sensible conditions.
The fundamental parameters that should be assessed are the short out present, open circuit
voltage.
High-efficiency solar cells are of interest to decrease the cost of solar energy. Many of the costs
of a solar power plant are proportional to the area of the plant; a higher efficiency cell may
reduce area and plant cost, even if the cells themselves are more costly. Efficiency's of bare cells,
to be useful in evaluating solar power plant economics, must be evaluated under realistic
conditions. The basic parameters that need to be evaluated are the short circuit current, open
circuit voltage.
2.5 Relay
An electrically operated switch called relay, through the coil of relay current flows and
creates magnetic field which attracts a lever and change the switch contacts. The relay can have
two switch positions i.e. On/Off and most have double changeover (throw) switch contacts as
shown in the diagram. Relays allow one circuit to switch a second circuit which can be entirely
isolated from the first.
For example, a low voltage battery circuit can use a relay to switch a 230V AC mains circuit.
Inside the relay there is no electrical connection between the two circuits; the link is
mechanical and magnetic.
2.5.1 Relay construction and working principle
A relatively large current is passed by the coil of relay, typically for a 12V relay 30mA, but for
relays designed to operate from lower voltages it can be as much as 100mA. This current ca not
be provided by most of the ICs and usually a transistor is used for the amplification of the small
IC current to the larger required for the relay coil. For the popular 555 timer IC, the maximum
output current is 200mA, so these devices can directly supply to the relay coils without
amplification.
These Relays are the electrical remote-control switches which means that these switches are
controlled by another switch, such a computer as in power train control module. To control
higher current circuit Relays, allow a small current flow circuit. Arrays of several design are
used such as 3-pin,4-pin,5-pin and 6-pin, single switches or dual switches.
All these relays are operated using same basic principles. In the figure below
All relays operate using the same basic principle. The example in figure: 16 below uses a 4-pin
relay. Relays have the following two circuits:
1) Load circuit (in left side)
2) Control circuit (in right side)
The load circuit has a switch and the control circuit has a small control coil. The coil in the
control circuit controls the operation of the switch in the load circuit.
Figure:a Figure: b
2.5.2 on condition
A magnetic field is created when current flows through control circuit, which causes the
switch to close. The part of the load circuit i.e. switch is used to control the connected electrical
circuit and hence current flows. This is the energized state
The relay become de-energized when the current flow via the control circuit. As there is no
magnetic field the switch opens and hence there is no flow of current via the load circuit.
2.6 LCD
An electronic visual, flat panel of video display called LCD (liquid crystal display) which
that uses the light modulating characteristic of liquid crystals (LCs). The liquid crystals do not
radiate the light directly.
These LCDs are use to display arbitrary images (e.g. in general purpose PCs) or fixed images
as in a digital clock which can be hidden or displayed, such as preset words, digits, 7-
segment displays. Same basic technology is use by these, except for the arbitrary images are
developed using large number of small pixels, whereas other displays have larger elements.
Wide range of applications are there for LCDs including the computer monitors, instrument
panels, aircraft cockpit display or television etc. In consumer devices these LCDs are very
common such as video players, gaming devices, clocks, watches, calculators, and telephones.
Cathode Ray Tube (CRT) are largely replaced by the LCDs in most of the application. These
LCDs are presented in a broader choice of screen sizes than plasma and CRT, and as no
phosphors is used in these LCDs, they cannot suffer from image burn-in. LCDs are, however,
vulnerable to image persistence.
A 16x2 Liquid crystal display can be specified as that it can display 16 characters per line
and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD
has two registers.
2.6.3 Command/Instruction Register
The instruction or command register stores the command instructions specified to the LCD.
A command is an instruction given to LCD to perform a predefined task like initializing, clearing
the screen, setting the cursor position, controlling display etc.
The data register stores the data that is to be presented on the LCD. The data consist of the
ASCII value of the character to be presented on the LCD.
The width and height dimensions of the display is described by graphics display resolution,
for example a computer monitor is in pixels. Certain groupings of width and height are
standardized and typically given a name and a set that is expressive of its dimensions. A higher
resolution of the display means that presented content appears sharper.
Figure 2.10: Graphic LCD
Graphic LCD displays, also called a monochrome graphics LCD displays or dot matrix
LCD displays, which have been in use from many years. The technology is older than current
cutting edge displays but it is by no means becoming a ‘Legacy’ type of display. In fact, look for
this display to increase in popularity. Graphic LCD displays unlike TFT (Thin Film Transistor)
or OLED (Organic light emitting diodes), do not offer color options. The graphic is displayed by
one color and require minimum power to operate. This LCD modules are able to display images,
numbers and letters that are created over the customer’s software.
Dot Matrix displays are recognized by the two sets of numbers. An example of this two-
set number is a 128 x 64. Which means that this display comprises of 128 dots on the X axis, or
horizontally, and 64 dots on the Y axis or Vertically. Each of these dots is sometimes denoted to
as a pixel, whose state is changeable independently of each other i.e. it can be turned ON and
OFF. The software is used by the customer to state to each dot when to turn ON and OFF. This is
analogous to the old ‘light bright’ toy.
Graphic LCD display is used in application where it is required to present more than
just letters or numbers. A crane manufacturer is required provide the display that show the
position of the crane as it moves from the level of the ground to the full extension.
Graphic LCD Display is used by the Gas Pumps to display more than just gallons or total
dollars. Currently these graphic LCDs are used to display advertising and weather reports and
even obtain a receipt via the touch screen interface connected to the glass of the display.
The 128x64 LCD is divided into two equal halves with each half being controlled by a
separate KS0108 controller. Such LCDs (using KS0108 controller) involve paging scheme, i.e.,
whole LCD is divided equally into pages. The paging scheme of the graphical LCD can be
easily understood from the given table.
1. 128x64 LCD means that it consists of 128 columns and 64 rows. In total there are (128x64 =
1024) pixels.
2. 128x64 LCD is divided equally into two halves. Each half is separately controlled by a
controller and each half consists of 8 pages. In above diagram, CS stands for Controller Select.
3. Each page consists of 8 rows and 64 columns. Thus, the two horizontal pages make 128 (64x2)
columns and 8 vertical pages make 64 rows (8x8).
The source code written by the programmer to perform the required operation on a PIC Chip
are called the instruction sets. Any programming language can used to write these codes such s
such as C, C++, assembly languages, and so on. These instruction sets are the predefined
commands for each function with its own syntaxes and are executed on PIC chips. Usually
Reduced Instruction Set Programming are use on by PIC chips that consist of only 35
instructions sets which are very easy to learn as compared to the CISC instruction set. The
instruction sets are classified into 5 groups by the basis of the type of the instructions. Here in
this first section the basics of computer programming by using various instruction sets are
described.
The instruction set are developed by the basis of the RISC structure in the PIC. The groups of
the instruction sets are given below.
Harvard architecture is used by the all PIC microcontroller family. In this architecture the
program and data are accessed from separate memories, so the device has a data memory bus and
a program memory bus (i.e. more than 8 lines in a normal bus). which expands the bandwidth,
which is the data throughput, over traditional von Neumann architecture in which the program
and data are fetched from the same memory (accesses over the same bus). Separating the data
and program memory further allows instructions to be sized differently than the 8-bit wide data
word.
Basic structure of a modern Peripheral interface controller chip is show in the picture
below.
3.2 Memory
The data and programs are stored in the memory of the PIC chip temporarily or permanently.
Like usual microcontrollers, the PIC chip also has certain amount of ROM, RAM, EEPROM,
and other flash memory etc.
The permanent memory is stored in ROM. It is also referred as n program memory. Certain
amount of ROM memory is available on PIC chip.
EEPROM memory is another type of ROM memory. During the run time the EEPROM act
like the RAM i.e. its contents changes during run time. But it is like ROM because after shutting
down the data remains on the Chip as like ROM. This is the one of the special advantages of
EEPROM. The value created in run time is stored on EEPROM, which is the basic function of
EEPROM in PIC chip.
RAM memory; is the complex memory module in a PIC chip. This memory related with
various type of registers (general-purpose registers and special function registers) and memory
BANK modules (BANK 0, BANK 1, etc.). The contents on the RAM erases as the power goes
off. In PIC chip the RAM is used to store temporary data and provide immediate results.
A special type of memory called Flash memory where operations such as READ, WRITE,
ERASE, can be done many times. Flash memory was invented by INTEL Corporation in 1980.
A certain amount of flash memory is available on PIC Chip.
3.3 Registers
A memory location in CPU called register is used to store information. Register can be
considered as the tiny scratchpad of the CPU, which temporarily stores the instruction or data.
The following is the basic classification of the registers.
A small storage area available on a CPU whose contents are more quickly accessible than
other storage available on PIC, is called general purpose register. It can simultaneously store
both data and addresses.
Special function registers are the part of RAM memory. Unlike general purpose registers,
their purpose is predetermined during the manufacturing time and cannot be changed later by the
users. These registers are dedicated to special functions.
3.4 Interrupts
Interrupts delays the running program temporarily. The running execution is haltered for
an interval by these interrupts. This interval/delay in running programs is referred as interrupts.
A current regular execution is stopped when an interrupt arrives. Interrupt can be performed by
internally (by using software) or externally (hardware interrupt).
3.5 Bus
Data bus is used for data transportation. Interfacing all the circuitry components inside
the PIC chip is the function of data bus.
For memory addressing mostly address buses are used. The address from CPU to
memory location is transmitted by the address bus.
USART or UART
For the transmission (TX) and reception (RX) of data these ports are used. This
transmission is only possible using various digital data transceiver modules like RF, IR,
Bluetooth, etc. One of the simplest way to communicate other devices with PIC chip is using
these ports.
Oscillators
An oscillation/clock generating circuit used to provide proper clock pulse to the PIC chip,
is called an oscillator. The timing and counting applications are helped by this clock pulses.
Various types of clock generator are used by PIC chip. The oscillators and its frequencies may
vary according to the application and type of PIC used. The normal oscillators used with A PIC
chip are LC (Inductor-Capacitor), RC (Resistor-Capacitor), RLC (Resistor-Inductor-capacitor),
crystal oscillators etc.
Stack
For storing the return addresses the PIC chip has an area, this unit or area is called Stack.
Which is used in Peripheral interface controllers. For the software stack the hardware stack is not
accessible whereas it is easily accessible to most of the controllers.
Input/output ports
For providing interface to various output/input devices and memories, these ports are
used. The number of ports may vary according to the type of the PIC chip.
The different advanced features of the PIC chip are included in this section. These
features may vary according to the type of the PIC chip. In a peripheral interface controller, some
of the various advanced features are oscillator start up timer, power up timer, power on reset,
brown out reset, low voltage programming, in circuit debugger, CCP module, voltage
comparator etc.
• Reliability
The PIC controlled system frequently exist in machines which are highly anticipated to
perform continuously for years without any error or failure and in many cases if an error occurs
it recover themselves with help of supporting firmware.
• Performance
Many systems embedded with PIC chips use a simple pipelined RISC processor for
computation and for data storage SRAM is provided by most of them, to increase the
performance.
Power consumption
Minimal power is required for the operation of PIC controlled system without sacrificing
performance. By dynamically and independently controlling multiple power platforms, power
consumption can highly be reduced.
• Memory
The PIC based system are mostly memory expandable and according to the usage and type of
application it easily adds more and more memory. In some cases, i.e. small application it can use
its built-in memory.
One of the utmost advanced microcontroller from Microchip is PIC 16F877. The usage of
this controller is very wide because of its low price, ease of availability, wide range of
applications and high quality. In most of the modern and experimental applications these
controllers are used. It is ideal to use this PIC controller for applications such as measurement
devices, machine control application, study purpose, and so on. The PIC 16F877 have all the
feature components which modern microcontrollers normally have. The figure of a PIC16F877
chip is shown below.
Figure 3.2: PIC 16F877
Comparing to the previous series, PIC16FXX series has more advanced and developed
features. Some of the important features of PIC16F877 series is given below.
o All single cycle instructions except for program branches which are two cycles.
o Up to 368×8bit of RAM (data memory), 256×8 of EEPROM (data memory), 8k×14 of flash
memory.
o Low power consumption (<0.6mA typical @3v-4MHz, 20µA typical @3v-32MHz and <1 A
typical standby).
3.7.2 Peripheral Features
o Timer 2: 8 bit timer/counter with 8 bit period registers with pre-scalar and post-scalar.
o Two Capture (16bit/12.5nS), Compare (16 bit/200nS), Pulse Width Modules (10bit).
o Synchronous Serial Port (SSP) with SPI (master code) and I2C (master/slave).
o Parallel Slave Port (PSP) 8 bit wide with external RD, WR and CS controls (40/46pin).
o 5 input/output ports.
o 3 timers.
o 2 CCP modules.
PIC16F877 has 5 basic output/input ports. These ports are normally labelled as PORT A (R
A), PORT B (RB), PORT C (RC), PORT D (RD), and PORT E (RE). For input/output
interfacing these ports are used. In this controller, “PORT A” is only 6 bits wide (RA-0 to RA-
7),” PORT B”, “PORT C”,” PORT D” are only 8 bits wide (RB-0 to RB-7, RC-0 to RC-7, RD-0
to RD-7),” PORT E” has only 3 bits wide (RE-0 to RE-7).
All these ports are bi-directional. The direction of the port is controlled by using TRIS(X)
registers (TRIS A used to set the direction of PORT-A, TRIS B used to set the direction for
PORT-B, etc.). Setting a TRIS(X) bit ‘1’ will set the corresponding PORT(X) bit as input.
Clearing a TRIS(X) bit ‘0’ will set the corresponding PORT(X) bit as output.
(If we want to set PORT A as an input, just set TRIS(A) bit to logical ‘1’ and want to set
PORT B as an output, just set the PORT B bits to logical ‘0’.)
o Analog input port (AN0 TO AN7) : these ports are used for interfacing analog inputs.
o TX and RX: These are the USART transmission and reception ports.
o SCK: these pins are used for giving synchronous serial clock input.
o SCL: these pins act as an output for both SPI and I2C modes.
o DT: these are synchronous data terminals.
o CK: synchronous clock input.
o SD0: SPI data output (SPI Mode).
o SD1: SPI Data input (SPI mode).
o SDA: data input/output in I2C Mode.
o CCP1 and CCP2: these are capture/compare/PWM modules.
o OSC1: oscillator input/external clock.
o OSC2: oscillator output/clock out.
o MCLR: master clear pin (Active low reset).
o Vpp: programming voltage input.
o THV: High voltage test mode controlling.
o Vref (+/-): reference voltage.
o SS: Slave select for the synchronous serial port.
o T0CK1: clock input to TIMER 0.
o T1OSO: Timer 1 oscillator output.
o T1OS1: Timer 1 oscillator input.
o T1CK1: clock input to Timer 1.
o PGD: Serial programming data.
o PGC: serial programming clock.
o PGM: Low Voltage Programming input.
o INT: external interrupt.
o RD: Read control for parallel slave port.
o CS: Select control for parallel slave.
o PSP0 to PSP7: Parallel slave port.
o VDD: positive supply for logic and input pins.
o VSS: Ground reference for logic and input/output pins
CHAPTER 4
For sake of simplicity and for ease of implementation, the block diagram should be made
before implementing the circuit. The central part of the project is PIC Microcontroller, which
controls all the process like measuring the voltage of the load using P.T (potential transformer),
using C.T. current will also be measured, where the power generated by solar is measure by
using other C.T, in the same way the voltage of the battery is measured using other P.T. Here 1
port of controller is connected to the LCD for displaying the following information displayed in
LCD.
Figure 4.1: Block Diagram
A circuit diagram should be made before implementing hardware, because it will help in
easy implementation and it also helps in easy removal of errors, if any exist.
The connection between all the component and interfacing interfaces with controller is
shown in circuit diagram. The regulator, which is used to provide a smooth 5V DC voltage, and
also used to operate pic microcontroller, LCD, relay etc.
Data pins, which are Four in numbers are used to interface with LCD. For C.T (current
transformer) two pins are reserved which measures the current and P.T (potential transformer)
for voltage measurement. For measuring battery voltage one pin is also reserved. The signals of
C.T, P.T and Battery are analog signals. And are required to convert into digital signals but PIC
controller (16F877) has its own ADC (analog to digital convertor) so there is no need of this
conversion. For relays two pins are reserved, in which one relay is used for switching the source
and other allows the power to WAPDA, which basically discernment the unit. PIC controller has
sufficient control to drive the relay so relay driver is used.
Figure 4.2: Circuit Diagram
The connection from circuit diagram and connect the components, are presented in this part.
Hardware circuit have number of parts, here it will be explained in detail whereas at the end
general overview would be given.
The Figure given below consist of regulator, pic controller, some C.Ts some P.Ts, LCD,
relay, relay driver regulator etc. As the function of regulator is mentioned above is that it is used
to provide smooth DC voltage to each component.
Figure 4.3: Whole Circuit
A system built can supply the power to the both sides, i.e. from consumer to WAPDA and
from WAPDA to consumers. The end-consumer will use the solar system which will fulfill the
necessity of its own load and in case of excesses unit system will transfer the power to WAPDA
site. The current of loads is measure by C.Ts as shown in figure. The power from solar panel is
captured/stored in the batteries. The invertor converts the DC current into AC. For measuring
voltage of subjective load, P.T is used. While the relay driver’s function is discussed in the last
section.
CHAPTER 5
CONCLUSION
5.1 Conclusion:
From the entire research (from library, teachers, engineers, Internet, research articles, technical
workshops, course books) that we’ve done in reference of our project. We have found that net
metering system is highly efficient, reliable, convenient, highly losses free and easy to use than
the conventional energy metering system. This project using net metering defines the designing
and working of integration of renewable energy. In this era of technology this project is highly
economical implementation for the people of Pakistan who are highly suffering from electricity
i.e. energy shortfalls. It is a practical and an efficient use of existing systems. This thesis also
discusses the management of load using Smart Net Metering by consumers. It also helps in meter
reading, detection of current conditions, battery voltage, less operation cost and possible the
elimination of corruption related to Net meter reading.
There are some limitations which can be possible to fulfill in the future here are some future
work recommendations:
• As this have the capability of managing only 200W of load, so the future work
recommendation is to design such a system which can manage 5KW of load.
sbitLCD_RS_Direction at TRISD3_bit;
sbitLCD_EN_Direction at TRISD2_bit;
void process_volt_1_ac();
void process_amps_1_ac();
void process_volt_2_ac();
void process_amps_2_ac();
void process_units_1();
void process_units_2();
void process_units_3();
void process_units_4();
void process_units_11();
void process_units_22();
void process_units_33();
void process_battery();
void process_solar();
void process_wapda();
/////////////////////////////variables/////////////////////////////////////
unsigned int
ac_volts_1,ac_volts_2,ac_amps_1,ac_amps_2,ac_amps_3,counter_1,counter_2,counter_3,volts_
batt,volts_solar,volts_wapda;
////////////////////////////////////////////////////////////////////////////////
char volt1,volt2,volt3;
char amps1,amps2,amps3;
char digita_3,digita_2,digita_1;
char digitb_3,digitb_2,digitb_1;
char digitc_3,digitc_2,digitc_1;
char digitz_3,digity_2,digitx_1;
char digitd_3,digitd_2,digitd_1;
char digite_3,digite_2,digite_1;
////////////////////////////////////////////////////////////////////////////////
TRISD = 0b00000000;
TRISC = 0b00000000;
TRISA = 0b11111111;
ADCON0 = 0b00000001;
ADCON1 = 0b00000000;
LED=0;
relay1=0;
relay2=0;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
delay_ms(100);
////////////////////////////////////////////////////////////////////////////////
do
process_volt_1_ac();
process_amps_1_ac();
process_volt_2_ac();
process_amps_2_ac();
process_battery();
process_solar();
process_wapda();
process_units_11();
process_units_22();
process_units_33();
process_units_4();
delay_ms(1000);
LED = ~LED;
} while(1);
////////////////////////////////////////////////////////////////////////////////
void process_volt_1_ac()
ADCON0 = 0b00010001;
delay_us(10);
adc_value= ADC_Read(2);
adc_value=(adc_value*500)/1023;
ac_volts_1 = adc_value;
volt3 = 48+ac_volts_1/100;
Lcd_Out(1, 1,"V1=");
Lcd_Chr(1, 4,volt3);
Lcd_Chr(1, 5,volt2);
Lcd_Chr(1, 6,volt1);
void process_amps_1_ac()
ADCON0 = 0b00011001;
delay_us(10);
adc_value= ADC_Read(3);
adc_value=(adc_value*500)/1023;
ac_amps_1 = adc_value;
amps3 = 48+ac_amps_1/100;
Lcd_Chr(1, 11,amps3);
Lcd_Chr(1, 12,'.');
Lcd_Chr(1, 13,amps2);
Lcd_Chr(1, 14,amps1);
/////////////////////////////////////////////////////////////////////////////////
void process_volt_2_ac()
{
ADCON0 = 0b00000001;
delay_us(10);
adc_value= ADC_Read(0);
adc_value=(adc_value*500)/1023;
ac_volts_2 = adc_value;
volt3 = 48+ac_volts_2/100;
Lcd_Out(2, 1,"V2=");
Lcd_Chr(2, 4,volt3);
Lcd_Chr(2, 5,volt2);
Lcd_Chr(2, 6,volt1);
void process_amps_2_ac()
ADCON0 = 0b00001001;
delay_us(10);
adc_value= ADC_Read(1);
adc_value=(adc_value*500)/1023;
ac_amps_2 = adc_value;
amps3 = 48+ac_amps_2/100;
amps2 = 48+(ac_amps_2/10) % 10;
Lcd_Chr(2, 11,amps3);
Lcd_Chr(2, 12,'.');
Lcd_Chr(2, 13,amps2);
Lcd_Chr(2, 14,amps1);
void process_units_1(){
counter_1++;
relay2=0;
relay1=1;
relay2=1;
relay1=1;
if(ac_amps_2 > 2 ){
counter_1++;
counter_2++;
}//end ac_amps_2
}//end else if
}
void process_units_11(){
Lcd_Out(3, 1,"SU=");
Lcd_Chr(3, 4,digita_3);
Lcd_Chr(3, 5,digita_2);
Lcd_Chr(3, 6,digita_1);
void process_units_2(){
counter_2++;
Lcd_Chr(3, 11,digitb_3);
Lcd_Chr(3, 12,digitb_2);
Lcd_Chr(3, 13,digitb_1);
void process_units_22(){
Lcd_Chr(3, 11,digitb_3);
Lcd_Chr(3, 12,digitb_2);
Lcd_Chr(3, 13,digitb_1);
void process_units_3(){
counter_3++;
digitb_3 = 48+counter_3/100;
Lcd_Out(4, 1,"WU=");
Lcd_Chr(4, 2,digitb_3);
Lcd_Chr(4, 3,digitb_2);
Lcd_Chr(4, 4,digitb_1);
void process_units_33(){
digitb_3 = 48+counter_3/100;
Lcd_Out(4, 1,"WU=");
Lcd_Chr(4, 4,digitb_3);
Lcd_Chr(4, 5,digitb_2);
Lcd_Chr(4, 6,digitb_1);
void process_units_4(){
counter_4 = counter_3-counter_2;
Lcd_Chr(4, 15,digitb_3);
Lcd_Chr(4, 16,digitb_2);
Lcd_Chr(4, 17,digitb_1);
void process_battery(){
ADCON0 = 0b00100001;
delay_us(10);
adc_value = ADC_Read(4);
adc_value=(adc_value*50)/1023;
volts_batt=adc_value;
digitz_3 = 48+volts_batt/100;
Lcd_Chr(1, 18,digity_2);
Lcd_Chr(1, 19,digitx_1);
///////////////////////////////////////////
if(volts_batt>= 13 ){
relay2=1;
relay1=1;
else{
counter_3++;
relay2=0;
relay1=0;
counter_1++;
relay2=0;
relay1=1;
///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
void process_solar(){
ADCON0 = 0b00110001;
delay_us(10);
adc_value = ADC_Read(6);
adc_value=(adc_value*50)/1023;
volts_solar =adc_value;
///////////////////////////////////////////
Lcd_Chr(2, 18,digitd_2);
Lcd_Chr(2, 19,digitd_1);
///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
void process_wapda(){
ADCON0 = 0b00101001;
delay_us(10);
adc_value = ADC_Read(5);
adc_value=(adc_value*500)/1023;
volts_wapda =adc_value;
///////////////////////////////////////////
digite_3 = 48+volts_wapda/100;
Lcd_Chr(3, 18,digite_3);
Lcd_Chr(3, 19,digite_2);
Lcd_Chr(3, 20,digite_1);
References
[1]
Baker, D. R. (2013, June 20). Is your smart meter spying on you? Retrieve
d October
smart-meter-spying-on-you/
[2]Berst,. (2009, November 10). Meter Maker Shakedown: The 5 That Will
Survive. Retrieved October 15, 2013, from Smart Grid News: http://w
ww.smartgridnews.com/artman/publish/Technologies_Metering_N ews/Smart-
Meter-Maker-Shakedown-The-5-That-Will-Survive-1399.html
[3] Beatty, C. (2012). Advanced Metering Management: Securing investment profitability and
http://www.landisgyr.com/webfoo/wpcontent/uploads/2012/11/LG_White_Paper_Secu
ring_investment_profitability_and_energy_market_compliance.pdf
[4]Burke, P. (2013, April). The Smart Meter Grid: The Perfect Storm. Retrieve
d Octobe2013, from The way to balance: http://thewaytobalance.com/SmartMet
ersArticle HYPERLINK "http://thewaytobalance.com/SmartMetersArticle-"-
TWTB.pdf Jones. (2011, September 9). Meter reader not needed: the world i
s digital.Retrieved October 16, 2013, from The Florida Times-
Union: Jacksonville.com
[6]Michels, S. (2012, July 20). PBS News Hour; “How Smart Are S
http://www.pbs.org/newshour/rundown/2012/07/ho HYPERLINK
"http://www.pbs.org/newshour/rundown/2012/07/how-"w HYPERLINK
"http://www.pbs.org/newshour/rundown/2012/07/how-"-smart-are-
smartmeters.html
[7]Mifflin, M. (n.d.). Smart Meter -Definition and Use. Retrieved October 7, 201
"%20%20%20 http://housewares.about.com/od/savingenergy/g/Smart-
"http://housewares.about.com/od/savingenergy/g/Smart HYPERLINK
"%20%20%20 http://housewares.about.com/od/savingenergy/g/Smart-"-Meter-
Definition-And-Use.htm
[8]
Porter, E. (2013, August 21). Couple sues to keep smart meters away from
home.
smart-meters-away- home/nZYjG/