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

THREE PHASE PREPAID DIGITAL ENERGY

METERING SYSTEM USING ZIGBEE RF


COMMUNICATION

A PROJECT REPORT

Submitted by

ANANDASUNDARARAMAN. S 12005105005
BARNABAS. M. S 12005105011
KUMARAN. R 12005105029
PRASANNA. V 12005105328

in partial fulfillment for the award of the degree


of
BACHELOR OF ENGINEERING
in

ELECTRICAL AND ELECTRONICS ENGINEERING

VELAMMAL ENGINEERING COLLEGE, CHENNAI


ANNA UNIVERSITY : CHENNAI – 600 025
APRIL 2009
ANNA UNIVERSITY : CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this Project Report “THREE PHASE PREPAID DIGITAL


ENERGY METERING SYSTEM USING ZIGBEE RF
COMMUNICATION” is a bonafide work of “ANANDASUNDARARAMAN.S,
BARNABAS.M.S, KUMARAN.R and PRASANNA.V” who carried out the
project work under my supervision.

SIGNATURE SIGNATURE

Prof.P.Narayana Bhaskar Mr.M.Jagadeesh Kumar


PROFESSOR SUPERVISOR
HEAD OF THE DEPARTMENT ASSISTANT PROFESSOR

Electrical and Electronics Engg. Electrical and Electronics Engg


Velammal Engineering College Velammal Engineering College
Chennai – 600 066. Chennai – 600 066

i
CERTIFICATE OF EVALUATION

College Name : 120: Velammal Engineering College


Branch : 105: Electrical and Electronics Engineering

Title of the Project Name of the Supervisor


Name of the students
with Designation

Anandasundararaman.S Three phase Prepaid Mr.M.Jagadeesh Kumar


Barnabas.M.S Digital Energy Metering
Asst. Professor
Kumaran. R System using Zigbee RF
Prasanna. V Communication

The Report of the Project work submitted by the above students in partial
fulfillment for the award of Bachelor of Engineering degree in ELECTRICAL
AND ELECTRONICS ENGINEERING of Anna University was evaluated
and confirmed to be report of the work done by the above students and then
evaluated.

INTERNAL EXAMINER EXTERNAL EXAMINER

ii
ACKNOWLEDGEMENT

We wish to express our sincere gratitude to the following persons with


whose help and encouragement we have completed our project successfully.
First of all, we would like to express our deep gratitude to our beloved and
respectable Chairman Thiru. M. V. Muthuramalingam and our Chief Executive
Officer Thiru. M. V. M. Velmurugan for their kind encouragement and blessings.
Our deepest gratitude and thanks to our Principal, Dr.J.Shanmugam who
has always helped us whenever we approached them during the course of our
project.
We wish to express our sincere thanks and gratitude to our Vice Principal,
Dr.Sheilaa Haran, for her continued support and guidance throughout the course
of the project.
Our profound gratitude to our Respected Head of the Department of
Electrical and Electronics Engineering, Prof.P.Narayana Bhaskar who has been a
guiding force and constant source of inspiration to us.
We thank our Project Guide, Mr.M.Jagadeesh Kumar, Asst. Professor for
his constant inspiration and perpetual support all through the course of the project.
Our thanks to all other Faculty and non – teaching staff members of our
department for their support and peers for having stood by us and helped us
complete this.

iii
ABSTRACT
Electronic prepaid energy meter is the emerging technology in the field of

electricity all over the world. It mainly ensures the accuracy of energy consumed

and eliminates the errors which usually occur in mechanical energy meters. In

addition to this, we use RF signals instead of using expensive smart card system.

This project uses the advantages of ADE 7758 – Energy Meter Chip and AT Mega

128 as the main host controller of the entire process. By using the toroidal current

transformer, voltage and current values are stepped down to a suit the functions of

electronic chips. The voltage and current values are multiplied using multiplier to

calculate the instantaneous power utilized by the consumer. Instantly the phase

difference between the voltage and current is noted by phase detector to calculate

the power factor. The Power utilized will be displayed on the LCD display in units,

along with the balance amount. These measured and noted power and current

values are transferred to AT Mega 128 host micro controller by means of SPI

status and data registers. These values are gathered at nearest EB office by means

of RF transceiver signals which is bidirectional. Once the prepaid amount is at the

stage of exhausting, buzzer and light emitting diode will pre inform to the utilities

about the minimum balance of power at the consumer premises. Then the utilities

will TOP UP power values by means of paying the money. RF signals are tamper

proof, by means of AES 128 bit security which is an added feature.


iv
TABLE OF CONTENTS

CHAPTER NO. TITLE PAGE NO.


ABSTRACT iv
LIST OF FIGURES viii
LIST OF ABBREVIATIONS x

1. INTRODUCTION 1
1.1 ENERGY METER 1
1.2 TYPES OF ENERGY METERS 2
1.2.1 Mechanical Energy Meters 2
1.2.2 Multiple Tariff Meters 3
1.2.3 Electronic Energy Meters 3
1.2.3.1 Advantages of Static Meter 4

2. METERING AND BILLING 5


2.1 MANUAL METERING SYSTEM 5
2.1.1 Shortcoming in the Present Process 5
2.2 SPOT BILLING 6
2.3 PREPAYMENT BILLING 6
2.3.1 Smart Card System 7
2.3.2 Disadvantages of using Smart Card 7

3. PREPAID METERING THROUGH RF TRANSCEIVERS 8


3.1 ADVANTAGES OF USING RF TRANSCEIVERS 8
3.2 TOOLS USED IN THE PROJECT 9

v
4. BASIC CIRCUIT DESIGN 10
4.1 PCB FABRICATION 10

5. DESIGN SPECIFICATIONS 12
5.1 POWER SUPPPLY AND OTHER MAIN
ACCESSORIES 12
5.1.1 Current Transformers 13
5.1.2 Specifications 13
5.1.3 Switched Mode Power Supply (SMPS) 13
5.1.4 Light Emitting Diode (LED) 14
5.1.5 Three Phase Contactor 15
5.1.6 Relay 15
5.1.7 Latch 15
5.1.8 Buzzer 16
5.1.9 Oscillator 16
5.2 RS 232 Driver 17
5.2.1 Features 17
5.2.2 Pin Diagram of RS 232 Driver 17
5.2.3 Description 17
5.2.4 Applications 18
5.3 ADE 7758 MICROCONTROLLER 18
5.3.1 Pin Diagram 18
5.3.2 Pin Description 18
5.4 ATmeg 128 Microcontroller 22
5.4.1 Pin Diagram and Block Diagram 22
5.4.2 Pin Description 23

vi
5.5 CC 2520 MICROCONTROLLER 26
5.5.1 Pin Diagram 26
5.5.2 Block Diagram of CC 2520 27
5.5.3 Pin Function Description 27
5.5.3.1 General Purpose I/O 28
5.5.3.2 Miscellaneous 28
5.5.3.3 Analog 28
5.5.4.4 Power / Ground Pins 29
5.6 HD 44780 LCD MICROCONTROLLER 30
5.6.1 Pin Diagram 30
5.6.2 Pin function Description 31

6. OPERATION 33
6.1 BASIC BLOCK DIAGRAM 33
6.2 GENERAL OPERATIONAL BLOCK DIAGRAM 34
6.3 OPERATIONAL DESCRIPTION 35

7. PROGRAMMING OF MICROCONTROLLER 38

8. CONCLUSION 63

APPENDIX 1: News Article from The Times of India


64
dated 10th January, 2009
APPENDIX 2: Data Sheet of ATMeg 128 65
REFERENCES 73

vii
LIST OF FIGURES

Figure No. Title Page No.

4.1 PCB Fabrication of ADE 7758 10


