Вы находитесь на странице: 1из 48

UNIVERSITY OF ZIMBABWE

DEPARTMENT OF ELECTRICAL ENGINEERING

PROJECT TITLE: REAL TIME ELECTRICITY USAGE MONITOR

NAME : MURWIRA TALENT TAFADZWA

REGISTRATION NUMBER : R081582N

SUPERVISOR : Mr C MUTEPFE

YEAR : 2011 - 2012

LEVEL : IV

Presented in Partial fulfilment of the requirements of the Degree of BSc Hons in


Electrical Engineering at the University of Zimbabwe.
i
Real Time Electricity Usage Monitor

Table of contents

Abstract

Chapter 1

1.1 Background of the project..........................................................................................................1


1.2 Problem statement......................................................................................................................2
1.3 Project scope..............................................................................................................................2
1.4 Objectives..................................................................................................................................2
1.5 Justification................................................................................................................................3
1.6 Project applications3

Chapter 2

2.1 Introduction................................................................................................................................4

2.2 Existing metering systems.........................................................................................................4

2.2.1 In-home display of energy use................................................................................................4

2.2.2 Plug-in meter...........................................................................................................................5

2.2.3 Energy saving power strip......................................................................................................6

2.2.4 Real time monitors..................................................................................................................6

2.2.5 Separate sensor and display type............................................................................................7

2.2.6 Electronic meter......................................................................................................................8

2.2.6.1 Real time clock....................................................................................................................9

2.2.7 Smart meters...........................................................................................................................9

2.3 GSM based remote energy monitoring......................................................................................9

2.3.1 Client side.............................................................................................................................10

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


ii
Real Time Electricity Usage Monitor
2.3.1.1 Transmitter section.............................................................................................................11

2.3.2 Server side.............................................................................................................................11

2.3.2.1 Receiver section.................................................................................................................12

2.3.3 Transmission channel............................................................................................................12

2.3.4 Role of GSM in remote billing.............................................................................................12

2.4 Current sensors.........................................................................................................................12

2.4.1 Using a shunt for current sensing..........................................................................................13

2.4.2 Using a current transformer for current sensing...................................................................13

2.5 Energy metering integrated circuits.........................................................................................14

2.5.1 SA2002H..............................................................................................................................15

Chapter 3

3.1 Liquid crystal display...............................................................................................................16

3.2 Microcontroller........................................................................................................................17

3.2.1 High-performance RISC CPU..............................................................................................17

3.2.2 Special microcontroller features...........................................................................................17

3.2.3 Reset signal...........................................................................................................................18

3.2.4 Clock signal..........................................................................................................................18

3.3 IR-speed sensor........................................................................................................................18

3.4 Power supply............................................................................................................................19

3.4.1 Description............................................................................................................................20

3.4.1.1 Transformer.......................................................................................................................20

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


iii
Real Time Electricity Usage Monitor
3.4.1.2 Bridge rectifier...................................................................................................................20

3.4.1.3 Smoothing..........................................................................................................................20

3.4.1.4 Regulation..........................................................................................................................21

3.4.1.5 Voltage regulator circuit....................................................................................................21

3.5 Overall design circuit diagram.................................................................................................22

Chapter 4

4.1 Software development.............................................................................................................23

Chapter 5
5.1Results and testing....................................................................................................................29

5.2 Testing.....................................................................................................................................30

5.2.1 Device under test.................................................................................................................30

5.3 First test...................................................................................................................................31

5.4 Menu function.........................................................................................................................31

5.4.1 Demonstrating menu functions.............................................................................................32

5.5 Second test...............................................................................................................................33

5.6 Third test..................................................................................................................................34

5.6.1 Low rate................................................................................................................................34

5.6.2 Average rate..........................................................................................................................35

5.6.3 Very high rate.......................................................................................................................35

5.7 Fourth test................................................................................................................................36

5.7.1 Power usage status................................................................................................................36

5.7.2 Load a bit high......................................................................................................................37

5.7.3 Excessive load.......................................................................................................................38

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


iv
Real Time Electricity Usage Monitor

Chapter 6
6.1 Conclusion...............................................................................................................................39

6.2 Project budget..........................................................................................................................39

6.3 Challenges................................................................................................................................40

6.4 Recommendations....................................................................................................................40

List of figures
Fig 1: Plug-in meter

Fig 2: Energy saving power strip

Fig 3: Separate sensor and display meter

Fig 4: Electronic meter

Fig 5: Client side

Fig 6: Server side

Fig 7: LCD display

Fig 8: IR-speed sensor

Fig 9: Smoothing

References 41

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


v
Real Time Electricity Usage Monitor

Acknowledgements

I record my sincere gratitude Mr. C. Mutepfe, my supervisor and lecturer in the department of
Electrical Engineering for the continuous and inspiring guidance and constructive criticisms
throughout this project work.

I would also like to take this opportunity to extend my great appreciation to other lecturers and
colleagues in the department for their wonderful contribution in form of suggestions and ideas
during my research.

Last, but not least i would also like to thank my family and friends for their support socially and
financially.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


vi
Real Time Electricity Usage Monitor

Abstract

Home energy monitoring systems has found impact in developed countries such as America and
most parts of Europe. Electrical energy is a renewable resource that needs to be saved as its
generation is costly. Currently Zimbabwe is experiencing power shortages, with electricity being
imported at a high cost from Mozambique, South Africa and as far as DRC. This is giving a
burden to the Electricity Department ZESA and hence the need to come up with an initiative that
encourages consumers to save electricity. ZESA is trying to encourage consumers to save
electricity and it is coming up with adverts that spell out the ways to reduce the so much wastage
of power. Some of the ways the Electricity Department includes the use of energy savers and
encouraging consumers to switch off their appliances when they are not in use.