4.2 PCB Fabrication 11
5.1 Pin Configuration of RS 232 Driver 17
5.2 Pin Diagram of ADE 7758 18
5.3 Pin Configuration of ATMeg 128 22
5.4 Block Diagram of ATMeg 128 23
5.5 Pin Configuration of CC 2520 26
5.6 Block Diagram of CC 2520 27
5.7 RF Transceiver Application Block 29
5.8 Pin Diagram of HD 44780 30
6.1 Basic Block Diagram 33
6.2 Operational Block Diagram 34
6.3 Signal Processing Block 36

viii
LIST OF ABBREVIATIONS

µC - Micro Controller
µF - Micro Farad
A - Ampere
ABS - Absolute
AC - Alternating Current
APCF - Active Power Calibration Frequency
CMOS - Complementary Metal Oxide
Semiconductor
CS - Chip Select
DOUT - Data Output for serial interface
EB - Electricity Board
GND - Ground
Hz - Hertz
I rms - Root Mean Square Current
IRO - Interrupt Request Output
kbps - Kilo bits per second
LCD - Liquid Crystal Display
LED - Light Emitting Diode
LFO - Low Frequency Oscillator
MHz - Mega Hertz
nF - Nano Farad
PC - Personal Computer
PCB - Printed Circuit Board
ix
PCE - Power Company Employee
ppm - Parts per Million
PSU - Power Supply Unit
RF - Radio Frequency
RS 232 - IEEE Recommended Standard 232
SBM - Spot Billing Machine
SCLK - Serial Clock Input for serial interface
SMPS - Switched Mode Power Supply
SPI - Serial Programming Interface
TTL - Transistor – Transistor Logic
V - Volt
VARCF - Reactive Power Calibration Frequency
Logic Output
VCC - Digital Supply Voltage
V rms - Root Mean Square Voltage

x
1. INTRODUCTION

The present scenario of power utility in India has major constraints


like poor power quality, excess utilization of power and power theft by
bypassing metering equipments. These constraints led to so much of loss
to the Government as well as to the Power Generation Companies. To
eradicate these problems and to have a profitable power market, we have
brought out a solution in the form of Prepaid Energy Meter using RF
Transceivers which allows a secure path for the load usage data to reach
the energy supply company and also conserve energy to a considerable
extent.

1.1 ENERGY METER


The energy meter is an electrical measuring device, which is used
to record Electrical Energy Consumed over a specified period of time, in
terms of units, at residences, corporate and industries. When used in
electricity retailing, the utilities record the values measured by these
meters to generate an invoice for the electricity. They may also record
other variables including the time when the electricity was used. The unit
of measurement on the electricity meter is the kilowatt hour, which is
equal to the amount of energy used by a load of one kilowatt over a
period of one hour, or 3,600,000 joules.

1
1.2 TYPES OF ENERGY METERS
The electrical energy meters are classified as
• Electromechanical energy meter (Ferraris type)
• Multiple Tariff Meters
• Electronic energy meter (Static type)

They can be further classified as


• Single phase meters.
• Poly phase meters.

1.2.1 Mechanical Energy Meters


In this type, the metallic disc is acted upon by two coils. One coil
produces a magnetic flux in proportion to the voltage and the other
produces a magnetic flux in proportion to the current. The field of the
voltage coil is delayed by 90 degrees using a lag coil. This produces eddy
currents in the disc and these effects exert a force on the disc in
proportionate to the product of the instantaneous current and voltage. A
permanent magnet exerts an opposing force proportional to the speed of
rotation of the disc. These acts as a brake which causes the disc to stop
spinning when power flow stops rather than allowing it to spin faster and
faster.

The electromechanical induction type meter operates based on


counting the revolutions of an aluminum disc whose revolution speed is
proportional to the power consumed. The number of revolutions is thus
proportional to the energy usage.

2
The drawbacks of this type of Energy meters are as follows.
Due to the effect of temperature on the resistance of eddy current paths,
they are subjected to serious errors, which increases the losses and result
in poor working. These errors lead to development of electronic type
energy meter, which has better working than mechanical type energy
meters.

1.2.2 Multiple Tariff Meters


Electricity retailers may wish to charge customers with different
tariffs at different times of the day to better reflect the costs of generation
and transmission. Since it is generally not possible to store electricity
during a period of low demand, for use during a period of high demand,
costs will vary significantly depend on the time of day. Based on the
demand on the power stations and power consumption by the utilities,
tariff has to be decided.

1.2.3 Electronic Energy Meters (or) Static Meters


The electronic type energy meter applies the concepts of digital
circuits and gives the output pulses, whose frequencies depends upon the
power consumed, which is displayed on LCD (Liquid crystal display).
The electronic meters are also known as Static meters, since there is no
moving part like disc as in the case of mechanical meter. It also records
other parameters of the load and supply such as maximum demand,
power factor and reactive power used etc.

3
1.2.3.1 Advantages of Static Meters
The Static watt-hour meter has overcome the disadvantages of the
Ferraris Meter. It has more advantages like good measuring accuracy and
wide ranges of scale, low power consumption, wide operating
temperature, equipped with fault indication etc.

Static meters are already in use and further research and


development is also being done only through Static Meters. The static
meters are being widely promoted in the international market.

Some of the advantages are discussed below:


• Identical measuring in both single and three phases so the need for
separate meters are eliminated.
• The measuring units contain no wearing points and they consume
low power. Bi- directional measurement is possible with the same
meter so no phase order errors occur.
• Mechanical meters are prone to positional influence because of
magnet suspension bearing/double jewel bearings, employed to
suspend the rotor mechanism, whereas in case of static metes are
free from such positional influences.
• Strong electromagnetic fields influence the mechanical meters as it
is based upon the induction principle, whereas the static meter is no
susceptible to this effect.
• No creeping – it is a phenomenon of asymmetrical flux distribution
in the air gaps which is predominant in mechanical meters. So it
cannot occur in static meters as it does not have any air gap.

4
2. METERING AND BILLING

2.1 MANUAL METERING SYSTEM


Visiting of power company employees to customer premises.
This initial yet very important event, signals the beginning of the
actual tariff process. An individual representing the power company
henceforth to be referred to as PCE throughout the course of this
literature, visits the premises of the customer and is eventually directed to
the place where the analog meter is placed.

2.1.2 Shortcoming in the present process


i) This process necessitates the presence and active participation of both
the consumer and the power company individual at the premises of the
former. Notwithstanding this, in absence of the consumer the meter needs
to be physically accessible to the employee i.e. placed in a suitable
location, which is not possible in most households. The unpredictability
of the arrival of the power company employee adds another element of
uncertainly to the whole process.
ii) Tampering of the energy meters is another challenge faced by all the
power companies. Tampering is done in cases of theft, which can lead to
losses valuable to the power company. The digital meter at best promises
to be completely tamper-proof. (Refer Appendix 1 for News Article on
Power theft)
iii) Flexibility in terms of the power company being able to access the
reading from the customer’s premises at any given time is a must in order
to meet any eventuality such as the customer not being present at his
premises at that very time.

5
The proposed digital meter has been designed fully keeping in mind the
above shortcomings in the existing systems.
iv) The manual logging process also introduces a wide range of errors
such as data transpose errors, reproduction errors etc. In transpose errors
the order of numeric representation is mistaken changed. For example, 21
is represented as 12. This type of errors can be significant and create
customer dissatisfaction.

2.2. SPOT BILLING


Spot billing is another method for collection and revenue
management .In this the meter reading is entered into a handheld device,
which stores the earlier meter reading. Then the bills are issued
instantaneously.

This is not as popular among the power companies as it proved


more expensive and complicated than the manual system. In this method
the data collected from every SBM (Spot Billing Machine) has to be
updated into a PC and the file must be run to post it into the database thus
taking lot of time. There is no flexibility as the customer has to be present
at the time when the reading is to be accessed by the PCE.

2.3 PREPAYMENT BILLING


In this type of Billing there are two types,
1. Smart card system
2. RF Transceiver system

6
2.3.1 Smart Card System
The Smart Card System for Electric Power Metering operates on
the following basis.
• The meters are installed at the user’s end
• The meter reader visits the place at specific intervals ( once in a
month) and notes down the meter reading
• The present meter reading is fed into the computer at the Electricity
board
• The software is designed to compute the number of units consumed
in the month = present reading - previous reading.
• Based on the number of units consumed during the month the bill
is generated at applicable slab rate
• The bill is sent to the consumer
• The consumer pays the amount at the electricity board office
• The details of payment is entered
• The overdue position of bills is generated
• Power supply is disconnected

2.3.2 Disadvantages of using Smart Cards


The present system suffers from the following disadvantages:
• Meter reader has to visit the place every month
• The reading is to be fed into the computer
• The bill generated is to be sent
• The consumer will have to stand in long queue for making payment
• Delay in initiating action for nonpayment
• Cost of installation is high
• Complex process
• Not Consumer Friendly
7
3. PREPAID METERING THROUGH RF TRANSCEIVER

The problems faced due to analog metering, manual metering, spot


billing and the unattended disadvantages of the Prepaid Metering System
using Smart Cards lead us through to find another solution for prepaid
metering which would provide easy billing and also save power and
prevent power theft. (Refer Appendix 1 for news article on Power Theft.)

Usage of RF Transceivers is the prepaid technology for the future


and our project was to design hardware for the monitoring and metering
of Power using RF Transceivers.

3.1 ADVANTAGES OF USING RF TRANSCEIVERS

• Since the device is highly tamper - proof no spurious alterations can


be made to the actual power reading thus reducing the incidence of
power theft.
• Mass manufacturing of the device ensures greater economy, the price
of the user premises equipment estimated to be around Rs. 5000.
Economy wise and technology wise the device promises to be
welcomed by the common man, industry and power company alike.
• The electricity board need not send the meter reader every month.
• Data entry problems and errors will not be there.
• Delay in payment / nonpayment will not arise.
• Consumer need not stand in long queues to make the payment.
• Easier to operate and maintain.

8
3.2 TOOLS USED IN THE PROJECT
a. Code Vision AVR – PCB Printing
b. OrCAD 9 – For Programming of Chips
c. Hercules – Virtual Simulation for the Project (Only for testing
circuits)

9
4. BASIC CIRCUIT DESIGN

4.1 PCB FABRICATION

Figure 4.1 PCB Fabrication of ADE 7758

10
Figure 4.2 PCB Fabrication

11
5. DESIGN SPECIFICATIONS

The design specifications can be broadly classified as:


• Power supply and other main accessories.
• Digital signal processors.
• Hardware specifications.
• Communication.
• Software specifications.

5.1 POWER SUPPLY AND OTHER MAIN ACCESSORIES:


Power supply units mainly contain:
• Toroidal Current transformers.
• SMPS.

Main accessories are:


• LED.
• Contactor.
• Relay.
• Buzzer.
• Oscillator
• Latch

12
5.1.1 Current Transformers
Current Transformers are instrument transformers designed for
measuring electrical current. Toroidal Current Transformers are smaller
and lighter than most other types of current transformers. They have no
air-gaps, no magnetic stray field, and are very quiet .Toroidal Current
Transformers with an accuracy of better than 1%, which can be used to
monitor, protect, and control electrical systems for the following
applications:
• Energy (watt-hour, electricity) meter, Energy management.
• Circuit breakers, electricity protection systems.

5.1.2 Specifications
• Primary current: 5 A – 8,000 A.
• Secondary Current: 0.1 A – 5 A.
• Frequency: 50 Hz – 400 Hz.
• Accuracy: 1% .
• Construction: Tape insulated.

5.1.3 Switched Mode Power Supply (SMPS)


A switching power supply (also called switch mode power supply
or SMPS) is an electronic power supply unit (PSU) that incorporates a
switching regulator, an internal control circuit that switches the load
current rapidly on and off in order to stabilize the output voltage.
Switching regulators are used as replacements for simpler linear
regulators when higher efficiency, smaller size or lighter weights are
required.

13
Switching power supply in automotive products often have
universal inputs, meaning that they can accept power from most mains
supplies throughout the world, with frequencies from 50 Hz to 60 Hz and
voltages from 100 V to 240 V (although a manual voltage "range" switch
may be required).
The features of the SMPS are as listed below
1) AC input range selected by switch.
2) Protections: Short circuit/Over load.
3) Cooling by free air convection.
4) 100% full load burn-in.
5) High reliability.

5.1.4 Light Emitting Diode (LED)


A light-emitting diode (LED) is an electronic light source. All
early devices emitted low-intensity red light, but modern LEDs are
available across the visible, ultraviolet and infra red wavelengths, with
very high brightness.

LEDs are based on the semiconductor diode. When the diode is


forward biased (switched on), electrons are able to recombine with holes
and energy is released in the form of light. This effect is called
electroluminescence and the color of the light is determined by the energy
gap of the semiconductor.

14
5.1.5 Three Phase Contactor
ITC-LC1-D type A.C. Contactors is suitable for frequency 50/60
Hz, rated insulation voltage up to 1000v, rated operation current 9330A
under AC-3 duty. It is mainly used for making/breaking electric circuits
at a long distance & for frequent starting/stopping & controlling A.C.
Motors. It is used in combination with thermal relay to compose a
magnetic motor starter.

5.1.6 Relay
A relay is an electrical switch that opens and closes under the
control of another electrical circuit. In the original form, the switch is
operated by an electromagnet to open or close one or many sets of
contacts. Because a relay is able to control an output circuit of higher
power than the input circuit, it can be considered to be, in a broad sense, a
form of an electrical amplifier.

5.1.7 Latch
These 8-bit registers feature totem-pole 3-STATE outputs designed
specifically for driving highly-capacitive or relatively low-impedance
loads.

The eight flip-flops of the DM74LS374 are edge-triggered D-type


flip flops. On the positive transition of the clock, the Q outputs will be set
to the logic states that were set up at the D inputs. A buffered output
control input can be used to place the eight outputs in either a normal
logic state (HIGH or LOW logic levels) or a high-impedance state. In the
high-impedance state the outputs neither load nor drive the bus lines
significantly.

15
The output control does not affect the internal operation of the
latches or flip-flops. That is, the old data can be retained or new data can
be entered even while the outputs are OFF.

5.1.8 Buzzer
A buzzer or beeper is a signaling device, usually electronic,
typically used in automobiles, household appliances such as a microwave
oven, or game shows. It most commonly consists of a number of switches
or sensors connected to a control unit that determines ‘if’ and ‘which’
button was pushed or a preset time has lapsed, and usually illuminates a
light on the appropriate button or control panel, and sounds a warning in
the form of a continuous or intermittent buzzing or beeping sound.
Nowadays, it is more popular to use a ceramic-based piezoelectric
sounder which makes a high-pitched tone. Usually these were hooked up
to "driver" circuits which varied the pitch of the sound for on and off.

5.1.9 Oscillator
An electronic oscillator is an electronic circuit that produces a
repetitive electronic signal, often a sine wave or a square wave.

A low-frequency oscillator (LFO) is an electronic oscillator that


generates an AC waveform at a frequency below 20 Hz. This term is
typically used in the field of audio synthesizers, to distinguish it from an
audio frequency oscillator.

16
5.2 RS 232 DRIVER
5.2.1 Features
• Operates with single 5V power supply.
• Operates Up to 12 kbps.
• Two drivers and two receivers.
• ± 30V Input levels.
• 2000V Human Body model.

5.2.2 Pin diagram of RS 232 Driver

Figure 5.1 Pin Configuration of RS 232 Driver

5.2.3 Description
The MAX233 is a dual driver/ receiver that include a capacitive
voltage generator to supply. TIA/ EIA -232-F voltages levels from a
single 5V supply. Each receiver converts TIA/ EIA -232-F inputs to 5V
TTL/ CMOS levels.