This project outlines the design of a home energy monitoring device that helps consumers to see
how much energy they are using and how much energy that they are wasting when they do not
switch off their televisions and radios throughout the night when everybody is asleep, keeping
cell phones on charger when they are fully charged. The projects will state the advantages of
home energy monitors and how consumers will be helped in saving electricity, consequently
reducing their electricity bills. Most residents are complaining that their bills are too high and
this energy monitoring system will shut the cry-out.

In addition to home energy monitoring a research in remote billing system was incorporated in
my project. Remote electricity billing is a unique concept, in which the electricity board can
collect meter readings from consumer using GSM network. Each consumer is provided with a
unique energy meter, which is having a GSM modem, microcontroller unit and a display unit
internally. A SIM card is required for communication. In this system the consumer sends a
request for bill to a remote server, the consumer will receive an SMS from the server showing
cost data.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


1
Real Time Electricity Usage Monitor

CHAPTER 1

1.1 Background of the project

In Zimbabwe at the present moment there is need of saving electricity because the current
electrical supply to consumers is scarce, other ways have been put in place in order to save
electricity, and these include:

Use of incandescent lamps i.e. energy savers,


Use of alternative sources of energy e.g. installing solar geysers,
Use of electric jugs to boil water.

The sum total of these methods is not an effective way of saving electricity, an alternative way is
to use single phase energy watt meters to monitor your home or business electricity consumption
through the month. This phenomenon is not yet well adapted by many consumers in Zimbabwe.
Unlike the main energy meter, an in-home display is a quick and easy way for consumers to see
what the cost of running their appliances is. Monitoring your monthly electric consumption can
be used to project your monthly bill.

There are a vast range of these meters; the issue is to carefully select a meter which would best
help to achieve the desired goal. The watt meters are grouped as whole house meters and others
that only measure power consumption of individual appliances. Whole house watt meters are
more attractive than those that measure the power consumption of individual appliances.

It is a necessity to introduce the watt meters to the consumers, and this design focuses on
designing a whole house wattmeter which is quite advantageous to use than watt meters that only
show the power consumption of individual appliances. The advantages are as follows:

keeps up with technological advances and hence can compete on the market,
It's easy to install and simple to use,
Accurate meter reading and billing and no problems due to faulty meters,
People save money on their electric bills by showing them exactly where they are
consuming energy and how even small changes in their electricity usage can save
money.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


2
Real Time Electricity Usage Monitor

1.2 Problem statement

At the present moment electrical energy is on high demand, and its generation is unable to meet
the demand. Consumers are paying a lot of money on their electricity bills. The need to save
electricity due to the increased consumption of electricity in residential areas has alarmed the
designing of a real time electricity usage monitor.

1.3 Project scope

This project mainly concentrates on designing an electricity monitoring device which is easy to
use and which does not require a technician or electrician to install it at home or business
premises. The project entitled real time monitor as the name entails this device works with the
existing utility meter and provides the electricity measurements in real-time in KWh.

1.4 Objectives

The main objective of the project is to design a device for measuring the power
consumed by all appliances at domestic level. The device should:
Provide the measurement in real time,
Should show an increase or drop in the reading if more devices are plugged or unplugged
respectively.
After coming up with a design, a prototype has to be made.
To analyse the existing technologies of monitoring electricity and come up with a
suitable technology that is ideal for the local market.
Most importantly the device must record the power consumption and the respective cost
of power consumption on a particular day in real time.
The device must show the cumulative power consumption and cost for the month.
Carrying out a research on GSM based energy meter.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


3
Real Time Electricity Usage Monitor

1.5 Justification

The need to save electricity due to the increased consumption of electricity in residential areas
has alarmed the designing of a real time electricity usage monitor. The device will help residents
to monitor their electricity consumption and to know which appliances take the greatest amount
of energy consumption and the ones that take the least amount of power. The theme of the
project is, ``Metering displays should be provided for each individual household in a form that is
accessible, attractive and clear``.

1.6 Project applications

In homes
Banks
Lodges
Flats
Rental accommodation
Malls

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


4
Real Time Electricity Usage Monitor

CHAPTER 2

2.1 Introduction

In this chapter we are going to describe the various types of energy meters available i.e. their
principle of operation, purpose and a general description of their architecture. The various types
are the common smart meters, electronic meters and home energy monitors: which are the main
objective of the project. The basic principle behind the operation of energy meters is the use of a
current sensor to measure the current. The measurement can then be displayed using analogue or
digital methods. Unlike the electromechanical induction meter, these metering systems use a
digital display as opposed to analogue display of the later.

2.2 Existing metering systems

2.2.1 In-home display of energy use or cost

An in-home display can be used to display information such as current energy use and cost. An
in-home display of energy of energy use or cost provides immediate and simple feedback.
Turning on a light or an electric stove increases energy usage and causes the display to change
significantly. This is direct feedback of the energy consumption, and makes this meter attractive
and gives information to the consumer about an instantaneous increase in the energy
consumption. With the main energy meter a small increase in the consumption does not give a
change in the meter reading. To realise a change of one unit on the main energy meter, it takes
some time before this is shown to the consumer but with an in-home display a real time feedback
is noticed. Indeed, with everything off, it easy it is easy to see the amount of electricity
consumed by electronics that are in the off} position. This saves to notify the consumer which
devices worth to keep plugged in even if they are in the off mode and the devices which must be
unplugged even if they are off. These devices are called vampire loads. This how the theme of
the project is achieved; ``Metering displays should be provided for each individual household in
a form that is accessible, attractive and clear``. This kind of display can help consumers to reduce
their electrical bills.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


5
Real Time Electricity Usage Monitor
The meter can be programmed to show the current cost of electricity, the current rate of use, and
cost of electricity for previous day, week, and month. This display is unique and different from
most metering displays.

2.2.2 Plug-in meter

Figure 1 Plug-in meter

These meters are plugged into the wall outlet and the device you wish to measure its power
consumption is plugged into the meter. The device is used to measure the power consumption of
gadgets such as refrigerators, washing machines and any other home electrical appliances. The
plug in meter measures the power consumption of the device plugged into it; this can help the
consumer to see how much energy is drawn by each device.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


6
Real Time Electricity Usage Monitor

2.2.3 Energy saving power strip

Figure 2 Energy saving power strip

Power strips are used to measure the power consumption of loads connected to it, it has many
sockets where you plug in the appliances. It can turn on and off the appliances connected to it.
They work just like a plug-in power meter except that they measure the power being used by
multiple devices plugged into the power strip. The plug-in meter and the power strip meter are
both good at detecting vampire loads. These loads are from power that continues to be consumed
after a device is shut off. Even though vampire loads may be small they add cost to the
consumers energy bill.

2.2.4 Real time monitors

This type of meter reads the pulse signal from the existing utility meter and records the
measurement in KWh. The data is transmitted to the display situated in a secure place in the
home. The added benefit is that you can see the entire electrical load on your home as it happens
i.e. in real time. This is such that if an appliance is turned on the power consumption rises up
instantaneously and likewise drops when it is turned off. The display can be programmed that
you can translate the KWh to dollars.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


7
Real Time Electricity Usage Monitor

2.2.5 Separate sensor and display meter

This meter consists of a current sensor such as CTs attached to the electricity cables and send the
data to a simple display. They can also send data to a computer display for daily energy use
analysis with some software that are being specifically designed for that purpose

ENERGY SENSOR

SIMPLE DISPLAY COMPUTER

DISPLAY

Figure 3 Separate sensor and display meter

This system lets residential and industrial electricity consumers to gather and analyze energy
consumption data. The sensor provides communications interfaces and data-integration
capabilities to help with the development of effective energy-management strategies. It can
measure electrical usage for the whole house and sections of a plant in industrial application;
connect to a monitoring devices or simply a display and accept pulses from utility meters. The
pulses are provided by an energy sensor i.e. a current transformer or shunt resistor method that
works with energy metering ICs. Data can then be sent to online energy-monitoring software
portals like Google Power Meter for presentation and analysis.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


8
Real Time Electricity Usage Monitor

2.2.6 Electronic meter

Memory RTC

Microcontroller Display

Current and Energy IC


voltage sensors

L
Load
N

Figure 4 Electronic meter

Electronic meter is a broad term to describe all the metering systems that uses LCD displays and
they have microcontrollers as the heart of the entire system. They have inbuilt automatic sensors
which helps to detect electrical energy theft or meter tampering. The use of microcontrollers
makes it possible to program it to protect against theft.

Electronic meters use a current transformer or shunt, energy metering IC and LCD display, while
advanced electronic meters can be read automatically using communication ports like RS232 or
RF modules. They also make use of wireless technologies like Bluetooth, GSM and GPRS to
transfer information about electrical consumption. The energy IC measures voltage and current,
and generates a pulse output proportional to power. These pulses are interpreted as meter
readings by the microcontroller and displayed on an LCD. In addition to measuring energy usage
used, electronic meters can also record other parameters of the load and supply such as
maximum demand, power factor and reactive power factor used e.t.c.
2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe
9
Real Time Electricity Usage Monitor

2.2.6.1 Real time clock (RTC)

The RTC is useful in remote energy meter billing systems mainly using GSM. It is used to
maintain the current time in off-line processing. The Real Time Clock is a low power, full binary
coded decimal (BCD) clock or calendar. Addresses and data are transferred serially via a two-
wire bi-directional bus. The clock or calendar provides seconds, minutes, hours, day, date, month
and year information. The end of the month date is automatically adjusted for months with fewer
than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-
hour format with AM/PM indicator. The DS1307 is an RTC that has a built-in power sense
circuit that detects power failures and automatically switches to the battery supply.

2.2.7 Smart meters

These meters record the amount of electricity consumption for a certain period of time. The
recorded data is then sent to the utility company for monitoring and billing purposes. Smart
meters can transfer data from and to the meter. This metering system implements a two way
communication protocol.

2.3 GSM based remote energy meter monitoring


While real time monitoring concern, consumers monitoring their home energy usage thus
reducing their bills, the project can be extended to give benefits to both the consumer and the
electricity supply authority (ZESA).

The purpose of the system is remote monitoring of the domestic energy meter. This system
enables the Electricity department to read the meter readings regularly without the person
visiting each house. This can be achieved by the use of microcontroller unit that continuously
monitors and records the energy meter readings in its permanent memory location. This system
also makes use of a GSM modem for sending data to a remote station.

The microcontroller based system continuously records the readings and the live meter reading
can be sent to the Electricity department on request. This system also can be used to disconnect
the power supply to the house in case of non-payment of electricity bills.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


10
Real Time Electricity Usage Monitor
The design has 3 major sections:

Client side (Consumer)


Server side (Electricity board)
Transmission protocol (GSM)

2.3.1 Client side (Consumer)

This side consists of the electronic meter and the embedded system designed to be interfaced
with it. The system consists of a microcontroller used to interface the Meter and the GSM
module. The module accepts data from the microcontroller and sends it to the server. At the
server the data is processed and sent back to the client.

LCD DISPLAY
MICROCONTROLLER

MICROCONTROLLER

MAX232 GSM
LED
MODEM
LIGHTING

OPTOCOUPLER

METER

Figure 5 Client side

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


11
Real Time Electricity Usage Monitor

2.3.1.1 Transmitter section

This section transmits the amount of energy consumed in units. The pulses from the digital meter
is the input to the microcontroller, the pulse is directly proportional to the power consumption.
The input to the microcontroller is generated by an IR speed sensor. Microcontroller is used to
count the pulses and after a specific preset number of pulses it increments the unit. MAX232 is
used as an interface between microcontroller and the GSM module. This is to ensure that the data
is transmitted serially to the GSM. The unit value is transmitted through GSM. An LCD module
interfaced with the microcontroller connected to the meter displays the pulses as count,
instantaneous units consumed and the bill.