17
These receivers have a typical threshold of 1.3 V, a typical hysteresis of
0.5 V, and can accept ±30V inputs. Each driver converts TTL/CMOS
input levels into TIA/ EIA -232-F levels.

5.2.4 Applications
• Battery- powered systems.
• Terminals.
• Modems and computers.

5.3 ADE 7758 ENERGY METER IC


5.3.1 Pin Diagram

Figure 5.2 Pin Diagram of ADE 7758

5.3.2 Pin Description

PIN 1: APCF-Active Power Calibration Frequency (APCF) Logic


Output. It provides active power information. This output is used for
operational and calibration purposes. The full-scale output frequency can
be scaled by writing to the APCFNUM and APCFDEN registers.

18
PIN 2: DGND-This provides the ground reference for the digital
circuitry in the ADE7758, that is, the multiplier, filters, and digital-to-
frequency converter. Because the digital return currents in the ADE7758
are small, it is acceptable to connect this pin to the analog ground plane
of the whole system.

PIN 3: DVDD-Digital Power Supply. This pin provides the supply


voltage for the digital circuitry in the ADE7758. The supply voltage
should be maintained at 5 V ± 5% for specified operation. This pin should
be decoupled to DGND with a 10 μF capacitor in parallel with a ceramic
100 nF capacitor.

PIN 4: AVDD- Analog Power Supply. This pin provides the supply
voltage for the analog circuitry in the ADE7758. The supply should be
maintained at 5 V ± 5% for specified operation. Every effort should be
made to minimize power supply ripple and noise at this pin by the use of
proper decoupling.

PIN 5, 6: IAP, IAN-Analog Inputs for Current Channel. This channel is


used with the current transducer. These inputs are fully differential
voltage inputs with maximum differential input signal levels of ±0.5 V,
±0.25 V, and ±0.125 V, depending on the gain selections of the internal
PGA. All inputs have internal ESD protection circuitry. In addition, an
over voltage of ±6 V can be sustained on these inputs without risk of
permanent damage.

PIN 7, 8: IBP, IBN as similar as PIN 5.

19
PIN 9, 10: ICP, ICN as similar as PIN 5.

PIN 11: AGND-This pin provides the ground reference for the analog
circuitry in the ADE7758, that is, ADCs, temperature sensor, and
reference. This pin should be tied to the analog ground plane or the
quietest ground reference in the system. To keep ground noise around the
ADE7758 to a minimum, the quiet ground plane should be connected to
the digital ground plane at only one point.

PIN 12: REF IN/OUT : This pin provides access to the on-chip voltage
reference. The on-chip reference has a nominal value of 2.4 V ± 8% and a
typical temperature coefficient of 30 ppm/°C. An external reference
source can also be connected at this pin.

PIN 13, 14: VN, VCP-Analog Inputs for the Voltage Channel. This
channel is used with the voltage transducer. It has the same description
has IAP AND IAN i.e. pin 5, 6. Instead of current rating, voltage ratings
are used here.

PIN 15, 16: VBP, VAP as similar as PIN 13.

PIN 17: VARCF-Reactive Power Calibration Frequency Logic Output. It


gives reactive power or apparent power information depending on the
setting of the VACF bit of the WAVMODE register. This output is used
for operational and calibration purposes.

20
PIN 18: IRO -Interrupt Request Output. This is an active low open-drain
logic output. Maskable interrupts include: an active energy register at half
level, an apparent energy register at half level, and waveform sampling
up to 26 kBPS

PIN 19: CLKIN-Master Clock for ADCs and Digital Signal Processing.
An external clock can be provided at this logic input. Alternatively, a
parallel resonant AT crystal can be connected across CLKIN and
CLKOUT to provide a clock source for the ADE7758. The clock
frequency for specified operation is 10 MHz.

PIN 20: CLKOUT-A crystal can be connected across this pin and
CLKIN as previously described to provide a clock source for the
ADE7758. The CLKOUT pin can drive one CMOS load when either an
external clock is supplied at CLKIN or a crystal is being used.

PIN 21: CS - Chip Select. Part of the 4-wire serial interface. This active
low logic input allows the ADE7758 to share the serial bus with several
other devices.

PIN 22: DIN- Data Input for the Serial Interface. Data is shifted in at this
pin on the falling edge of SCLK.

PIN 23: SCLK - Serial Clock Input for the Synchronous Serial Interface.
All serial data transfers are synchronized to this clock. The SCLK has a
Schmidt-trigger input for use with a clock source that has a slow edge
transition time, for example, opto-isolator outputs.

21
PIN 24: DOUT - Data Output for the Serial Interface. Data is shifted out
at this pin on the rising edge of SCLK. This logic output is normally in a
high impedance state; unless it is driving data onto the serial data bus.

5.4 ATmeg 128 MICROCONTROLLER


5.4.1 Pin Diagram and Block Diagram

Figure 5.3 Pin Configuration of ATmeg 128

22
Figure 5.4 Block Diagram of ATmeg 128

5.4.2 Pin Description of ATmeg 128

VCC: Digital supply voltage.


GND: Ground.

Port A (PA7, PA0): Port A is an 8-bit bi-directional I/O port with


internal pull-up resistors (selected for each bit). The Port A output buffers
have symmetrical drive characteristics with both high sink and source
capability.

23
As inputs, Port A pins that are externally pulled low will source current if
the pull-up resistors are activated. The Port A pins are tri-stated when a
reset condition becomes active, even if the clock is not running. The Port
A has an alternate function as the address low byte and data lines for the
External Memory Interface.

Port B (PB7, PB0): Port B is an 8-bit bi-directional I/O port with


internal pull-up resistors (selected for each bit). Refer port A for
explanation. Port B pins from PB3 TO PB0 has alternate functions of the
overriding signals and similarly the Port B pin from PB7 TO PB 4 pin can
serve as an external output for the Timer/Counter1 Output Compare B.

Port C (PC7, PC0): Port C is an 8-bit bi-directional I/O port with


internal pull-up resistors (selected for each bit). It has the explanation
same as the port A. Port C also serves the overriding the signals as in the
case of port B.

Port D (PD7, PD0): Port D is an 8-bit bi-directional I/O port with


internal pull-up resistors (selected for each bit). It has the same
explanation has port A. Ports D also functions as overriding the signals
and Timer/Counter counter sources.

Port E (PE7, PE0): Port E is an 8-bit bi-directional I/O port with


internal pull-up resistors (selected for each bit). Refer port A for
explanation. Port E also serves as the external interrupt sources and
overriding the signals.

24
Port F (PF7, PF0): Port F serves as the analog inputs to the A/D
Converter. Port F also serves as an 8-bit bi-directional I/O port, if the A/D
Converter is not used. Port pins can provide internal pull-up resistors
(selected for each bit). Refer port A for explanation. If the JTAG interface
is enabled, the pull-up resistors on pins PF7 (TDI), PF5 (TMS), and PF4
(TCK) will be activated even if a Reset occurs. The TDO pin is tri-stated
unless TAP states that shift out data are entered. Port F also serves the
functions of the JTAG interface.

Port G (PG4, PG0): Port G is a 5-bit bi-directional I/O port with


internal pull-up resistors (selected for each bit). Refer port A for its
explanation. In ATmega103 compatibility mode, these pins only serves as
strobes signals to the external memory as well as input to the 32 kHz
Oscillator, and the pins are initialized to PG0 = 1, PG1 =1, and PG2 = 0
asynchronously when a reset condition becomes active, even if the clock
is not running. PG3 and PG4 are oscillator pins.7RESET Reset input. A
low level on this pin for longer than the minimum pulse length will
generate a reset, even if the clock is not running. Shorter pulses are not
guaranteed to generate a reset.

XTAL1:
Input to the inverting Oscillator amplifier and input to the internal
clock operating circuit.

XTAL2:
Output from the inverting Oscillator amplifier.