2.3.2 Server side (Electricity board)

The server side has the GSM reception module interfaced directly to a computer (server). The
server is programmed to display all necessary details. After receiving data, the server processes it
and sends it back to the client for display at client side. An LCD at the client side displays the
information from the server i.e. bill description.

MAX232 GSM
COMPUTER
MODEM

Figure 6 Server side

The basic principle behind the operation of this project is on to provide meter reading data to the
electricity service provider.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


12
Real Time Electricity Usage Monitor

2.2.2.1 Receiver section

This section deals with the processing of data received from different consumers. The server
sends a request to the module installed at consumers end along with the specific address from
where unit details have to be transmitted back. When the required information is transmitted
back, the server reads and stores it. It then issues appropriate billing function. This bill is then
transmitted back to the consumer where the bill details are displayed on an LCD.

2.3.3 Transmission Channel

The GSM transmission is used to establish connection between client and server. Once the
connection is established, the consumers energy meter is on real time conversation with the
server. Since we have to transmit data over a distance of many kilometers, GSM proves to be
very efficient.

2.3.4 Role of GSM modem in remote billing

User GSM modem will transmit the consumption amount to office MODEM.
Office MODEM will receive the data sent by the user MODEM.
Instead of IR we are using GSM because in IR lots of disturbance will be there when
distance is more.
GSM is less costly when compared to IR.

2.4 Current sensors

The basic principle behind the operation of energy meters is the use of a current sensor to
measure the current. The measurement can then be displayed using analogue or digital methods.
Two types of sensors are available, a shunt and clip-on current transformers. This method of
measuring AC electrical energy does not require breaking of the mains wire, which makes it
safe. The current sensor is clipped-on to the wire, and the sensor measures the current flowing in
the live or neutral mains wire. Simply clipping on the sensor to the mains wire will allow
electrical energy used by the whole house to be measured.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


13
Real Time Electricity Usage Monitor

2.4.1 Using a shunt for current sensing

A shunt is basically a resistor working as a potential divider and is used as a current sensor in
energy meters. The values of the shunt used in energy meter applications are typically (0.001-
100). For cost reasons smaller values are used. To improve low current measurements, larger
resistance are used. A shunt is a cost-effective solution for single phase distribution system. A
shunt has many advantages over current transformers:

Shunts do not suffer from the DC saturation effect.


Also, the phase response of a shunt is linear across the complete range of the input
current.

A disadvantage of shunts is that they are purely resistive, a shunt dissipates more power in the
form of heat when high current is passed through it, increasing the overall power consumption of
the energy meter.

2.4.2 Using a current transformer for sensing

A current transformer can be used as a sensor to measure the current passing through the single
phase lines. The turn ratio of the current transformer determines the current in the secondary coil
of the transformer. The turn ratio of the current transformer must be chosen in such a way that
the current transformer does not get saturated over the full dynamic range of the energy meter. In
a case when the current from the second coil an input to a microcontroller, a load resistor is used
to convert the secondary current of the current transformer into the voltage signal. The voltage
level of this signal must remain within the limits of the analogue to digital converter used in the
design of the meter.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


14
Real Time Electricity Usage Monitor

2.5 Energy metering integrated circuits

Electronic energy meters are replacing traditional electromechanical meters in many residential,
commercial and industrial applications because of the versatility and low-cost offered by
electronic meter designs. This revolution has been realized due to the evolution of energy ICs.
These meters can offer more features that were impractical with the old mechanical designs.
Some of the features introduced by the evolution of energy metering ICs are:

Temper detection to protect against meter tampering and theft of service


It also can measure and record energy usage at different times of the day, so utilities can
bill customers for energy based on time of usage.
An electronic energy meter also can enable automatic meter reading (AMR), whereby
energy metering data is transmitted to the utility over an RF, power line, Bluetooth, GSM
or even infrared communications link.
Improved accuracy and lower power consumption. With an electro-mechanical meter, the
error in the basic energy usage measurement is on the order of 1% but with an electronic
implementation, it is possible to reduce that error to less than 0.1%.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


15
Real Time Electricity Usage Monitor

2.5.1 SA2002H

An example of energy integrated circuits is SA2002H. The SA2002H is a CMOS mixed signal
analogue or digital integrated circuit, which performs power or energy calculations across a
power range of 1000:1. The integrated circuit includes all the required functions for single phase
power and energy measurement. The SA2002H generates pulses, the frequency of which is
proportional to the measured power consumption.

Block diagram

POWER
INTEGRAT
INPUT POWER TO
OR
CURRENT FREQUENCY
FOUT
CONVERSIO
ADC N
REF VOLTAGE
CURRENT REFERENCE

INPUT
VOLTAGE
OSCILLAT TIMING
OR
VOLTAGE REF

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


16
Real Time Electricity Usage Monitor

CHAPTER 3
This chapter describes the components used in the project; the main components are the
microcontroller which is the heart of the project, liquid crystal display and the power supply.
Also in this chapter is the circuit diagram of the entire project.

3.1 Liquid crystal display

Liquid crystal displays are an easy way of display information to the user; parallax errors
introduced by analogue meters are removed. They provide useful interface to the user, the
display can be one line or two lines, and each line has 16 characters. Messages giving the user
instructions can be displayed and these applications make the device easy to use, a program in
the microcontroller provides these instructions. Liquid crystal displays are specifically made to
be activated by microcontrollers and not standard ICs. The LCD is shown below:

Figure 7 LCD display

Liquid crystal display (LCD) is used in this project instead of LEDs or analogue display, this is
due to the declining prices of LCD, the ability to display numbers, characters and graphics,
incorporation of a refreshing controller into the LCD thereby relieving the CPU of the task of
refreshing the LCD and also the ease of programming for characters and graphics.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