25
AVCC:
AVCC is the supply voltage pin for Port F and the A/D Converter.
It should be externally connected to VCC, even if the ADC is not used. If
the ADC is used, it should be connected to VCC through a low-pass
filter.

AREF:
AREF is the analog reference pin for the A/D Converter.

PEN:
PEN is a programming enable pin for the SPI Serial Programming
mode, and is internally pulled high. By holding this pin low during a
Power-on Reset, the device will enter the SPI Serial Programming mode.

5.5 CC 2520 MICROCONTROLLER


5.5.1 Pin Diagram

Figure 5.5 Pin Diagram of CC 2520

26
5.5.2 Block Diagram of CC 2520

Figure 5.6 Block Diagram of CC 2520

5.5.3 Pin Function Description


PIN 1: SO - SPI interface: Serial Out.
PIN 2: SI - SPI interface: Serial In.
PIN 3: CSn - SPI interface: Chip Select, active low.

27
5.5.3.1 General Purpose I/O
PIN 4: GPIO5 - General purpose digital I/O.
PIN 5: GPIO4 - General purpose digital I/O.
PIN 6: GPIO3 - General purpose digital I/O.
PIN 7: GPIO2 - General purpose digital I/O.
PIN 9: GPIO1 - General purpose digital I/O.
PIN 10: GPIO0 - General purpose digital I/O.

5.5.3.2 Miscellaneous
PIN 25: RESETn - External reset pin, active low.
PIN 26: VREG_EN - When high, digital voltage regulator is active.
PIN 15, 18, and 21: NC – Not Connected.

5.5.3.3 Analog
PIN 23: RBIAS - External precision bias resistor for reference current.
56 kΩ, ±1%.
PIN 19: RF_N - Negative RF input signal to LNA in receive mode.
Negative RF output signal from PA in transmit mode.
PIN 17: RF_P - Positive RF input signal to LNA in receive mode.
Positive RF output signal from PA in transmit mode.
PIN 13: XOSC32M_Q1 - Crystal oscillator pin 1.
PIN 12: XOSC32M_Q2 - Crystal oscillator pin 2.

28
5.5.2.4 Power / Ground Pins
PIN 11, 14, 16, 20, and 22: AVDD - 1.8 V to 3.8 V analog power supply
connections. AVDD_GUARD - Power supply connection for digital
noise isolation and digital voltage regulator.
PIN 27: DCOUPL - 1.6 V to 2.0 V digital power supply output for
decoupling.
PIN 8: DVDD - 1.8 V to 3.8 V digital power supply for digital pads.

Figure 5.7 RF Transceiver Application Block

29
5.6 HD44780 LCD MICROCONTROLLER
5.6.1 Pin Diagram

Figure 5.8 Pin Diagram of HD 44780

30
5.6.2 Pin Function Description

RS: Selects registers.


0: Instruction registers (for write) busy flag: address counter (for
read)
1: Data register (for write and read)

R/ defined: Selects read or write.


0: Write
1: Read

E: Starts data read/write.

DB4 to DB7: Four high order bidirectional tri state data bus pins. Used
for data transfer and receive between the MPU and the HD44780U. DB7
can be used as a busy flag.

DB0 to DB3: Four low order bidirectional tri state data bus pins. Used for
data transfer and receive between the MPU and the HD44780U.These
pins are not used during 4-bit operation.

CL1: Clock to latch serial data D sent to the extension Driver.

CL2: Clock to shift serial data D.

M: Switch signal for converting the liquid crystal drive waveform to AC.

31
D: Character pattern data corresponding to each segment signal.

COM1 to COM16: Common signals that are not used are changed to
non-selection waveforms. COM9 to COM16 are non-selection
waveforms at 1/8 duty factor and COM12 to COM16 are non-selection
waveforms at 1/11 duty factor.

SEG1 to SEG40: Segment signals

V1 to V5: Power supply for LCD drive


VCC –V5 = 11 V (max)

VCC, GND: VCC: 2.7V to 5.5V, GND: 0V

OSC1, OSC2: When crystal oscillation is performed, a resistor must be


connected externally. When the pin input is an external clock, it must be
input to OSC1.

32
6. OPERATION

6.1 BASIC BLOCK DIAGRAM

Figure 6.1 Basic Block Diagram of the project

33
6.2 GENERAL OPERATIONAL BLOCK DIAGRAM

Sending End

SPI RS 232
ADE 7758 ATmeg 128 µC

3 Ph I/P 3 Ph O/P CC 2520

Antenna
Antenna

CC 2520
RS 232
PC Interface
µC

Receiving End

Figure 6.2 Operational Block Diagram

34
6.2 OPERATIONAL DESCRIPTION
Generally, three phase power supplies from the electricity board
are logging into our houses for utilization. Three phase lines are passed
through the toroidal current transformer for stepping down the value
suitable for the working of the electronic chips. Similarly, these three
phase lines are soldered to the energy meter chip ADE 7758, for voltage
measuring purpose. Here the oscillator range of ADE 7758 chip is
10MHZ. Then current and voltage terminals are connected to
corresponding pins of ADE 7758 chip. In that chip, there is an 16 bit,
second order sigma – delta ADC with an over sampling rate of 833KHz,
which converts the analog current and voltage signals to digitalized
signals.

Digitalized current signals are filtered by high pass filter to


remove the DC component offset in current channel. Then the
corresponding current and voltage signals are multiplied by means of
multipliers which give the apparent power. Again this apparent power
signal is filtered by low pass filters to reduce line frequency harmonics
and extract the real power. These real power values are made absolute by
ABS formula. Finally, the real power values of each phase are added.
These digital real power values are converted to frequency by digital to
frequency converter which produces high frequency and low frequency
output. The higher output frequency is generated by accumulating the
instantaneous real power signal over a much shorter time, while
converting it to a frequency. Low frequency output is generated from real
power information accumulated over a relatively long period of time.

35
At the same time, phase detectors are used to detect the phase
difference between current and voltage of each phase. Finally we
calculate VI cosφ which is the real power and VI sinφ which is reactive
power. Then these are integrated with respect to time to measure the
energy utilized by the consumer.

These measured and calculated values are transferred to host


microcontroller ATmeg 128, whose oscillator range is 16MHZ. These are
achieved by means of serial peripheral interface which has serial
peripheral data register and status registers. The LCD display indicates
the values of I rms , V rms , apparent power, reactive power, frequency, no of
units consumed and the balance amount of money. In the mother board
there are 3 LED which perform separate tasks. First LED indicates the
status of contactor whether the switch is ON or OFF. Second LED will
glow when the balance amount of money goes below 10 rupees. Third
LED shows the normal working of energy meter.

Figure 6.3 Signal Processing Block

36
Then the LED display values are also viewed at the nearest
electricity board office by means of RF transceiver. It is used to send and
receive the information from EB office and also receive from the
customer end. As soon as the energy consumed by the customer reaches
the amount just below 10 rupees, a buzzer starts its buzzing sound along
with the glow of LED which also indicates to customer about his lack of
balance and also indicates at the EB office terminal. At that time,
customer has to inform to the EB office to top up the money by means of
toll free telephone numbers or by means of internet. Once the account is
recharged the customer gets uninterrupted power supply. This process is
repeated for reliable power supply.

37
7. PROGRAMMING OF MICROCONTROLLER

//Declarations
#include <mega128.h>
#include <spi.h>
#include <math.h>
#define LCD_COMMAND_B 0x99
#define RED 1
#define GREEN 2
#define ORANGE 3
#define BREAKER_CNT 8000
#define LED_PIN PORTC.0
#define AP_V 16
#define VA_V 16
#define IA_V 16
#define A_WATTHR 0x01
#define B_VARHR 0x05
# #define C_VAHR 0X09
#define A_IRMS 0x0A
#define A_VRMS 0x0D
#define VPEAK 0x21
#define IPEAK 0x22
#define ADE_CS PORTB.5
#define LOW 0
#define HIGH 1

38
// USART1 Receiver buffer
#define RX_BUFFER_SIZE1 50
char rx_buffer1[RX_BUFFER_SIZE1];
unsigned char rx_wr_index1,rx_rd_index1,rx_counter1;

// This flag is set on USART1 Receiver buffer overflow


bit rx_buffer_overflow1;

// Get a character from the USART1 Receiver buffer


#pragma used+
char getchar1(void)
{
char data;
while (rx_counter1==0);
data=rx_buffer1[rx_rd_index1];
if (++rx_rd_index1 == RX_BUFFER_SIZE1) rx_rd_index1=0;
#asm("cli")
--rx_counter1;
#asm("sei")
return data;
}
//User Details to be displayed in LCD
// Declare your global variables here
flash char *STRTUP_MSG[4]={
" TAMIL NADU ",//0
" ELECTRICITY BOARD ",//1
" [TNEB] ",//2

39
"****WELCOMES YOU****"//3
};
flash char *UDE[4]={
//0123456789ABCDEF6789
"UN = DCS ",//0
"SN = 12345 ",//1
"CN = 044-43551421 ",//2
"ML = 1000watts "//3
};
flash char *AP[4]={
//0123456789ABCDEF6789
" V I AP ",//0
"A ",//1
"B ",//2
"C "//3
};
flash char *AC[4]={
//0123456789ABCDEF6789
" V I AC ",//0
"A ",//1
"B ",//2
"C "//3
};
flash char *RP[4]={
//0123456789ABCDEF6789
" V I RP ",//0
"A ",//1

40
"B ",//2
"C "//3
};
flash char *VI[4]={
//0123456789ABCDEF6789
" V I ",//0
"PEK ",//1
"NOR ",//2
"LOW "//3
};
flash char *UR[4]={
//0123456789ABCDEF6789
" U R ",//0
"Ra/Hr ",//1
"AVI ",//2
" DT= hrs "//3
};
flash char *END_MSG[4]={
" CONTACT TNEB @ ",//0
" 044-26200261 ",//1
"E_M:QUERIES@TNEB.COM",//2
"*****THANK YOU******"//3
};

41
//RF Communication
Flash unsigned char
IMR[]="***PEM0904M0;IMREADY;===@@@@@@@@@@@@@
@@@@@@@@@@@@@";
flash unsigned char UD[]="***PEM0904M1;JKPROJECT TEAM
2009;SN:12345678;===";
flash unsigned char
CN[]="***PEM0904M1;CONTACTNUMBER=044-
43551421;===@@@@@@@";
flash unsigned char
AMST[]="***PEM0904M3;A|P=123456;R/U=12;PDU=123;DT=123;==
=@";
flash unsigned char
VOLT[]="***PEM0904M4;VA=123;VB=123;VC=123;===@@@@@
@@@@@@@@";
flash unsigned char
CUR[]="***PEM0904M5;IA=123;IB=123;IC=123;===@@@@@@@
@@@@@@";
flash unsigned char
PHI[]="***PEM0904M6;PIA=123;PIB=123;PIC=123;===@@@@@@
@@@@";
flash unsigned char
FT[]="***PEM0904M7;FA=12.3;FB=12.3;FC=12.3;T=12.3;===@@@
@";

42
//Getting details from ADE 7758
union{
signed char uc8_data[4];
signed int ui16_data[2];
signed long int uli32_data;
}u, v;

//Read Functions
signed int Fun_Read_A_WATT(void) {
unsigned char junk = 0;
u.uli32_data = 0; //clears the union
ADE_CS = LOW;
SPDR = A_WATTHR; //loads the register valve.
while(!(SPSR & 0x80));
junk = SPDR;
delay_ms(1);

SPDR = 0x00;
while(!(SPSR & 0x80));
u.uc8_data[1] = SPDR; //sends the MSB (15-8).
delay_ms(1);

SPDR = 0x00;
while(!(SPSR & 0x80));
u.uc8_data[0] = SPDR; //sends the LSB (7-0).
delay_ms(1);
ADE_CS=HIGH;

43
return(u.ui16_data[0]); //retrns the 16 bit value.
}

unsigned char Fun_Read_TEMP(void) {


unsigned char junk= 0;

ADE_CS=LOW;
SPDR=TEMP; //loads the register valve.
while(!(SPSR & 0x80));
junk=SPDR;

SPDR=0x00;
while(!(SPSR & 0x80));
junk = SPDR; //sends the LSB (7-0).
ADE_CS=HIGH;

return(junk); //retrns the 8 bit value.


}
unsigned int Fun_Read_AVRMSGAIN(void) {
unsigned char junk = 0;
u.uli32_data = 0; //clears the union

ADE_CS = LOW;
SPDR = AVRMSGAIN; //loads the register valve.
while(!(SPSR & 0x80));
junk = SPDR;

44
SPDR = 0x00;
while(!(SPSR & 0x80));
u.uc8_data[1] = SPDR; //sends the MSB (xxxx11-8).

SPDR = 0x00;
while(!(SPSR & 0x80));
u.uc8_data[0] = SPDR; //sends the LSB (7-0).
ADE_CS = HIGH;

return(u.ui16_data[0]); //retrns the 12 bit value.


}

unsigned int Fun_Read_AVARG(void) {


unsigned char junk = 0;
u.uli32_data = 0; //clears the union

ADE_CS = LOW;
SPDR = AVARG; //loads the register valve.
while(!(SPSR & 0x80));
junk = SPDR;

SPDR = 0x00;
while(!(SPSR & 0x80));
u.uc8_data[1] = SPDR; //sends the MSB (xxxx11-8).

SPDR = 0x00;
while(!(SPSR & 0x80));

45
u.uc8_data[0] = SPDR; //sends the LSB (7-0).
ADE_CS = HIGH;

return(u.ui16_data[0]); //retrns the 12 bit value.


}

unsigned int Fun_Read_AWATTOS(void) {


unsigned char junk = 0;
u.uli32_data = 0; //clears the union

ADE_CS = LOW;
SPDR = AWATTOS; //loads the register valve.
while(!(SPSR & 0x80));
junk = SPDR;

SPDR = 0x00;
while(!(SPSR & 0x80));
u.uc8_data[1] = SPDR; //sends the MSB (xxxx11-8).

SPDR = 0x00;
while(!(SPSR & 0x80));
u.uc8_data[0] = SPDR; //sends the LSB (7-0).
ADE_CS = HIGH;

return(u.ui16_data[0]); //retrns the 12 bit value.


}

46
void Fun_Write_APHCAL(unsigned char write_data) {
unsigned char junk = 0;

ADE_CS = LOW;
SPDR = (APHCAL | 0x80);
while(!(SPSR & 0x80));
junk = SPDR;

SPDR = write_data;
while(!(SPSR & 0x80));
junk = SPDR; //sends the LSB (7-0).
ADE_CS = HIGH;
}
unsigned char Fun_Read_VARDIV(void) {
unsigned char junk = 0;

ADE_CS = LOW;
SPDR = VARDIV; //loads the register valve.
while(!(SPSR & 0x80));
junk = SPDR;

SPDR = 0x00;
while(!(SPSR & 0x80));
junk = SPDR; //sends the LSB (7-0).
ADE_CS = HIGH;

return(junk); //retrns the 8 bit value.

47
}
unsigned char Fun_Read_VADIV(void) {
unsigned char junk = 0;

ADE_CS = LOW;
SPDR = VADIV; //loads the register valve.
while(!(SPSR & 0x80));
junk = SPDR;

SPDR = 0x00;
while(!(SPSR & 0x80));
junk = SPDR; //sends the LSB (7-0).
ADE_CS = HIGH;

return(junk); //retrns the 8 bit value.


}