17
Real Time Electricity Usage Monitor

3.2 Microcontroller

The microcontroller used in this project is P16F628A. The microcontroller is the heart of the
project and performs all the control functions on the device. In selecting the microcontroller, cost
reduction of the project had much influence. Using P16F628A instead of P16F887 reduced the
cost by seven United States dollars. P16F887 has a greater memory but P16F628 was able to
handle the source code for the project.

3.2.1 High-Performance RISC CPU

Operating speed: 20 MHz


Operating voltage: 3.0-5.5V
Industrial temperature range (-40 to +85C)
Interrupt capability
8-level deep hardware stack
Direct, Indirect and Relative Addressing modes
35 single-word instructions

3.2.2 Special Microcontroller Features

Flash Memory: 3584 bytes (2048 words)


Data SRAM: 224 bytes
Data EEPROM: 128 bytes
Power-saving Sleep mode
Programmable weak pull-ups on PORTB
Multiplexed Master Clear/Input-pin
Watchdog Timer with independent oscillator for reliable operation
Low-voltage programming
In-Circuit Serial Programming (via two pins)
Programmable code protection
Power-on Reset
Power-up Timer and Oscillator Start-up Timer

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


18
Real Time Electricity Usage Monitor

3.2.3 Reset signal

In order that the microcontroller can operate properly, a logic 0 (0V) must be applied to the reset
pin RS. The push button connecting the reset pin RS to power supply VCC is not necessary.
However, it is almost always provided because it enables the microcontroller safe return to
normal operating conditions if something goes wrong. 5V is brought to this pin, the
microcontroller is reset and program starts execution from the beginning.

3.2.4 Clock signal

Even though the microcontroller has a built-in oscillator, it cannot operate without two external
capacitors and quartz crystal which stabilize its operation and determines its frequency
(operating speed of the microcontroller). The value of the capacitors used does not need to be
precise, there should be in the range 22-30 picofarads and the crystal ranges 4-20MHz

3.3 IR-speed sensor

This is a circuit designed to monitor the speed of rotation of the aluminium disc. The disc is
rotated across the USLOT. The USLOT consists of IR transmitter and receiver which should be
placed straight in line with each other. The infrared sensor and senses the rotation of the disc and
the associated circuits generates a pulse which is proportional to the energy usage and this pulse
is sent to the microcontroller which displays the energy usage. The schematic circuit for the IR-
speed sensor is shown below:

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


19
Real Time Electricity Usage Monitor

Figure 8 IR-speed sensor

3.4 Power supply

This section is going to describe a regulated power supply which is a requirement for all digital
circuits. The block diagram of the power supply is shown below:

The power supply supplies the required energy for both the microcontroller and the associated
circuits. It is the most essential part of the circuit because to run the constituent ICs circuit has to
be provided with the correct amount of power. These ICs can run on DC power. Hence the
required DC supply has to be generated.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


20
Real Time Electricity Usage Monitor

3.4.1 Description

Power supply is essential in any project, a description of the various part of the power supply
below:

3.4.1.1 Transformer

The function of the transformer is to step down the voltage level from the available from the
available 220V AC to the desired voltage. The transformer used in this project steps down 220V
to 12V.

3.4.1.2 Bridge rectifier

The function of the rectifier is to convert the alternating voltage signal input into a unidirectional
voltage. This function is provided by semiconductor diodes connected in bridge configuration.
Diodes 1N4007 are used as rectifiers.

3.4.1.3 Smoothing

The smoothing block smoothens the DC from varying greatly to a small ripple. The ripple
voltage is defined as the deviation of the load voltage from its DC value. Smoothing is also
named as filtering.

Filtering is frequently effected by shunting the load with a capacitor. The action of this system
depends on the fact that the capacitor stores energy during the conduction period and delivers
this energy to the loads during the no conducting period. In this way, the time during which the
current passes through the load is prolongated, and the ripple is considerably decreased. The
action of the capacitor is shown with the help of waveform below.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


21
Real Time Electricity Usage Monitor

Figure 9 Smoothing

3.4.1.4 Regulation

To obtain a constant voltage specific ICs are used as voltage regulator. Voltage regulator
LM7805 is used to obtain a 5V DC. The ICs have three terminals an input, an output and a
ground terminal. Inorder to obtain an output of 5V, the supply from the transformer should be at
least 3V above 5V. generally the input of a regulator shold be at least three times greatrer than
the output.

Voltage regulators comprise a class of widely used ICs. Regulator IC units contain the circuitry
for reference source, comparator amplifier, control device, and overload protection all in a single
IC. Although the internal construction of the IC is somewhat different from that described for
discrete voltage regulator circuits, the external operation is much the same. IC units provide
regulation of either a fixed positive voltage, a fixed negative voltage, or an adjustably set
voltage.

3.4.1.5 Voltage regulator circuit

IN OUT

GND

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


22
Real Time Electricity Usage Monitor

3.5 Overall design circuit diagram

VDD LCD1
LM016L

U2

VDD
VSS

VEE

RW
16 17

RS

D0
D1
D2
D3
D4
D5
D6
D7
RA7/OSC1/CLKIN RA0/AN0

E
15 18
RA6/OSC2/CLKOUT RA1/AN1
1
RA2/AN2/VREF

1
2
3

4
5
6

7
8
9
10
11
12
13
14
4 2
RA5/MCLR RA3/AN3/CMP1
3
RA4/T0CKI/CMP2
6
RB0/INT
7
RB1/RX/DT
8
RB2/TX/CK
9
RB3/CCP1
10
RB4
RB5
11 R4
12 10k
RB6/T1OSO/T1CKI
13
RB7/T1OSI
PIC16F648A