void Fun_Write_APCFNUM((unsigned int write_data) {


unsigned char junk = 0;
u.uli32_data = write_data; //clears the union

ADE_CS = LOW;
SPDR = (APCFNUM | 0x80);
while(!(SPSR & 0x80));
junk = SPDR;

SPDR = u.uc8_data[1];

48
while(!(SPSR & 0x80));
junk = SPDR; //sends the MSB (xxxx11-8).

SPDR = u.uc8_data[0];
while(!(SPSR & 0x80));
junk = SPDR; //sends the LSB (7-0).
ADE_CS = HIGH;
}

void Fun_Write_APCFDEN(unsigned int write_data) {


unsigned char junk = 0;
u.uli32_data = write_data; //clears the union

ADE_CS = LOW;
SPDR = (APCFDEN | 0x80);
while(!(SPSR & 0x80));
junk = SPDR;

SPDR = u.uc8_data[1];
while(!(SPSR & 0x80));
junk = SPDR; //sends the MSB (xxxx11-8).
SPDR = u.uc8_data[0];
while(!(SPSR & 0x80));
junk = SPDR; //sends the LSB (7-0).
ADE_CS = HIGH;
}
void Fun_Write_VARCFDEN (unsigned int write_data) {

49
unsigned char junk = 0;
u.uli32_data = write_data; //clears the union

ADE_CS = LOW;
SPDR = (VARCFDEN | 0x80);
while(!(SPSR & 0x80));
junk = SPDR;

SPDR = u.uc8_data[1];
while(!(SPSR & 0x80));
junk = SPDR; //sends the MSB (xxxx11-8).

SPDR = u.uc8_data[0];
while(!(SPSR & 0x80));
junk = SPDR; //sends the LSB (7-0).
ADE_CS = HIGH;
}
unsigned char Fun_Read_VERSION(void) {
unsigned char junk = 0;

ADE_CS = LOW;
SPDR = VERSION; //loads the register valve.
while(!(SPSR & 0x80));
junk = SPDR;

SPDR = 0x00;
while(!(SPSR & 0x80));

50
junk = SPDR; //sends the LSB (7-0).
ADE_CS = HIGH;

return(junk); //retrns the 8 bit value.


} */

// LCD Functions
// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
TCNT0=6;
if(++timecount == 200)
{
g++;
timecount = 0;
}
}
void TIME(void)
{
switch(2)
{
case 0:
Load_FBuf(STRTUP_MSG[0]);
Lcd_Dispmessage(1);
Load_FBuf(STRTUP_MSG[1]);
Lcd_Dispmessage(2);
Load_FBuf(STRTUP_MSG[2]);

51
Lcd_Dispmessage(3);
Load_FBuf(STRTUP_MSG[3]);
Lcd_Dispmessage(4);
break;
case 1:
Load_FBuf(UDE[0]);
Lcd_Dispmessage(1);
Load_FBuf(UDE[1]);
Lcd_Dispmessage(2);
Load_FBuf(UDE[2]);
Lcd_Dispmessage(3);
Load_FBuf(UDE[3]);
Lcd_Dispmessage(4);
break;
}
}

void V_I(void)
{
/*q=uli32_V/100;
r=uli32_V%100;
LCD_Buff[VI_V]=q+48;
q=r/10;
LCD_Buff[VI_V+1]=q+48;
q=r%10;
LCD_Buff[VI_V+2]=q+48;*/
q=uli32_I/100;

52
r=uli32_I%100;
LCD_Buff[VI_I]=q+48;
q=r/10;
LCD_Buff[VI_I+1]=q+48;
q=r%10;
LCD_Buff[VI_I+2]=q+48;
}
//write led function latched the data in the databus to the 74ls574 during
the rising edge of the clock pin.
void Write_4_LED()
{
DATA_DIRC=OUTPUT; //OUTPUT
DATA_PORT=LED_R;
DATA_DIRC=OUTPUT; //OUTPUT
DATA_PORT=LED_R;
LED_PIN=CLEAR;
delay_us(2);
LED_PIN=SET;
DATA_PORT=LED_R;
DATA_DIRC=INPUT;
}

//Reading Logic
unsigned char Fun_M0_IMREADY(void){
strcpyf(Ud_Tx_buff,IMR);
for(i=0;i<50;i++){
putchar1(Ud_Tx_buff[i]);

53
}
}

unsigned char Fun_M1_USERDETAILS(void){


strcpyf(Ud_Tx_buff,UD);
for(i=0;i<50;i++){
putchar1(Ud_Tx_buff[i]);
}
}

unsigned char Fun_M1_CONTACTNUMBER(void){


strcpyf(Ud_Tx_buff,CN);
for(i=0;i<50;i++){
putchar1(Ud_Tx_buff[i]);
}
}
/*unsigned char Fun_M1_USERNAME(void){
strcpy(Ud_Tx_buff,UN);
for(i=0;i<50;i++){
putchar1(Ud_Tx_buff[i]);
}
}
unsigned char Fun_M1_SERIALNUMBER(void){
strcpy(Ud_Tx_buff,SN);
for(i=0;i<50;i++){
putchar1(Ud_Tx_buff[i]);
}

54
}*/

void Fun_M2_ENERGYSTATUS(void){

strcpyf(Ud_Tx_buff,ES);
q=U_DATA_0/100000;
r=U_DATA_0%100000;
Ud_Tx_buff[AP_V]=q+48;
q=r/10000;
r1=r%10000;
Ud_Tx_buff[AP_V+1]=q+48;
q=r1/1000;
r=r1%1000;
Ud_Tx_buff[AP_V+2]=q+48;
q=r/100;
r1=r%100;
Ud_Tx_buff[AP_V+3]=q+48;
q=r1/10;
Ud_Tx_buff[AP_V+4]=q+48;
q=r1%10;
Ud_Tx_buff[AP_V+5]=q+48;
q=U_DATA_1/100000;
r=U_DATA_1%100000;
Ud_Tx_buff[RP_V]=q+48;
q=r/10000;
r1=r%10000;
Ud_Tx_buff[RP_V+1]=q+48;

55
q=r1/1000;
r=r1%1000;
Ud_Tx_buff[RP_V+2]=q+48;
q=r/100;
r1=r%100;
Ud_Tx_buff[RP_V+3]=q+48;
q=r1/10;
Ud_Tx_buff[RP_V+4]=q+48;
q=r1%10;
Ud_Tx_buff[RP_V+5]=q+48;

q=U_DATA_2/100000;
r=U_DATA_2%100000;
Ud_Tx_buff[AC_V]=q+48;
q=r/10000;
r1=r%10000;
Ud_Tx_buff[AC_V+1]=q+48;
q=r1/1000;
r=r1%1000;
Ud_Tx_buff[AC_V+2]=q+48;
q=r/100;
r1=r%100;
Ud_Tx_buff[AC_V+3]=q+48;
q=r1/10;
Ud_Tx_buff[AC_V+4]=q+48;
q=r1%10;
Ud_Tx_buff[AC_V+5]=q+48;

56
for(i=0;i<50;i++){
putchar1(Ud_Tx_buff[i]);
}
}
unsigned char Fun_M3_AMOUNTSTATUS(void){
strcpyf(Ud_Tx_buff,AMST);
q=U_DATA_3/100000;
r=U_DATA_3%100000;
Ud_Tx_buff[AMPD_V]=q+48;
q=r/10000;
r1=r%10000;
Ud_Tx_buff[AMPD_V+1]=q+48;
q=r1/1000;
r=r1%1000;
Ud_Tx_buff[AMPD_V+2]=q+48;
q=r/100;
r1=r%100;
Ud_Tx_buff[AMPD_V+3]=q+48;
q=r1/10;
Ud_Tx_buff[AMPD_V+4]=q+48;
q=r1%10;
Ud_Tx_buff[AMPD_V+5]=q+48;

q=U_DATA_4/10;
Ud_Tx_buff[RPU_V]=q+48;
q=U_DATA_4%10;

57
Ud_Tx_buff[RPU_V+1]=q+48;

q=U_DATA_5/100;
r1=U_DATA_5%100;
Ud_Tx_buff[PDU_V]=q+48;
q=r1/10;
Ud_Tx_buff[PDU_V+1]=q+48;
q=r1%10;
Ud_Tx_buff[PDU_V+2]=q+48;

q=U_DATA_6/100;
r1=U_DATA_6%100;
Ud_Tx_buff[DT_V]=q+48;
q=r1/10;
Ud_Tx_buff[DT_V+1]=q+48;
q=r1%10;
Ud_Tx_buff[DT_V+2]=q+48;

for(i=0;i<50;i++){
putchar1(Ud_Tx_buff[i]);
}
}
/*unsigned char Fun_M3_AMOUNTPAID(void){
strcpy(Ud_Tx_buff,AMPA);
for(i=0;i<50;i++){
putchar1(Ud_Tx_buff[i]);
}

58
}
unsigned char Fun_M3_RUPEESPERUNIT(void){
strcpy(Ud_Tx_buff,RPU);
for(i=0;i<50;i++){
putchar1(Ud_Tx_buff[i]);
}
}
unsigned char Fun_M8_TEMPERATURE(void){
strcpyf(Ud_Tx_buff,TEM);
for(i=0;i<50;i++){
putchar1(Ud_Tx_buff[i]);
}
} */