D1 D2
R5
D3
10k R1 P1
330 R2 R3
330 330
1
DCD
6
DSR
2
RXD
7
RTS
3
TXD
8
CTS
4
DTR
9
RI

ERROR
COMPIM

Figure 10 Overall design circuit diagram

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


23
Real Time Electricity Usage Monitor

CHAPTER 4

4.1 Software development

This chapter deals with programming the microcontroller to meet the objectives of the project.
The programming language used is proton. The source code for the project is shown below:

'****************************************************************
'* Name : Real Time Electricity Usage Monitor *
'* Author : [MURWIRA T.T R081582N] *
'* Notice : Copyright (c) 2012 [] *
'* : All Rights Reserved *
'* Date : 2012/04/27 *
'****************************************************************

Device = 16F628A
Xtal 20

All_Digital TRUE

On_Hardware_Interrupt GoTo ISR

Declare LCD_RSPin PORTB.3


Declare LCD_Interface 4
Declare LCD_Lines 2
Declare LCD_CommandUs 2000
Declare LCD_DataUs 100
Declare LCD_Type 0

Symbol PS0 = OPTION_REG.0 ' Prescaler Rate Select


Symbol PS1 = OPTION_REG.1 ' Prescaler Rate Select
Symbol PS2 = OPTION_REG.2 ' Prescaler Rate Select
Symbol PSA = OPTION_REG.3 ' Prescaler Assignment
Symbol T0SE = OPTION_REG.4 ' TMR0 Source Edge Select
Symbol T0CS = OPTION_REG.5 ' TMR0 Clock Source Select
Symbol INTEDG = OPTION_REG.6 ' Interrupt Edge Select
Symbol NOT_RBPU = OPTION_REG.7 ' PORTB Pull-up Enable

Symbol RBIF = INTCON.0 ' RB Port Interrupt Flag


Symbol INTF = INTCON.1 ' RB0 External Interrupt Flag
Symbol T0IF = INTCON.2 ' TMR0 Overflow Interrupt Flag
Symbol RBIE = INTCON.3 ' RB Port Change Interrupt Enable
Symbol INTE = INTCON.4 ' RB0 External Interrupt Enable
Symbol T0IE = INTCON.5 ' TMR0 Overflow Interrupt Enable
Symbol PEIE = INTCON.6 ' Peripheral Interrupt Enable
Symbol GIE = INTCON.7 ' Global Interrupt Enable

Symbol TMR1ON = T1CON.0 ' Timer1 ON


Symbol TMR1CS = T1CON.1 ' Timer1 Clock Source Select

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


24
Real Time Electricity Usage Monitor
Symbol NOT_T1SYNC = T1CON.2 ' Timer1 External Clock Input
Synchronization Control
Symbol T1INSYNC = T1CON.2 ' Timer1 External Clock Input
Synchronization Control
Symbol T1SYNC = T1CON.2 ' Timer1 External Clock Input
Synchronization Control
Symbol T1OSCEN = T1CON.3 ' Timer1 Oscillator Enable Control
Symbol T1CKPS0 = T1CON.4 ' Timer1 Input Clock Prescale Select
bits
Symbol T1CKPS1 = T1CON.5 ' Timer1 Input Clock Prescale Select
bits

Symbol TMR1IE = PIE1.0 ' TMR1 Overflow Interrupt Enable


Symbol TMR2IE = PIE1.1 ' TMR2 to PR2 Match Interrupt Enable
Symbol CCP1IE = PIE1.2 ' CCP1 Interrupt Enable
Symbol TXIE = PIE1.4 ' USART Transmit Interrupt Enable
Symbol RCIE = PIE1.5 ' USART Receive Interrupt Enable
Symbol CMIE = PIE1.6 ' Comparator Interrupt Enable
Symbol EEIE = PIE1.7 ' EE Write Complete Interrupt Enable

Symbol TMR1IF = PIR1.0 ' TMR1 Overflow Interrupt Flag bit


Symbol TMR2IF = PIR1.1 ' TMR2 to PR2 Match Interrupt Flag
Symbol CCP1F = PIR1.2 ' CCP1 Interrupt Flag
Symbol TXIF = PIR1.4 ' USART Transmit Interrupt Flag
Symbol RCIF = PIR1.5 ' USART Receive Interrupt Flag
Symbol CMIF = PIR1.6 ' Comparator Interrupt Flag
Symbol EEIF = PIR1.7 ' EEPROM Write Operation Interrupt Flag

Dim PULSES As Word


Dim KWH As Float
Dim METERED_UNITS As Word
Dim RPS As Float

Dim TEMP1 As Byte


Dim TEMP2 As Byte
Dim MODE_BIT As Byte
Dim PREV_MODE As Byte
Dim COST As Float
Dim DURATION As Byte
Dim PREV_PULSES As Word
Dim TIME As Word
Dim GSM_BIT As Byte
Dim SEND_SMS As Bit

Dim DATA_IN As Float


Dim DATA_OUT As Float

'PULSES = ERead 0
'METERED_UNITS = ERead 4
PREV_PULSES = 0
PULSES = 0
KWH = 0
MODE_BIT = 0
PREV_MODE = 0
COST = 0

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


25
Real Time Electricity Usage Monitor
DURATION = 0
RPS = 0
TIME = 0
GSM_BIT = 0
PORTA = 0
PORTB = 0

TRISA = %11111000
TRISB.0 = 1

Declare LCD_ENPin PORTA.3


'DelayMS 500
''Cls

Cls
Print At 1, 2, "DESIGNED BY"
Print At 2, 1, "R081582N TALENT"
DelayMS 5000
Cls
DelayMS 100
MAIN:
' Initiate the interrupt
GIE = 0 ' Turn off global interrupts
PSA = 0 ' Assign the prescaler to
external oscillator
PS0 = 1 ' Set the prescaler
PS1 = 1 ' to increment TMR0
PS2 = 1 ' every 256th instruction cycle
T0CS = 0 ' Assign TMR0 clock to internal
source
TMR0 = 6 ' initialise TMR0 to count 250
b4 overflow
T0IE = 1 ' Enable TMR0 overflow interrupt
INTE = 1 ' enable RB0 interrupt
GIE = 1 ' Enable global interrupts