// Display Logic
unsigned char Fun_MODE(void){
MODE=Fun_CHK_4_MX();
switch(MODE)
{
case '0':
for(i=z;i<y;i++){
if(rx_buffer1[i+3]=='R' && rx_buffer1[i+4]=='U' &&
rx_buffer1[i+5]=='R'
&& rx_buffer1[i+6]=='E' && rx_buffer1[i+7]=='A'
&& rx_buffer1[i+8]=='D'
&& rx_buffer1[i+9]=='Y'){
Fun_M0_IMREADY();

59
}
}
break;
case '1':
for(i=z;i<y;i++){
if(rx_buffer1[i+3]=='U' && rx_buffer1[i+4]=='S' &&
rx_buffer1[i+5]=='E'
&& rx_buffer1[i+6]=='R' && rx_buffer1[i+7]=='D'
&& rx_buffer1[i+8]=='E'
&& rx_buffer1[i+9]=='T' && rx_buffer1[i+10]=='A'
&& rx_buffer1[i+11]=='I'
&& rx_buffer1[i+12]=='L' &&
rx_buffer1[i+13]=='S'){
Fun_M1_USERDETAILS();
Fun_M1_CONTACTNUMBER();
}
/*else if(rx_buffer1[i+3]=='U' &&
rx_buffer1[i+4]=='S' && rx_buffer1[i+5]=='E'
&& rx_buffer1[i+6]=='R' && rx_buffer1[i+7]=='N'
&& rx_buffer1[i+8]=='A'
&& rx_buffer1[i+9]=='M' && rx_buffer1[i+10]=='E'){
Fun_M1_USERNAME();
}
else if(rx_buffer1[i+3]=='S' && rx_buffer1[i+4]=='E'
&& rx_buffer1[i+5]=='R'
&& rx_buffer1[i+6]=='I' && rx_buffer1[i+7]=='A' &&
rx_buffer1[i+8]=='L'

60
&& rx_buffer1[i+9]=='N' && rx_buffer1[i+10]=='U'
&& rx_buffer1[i+11]=='M'
&& rx_buffer1[i+12]=='B' && rx_buffer1[i+13]=='E'
&& rx_buffer1[i+14]=='R'){
Fun_M1_SERIALNUMBER();
}*/
}
break;
case '2':
for(i=z;i<y;i++){
if(rx_buffer1[i+3]=='E' && rx_buffer1[i+4]=='N' &&
rx_buffer1[i+5]=='E'
&& rx_buffer1[i+6]=='R' && rx_buffer1[i+7]=='G'
&& rx_buffer1[i+8]=='Y'
&& rx_buffer1[i+9]=='S' && rx_buffer1[i+10]=='T'
&& rx_buffer1[i+11]=='A'
&& rx_buffer1[i+12]=='T' && rx_buffer1[i+13]=='U'
&& rx_buffer1[i+14]=='S'){
Fun_M2_ENERGYSTATUS();
}
/*else if(rx_buffer1[i+3]=='A' &&
rx_buffer1[i+4]=='C'){
Fun_M2_AC();
}
else if(rx_buffer1[i+3]=='R' &&
rx_buffer1[i+4]=='P'){
Fun_M2_RP();
}
61
else if(rx_buffer1[i+3]=='A' &&
rx_buffer1[i+4]=='P'){
Fun_M2_AP();
}*/
}
break;
}
}
void main(void)
{
PORTG=0x18;
SPSR=0x00;
#asm("sei")
INIT_LCD();
Lcd_Write_Cmd(BLINK_OFF);
for(uc_j=0; uc_j<5; uc_j++)
{ for(uc_i=1; uc_i<4; uc_i++)
{ ON_LED(uc_i,uc_j);
Write_4_LED();
delay_ms(100);
}
}

62
8. CONCLUSION

The Three phase prepaid energy meter was designed by using


ZigBee RF Communication. The more efficient way of metering, was
observed in our project. The hardware designed and fabricated was tested
under maximum load conditions and the system was found to respond at a
faster rate than conventional analog meters. This project will reduce the
risk of misuse of power

The future of EB Metering system is Prepaid Technology through


RF transceivers and implementation of the same would lead to
sustainable Energy management and also conservation of Power both at
the supplier end and also at the consumer end.

On the successful large scale implementation of this Project,


Energy Theft by industries and consumers can be reduced and it can be
prevented to the core in the days to come.

63
APPENDIX 1

NEWS ARTICLE FROM THE TIMES OF INDIA DATED 10th


JANUARY 2009

Plastic firm charged with power theft worth Rs. 59L

TIMES NEWS NETWORK

Chennai: Suburban police officials are on the lookout for the proprietors
of a plastic manufacturing firm, who reportedly stole electricity from
overhead TNEB wires, to the tune of Rs 59.43 lakhs over a period of a
year. Based on a complaint filed by Jagadish Kumar, assistant engineer of
TNEB’s Manali unit, police have launched a search for Isakkimuthu and
Hanuman Patel, proprietors of Swastik Plastic Company, Thiruvotriyur.
According to suburban police officials, the two had connected a metal
hook to the electric wires running over their factory and during the night,
he had been stealing electricity through this. During the day though, the
hooks were removed and all signs of the theft would be covered up.
Despite the meters recording the excessive electricity being used, TNEB
officials realised that such large quantities were being stolen only after
many consumers lodged complaints of being over-billed. The officials
then launched an enquiry into the issue a few weeks back and through
field investigation, they narrowed down on the spot where the electricity
was stolen. Police officials are on the lookout for the two proprietors,
who are absconding.

64
APPENDIX 2

Data Sheet of ATMeg 128

Typical Characteristics of ATMeg 128

65
66
67
68
69
70
71
72
REFERENCES

1. “Anti tampering energy meters”, Electrical India, February 2005.


2. Daigle, Paul - “All Electronic Power and Energy Meters”. Analog
Dialogue. Volume 33. Number 2. February, 1999.
3. Kenneth J. Ayala (2004) “The 8051 micro controllers architecture,
programming and applications”, Penram international publishing (I) Pvt.
Ltd.
4. “Keep energy cost to minimum”, Electrical Engineering Update, January
– February 05.
5. “Mains Monitor” – Project in Everyday Practical Electronics Magazine,
August 2008 Issue http://www.epemag.wimborne.co.uk/0808.htm
6. Muhammad Ali Mazidi and Janice Gillispie Mazidi (2002) “The 8051
microcontroller and embedded system”, Pearson education.
7. Pages from http://www.analogdevices.com
8. White Papers from www.scholar.google.com

73

Вам также может понравиться