TRISA.0 = 0
TRISA.1 = 0
TRISA.2 = 0

'For TEMP1 = 1 To 5
'
High PORTA.0
'
Low PORTA.1
'
DelayMS 300
'
Low PORTA.0
'High PORTA.1
' DelayMS 300
' Next
' Cls
' Low PORTA.1
INTEDG = 1
' .......................MAIN PROGRAM LOOP STARTS
HERE............................................
Cls

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


26
Real Time Electricity Usage Monitor
START:

If TIME > 380 Then 'set timer0 to delay 5 seconds


DURATION = DURATION + 1
RPS = (PULSES - PREV_PULSES)/5 ' check PULSES that appear in 5
seconds
PREV_PULSES = PULSES ' store present pulse count.
TIME = 0 ' clear time

EndIf

If DURATION > 9 Then


DURATION = 0
EndIf

If RPS > 10 Then 'threshold for red range power usage


PORTA = %00000001
High PORTA.0
ElseIf RPS > 5 Then 'threshold for amber range power usage
PORTA = %00000010
High PORTA.1
Else 'threshold for green range power usage
PORTA = %00000100
High PORTA.2
EndIf

Call MODE_CHECK
Call MODE_CHANGE 'go to a subroutine that tests if mode has
changed from previous
Call MODE 'jump program to selected mode
GoTo START 'start again the whole sequence
'............................................................................
......................
'.....................INTERRUPT SERVICE ROUTINE FOR COUNTING
PULSES................................
ISR:
GIE = 0 ' Disable global interrupts
While GIE = 1 ' Make sure they are off
GIE = 0 ' Continue to clear GIE
Wend ' Exit when GIE is clear

If INTF = 1 Then 'When a pulse is detected


PULSES = PULSES + 1 'Pulse count increments
'EWrite 0, [ PULSES ]
'delayUS 200
INTF = 0 'Interrupt flag is cleared
EndIf

If T0IF = 1 Then 'when Timer0 overflows


TIME = TIME + 1 'Time interval count is incremented

T0IF = 0 'Timer0 overflow flag is cleared


TMR0 = 6 'Timer0 is initialised with value 6 to count
250 cycles b4 overflow
EndIf

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


27
Real Time Electricity Usage Monitor
Context Restore 'RESTORE VALUES OF IMPORTANT VARIABLES TO
LEVELS HELD B4 INTERRUPT

'............................................................................
........................
'......................CHECK SELECTED MODE AND JUMP TO THE MODE
PROGRAM..............................

MODE:

Select MODE_BIT
Case 0
'FIRST MENU
Print At 1, 1, "P = ", # PULSES
Print At 2, 1, "PPS = " , Dec3 RPS
Print At 1, 15, "T", # DURATION
PREV_MODE = 0

Case 1 'SECOND MENU


KWH = PULSES / 240
Print At 2, 1, "KWh = ", # KWH
Print At 1, 3, "POWER USAGE"
PREV_MODE = 1
Case 2 'THIRD MENU
Print At 1, 1, "CONSUMPTION RATE"
Print At 2, 1, "PPS = " , # RPS
PREV_MODE = 2
Case 3 'FOURTH MENU
Print At 1, 2, "POWER STATUS"
If PORTA.0 = 1 Then
Print At 2, 1, "EXCESSIVE LOAD! "
ElseIf PORTA.1 = 1 Then
Print At 2, 1, "LOAD A BIT HIGH "
Else
Print At 2, 1, "POWER USAGE GOOD"
EndIf
PREV_MODE = 3
GSM_BIT = 0

Case Else 'MAKE PROGRAM GETS TO


MENU 1
MODE_BIT = 0
End Select

Return

'............................................................................
....................
'..................CHECK IF THE MODE BUTTON IS
PRESSED...........................................

MODE_CHECK:
If PORTA.4 = 0 Then 'check if mode button is pressed
MODE_BIT = MODE_BIT + 1 'if pressed, increment mode
value

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


28
Real Time Electricity Usage Monitor
DELAY: For TEMP1 = 0 To 10
DelayMS 50
If PORTA.4 = 1 Then ESCAPE
Next

EndIf

Return
'............................................................................
.......................

'..................ROUTINE TO CHECK IF MODE HAS BEEN


CHANGED..................................
'IF IT HAS BEEN CHANGED, THE LCD WILL BE CLEARED FIRST, OTHERWISE IT IS NOT
CLEARED...........

MODE_CHANGE:
If MODE_BIT <> PREV_MODE Then 'if present mode is not previous
mode then
Cls 'refresh screen (clear everything
on display)
DelayMS 50 'delay a moment
EndIf

Return 'go back to the calling point

'............................................................................
.................

'............................................................................
....................

'....................................................

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


29
Real Time Electricity Usage Monitor

CHAPTER 5

5.1 Results and testing

The picture below shows a laboratory model that was designed for the project. The prototype
worked and i tested it several times and giving the same result. The prototype has reverse
polarity protection diodes that protect it from power supply polarity changes. The circuit was
designed to work with a regulated 5V DC power supply. Displayed on the liquid crystal display
was the rate of power consumption by a consumer, the energy use in KWh and power status i.e.
good, average and excessive. Also the LEDs were showing the rate of power consumption
starting from the green LED to the red LED showing an increase in power consumption.
Unplugging electronic devices cause a decrease in power consumption and the LEDs will change
in colour from red, amber and green respectively.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


30
Real Time Electricity Usage Monitor

5.2 Testing

5.2.1 Device under test

A disc on a rotating motor resembled the aluminium disc on the electromechanical induction
meter. The disc is mounted on a rotating shaft and speed of rotation is varied slowly, increasing
the number of pulses displayed the rate of consumption and the amount of energy in KWh.

In picture above is the prototype under test powered by a 9V battery. A regulated power supply
needed by the circuit is achieved by use of 5V regulators. A red LED was ON showing that the
disc was rotating fast enough to exceed a rate of 10 pulses per second. This condition denotes
excessive load.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


31
Real Time Electricity Usage Monitor

5.3 First test

On plugging on the meter displayed my name and registration number i.e. DESIGNED BY
R081582N TALENT. This is shown in the picture below:

5.4 Menu function

Menu function is used to select the mode to display on the LCD. Pressing the menu button
allows to see what is next on the display. Four cases were displayed and these are:

1. Case 0: This displayed the number of pulses from the speed sensor and the rate of power
consumption denoted PPS.
2. Case 1: Displayed the power usage in KWh. One KWh equals 240 pulses and this was
displayed on the second line of the LCD.
3. Case 2: Case 2 displays the consumption rate i.e. PPS.
4. Case 3: This displayed the three states of energy usage: Power status= excessive load,
load a bit high and power usage good. When the disc is rotating at low speed, power
usage good is shown on the screen and the green LED lights showing the same condition.
For a rate of use which was set in the range greater than 5 to 10 pulses per second, power

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


32
Real Time Electricity Usage Monitor
status displayed: load a bit high and the amber LED turns on. Likewise a rate greater than
10 pulses per second displays excessive load and the red LED turns on showing that an
abnormal load has been plugged.

5.4.1 Demonstrating menu function

The picture below demonstrates the menu button in use: Menu at case 1

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


33
Real Time Electricity Usage Monitor

5.5 Second test

After displaying the name the device goes on showing the first screening on the menu. This
displays the number of pulses coming on from the IR-speed sensor on the first line of the 16x2
LCD. On the second line it displays the rate of energy use i.e. the number of pulses per second.
This is shown in the following photo:

In the photo, first line records 1553 pulses and a rate of energy usage PPS = 6.400. As expected
this rate is greater than 5 and the amber LED is ON while the green and red LEDs are OFF.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


34
Real Time Electricity Usage Monitor

5.6 Third test

This is case 2 on the menu function, it shows the consumption rate. Demonstration photos are
shown below for low rate, average and very high rate of consumption.

5.6.1 Low rate

Low rate shows consumers that their rate of consumption is within normal range. The devices
plugged will be low power devices for examples radios, television and lights. Low rate ranges
from 0 to 5 pulses per second. This can be used to detect ghost loads which consume energy
even when they are turned OFF. If no appliances are in use rate must be zero i.e. PPS=0.000. If
this is not the case a consumer then knows that some appliances are taking up energy even when
they are turned off and must be unplugged after use.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


35
Real Time Electricity Usage Monitor

5.6.2 Average rate

Average rate ranges from greater than 5 pulses per second to 10 pulses per second.

5.6.3 Very high rate

Very high rate is greater ten pulses per second showing that high power devices have been
plugged and some should be turned OFF to save electricity.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


36
Real Time Electricity Usage Monitor

5.7 Fourth test

The fourth step was to display the power status i.e. power usage good, load a bit high and
excessive load.

5.7.1 Power usage good

This is displayed for a rate below 5 pulses per second and the demonstration is shown below:

This is user friendly kind of metering system that has a smart way of communicating with
consumers.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


37
Real Time Electricity Usage Monitor

5.7.2 Load a bit high

This is displayed for a rate above 5 pulses per second to 10 pulses per second. The demonstration
is below; with the amber LED ON showing that load is a bit high as expected.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


38
Real Time Electricity Usage Monitor

5.7.3 Excessive load

This is displayed for a rate above 10 pulses per second. The photo under of the device under
demonstration is shown below:

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


39
Real Time Electricity Usage Monitor

CHAPTER 6

6.1 Conclusion

In coming up with the prototype cost effective solutions were taken into consideration. The
components list and prices are show in the project budget and the total cost of the project was
USD37.65 that could be halved or even reduced to below half by buying component from
outside Zimbabwe where prices are low. The project can be commercialized by ZESA since it is
the only licensed company that distributes energy meters.

6.2 Project budget

Components Price per unit in Quantity Total Cost in


USD USD
Microcontroller 6 1 6
LCD 20 1 20
Crystal oscillator 1 1 1
Vero board 5 1 5
MAX 232 1 1 1
LS7404 1 1 1
Regulators 0.50 2 1
Resistors 0.05 13 0.65
IR sensor 0.50 1 0.50
Photodiode 0.50 1 0.50
Capacitors 0.20 5 1

Total project cost = USD37.65

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


40
Real Time Electricity Usage Monitor

6.3 Challenges

Some components needed are not locally available and difficult to procure from outside
the country.
Lack of project funding results in starting implementation late.
Despite the challenges the project was successful

6.4 Recommendations

With technology reaching greater heights, at this juncture engineers are trying to reduce the
power usage. The energy monitoring system is one such technology that is useful to this issue.

In light of the above mentioned i therefore recommend that the project be implemented and the
nation can benefit from it.

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe


41
Real Time Electricity Usage Monitor

References

Textbooks

1. Muhammad H. Rashid. 'Power electronics and devices', Englewood Cliffs, N.J, Prentice Hall,
2005.

2. E. Acha. 'Power electronic control in electrical systems', Oxford, Boston, 2002.

3. Pauddar, C. M. Bradley, David A. 'Power Electronics: Semiconductors', New Delhi, Jain,


1999.

Websites

1. http: //www.1000projects.com

2. http: //www. home-energy-metering.com

3. http: //www. energymonitor.com

4. http: //www. sames.co.zw

2012 By T. T. Murwira, Supervised by Mr. C. Mutepfe