108
i DEVELOPMENT OF A MICROCONTROLLER BASED G.S.M INTERACTIVE ENERGY METER BY FARAYOLA, PRAISE OLOLADE MATRIC NUMBER: 158164 A PROJECT REPORT SUBMITTED TO THE DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING, FACULTY OF TECHNOLOGY, UNIVERSITY OF IBADAN, IN PARTIAL FULFILMENT OF THE REQUIREMENT FOR THE AWARD OF BACHELOR OF SCIENCE DEGREE IN ELECTRICAL AND ELECTRONIC ENGINEERING OF THE UNIVERSITY OF IBADAN. DECEMBER, 2015

DEVELOPMENT OF A MICROCONTROLLER BASED G.S.M …

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

i

DEVELOPMENT OF A MICROCONTROLLER BASED

G.S.M INTERACTIVE ENERGY METER

BY

FARAYOLA, PRAISE OLOLADE

MATRIC NUMBER: 158164

A PROJECT REPORT SUBMITTED TO THE DEPARTMENT

OF ELECTRICAL AND ELECTRONIC ENGINEERING,

FACULTY OF TECHNOLOGY, UNIVERSITY OF IBADAN,

IN PARTIAL FULFILMENT OF THE REQUIREMENT FOR

THE AWARD OF BACHELOR OF SCIENCE DEGREE IN

ELECTRICAL AND ELECTRONIC ENGINEERING OF THE

UNIVERSITY OF IBADAN.

DECEMBER, 2015

ii

CERTIFICATION

This is to certify that the project upon which this report is based was carried out

by FARAYOLA, PRAISE OLOLADE in the Department of Electrical and Electronic

Engineering, Faculty of Technology, University of Ibadan.

…………………… ………………..

Dr. O.A Fakolujo Date

Project Supervisor

…………………… ………………

Prof. A. Olatunbosun Date

Head of Department

iii

DEDICATION

This project is dedicated to my mum, Mrs Esther Farayola; to my sister, Dorcas Farayola

and to my wife (although we have not met). Unto God be all the glory.

iv

AKNOWLEDGEMENT

I thank the Lord God Almighty who is and will always remain the source and secret of my

strength. I cannot but say a big ‘thank you’ for the sound health, favour and speed

bestowed upon me during the process and span of this project.

I express my profound gratitude to my supervisor, Dr O.A Fakolujo for his advice, support

and guidance throughout the period of this project. This project has really helped me to

gain a sound and practical knowledge of nearly all the topics covered during my

undergraduate study. Thank you very much sir. It is indeed a privilege to have been

supervised by you.

I wish to acknowledge Mr Ibrahim, the managing director at Digitouch Electronics. Thank

you for giving me the opportunity to carry out this research and design work at your

organization. Thank you for also helping with the codes.

I am most grateful to all members of the Gospel Students’ Fellowship, University of

Ibadan chapter who stood by me throughout my stay in the university.

Thanks to Rahmat, Fikayo, Eniola and Busayo for their constructive critism and support.

I am forever indebted to my family, especially for their financial support and prayers

during the course of this project and my entire stay in the university.

Thanks to Oke Oluwadamilare for permitting me to use the room as my personal

laboratory. You are a friend indeed.

v

ABSTRACT

The electromechanical energy meter which is still in use today and common is many part

of Nigeria is an old way of metering. Even the new smart card based prepaid meter once

distributed by the electricity distributing company has its flaws among which is its high

cost and unavailability. It is therefore imperative that a low cost energy meter with

a level of intelligence and smartness is built and made available.

Phase voltage and current were measured and converted to their digital equivalent using an

analogue to digital converter contained within an ATmega8A microcontroller. The

microcontroller was programmed to determine the RMS value of the measured signals and

subsequently calculate RMS power. These are displayed by the meter in real time.

This project also focuses on and incorporates SMS communicability. The user is also

given limited ability and power to consent to reading request before the meter is read and

energy readings are sent via SMS.

This project was implemented on a locally made single layer printed circuit board with the

aid of Express PCB software. Simulation was carried out using proteus software and AVR

development kit.

The project has been used to measure voltage accurately within a 2 – 3 % margin of error.

However, the margin of error for power measurement was observed to be related to how

close or far the line voltage is from 220V.

vi

TABLE OF CONTENTS

Title Page 00

Certification 00

Dedication 00

Acknowledgement 00

Abstract 00

Table of Contents 00

List of Figures 00

List of Tables 00

Chapter one - INTRODUCTION 00

1.1 Background 01

1.2 Problem Statement 03

1.3 Aim and Objectives 04

1.4 Parameters to Be Measured 05

1.5 Significance of Study 05

1.6 Motivation for the Project 05

1.7 Scope and Limitation of Study 06

vii

Chapter Two – LITERATURE REVIEW 07

2.1 Brief History of Metering 07

2.2 Evolution of Meters 09

2.2.1 Electrolytic Meters 09

2.2.2 Pendulum Meters 10

2.2.3 Motor Meters 11

2.2.4 Induction Meters 13

2.2.5 Electronic Meters 14

2.2.6 Remote Monitoring of Meters 15

2.3 Types of Energy Meter 16

2.3.1 The Electromechanical Meter 16

2.3.2 The Electronic Meter 18

2.4 Comparison of Various Types of Meters 20

2.5 Current Trends in Metering Technology 21

2.5.1 Pre-Paid Metering (GPRS Meter) 22

2.6 Literature Background of the Major Devices Used 23

2.6.1 Voltage Transducer (VT) 23

viii

2.6.2 Current Transducer (CT) 24

2.6.2.1 Sense Resistor 24

2.6.2.2 Current Transformer 24

2.6.2.3 Hall Effect Sensor 25

2.6.3 The Liquid Crystal Display 26

2.6.4 The EEPROM (Electrically Erasable Programmable Read Only Memory) 28

2.6.5 The GSM Module (NEOWAY, M590) 29

2.6.6 The Disconnection Relay 31

2.6.7 The Microcontroller, Atmega8A 31

Chapter Three – DESIGN METHODOLOGY 36

3.1 Introduction 36

3.2 Phase Voltage Sensing 37

3.3 Phase Current Sensing 38

3.4 Added Circuits 41

3.4.1 Power Supply circuit 41

3.4.2 Relay Circuit 42

3.4.3 Load Circuit 43

3.4.4 Status LED and Interface Button Circuit 44

ix

3.5 Communication and Control Circuit 45

Chapter Four – IMPLEMENTATION AND TESTING 49

4.1 PCB Designs 50

4.1.1 Voltage Sensing Circuit Design 50

4.1.2 Current Sensing Circuit Design 51

4.1.3 Relay Circuit Design 52

4.1.4 GSM Circuit Design 53

4.1.5 Microcontroller Circuit Design 54

4.2 Layout of Components on the PCB and Testing Of the Boards 56

4.2.1 Voltage Sensing Circuit Layout 56

4.2.2 Current Sensing Circuit Layout 57

4.2.3 Relay Circuit Layout 58

4.2.4 Microcontroller Circuit Layout 59

4.2.5 GSM Circuit Layout 60

4.3 Coupling of Different Units and Testing 61

4.4 Packaging 63

4.5 Final Testing and Project Evaluation 64

4.5.1 No Load Test 64

x

4.5.2 Varying Load Test 65

4.5.3 GSM Signalling Tests 67

4.6 Project Evaluation 69

Chapter Five – CONCLUSION AND RECOMMENDATION 70

5.1 Conclusion 70

5.2 Challenges 71

5.3 Recommendations 71

References 72

Appendix I – The Compiled C Code for the Programmed Atmega8a 74

Appendix II – SMS Service Commands 94

xi

LIST OF FIGURES

Figure 2.1 Electrolytic Meter 10

Figure 2.2 Pendulum Meter 11

Figure 2.3 Motor Meter 12

Figure 2.4 Induction Meter 13

Figure 2.5 Electronic Meter 14

Figure 2.6 Smart Meters 15

Figure 2.7 Electromechanical Meter 17

Figure 2.8 Electronic Meter 19

Figure 2.9 Centre Tapped Transformer 23

Figure 2.10 Liquid Crystal Display 28

Figure 2.11 Overview of GSM Modem 29

Figure 2.12 GSM Module Design 30

Figure 2.13 Disconnection Relay 31

Figure 2.14 ATmega8A IC 32

Figure 2.15 ATmega8A pin Configuration 33

Figure 2.16 Internal Structure of Atmega8a Microcontroller 35

xii

Figure 3.1 Block Diagram of the Real Time Metering System 36

Figure 3.2 Circuit to Measure Phase Voltage 38

Figure 3.3 Dummy Resistor Method 39

Figure 3.4 Current Sensing Circuit Using A Monitored Voltage 40

Figure 3.5 Conversion circuit for AC Monitored Voltage to DC Voltage 40

Figure 3.6 Power Supply Circuit 41

Figure 3.7 Power Supply Circuit for Relay 42

Figure 3.8 Relay Circuit 43

Figure 3.9 Load Circuit 44

Figure 3.10 LED Circuit 45

Figure 3.11 Interface Button Circuit 45

Figure 3.12 GSM Module Interfacing Circuit 46

Figure 3.13 Serial Interface Description 47

Figure 3.14 Microcontroller Circuit 48

Figure 4.1 Voltage Sensing and Power Supply Circuit PCB Design 51

Figure 4.2 Current Sensing Circuit PCB Design 52

Figure 4.3 Relay Circuit PCB Design 53

Figure 4.4 GSM Circuit PCB design 54

xiii

Figure 4.5 Microcontroller Circuit PCB Design 55

Figure 4.6 Voltage Sensing Circuit Layout 56

Figure 4.7 Current Sensing Circuit Layout 57

Figure 4.8 Relay Circuit Layout 59

Figure 4.9 Microcontroller Circuit Layout 60

Figure 4.10 GSM Circuit Layout 61

Figure 4.11 Coupling of Units and Testing With Load 62

Figure 4.12 Testing Again Of Some Circuits 62

Figure 4.13 Packaging the Project 63

Figure 4.14 No Load Test 64

Figure 4.15 Variable Load Test 66

Figure 4.16 Interactive Meter Reading For 300 Watt Load 66

Figure 4.17 SMS Sent From the Meter 69

xiv

LIST OF TABLES

Table 2.1 Comparison of the Different Types of Meter 21

Table 2.2 Benefits and Drawbacks of Current Sensing Technologies 26

Table 2.3 Specifications of the GSM Module 29

Table 2.4 Features of the GSM Module 30

Table 4.1 Current Sensing Results 58

Table 4.2 Results from No Load Test 65

Table 4.3 Result from Variable Load Test 67

1

CHAPTER ONE

INTRODUCTION

1.1 BACKGROUND

Electrical energy in Nigeria has indeed come to stay. We have finally come to agree and

accept the fact that we cannot do without it. A large part of the Nigerian economy today in

one form or the other depends on its stability and availability. It lights up our streets and

power up a lot of home appliances that make our residential homes more comfortable.

Most of the machines in our industries run on electricity and so do radio and television

long range transmitters. The researcher believes that we have come to a point where

electrical energy form part of our day to day life and affair. This conclusion is very

important as it brings to limelight a very important premise. This important and transmitted

electrical energy has to be paid for.

The importance of quality in electrical energy measurement cannot be over emphasized.

Accuracy, safety, fast time collection and simplicity in data collection are some of the

things to watch out for in an effective measurement and payment system. Hence over the

years, there has been need for various improvements by engineers in the ways and means

of electrical metering.

Metering is the process of measuring energy consumed in different or varying forms. This

could be energy from water, gas, heat, electricity etc. In electricity, metering, also known

as power metering is the process of effectively determining and monitoring power

consumption.

2

The single phase meter is most of the times used for electrical energy measurement. This is

because most of the residential homes use single phase connection system. It is designed

with the aim of measuring the power from electrical components across a single phase

connection and then giving the equivalent energy for the measured power with respect to

time. This value is used by utility companies to ensure proper billing of consumers.

In Nigeria, post-paid metering has not been very successful giving consideration to the

inadequacies of the public utility company, Ibadan Electricity Distribution Company

(I.B.E.D.C). This could be attributed to the unavailability of enough man-power to take

down energy readings for billing, archaic methods of data storage and processing,

inaccessibility of the meters in rural areas, etc. This results in I.B.E.D.C opting for the use

of estimated bills instead of actual bills in most of the cases.

In recent times, advances have been made in the field of metering and it can be said to be

one of the fastest growing areas in electrical and electronic engineering with the advent of

embedded systems. In most developed nations, pre-paid metering is being employed on a

full scale basis and also remote metering (accessing of data in a meter from a remote

location). But such deployment of meter technology is yet to be implemented on a large

scale in most of Sub-Saharan Africa (Nigeria inclusive) Hence: the need for this project.

Although this meter is a single phase meter, a three phase meter which would have more

applications in places involving more loads and three phase electrical connections can also

be designed and constructed. Due to time constraint, scope of study and shortage of funds,

this project has been limited to a single phase meter.

3

1.2 PROBLEM STATEMENT

The known traditional way of meter reading for electricity consumption and billing in

Nigeria has always been by human operators. They visit from one place to another

periodically. This requires more time to collect data regarding energy consumption by

users and also require more labour operators. Moreover, human operator billing are usually

prone to error as some locations are not easily accessible for reading energy consumption.

These errors may be due to bad weather conditions or violence in a part of the country.

Printed bills also do get missing, leaving the user in a confused state over his or her bills.

A user with a very tight work schedule may not have the time to check or be around when

the human operators come for billing. Physically disable person are also unable to get

information and alert signal regarding power consumption.

Most energy users also do not have an idea of the exact and immediate power reading from

their homes. Knowledge of this would be a very great and important tool in emphasizing

energy conservation on the part of the user.

Most of the recent smart meters we have around use a common metering chip, ADE7755.

It has been observed that it cannot detect small changes in power. This is not a true

representation of an ideal smart meter which should be able to measure very accurately and

precisely energy consumptions.

In order to achieve efficient meter reading, real time power monitoring, reduce billing

errors and operation cost, The Micro-Controller based GSM Interactive Energy Meter play

a vital role to addressing the above mentioned problems.

4

1.3 AIM AND OBJECTIVES

The aim of this project is to design and develop a real time electrical energy monitoring

system for remote data acquisition. This remote data acquisition system will utilize the

existing wireless communication network (GSM) to transfer and store information in a

database which can be accessed by authorized personnel who are operators of the

distribution network, researchers and academicians. Data collection sets ground for load

forecasting, dynamic pricing, distribution prioritizing, energy design, power analysis and

waste reduction.

The objectives of this project are:

1) To measure current and voltage signals using appropriate sensors.

2) To interface a GSM module for wireless transmission.

3) To write a microcontroller program that will control the GSM module, indication

LED‟S and other user interface buttons. The program would also be able to interprete

current and voltage signals and carry out the necessary power and energy calculations.

4) Ensure that the whole project is done using PCB technology and packaged.

5) Calibrate energy meter and carry out project evaluation.

5

1.4 PARAMETERS TO BE MEASURED

It is intended to measure the RMS values of current and voltage. Eventually, information

obtained will be used to calculate power and energy.

1.5 SIGNIFICANCE OF STUDY

Working on this project is an opportunity to gain sufficient knowledge on instrumentation

and data acquisition techniques. Also, design and project management skills will be

obtained by carrying out the project diligently. Beyond these gains, the project intends to

provide real time and efficient data acquisition in the area of electricity consumption in

Nigeria.

Also, Energy users would be able to monitor the extent of immediate power usage from

their energy meters. This would over time encourage energy conservation on the part of

users.

1.6 MOTIVATION FOR THE PROJECT

From experience gained during SIWES (Student Industrial Work Experience Scheme)

program in an electronic company (Digitouch Electronics), the Researcher got interested in

building and assembling electronic devices. The use of PROTEUS for circuit simulations,

use of PCB technology and assembly of devices got the researcher interested in the project.

The GSM interactivity was added to the project because the researcher wanted to know

how to interface and work with GSM technology.

6

1.7 SCOPE AND LIMITATION OF STUDY

The scope of this project is to achieve the stated objectives including placing of the project

on a locally made Printed Circuit Board (PCB). Due to time constraint, shortage of funds

and lack of good technical know-how on writing and developing system software, this

project will also be limited to SMS, as a mode of communication instead of GPRS which is

more efficient and secured.

The scope of this project is the measurement of electrical signals by relevant transducers

and converting the signals generated to digital signals and then transmitted over the

existing GSM network to a database.

7

CHAPTER TWO

LITERATURE REVIEW

2.1 BRIEF HISTORY OF METERING

As commercial use of electric power spread in the 1880s (Hammond, 1941), it

became increasingly important that an electrical energy meter, similar to the then existing

gas meter was required to properly bill customers for the cost of energy instead of

billing for a fixed number of lamps per month. Many experimental types of meter were

developed. Thomas Edison at first worked on a DC electromechanical meter with a

direct reading register, but instead developed an electrochemical metering system

which used an electrolytic cell to totalize current consumption. At periodic intervals

the plates were removed, weighed, and the customer billed (Lanphur, 1925).

The electrochemical meter was labour-intensive to read and not well received by

customers. In 1885 Ferranti offered a mercury motor meter with a register similar to gas

meters; this had the advantage that the consumer could easily read the meter and verify

consumption. The first accurate recording electricity consumption meter was a DC meter

by Dr Hermann Aron, who patented it in 1883 (Hammond, 1941). Hugo Hirst of

the British General Electric Company introduced it commercially into Great Britain

from 1888. Meters had been used prior to this, but they measured the rate of power

consumption at that particular moment. Dr Hermann Aron‟s meter recorded the total

energy used over time, and showed it on a series of clock dials.

The first specimen of the AC kilowatt-hour meter produced on the basis of Hungarian

Ottó Bláthy's patent and named after him was presented by the Ganz Works at the

8

Frankfurt Fair in the autumn of 1889 (Hammond, 1941), and the first induction

kilowatt-hour meter was already marketed by the factory at the end of the same year.

These were the first Alternating- Current watt meters known by the name of Bláthy-meters.

The AC kilowatt hour meters used at present operate on the same principle as Bláthy's

original invention.

Around 1889, Elihu Thomson of the American General Electric

Company developed a recording watt meter based on an ironless commutator motor

(Edison Electrical Institute, 2002). This meter overcame the disadvantages of the

electrochemical type and could operate on either alternating or direct current.

In 1894 Oliver Shallenberger of the Westinghouse Electric Corporation applied the

induction principle previously used only in AC ampere-hour meters to produce a watt-hour

meter of the modern electromechanical form, using an induction disk whose rotational

speed was made proportional to the power in the circuit. Although the induction

meter would only work on alternating current, it eliminated the delicate and

troublesome commutator of the Thomson design (Lanphur, 1925).

General Electric introduced its first attempt at a polyphase meter known simply as the

Thomson Polyphase Wattmeter. This meter was massive due to the large disk and

widely spaced stators in an attempt to eliminate interference between the stators. It

was not very popular since the industry preferred a more compact meter.

An engineer at Westinghouse, Paul McGahan came up with a workable design for

polyphase meters (Lanphur, 1925). Two single-phase meters were installed in a tall case

with a common shaft and register. This design was adopted by all manufacturers and built

in various forms until 1969.

With the advances in electronics in the 1970s, manufacturers started introducing the

electronic registers and automatic meter reading device. By mid 1980s, manufacturers

9

started offering hybrid meters with electronic registers mounted on induction-type meters.

By the early 1990s, further advances in electronics allowed the manufacturers to

start introducing meters that were fully electronic and used no moving parts (aside

from the switches used to access various functions on the meters). Following

acceptance of the new electronic meters, the manufacturers begin dropping induction-type

polyphase models from their product lines, and when electronic single phase models

became feasible and popular, all manufacturers cut back on and some discontinued the

single phase models (Okeola, 2008).

2.2 EVOLUTION OF METERS

Smart meters are now in use in most countries. It has made a lot of things easier, but there

is still a great need to look into how this meter has evolved over the years. First from the

slow and inefficient electrolytic types and now to the electronic ones that has made smart

metering possible.

2.2.1 Electrolytic Meters

The Electrical distribution company set up by Thomas Edison was used for lighting and

was implemented using direct current. Thomas created his own technology to sell

electricity. His technology used the electrochemical effect of current for its measurement

and billing. It contained an electrolytic cell into which accurately weighed strip of copper

is placed at the beginning of the billing period. The current passing through the electrolyte

causes a deposition of the copper. At the end of the billing period, the copper strip is then

weighed again. The difference of the weights before and after the billing period is

proportional to the current that passed through the entire billing period.

10

The shortcomings of this electrolytic meter include discomfort to both utility and customer

when taking readings and they could only measure ampere-hours and were not suitable

when voltage fluctuated. Figure 2.1 shows an electrolytic meter.

Figure 2.1: Electrolytic Meter

2.2.2 Pendulum Meters

In its more advanced form this meter had two pendulums, with a coil on both pendulums

connected to the voltage. Below the pendulums there were two current coils winding in

opposite directions. One of the pendulums therefore was running slower and the other

faster than without load. The difference between the oscillation times drove the counting

mechanism. The role of the two pendulums was swapped every minute, so that the initial

difference between the oscillation times of the pendulums could be compensated. At the

11

same time, the clock was wound up. These meters were expensive because they contained

two clocks, and they were gradually replaced by motor meters. Pendulum meters measured

ampere-hours or watt-hours, but could be used only for direct current. Figure 2.2 shows a

pendulum meter.

Figure 2.2: Pendulum Meter

2.2.3 Motor Meters

In such meters, the driving torque is proportional to the load and is balanced by a braking

torque, so that the rotor speed is proportional to the load when the torques is in

equilibrium.

12

The American Elihu Thomson (1853- 1937) developed his „Recording wattmeter‟ in 1889

for General Electric. It was an iron-less motor, with the rotor excited by the voltage

through a coil and a resistor, using a commutator. The stator was excited by the current,

and the driving torque was therefore proportional to the product of voltage and current.

The braking torque was provided by a permanent magnet acting on an aluminium disk,

fixed to the rotor.

This meter was used mainly for DC. The big disadvantage of the motor meters was the

commutator. Figure 2.3 shows a motor meter.

Figure 2.3: Motor Meter

13

2.2.4 Induction Meters

With the invention of Alternating current by Nikola Tesla and later the transformer came

the induction meters. Oliver Blackburn Shallenberger (1860-1898) developed an induction

type watt-hour meter for Westinghouse in 1894. It had the current and voltage coils located

on opposite sides of the disc, and two permanent magnets damping the same disc. It was

also large and heavy, weighing 41 pounds. It had a drum-type register. Ludwig Gutmann,

working for Sangamo, developed the “Type A” AC watt-hour meter in 1899. The rotor was

a spirally slotted cylinder positioned in the fields of the voltage and current coils. A disk

riveted to the bottom of the cylinder was used for braking with a permanent magnet. There

was no power factor adjustment. Figure 2.4 shows an induction meter.

Figure 2.4: Induction Meter

14

2.2.5 Electronic Meters

Electronic technologies did not find their way to metering until the first analogue and

digital integrated circuits became available in the 1970s. This can easily be understood if

one thinks of the power consumption limitations in the closed meter boxes, and the

expected reliability.

The new technology has given a new impetus to the development of electricity meters.

Initially, high precision static meters were developed, mainly using the time division

multiplication principle. Hall cells were also used, primarily for commercial and residential

meters. Hybrid meters consisting of induction meters and electronic tariff units were

constructed in the 1980s. This technology had a relatively short run. Figure 2.5 shows an

electronic meter.

Figure 2.5: Electronic Meter

15

2.2.6 Remote Monitoring of Meters

The idea of remote metering was born in the 1960s. Initially, remote pulse transmission

was used, but this has gradually been replaced by using various protocols and

communication media. Today meters with complex functionality are based on the

latest electronic

technology, using digital signal processing, with most functions being implemented

in firmware. These meters are collectively called smart meters. Figure 2.6 shows smart

meters.

Figure 2.6: Smart Meters

16

2.3 TYPES OF ENERGY METERS

Electricity meters operate by continuously measuring the instantaneous voltage (volts)

and current (amperes) and finding the product of these to give instantaneous

electrical power (watts) which is then integrated against time to give energy used (joules,

kilowatt-hours etc.).

Meters for smaller services (such as small residential customers) can be connected directly

in-line between source and customer. For larger loads, more than about 200 ampere of

load, current transformers are used, so that the meter can be located other than in

line with the service conductors. Apart from the evolution of energy meters which

showed how they advanced in years, the meters generally fall into two basic categories,

electromechanical and electronic.

2.3.1 The Electromechanical Meter

The electromechanical induction meter operates by counting the revolutions of an

aluminium disc which is made to rotate at a speed proportional to the power. The number

of revolutions is thus proportional to the energy usage. It consumes a small amount of

power, typically around 2 watts (Nagarju, 1998).

The metallic disc is acted upon by two coils. One coil is connected in such a way that it

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 the effect is such that a force is

exerted on the disc in proportion 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. The equilibrium between these two opposing forces results in the disc

17

rotating at a speed proportional to the power being used. The disc drives a register

mechanism which integrates the speed of the disc over time by counting revolutions, much

like the odometer in a car, in order to render a measurement of the total energy used over a

period of time. Figure 2.7 shows an electromechanical meter.

Figure 2.7: Electromechanical Meter

Let The amount of energy represented by one revolution of the disc be denoted by the

symbols Kh which is given in units of watt-hour per revolution. Using the value of Kh, one

can determine the power consumption at any given time by timing the disc with a

stopwatch (Chengi, 2008). If the time in seconds taken by the disc to complete one

revolution is T, then the power P in watts is given by

P = 3600 * Kh / T 2.1

18

For example if Kh = 10.5 and one revolution takes place in 15 seconds, the power is

therefore;

P = 3600 * 10.5 / 15

P = 2520 Watt

This method can be used to determine the power consumption of household devices

by switching them one by one. In an induction type meter “creep” can adversely affect

accuracy, which occurs when the meter disc rotates continuously with potential applied.

2.3.2 The Electronic Meter

Electronic meters display the energy used on an LCD (Liquid Crystal Display) or

LED display, and can also transmit readings to remote places. This meter has an

analogue or digital conversion of the current and voltage supply, signals filtering and

the multiplying of the acquired information as requested e.g. kWh, Watts, Power factor

etc. The specified voltage value at the user interface is about 110V-240V. It has a 20%

margin and 20A-80A for the current while inside the meter the electronic component uses

about 5V-12V dc voltage and a minimum 200mA current (Calo, 2006).

Added to measuring electricity, the electronic meter can also record other parameters of the

load and supply such as maximum demand, power factor. It includes electronic clock

mechanisms to compute a value, rather than an amount of electricity consumed, with

the pricing varying seasonally. Figure 2.8 shows an electronic meter.

19

Figure 2.8: Electronic Meter

An electronic meter design has a power supply, a metering chip, a processing and

communication module (i.e. A microcontroller), and other modules such as RTC,

EPROM, LCD display, modem (in the case of GPRS/SMS mode of communication), etc.

The metering module has the voltage and current inputs and has a voltage reference,

samplers and quantizers. It also consists of an ADC (Analogue to Digital Conversion)

section to yield the digitized equivalents of all the inputs. They are then processed with the

20

use of a Digital Signal Processor for calculation of metering parameters such as powers,

energies etc.

The largest source of long-term errors in the meter is drift in the preamp and next

is the precision of the voltage reference. They both vary with temperature as well and vary

widely because most meters are outdoors. Creating compensation for these is a major part

of meter design. The processing and communication section is responsible for calculating

the various derived quantities from the digital values generated by the metering circuitry.

2.4 COMPARISON OF VARIOUS TYPES OF METERS

The electromechanical meter is inadequate due to a problem called „creep‟. This is the

continuous rotation of the meter disc with potential applied over a period of time.

The phenomenon affects the accuracy of the meter and also the ability of some engineers

to make alterations to the springs and gears in the meter in a bid to slow down the reading

of the meter make it very vulnerable (Edison Electrical Institute, 2002). The later

improvement was the electronic meter which is smaller, more economical and easier to get

precise data calculations from the meter. The electronic meter cannot be compromised

once it has gone through the production stage, any form of alteration on the meter

after its production, could lead to permanent damage of the meter. Table 2.1 shows a

comparison of the different types of meters.

21

Table 2.1: Comparison of the Different Types of Meter

Functions Electromechanical Electronic Smart Meter

Measurement Coil, rotating disc

and counters

ADC‟s, DSP-

Microprocessor

Metering and

communication ASIC

Storage Nil EPROM, RAM

and Flash

EPROM, RAM and Flash

Communication Nil Optical/

RS232/RS485

PLC/GPRS/CDMA/RF

Mesh/ Wi-max

Protocols Nil Proprietary/ open

Protocols

Open Protocols DLMS

(IEC-62056)/ ANSI

C12/M – Bus

Other Functions Nil Multi-tariff,

billing schedules

Remote

connection/disconnection,

demand response/ real

time pricing/ sub meter/

HAN

2.5 CURRENT TRENDS IN METERING TECHNOLOGY

The problems in conventional manual metering system motivated the technologists to go

for alternative automatic methods for determining the consumption of electricity. The

primary driver for the automation of meter reading is not only to reduce labour

costs but also to resolve the problem of high system cost, inaccurate energy calculation,

22

grounding and noise interfacing, tamper detection capability and fault clearance. Most

electric meters especially in multi-storied buildings in metro cities, are located in places

that cannot be accessed by the utility company and require an appointment with the

homeowner for the purpose of meter reading. Electricity tends to be a more valuable

commodity as compared to others and the consumed energy must be measured through

actual readings rather than estimated readings.

2.5.1 Pre-Paid Metering (GPRS Meter)

This requires the customer to make advance payment before electricity can be used. If the

available credit is exhausted then the supply of electricity is cut off by a latching relay.

This form of meter communication is very preferred because it offers you the opportunity

to communicate with the meter in real time. Unlike other communication systems, it is one

which is always online. Meters connected via GPRS can then communicate with the

BCS (base computer station) automatically. The base computer station is simply

where the management systems for the GPRS meters are located. In cases of errors,

alarms can be raised by the specified meter to the BCS.

First, the meter has a SIM card with which it is able to communicate with the base station

by recording an IP address of the BCS in its SIM card. The GPRS service provider

(typically mobile phone service provider) will then charge on the quantum of data transfer

and not on connection time. The GPRS is the fastest and cheapest system for remote

monitoring of HT (high tension) meters (Okeola, 2008).

23

2.6 LITERATURE BACKGROUND OF THE MAJOR DEVICES USED

A lot of electrical components were used in the process of completing this project. Some of

these components are new to the researcher. Hence understanding them and how they work

is of great importance.

2.6.1 Voltage Transducer (VT)

Voltage transformer gets used in electrical power system for stepping down the

system voltage to a safe value which can be fed to low ratings meters and relays.

Commercially available relays and meters used for protection and metering, are designed

for low voltage.

The voltage transformer steps down the system voltage by a proportion which is the

transformation ratio. The output voltage on the secondary is connected to suitable

amplifiers or other signal conditioning circuit to carryout measurement or control. Figure

2.9 shows a centre tapped transformer.

Figure 2.9: Centre Tapped Transformer

24

2.6.2 Current Transducer (CT)

Measuring electrical current can be done using several methods. There are three methods

that are typically used for measuring current: sense resistors, current transformers and Hall

Effect sensors. Each has attributes that differentiate them on a cost versus performance

scale.

General characteristics of different current measurement methods are discussed:

2.6.2.1 Sense Resistor

The most commonly used method for measuring current is to run the current through

a known resistor. The voltage drop over this resistor is determined by the current and

the resistor value. A low value resistance is placed in the circuit and the voltage

across it measured. Select a small resistance does not cause much voltage drop over it, so

measuring does not considerably complex measured circuit. The resistance is known as a

shunt. Any resistance may be used but for large currents and precise results special shunt

resistor are available.

They usually have high power dissipation, no galvanic isolation, low cost and are typically

used for low currents.

2.6.2.2 Current Transformer

The current transformer outputs a secondary current proportional to the input

primary current. The output current can then be easily measured or used as control for

other circuits.

25

The primary winding is connected in series with the source current to be measured, while

the secondary winding is normally connected to a meter, relay, device or a burden resistor

to develop a low level voltage that is amplified for control purposes. In many high current

applications the primary coil is just wire going through the toroid core of the

current transformer (equivalent to one turn primary coil). When using just one wire going

through the core, that wire can easily made thick enough to be able to handle large

currents.

Current transformers are relatively simple to implement and are passive devices that do not

require driving circuitry to operate. The primary current (AC) will generate a magnetic

field that is coupled into a secondary coil by Faraday‟s Law. The magnitude of the

secondary current is proportional to the number of turns in the coil, which is typically as

high as 1000 turns or even more. Output coil outputs give the indication of the current

(voltage directly proportional to the current) and provide galvanic isolation. This technique

has the advantage that the secondary can be grounded – there is no common mode voltage

to deal with.

2.6.2.3 Hall Effect Sensor

The Hall Effect uses a semiconductor sensor to convert the magnetic field accompanying

the measurement current, into a signal voltage. The output includes both DC and AC

components, which makes it attractive

Table 2.2 shows the benefits and drawbacks of current sensing technologies.

26

Table 2.2: Benefits and Drawbacks of Current Sensing Technologies

2.6.3 The Liquid Crystal Display

The liquid crystal display is an electro-optical device used to display digits and characters.

This display is a 20 x 4 (still contended) display which would display power consumption

in watts, energy consumption in KWH and the time elapsed. The LCD would be an

alphanumeric type to aid the display of letters.

The LCD is becoming largely popular and replacing the use of LEDs for the

Sensor Benefits Drawback

Sense Resistor Very low cost, good linearity Poor high current

capability, no galvanic

isolation, usually high

power dissipation

Current transformer High current performance,

low power consumption,

Works only for AC phase

shift problem, larger size

Hall Effect Sensor High current performance,

good linearity, optimized

response time, No insertion

losses, Capable AC and DC

wide dynamic range,

provides galvanic isolation

Higher cost, Moderate to

high power consumption.

27

following reasons:

LCDs are more affordable.

They can display numbers, characters and graphics but this cannot be done by LEDs

due to limited numbers and characters.

Incorporation of a refreshing controller into the LCD thereby relieving the CPU of the

tasks of refreshing the LCD. This cannot be done in the LED because it must be refreshed

by the CPU.

Easier programming for characters and graphics.

The LCD unit may also be operated with dual 4-bit or single 8-bit data transfers in order to

accommodate interfaces with both 4-bit and 8-bit microcontrollers.

LCD (liquid crystal display) is the technology used for displays in notebook and other

smaller computers. Like light-emitting diode (LED) and gas-plasma technologies, LCDs

allow displays to be much thinner than cathode ray tube (CRT) technology. LCDs consume

much less power than LED and gas-display displays because they work on the principle of

blocking light rather than emitting it.

An LCD is made with either a passive matrix or an active matrix display grid. The active

matrix LCD is also known as a thin film transistor (TFT) display. The passive matrix LCD

has a grid of conductors with pixels located at each intersection in the grid. A current is

sent across two conductors on the grid to control the light for any pixel. An active matrix

has a transistor located at each pixel intersection, requiring less current to control the

luminance of a pixel. For this reason, the current in an active matrix display can be

switched on and off more frequently; improving the screen refresh time (your mouse will

appear to move more smoothly across the screen, for example).

Some passive matrix LCD's have dual scanning, meaning that they scan the grid twice with

28

current in the same time that it took for one scan in the original technology. However,

active matrix is still a superior technology. Figure 2.10 shows a Liquid Crystal display.

Figure 2.10: Liquid Crystal Display

2.6.4 The EEPROM (External Erasable Programmable Read Only Memory)

External memory exists off chip in the form of EEPROM. This is a serial in out memory.

Serial memory devices offer significant advantages over parallel devices in

applications where lower data transfer rates are acceptable. In addition to requiring less

board space, serial devices allow microcontroller I/O pins to be conserved. It is used in this

project as a complement to the micro-controller to store the energy values. These values

are stored here in the advent of power outage so that the LCD can continue to display after

the power returns.

29

2.6.5 The GSM Module (NEOWAY, M590)

The GSM module is used for the wireless communication. M590 pure-data

Communication Module is an ultra-compact GSM/GPRS industrial wireless module,

optional Dual-band or Quad-band. It provides a high-quality SMS, GPRS data connection

for use in industrial and commercial fields

Neo_M590 is a kind of GSM/GPRS wireless module for dual-band. It has SMS, data

service and other functions. This modem is used to aid the communication of the meter

through the microcontroller via SMS. Table 2.3 shows design specifications of the module.

Table 2.3: Specifications of GSM Module

SPECIFICATIONS DESCRIPTIONS

Dimensions 27.6mm*21.6mm*2.6mm

(length*width*height)

Weight 5g

Overview

Figure 2.11: Overview Of GSM Modem

30

Table 2.4: Features of the GSM Module

Table 2.4 shows the features of the GSM Module while figure 2.12 shows the GSM

module design.

Figure 2.12: GSM Module Design

31

2.6.6 The Disconnection Relay

A relay is a switch that is electrically operated. Current flowing through the relay coil

creates a magnetic field which attracts a lever and changes the switch contacts. The coil

current can be on or off so relays have two switch positions and most have changeover

switch contacts as shown in the diagram. Relays allow one circuit to switch a second

circuit which is completely isolated from the first. There is no electrical connection inside

the relay between the two circuits i.e., the link is magnetic and mechanical.

The latching relay is bi-stable (two relaxed states). When the current is switched off, the

relay remains in previous state. This is achieved with a solenoid having two opposing coils

with an over-centre spring or permanent magnet to hold the armature and contacts in

position while the coil is relaxed. This type of relay has the advantage of consuming power

only for an instant, while it is being switched and it retains its last setting across a power

outage. Thus, only a clear signal from the microcontroller will activate the relay.

Figure 2.13: Disconnection Relay

2.6.7 The Microcontroller, ATmega8A

The microcontroller is at the centre of this project because it controls all important

components and performs the necessary power and energy calculations. Care has to be

32

taken on the type of Micro-controller used as each micro controller has its own merit and

demerit. The Atmega8 AVR controller was chosen because it is affordable, has a fast time

response and it can be programmed with the C language.

The ATmega8A is a low-power CMOS 8-bit microcontroller based on the AVR RISC

architecture. By executing powerful instructions in a single clock cycle, the ATmega8A

achieves throughputs approaching 1 MIPS per MHz, allowing the system designer to

optimize power consumption versus processing speed. Figure 2.14 shows the integrated

circuit which is a dual in line package.

Figure 2.14: ATmega8A IC

Figure 2.15 shows the pin configuration for the microcontroller. It has 28 pins. The AVR

core combines a rich instruction set with 32 general purpose working registers. All the 32

registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two

independent registers to be accessed in one single instruction executed in one clock cycle.

The resulting architecture is more code efficient while achieving throughputs up to ten

times faster than conventional CISC microcontrollers.

33

Figure 2.15: ATmega8A Pin Configuration

The AVR core combines a rich instruction set with 32 general purpose working registers.

All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing

two independent registers to be accessed in one single instruction executed in one clock

cycle. The resulting architecture is more code efficient while achieving throughputs up to

ten times faster than conventional CISC microcontrollers.

34

The ATmega8A provides the following features: 8K bytes of In-System Programmable

Flash with Read-While-Write capabilities, 512 bytes of EEPROM, 1K byte of SRAM, 23

general purpose I/O lines, 32 general purpose working registers, three flexible

Timer/Counters with compare modes, internal and external interrupts, a serial

programmable USART, a byte oriented Two-wire Serial Interface, a 6-channel ADC (eight

channels in TQFP and QFN/MLF packages) with 10-bit accuracy, a programmable

Watchdog Timer with Internal Oscillator, an SPI serial port, and five software selectable

power saving modes. The Idle mode stops the CPU while allowing the SRAM,

Timer/Counters, SPI port, and interrupt system to continue functioning. The Power-down

mode saves the register contents but freezes the Oscillator, disabling all other chi functions

until the next Interrupt or Hardware Reset. In Power-save mode, the asynchronous timer

continues to run, allowing the user to maintain a timer base while the rest of the device is

sleeping. The ADC Noise Reduction mode stops the CPU and all I/O modules except

asynchronous timer and ADC, to minimize switching noise during ADC conversions. In

Standby mode, the crystal/resonator Oscillator is running while the rest of the device is

sleeping. This allows very fast start-up combined with low-power consumption.

The ATmega8A AVR is supported with a full suite of program and system development

tools, including C compilers, macro assemblers, program debugger/simulators, In-Circuit

Emulators, and evaluation kits. Figure 2.16 shows the internal structure of ATmega8A

microcontroller.

35

Figure 2.16: Internal Structure of ATmega8A microcontroller

36

CHAPTER THREE

DESIGN METHODOLOGY

3.1 INTRODUCTION

The real time electrical energy monitoring system for remote data acquisition is designed

by combining a set of modular units. For the purpose of this work, the project is divided

into four modules which are described in full details below. The modular concept in design

is used because it makes the work easier to construct, implement and debug. Figure 3.1

shows the block diagram of the whole system.

The five different modules are listed below. They are:

Phase Voltage sensing ( Hardware)

Phase Current sensing ( Hardware)

Added Circuits (Hardware)

Communication and control circuit(Hardware and Software)

Figure 3.1: Block Diagram of the Real Time Metering System

37

3.2 PHASE VOLTAGE SENSING

A circuit is constructed to measure the phase voltage. In designing this circuit, the aim is to

measure the root-mean-square value of the voltage. It is very difficult (and quite

expensive) to measure the RMS value of the phase voltage. For this reason, the average

DC value of the phase voltage is measured and then this is converted to the RMS value by

applying some of the equations described later in this chapter.

A 220V to 12V centre tapped transformer is used to step down the AC voltage to DC

voltage. To convert this AC voltage to DC, a rectification circuit is used. Two diodes are

used to rectify the AC voltage to a DC average value. Capacitors are not used for

smoothing the output because it gives a poor time response to change in voltage value. The

output voltage is fed into the microcontroller.

Current practices require the use of a buffer between the voltage sensing circuit and the

microcontroller to avoid loading effect but this is not considered in this project. The

loading effect is assumed negligible.

The microcontroller used, ATmega8A has an internal analogue to digital converter which

makes interfacing easy, hence resistors are used to step down the DC voltage to a value

that can work and be interfaced with the microcontroller.

ref

inout

v

vv

1024

3.1

Where

VOUT is the output of the Analogue to Digital Converter

VIN is the input DC voltage to the Microcontroller

VREF is the reference voltage of the ADC of ATmega8A which is 2.56V

38

During calibration, the variable resistor is tuned until the output of the circuit gives a gain

of 0.01. Hence if the input AC voltage is 210V, the DC output is 2.1V. This is converted

back to RMS value by the codes in the microcontroller after conversion to a digital value.

Figure 3.2 shows the circuit used to measure phase voltage.

Figure 3.2: Circuit to Measure Phase Voltage

3.3 PHASE CURRENT SENSING

The phase current sensing circuit is divided into two parts.

- Current sensing circuit using a monitored voltage

- Conversion of the AC monitored voltage to DC voltage

There are numerous ways of sensing current in a circuit. Some of them include using a

current transformer or dedicated integrated circuits. The method used for current sensing in

this project is the dummy resistor method. This is shown in figure 3.3.

39

Figure 3.3: Dummy Resistor Method

Considering Figure 3.3, the current passing through R17 (Load) can be found using the

dummy resistor method. A known resistor (R16) which is the dummy resistor and with low

resistance is connected in series with the load.

V = IR 3.2

When a voltage source is connected across the resistors, there is voltage drop across the

dummy resistor. If this voltage is monitored, it can be used to monitor the changes in

current as the resistance is constant.

The value of the dummy resistor is taken to be very little so that the power that would be

dissipated and wasted by it will be very little as

P = I2R 3.3

Hence, the voltage across the resistor is connected to a differential amplifier. The amplifier

is given a gain to ensure that the output is a bit increased. The circuit is shown in figure

3.4.

40

,

Figure 3.4: Current Sensing Circuit Using a Monitored Voltage

The output cannot be fed into the microcontroller yet because it is still an AC. The output

needs to be converted to DC. This can be done by a circuit consisting of amplifiers. This is

shown in the figure 3.5.

Figure 3.5: Conversion Circuit for AC Monitored Voltage to DC Voltage

41

3.4 ADDED CIRCUITS

This consists of other circuits that revolve around the microcontroller. They are built and

tested individually before joining them to other circuits in the project.

3.4.1 Power Supply Circuits

The microcontroller used in this project, ATmega8A needs a 5V power source to function

properly. Some of the amplifiers used in the current sensing part of the circuit need a

voltage rail of 5V to -5V. The GSM modem needs a power source and so does other part of

the circuit. Hence there is need to put all these power sources all in one place so that

connecting wires can be used to connect them to where they are needed in the circuit.

A centre tapped transformer is used to step down the 220V AC to 12V AC. A rectifier is

used to convert it to DC. Two regulators are used. The 7805 is used to give a positive 5V,

while the 7905 is used to give a negative 5V. The capacitors connected are used for

smoothening the DC voltages. Thus +5V, -5V and ground can be tapped from this circuit.

This is shown in figure 3.6

Figure 3.6: Power Supply Circuit

42

It is further observed that there are parts of the circuit that need a +12V supply. This can be

tapped from the circuit in figure 3.6 by placing wires at points before the regulators, but

this would lead to loading effect. Hence another transformer is used. A rectifier is

connected to it to convert the AC to DC. This is shown in figure 3.7. A 12V regulator is

not used because it is only the relay that is connected to this supply and the relay can still

work within a range of 10V to 14V which is likely to be the output from the rectifier even

if there are voltage fluctuations.

This brings the total number of transformers used in the project to three. One is used for

the power circuit, one is used for the voltage sensing circuit while the last is used to power

up the relay. This is shown in figure 3.7

Figure 3.7: Power Supply Circuit for Relay

3.4.2 Relay Circuit

The load is connected to the relay before it is connected to the power source. This enable

the power utility company to be able to switch the relay on or off from their side. The relay

circuit is shown in figure 3.8.

43

Figure 3.8: Relay Circuit

The relay circuit is made up of a transistor and a relay. When the transistor is biased, the

transistor comes on. Hence the input voltage to the transistor is connected to the

microcontroller. An input of Logic 1 will make the transistor bias and turn on the relay. An

input of Logic 0 will make the transistor not biased and hence turn of the relay. This is

very important as it ensures that the power utility company has the power to turn on and

off access to electrical energy on the part of the consumer.

3.4.3 Load Circuit

For the purpose of this project, a load has to be assumed. The circuit for the used load in

this project is shown in figure 3.9.

44

Figure 3.9: Load Circuit

It consists of four electric bulb with different wattage connected to switches. When the

switches are altered, they give a variation in the total power of the load. A socket is also

connected so that other electrical gadgets like phone chargers could be connected to the

energy meter.

3.4.4 Status Led and Interface Button Circuit

There are two „status‟ LED implemented into the design. One is to show if the relay is on

or off. The other is used to show whether there is a request for meter reading. The Interface

button is to consent to the request. Before the meter reading is sent out, the button has to be

45

pressed. This ensures that the utility company is only allowed to read the meter with the

consent of the user. The circuit for the status Led are shown in figure 3.10. The input is

connected to the microcontroller. Logic 1 from the microcontroller would turn on the LED.

The circuit for the interface button is shown in fig 3.11. The output of the circuit is

connected to the microcontroller. A press of the button sends a logic one to the

microcontroller.

Figure 3.10: LED Circuit

Figure 3.11: Interface Button Circuit

3.5 COMMUNICATION AND CONTROL CIRCUIT

The communication is made possible by the use of the GSM module. The GSM module

that is used for this project is the Neoway M590 module. The modem (which is the modem

and the circuit built around it for proper functioning) is basically used to aid the

communication of the meter through the microcontroller via SMS.

The module is a GSM/GPRS wireless module for dual band. Incorporated in it is SMS,

46

data service and other functions. The module has the advantage of being used in two

modes, either as SMS or GPRS.

Figure 3.12: GSM Module Interfacing Circuit

Figure 3.12 shows the interfacing circuit for the GSM module. Receive and transmit pins

from the GSM circuit is connected to receive and transmit pins from the microcontroller.

The interface is usually used for AT commands, data services, updating software and so

on. Figure 3.13 shows the serial interface description.

47

Figure 3.13: Serial Interface Description

The voltage sensing circuit output and the current sensing circuit output is fed into the

micro-controller where it is interpreted and the necessary calculations can be carried out.

Most of the calculations are carried out in the software.

This is a critical unit in the power measuring system. Within the microcontroller, complex

mathematical computations and functional loops are performed to work on the sensed data

to be able to present it to humans as readable information. This unit is made up of only the

Atmega8 microcontroller and the LCD.

At the analogue input of the Atmega8, the values of voltages representing the sensed phase

current and voltage are read. Since the voltage seen by the ADC is just a representation of

the actual data that was sensed by any of the measuring device, calculations must be

done to retrieve the value of phase current and voltage that was measured. These

calculations are based on some laws that govern the components that make up the

measurement circuit. For instance, there will be voltage drops and across the transformer a

reduction in voltage occurs. Knowledge of the transformation constant and the value of

voltage drop will permit working back to the value that was actually measured.

Of importance also is the fact that of interest to this project is the RMS value of both the

48

current and the voltage. Hence, some fundamental laws of electricity will be implemented

in the processing unit to determine the value of the RMS current and voltage.

The microcontroller is interfaced with a LCD to display the current reading, Voltage,

Power and energy reading over a particular time. Figure 3.14 shows a microcontroller

circuit.

Figure 3.14 Microcontroller Circuit

49

CHAPTER FOUR

IMPLEMENTATION AND TESTING

After the circuit has passed the design stage and proper considerations have been made

based on calculations and tolerance, the components to construct the circuit were then

purchased. Very scarce components like the GSM modem and Atmega8A

microcontroller were ordered abroad, while the relatively obtainable components were

purchased within Nigeria.

The designed circuit was simulated on Proteus before transferring to the P.C.B after results

were considered satisfactory. The units were constructed and tested modularly once again

to ensure that they performed their required function before coupling the units together to

form the complete measurement system.

The implementation and testing of the project is sectioned into five parts which are;

PCB designs

Layout of Components on the PCB and testing of the boards

Coupling of the different units together and testing

Packaging

Final testing and project evaluation

50

4.1 PCB DESIGNS

The circuits are first simulated on Proteus to ensure that the circuits are functional. Another

software known as Express PCB is then used to design the printed circuit board. After the

design it is then printed unto a glossy paper.

With the help of a hot iron, the design is transferred to a copper plate that has an insulated

base. The plate is then etched by dipping it in a chemical. After this, the board is drilled

and ready for components to be soldered upon it.

4.1.1 Voltage Sensing Circuit Design

The voltage sensing circuit and the power circuit that supplies power to various

components are constructed on the same PCB to reduce space and enhance compactness.

Points for signal entry and signal output are drilled into the board. Points for board

mounting are also drilled. This is shown in figure 4.1.

51

Figure 4.1: Voltage Sensing and Power Circuit Design

4.1.2 Current Sensing Circuit Design

The current sensing circuit is designed putting in mind that high AC voltages should be

separated from the low AC voltages. The dummy resistor is moved closer to the edge of

the board to ensure this. Points for signal entry and signal output are also drilled into the

board. This is shown in figure 4.2.

52

Figure 4.2: Current Sensing Circuit Design

4.1.3 Relay Circuit Design

The relay circuit consist of the relay, transistor and a series of resistors. The ground of the

transistor and the ground of the relay are connected together. The transistor input is

connected to the microcontroller for bias voltage while the relay input is connected to a

12V supply form the power circuit. Points for signal entry and signal output are drilled into

the board. Points for board mounting are also drilled. This is shown in figure 4.3.

53

|Figure 4.3: Relay Circuit Design

4.1.4 GSM Circuit Design

The GSM circuit is designed putting the modem dimensions and pin configuration in mind.

It is designed so that the modem can stand and not lie down on the board. This would

enhance better network reception. Some resistors and capacitors are also put in place to

ensure that the modem is powered. Points for signal entry and signal output are drilled into

the board. Points for board mounting are also drilled. This is shown in figure 4.4.

54

Fig 4.4: GSM Circuit Design

4.1.5 Microcontroller Circuit Design

This is one of the most important part of the entire measurement system as it gives control

to other part of the circuit. Care has to be taken in the design of this part to ensure that

there is no bridge of signals as this may result to serious damage to components, especially

the microcontroller.

The microcontroller is placed isolated from other components. This is to ensure that there

is ventilation space. The LCD is also joined to this circuit hence the pins used for this

connections are place very close to the edge of the board.

The regulator ensures that not more than 5V gets to the microcontroller while the capacitor

filters the DC voltage and stabilizes it. Points for signal entry and signal output are drilled

into the board. Points for board mounting are also drilled. This is shown in figure 4.5.

55

Figure 4.5: Microcontroller Circuit Design

56

4.2 LAYOUT OF COMPONENTS ON THE PCB AND TESTING OF THE

BOARDS

After the boards have been etched and drilled, components are then soldered unto

the board. The boards are individually tested to ensure that there are no mistakes in

design and soldering.

4.2.1 Voltage Sensing Circuit Layout

After the voltage sensing circuit has been soldered completely. It is tested. The voltage

sensing part and the power circuit are constructed on the same board for compactness. This

is shown clearly in figure 4.6.

Figure 4.6: Voltage Sensing Circuit Layout

57

The output of the power circuit is tested and it gave 5V and -5V respectively when

measured with respect to the ground.

The Voltage sensing circuit output at first gave 0.7V. The variable resistor was tuned until

it gave a gain of 0.01. When the input voltage was 210V, it read 2.1V.

4.2.2 Current Sensing Circuit Layout

The current sensing circuit is soldered and tested. The dummy resistor was reduced by

applying more resistors in parallel. This is shown clearly in figure 4.7.

Figure 4.7: Current Sensing Circuit Layout

The circuit is tested by linking the dummy resistor with 4bulbs to act as load. The

following table was recorded.

58

Table 4.1: Current Sensing Results

Number of Bulbs put on Output Voltage (V)

1 0.62

2 1.20

3 1.76

4 2.40

The table clearly shows that there is a linear relationship between the number of bulbs put

on and the output voltage. This means that there is a relationship between the current

flowing in the bulbs and the output voltage.

4.2.3 Relay Circuit Layout

The relay circuit is soldered and tested. It is observed that it needs a 12V to power the

relay. The transistor makes it possible for 5V or logic 1 from the microcontroller to bias

the transistor and switch on the relay. When it was tested, the clicking sound was heard.

This is shown in figure 4.8.

59

Figure 4.8: Relay Circuit Layout

4.2.4 Microcontroller Circuit Layout

The microcontroller circuit is soldered and also tested. The LCD light intensity was fixed

by a resistor. A dummy program was written for the microcontroller to see if the LCD

would come on. It came on and was bright. This shows that it is working well and that the

resistor used to fix the LCD backlight is okay. The microcontroller is then removed and the

codes to control other parts of the circuit are added to it.

60

A regulator is used to ensure that not more than 5V gets to the microcontroller. The LCD is

not elevated to ensure that it easily fits during packaging of the project. This is shown in

figure 4.9.

Figure 4.9: Microcontroller Circuit Layout

4.2.5 GSM Circuit Layout

The GSM circuit part was easy to solder but the testing was tedious. This was because the

researcher was new to the codes and the modem. It was interfaced with other parts of the

61

circuit to ensure that receive and transfer pins were working properly. This is shown more

clearly in figure 4.10.

Figure 4.10: GSM Circuit Layout

4.3 COUPLING OF THE DIFFERENT UNITS AND TESTING

The individually tested parts of the system are now brought together to aid testing and

evaluation. They are mounted on a board and more tests are carried out.

This aided Comparism and progress in the project. This is the result of the variation of a

parameter in one circuit can easily be sensed in other surrounding circuits. This is shown in

figure 4.11.

62

Figure 4.11: Coupling Of Units Together and Testing With Load

During the testing, there was some part of the circuits that developed faults. Such circuits

were removed and individually tested again. This is shown in figure 4.12.

Figure 4.12: Testing Again Of Some Circuit

63

4.4 PACKAGING

All boards are all integrated into a black coloured plastic casing for the purpose of

compatibility. The plastic casing had the LCD showing through it. The package has 2 input

and output slots each all passed through terminal blocks. This is shown in figure 4.13.

Figure 4.13: Packaging the Project

64

4.5 FINAL TESTING AND PROJECT EVALUATION

After the packaging has been complete, series of tests is carried on the interactive meter.

The tests are as follows

No load test

Varying Load Test

GSM signalling Tests

4.5.1 No Load Test

The meter is put on with no load connected to it. Readings were taking from the meter and

from a multimeter. This is shown in figure 4.14.

Figure 4.14: No Load Test

65

Input voltage

reading from

multimeter (V)

Input voltage

reading by

interactive meter (V)

Difference in

readings (V)

Efficiency (%)

188.8 185 3.8 97.98

189.8 186 3.8 97.99

187.8 183 4.8 97.44

179.8 176 3.8 97.88

Table 4.2: No Load Test

The variation in the input voltage was gotten from the unstable variation from power

supply. The average efficiency of the meter is therefore calculated to be 97.82%

4.5.2 Varying Load Test

The load is varied by alternating the switch connected to the bulbs. The bulb is assumed to

have a power factor of 1. Hence

1VA = 1 Watt

The test is shown more clearly in figure 4.15 and figure 4.16. The results of the test is

reported by table 4.3.

66

Figure 4.15: Varying Of the Bulbs to Vary the Load

Figure 4.16: Interactive Meter Reading For 300 Watt Load

67

Table 4.3: Varying load test

Load Supposed

Wattage

(watt)

Voltage

shown by

meter (V)

Current

shown by

meter (A)

Power shown

by meter

(Watt)

Difference in

power readings

(Watt)

Efficiency

(%)

1 bulb 100 183.0 0.4 73.2 26.8 73.2

1 bulb 200 183.2 0.8 146.6 53.4 73.3

2 bulbs 300 180.0 1.3 234.0 66.0 78.0

2 bulbs 400 180.0 1.7 306 94.0 76.5

3 bulbs 500 170.4 2.1 357.9 142.1 71.6

The average efficiency of the meter for power reading is 74.52%.

4.5.3 GSM Signalling Tests

Three codes have been programmed into the GSM modem which it responds to. These

codes are to be sent through SMS to the phone number. The phone number of the SIM card

used for the project is 07015691154. The codes are explained below

ON ( To put on the relay that controls the load)

OFF ( To switch off the relay that controls the load)

USAGE (To request for the energy reading)

68

On Test

When the relay is off, the green LED is on and no voltage is given to the output channel.

ON is sent through SMS to the modem. It is observed that it took 3 minutes to switch on

the relay. This is indicated by the LED going off and voltage is now given to the output

channel.

Off Test

When the relay is on, the green LED is off. OFF is sent to the modem through SMS. It was

observed that it took less than two minutes to take effect and switch off the relay. This is

indicated by the LED switching on. The timing is reduced because the GSM modem is

now well booted and alert.

Usage Test

USAGE is sent to the modem and within a minute the red LED comes on to indicate that

there is a request for meter reading pending. After the consent button has been pressed, the

red LED goes off and SMS containing the energy reading is sent to the phone. The timing

is under two minutes.

69

Figure 4.17: SMS Sent from the Meter

- ID1234 shows the identity of the meter.

- 0.000002.52 WHr shows the energy reading from the meter.

4.6 PROJECT EVALUATION

It is observed that the efficiency for power measurement greatly increased as the input

voltage approached 220V. Hence for maximum efficiency of the meter, the line voltage

should be within 210V to 230V.

70

CHAPTER FIVE

CONCLUSION AND RECOMMENDATION

5.1 CONCLUSION

In conclusion, advancement in metering technology has provided a means of

effectively measuring, controlling and monitoring electrical energy. This was achieved by

using the dummy resistor method for current sensing and incorporating a GSM modem for

wireless communication.

The objectives achieved in this project include:

1) Measuring current and voltage signals using appropriate sensors.

2) Designing a circuit that will interpret the signals and use them to perform power

calculations.

3) Writing a microcontroller program to carry out all current, voltage, power and energy

calculations.

4) Interfacing a GSM module for wireless transmission.

5) Rewriting the microcontroller program to control the GSM module, indication LED‟S

and other user interface buttons.

6) Ensuring that the whole project is done using PCB technology and packaged.

7) Calibrating the energy meter and carrying out project evaluation.

71

5.2 CHALLENGES

Some of the challenges faced in executing this project include:

There was difficulty in getting some important components within Nigeria. The

solution was to import these components. The delay in transportation put the

project on hold for a significant period of time.

Power supply within and outside the campus was erratic, hence work on the project

took longer than it should have. Even tests were difficult to take during those

periods of power failure.

There was also problem calibrating the meter as the power supply was not stable.

The voltage was always fluctuating.

5.3 RECOMMENDATIONS

Further research work can be put forward on the GSM module as this can also be

operated in the GPRS mode which is a better and more secured way of monitoring.

Further research can be carried out in improving the operating voltage and power of

the meter.

The anti-tamper detector can also be incorporated in the design as this also provides

more security measures against theft.

A double sided layer PCB could also be used instead of a single layer used in this

project as this provides a better compact design.

An EPROM can be connected to the microcontroller to save used energy reading

before the meter goes off in case of a power failure.

72

REFERENCES

Analog Devices Corporation, 2000. Energy Metering Ic with Pulse Output. Data Sheet.

pp.1-16.

Atmel Corporations, 2002. 8 bit Microcontroller Pin Description. Data Sheet. pp.1-35.

Balakrishna, 2009. World Meter Design Corporation. [Online] Freescale semiconductor

Productions Available at: http:/freescale.com

Blozis, S., 2003. Philips Semiconductor Corporations. [Online] Philips

Semiconductor Productions. Available at: http://www.semiconductors.philips.com/i2c

Calo, 2006. Automated Meter Reading Corporation. [Online] Available at:

http://www.electronicmeter.com

Chengi, 2008. [Online] Kalkitech Intelligent Energy System Productions. Available at:

http://kalkicommunications.com

Collins, A., 1999. A Low Cost Watt Hour Energy Meter Based on the ADE7755.

Application note. pp.2-20.

Concordia, 1982. Load Representation in Power System Stability Studies. IEEE, PAS-101.

Edison Electrical Institute, 2002. Handbook for Electric Metering. Manual. United State:

EEI press Edison Electrical Institute.

Falcone, 2002. MultiPhase Flow Metering: Current Trends and Future Development.

Society of Petroleum Engineers, 54, pp.77-84.

Hammond, B., 1941. Science Direct. [Online] Available at:

http://www.sciencedirect.com/historicaltimelineofelectricmeters

Honebein, C., 2010. Digital Electric Meter. The Electricity Journal, pp.76-82.

Honebein, P., Cammarano, F. & Donelly, K., 2009. Five Principles for Embracing

Customers as Co-creators of value. Electric Journal, pp.39-44.

73

Irazabal, J., 2003. I2c Bus Manual. Application note, 2003 March. pp.1-51.

ISO/IEC, 2006. International Standard Organization. 3rd ed. IEC press.

Kaplan, R., 999. Frequently Asked Questions and Answers on Analog Devices

Energy (ADE) products. Application note. pp.1-15.

Lanphur, C., 1925. Electric Meter history and Progress. Handbook. Westinghouse Press.

Mangla, N., 2010. [Online] Microcontroller Solutions Group Available at:

http://www.freescale.com

Nagabhooshan, 2005. Electrosoft Corporation. [Online] Available at:

http://electrosoft.com

Nagarju, 1998. Networked Electronic Energy Meter with Power Quality Analysis.

IEEE transactions on Electric Power, III, pp.45-57.

Novarm, 2008. Diptrace Corporation. [Online] Available at: http://www.diptrace.com

Nwaoyo, I., 2011. Design and Construction of a Smart Card Based Single Phase Meter.

Final Year Project. Ogun State: Convenant University.

Okeola, M., 2008. Application and Usage of Portable Test Equipment and

TestBench. Training Report. Shenzhen: Shenzhen Clou Electronics.

Okeola, M., 2008. GPRS Meter Technical Manual. Manual. Lagos: Momas Systems

Nigeria Limited.

Singh, T., 2009. Smart Metering the Cloud. 18th IEEE International Workshops on

Enabling Technologies Conference. Amsterdam, 2009. IEEE Press.

Vector Institute, 2010. Vector's Advanced Embedded Development Board for 8051

User Manual. Manual. Hyderabad: Vector Institute Press Vector Institute.

Vineetal, 2009. Reactive Power and System Frequency Relationship: A Case Study.

In Kumar, ed. 7th International R&D conference. New-Delhi, 2009.

Wayne, C., 1912. Electric Measuring Instruments and Meters. Handbook. Wayne Press.

74

APPENDIX I

The Compiled C code for the programmed Microcontroller (ATmega8A)

;R19 FOR DELAY ;R16 AND R18 FOR LCD ;R17 AND R20 FOR GENERAL ;R29 SAVE SREG ;R21 HOLD TIMING ;R22 HOLD TIMING ;R23 TIMING DONE ;R24 TIMING TO SEC ;R25 GNERAL INT .EQU PORTB = 0X18 .EQU DDRB = 0X17 .EQU PINB = 0X16 .EQU PORTC = 0X15 .EQU DDRC = 0X14 .EQU PINC = 0X13 .EQU PORTD = 0X12 .EQU DDRD = 0X11 .EQU PIND = 0X10 .EQU SPH = 0X3E .EQU SPL = 0X3D .EQU UBRRH = 0X20 .EQU UCSRC = 0X20 .EQU UBRRL = 0X09 .EQU UCSRB = 0X0A .EQU UCSRA = 0X0B .EQU UDR = 0X0C .EQU ADMUX = 0X07 .EQU ADCSRA = 0X06 .EQU ADCH = 0X05 .EQU ADCL = 0X04 .EQU TCCR0 = 0X33 .EQU TCNT0 =0X32 .EQU TIMSK = 0X39 .EQU TIFR = 0X38 .EQU SREG = 0X3F .EQU TCCR1A = 0X2F .EQU TCCR1B = 0X2E .EQU TCNT1H = 0X2D .EQU TCNT1L = 0X2C .EQU SFIOR = 0X30 .EQU TCCR2 = 0X25 .EQU TCNT2 = 0X24; EXTERNAL CRYSTAL NO CAP ADDED .EQU GICR = 0X3B .EQU MCUCR = 0X35 .EQU ASSR = 0X22 .EQU EEARH = 0X1F .EQU EEARL = 0X1E .EQU EEDR = 0X1D .EQU EECR = 0X1C

.EQU RESULT1 = 0X60 .EQU RESULT2 = 0X61 .EQU DRESULT1 = 0X62 .EQU DRESULT2 = 0X63 .EQU ADRES1 = 0X64 .EQU ADRES2 = 0X65 .EQU ADRES3 = 0X66 .EQU ADCCOUNT = 0X67 .EQU SVOLT1 = 0X68 .EQU SVOLT2 = 0X69 .EQU SVOLT3 = 0X6A .EQU SCURR1 = 0X6B .EQU SCURR2 = 0X6C .EQU SCURR3 = 0X6D .EQU POW1 = 0X6E .EQU POW2 = 0X6F .EQU POW3 = 0X70 .EQU POW4 = 0X71 .EQU TEMP1 = 0X72 .EQU TEMP2 = 0X73 .EQU TEMP3 = 0X74 .EQU SWATT1S = 0X75 .EQU SWATT2S = 0X76 .EQU SWATT1 = 0X77 .EQU SWATT2 = 0X78 .EQU SWATT3 = 0X79 .EQU SWATT4 = 0X7A .EQU WATT1 = 0X7B .EQU WATT2 = 0X7C .EQU WATT3 = 0X7D .EQU WATT4 = 0X7E .EQU WATT5 = 0X7F .EQU WATT6 = 0X80 .EQU WATT7 = 0X81 .EQU WATT8 = 0X82 .EQU WATT1D = 0X83 .EQU WATT2D = 0X84 .EQU RWATT1D = 0X85 .EQU RWATT2D = 0X86 .EQU RWATT1 = 0X87 .EQU RWATT2 = 0X88 .EQU RWATT3 = 0X89 .EQU RWATT4 = 0X8A

75

.EQU VALUE = 0X8B

.EQU CC = 0X8C .EQU ADCCOUNT2 = 0X8F .EQU ADRES1B = 0X90 .EQU ADRES2B = 0X91 .EQU ADRES3B = 0X92 .EQU POW5 = 0X93 .EQU SWATT5 = 0X94 .EQU RWATT5 = 0X95 .EQU CC2 = 0X96 .EQU SETUP = 0X97 .EQU BOX = 0X98 .ORG 0X00 RJMP START NOP NOP NOP NOP NOP NOP NOP RJMP TIME1 TIME1: LDI R25,0X01 LDI R29,0X28 OUT TCNT1L,R25 OUT TCNT1H,R29 IN R29,SREG INC R24 CPI R24,0X19 BRNE TIME1END CLR R24 LDS R25,CC2 CPI R25,0X03 BREQ TIME1B INC R25 STS CC2,R25 RJMP TIME1C TIME1B: LDI R25,0X01 STS CC,R25 TIME1C: INC R21 CPI R21,0X0A BRNE TIME1END CLR R21 INC R22

CPI R22,0X06 BRNE TIME1END CLR R22 LDI R23,0X01 TIME1END: OUT SREG,R29 RETI MESSAGE: CLR R30 LDI R31,0X04 LDS R17,WATT8 ORI R17,0X30 ST Z+,r17 LDS R17,WATT7 ORI R17,0X30 ST Z+,r17 LDS R17,WATT6 ORI R17,0X30 ST Z+,r17 LDS R17,WATT5 ORI R17,0X30 ST Z+,r17 LDS R17,WATT4 ORI R17,0X30 ST Z+,r17 LDS R17,WATT3 ORI R17,0X30 ST Z+,r17 LDI R17,0X2E ST Z+,r17 LDS R17,WATT2 ORI R17,0X30 ST Z+,r17 LDS R17,WATT1 ORI R17,0X30 ST Z+,r17 RET MESSAGE2: LDI R30,0X09 LDI R31,0X04 LDI R17,0X20 ST Z+,r17 LDI R17,0X57 ST Z+,r17

76

LDI R17,0X48 ST Z+,r17 LDI R17,0X72 ST Z+,r17 LDI R17,0X20 ST Z+,r17 RET SUBSETUP: LDI R17,0X00 OUT UBRRH,R17 LDI R17,0X05 OUT UBRRL,R17 LDI R17,0X18 OUT UCSRB,R17 LDI R17,0X86 OUT UCSRC,R17 LDI R17,0X01 STS SETUP,R17 RET START: LDI R17,0X5F OUT SPL,R17 LDI R17,0X04 OUT SPH,R17 CLR R17 OUT PORTD,R17 LDI R17,0XFC OUT DDRD,R17 LDI R17,0X02 OUT PORTB,R17 SER R17 OUT DDRB,R17 LDI R17,0X40 OUT ADMUX,R17 LDI R17,0X86 OUT ADCSRA,R17 LDI R17,0x01 OUT TCNT1L,R17 LDI R17,0x28 OUT TCNT1H,R17

LDI R17,0X02 OUT TCCR1B,R17 LDI R17,0X04 OUT TIMSK,R17 CLR R17 OUT EEARH,R17 OUT EEARL,R17 OUT EEDR,R17 OUT EECR,R17 SBIS PINC,3 RJMP INTCONTD LDI R17,0X00 MOV R12,R17 RCALL SAVEMEM LDI R17,0X01 RCALL SAVEMEM LDI R17,0X02 RCALL SAVEMEM LDI R17,0X03 RCALL SAVEMEM LDI R17,0X04 RCALL SAVEMEM LDI R17,0X05 RCALL SAVEMEM LDI R17,0X06 RCALL SAVEMEM LDI R17,0X07 RCALL SAVEMEM LDI R17,0X08 RCALL SAVEMEM LDI R17,0X09 RCALL SAVEMEM INTCONTD: LDI R17,0X00 RCALL LOADMEM STS WATT1D,R12 LDI R17,0X01 RCALL LOADMEM STS WATT2D,R12 LDI R17,0X02 RCALL LOADMEM STS WATT1,R12

77

LDI R17,0X03 RCALL LOADMEM STS WATT2,R12 LDI R17,0X04 RCALL LOADMEM STS WATT3,R12 LDI R17,0X05 RCALL LOADMEM STS WATT4,R12 LDI R17,0X06 RCALL LOADMEM STS WATT5,R12 LDI R17,0X07 RCALL LOADMEM STS WATT6,R12 LDI R17,0X08 RCALL LOADMEM STS WATT7,R12 LDI R17,0X09 RCALL LOADMEM STS WATT8,R12 LDI R17,0X0A RCALL LOADMEM MOV R13,R12 LDI R17,0X0B RCALL LOADMEM MOV R14,R12 STS BOX,R12 OR R12,R13 OUT PORTB,R12 CLR R17 STS POW1,R17 STS POW2,R17 STS POW3,R17 STS POW4,R17 STS POW5,R17 STS CC,R17 STS SETUP,R17 RCALL MESSAGE RCALL MESSAGE2 CLR R24 CLR R23 CLR R21 CLR R22 RCALL INTLCD BSET 7

LDI R17,0X01 STS VALUE,R17 REDO: CALL ADCCONVERT REDOLOOP: RCALL READVOLTAGE RCALL READCURRENT LDS R17,ADCCOUNT2 CPI R17,0X04 BRNE REDOLOOP LOOPNEXT: LDS R17,ADRES3 LDS R20,ADRES2 CALL ROTATER STS RESULT2,R17 STS RESULT1,R20 RCALL PRESULT1 LDI R18,0X08 LDI R16,0X80 RCALL RSLOW LDS R18,DRESULT2 STS SVOLT3,R18 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,DRESULT1 STS SVOLT2,R18 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,RESULT1 STS SVOLT1,R18 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R17,ADRES3B LDS R20,ADRES2B CALL ROTATER CLC ROR R17 ROR R20

78

CLC ROR R17 ROR R20 CALL DECREASEBY20 STS RESULT2,R17 STS RESULT1,R20 RCALL PRESULT1 LDI R18,0X60 LDI R16,0X80 RCALL RSLOW LDS R18,DRESULT2 STS SCURR3,R18 LDS R18,DRESULT1 STS SCURR2,R18 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDI R18,0XE2 LDI R16,0X2E RCALL RSHIGH LDS R18,RESULT1 STS SCURR1,R18 SWAP R18 LDI R16,0X30 RCALL RSHIGH RCALL MULTIPLY RCALL LCDMIN SBIC PINC,3 RCALL SENDM SBRS R23,0 RJMP REDO LDS R17,SETUP SBRS R17,0 RCALL SUBSETUP RCALL WATTHR RCALL SERIAL2NEW RCALL SERIAL2F RCALL SERIAL3 LDS R17,VALUE

INC R17 STS VALUE,R17 CPI R17,0X04 BREQ REDONEXT RJMP REDO REDONEXT: LDI R17,0X01 STS VALUE,R17 RJMP REDO LCDMIN: LDI R18,0XE0 LDI R16,0X80 RCALL RSLOW MOV R18,R22 SWAP R18 LDI R16,0X30 RCALL RSHIGH MOV R18,R21 SWAP R18 LDI R16,0X30 RCALL RSHIGH RET DECREASEBY20: CPI R20,0X00 BRNE DECB CPI R17,0X00 BRNE DECB RET DECB: CPI R20,0X15 BRCC DECC CPI R17,0X00 BREQ DECD DEC R17 SUBI R20,0X14 LDI R16,0XFF ADD R20,R16 INC R20 RET DECC: SUBI R20,0X14 RET DECD: CLR R17 CLR R20 RET ROTATER: CLC ROR R17 ROR R20 CLC ROR R17

79

ROR R20 RET CLC ROR R17 ROR R20 CLC ROR R17 ROR R20 RET ADCCONVERT: CLR R17 STS ADRES1,R17 STS ADRES2,R17 STS ADRES3,R17 STS ADCCOUNT,R17 STS ADCCOUNT2,R17 STS ADRES1B,R17 STS ADRES2B,R17 STS ADRES3B,R17 RET ADCCONVERTB: SBI ADCSRA,6 ADCCONVERTC: SBIC ADCSRA,6 RJMP ADCCONVERTC IN R17,ADCL LDS R20,ADRES1 ADD R20,R17 STS ADRES1,R20 IN R17,ADCH LDS R20,ADRES2 ADC R20,R17 STS ADRES2,R20 BRCC ADCCONVERTD LDS R17,ADRES3 INC R17 STS ADRES3,R17 ADCCONVERTD: LDS R17,ADCCOUNT INC R17 STS ADCCOUNT,R17 CPI R17,0X00 BRNE ADCCONVERTBB LDS R17,ADCCOUNT2 INC R17 STS ADCCOUNT2,R17

ADCCONVERTBB: RET ADCCONVERTBX: SBI ADCSRA,6 ADCCONVERTCX: SBIC ADCSRA,6 RJMP ADCCONVERTCX IN R17,ADCL LDS R20,ADRES1B ADD R20,R17 STS ADRES1B,R20 IN R17,ADCH LDS R20,ADRES2B ADC R20,R17 STS ADRES2B,R20 BRCC ADCCONVERTDX LDS R17,ADRES3B INC R17 STS ADRES3B,R17 ADCCONVERTDX: RET READVOLTAGE: LDI R17,0X40 OUT ADMUX,R17 RCALL DELAYMX RCALL ADCCONVERTB RET READCURRENT: LDI R17,0X41 OUT ADMUX,R17 RCALL DELAYMX RCALL ADCCONVERTBX RET WATTHR: CLR R23 LDS R17,POW1 STS SWATT1,R17 LDS R17,POW2 STS SWATT2,R17 LDS R17,POW3 STS SWATT3,R17 LDS R17,POW4 STS SWATT4,R17 LDS R17,POW5

80

STS SWATT5,R17 CLR R17 STS SWATT1S,R17 STS SWATT2S,R17 STS RWATT1D,R17 STS RWATT2D,R17 STS RWATT1,R17 STS RWATT2,R17 STS RWATT3,R17 STS RWATT4,R17 STS RWATT5,R17 WATTHR2: LDS R17,SWATT1S CPI R17,0X06 BRCC WATTHR3 RJMP WATTHRADJ WATTHR3: SUBI R17,0X06 STS SWATT1S,R17 LDS R17,RWATT1D INC R17 STS RWATT1D,R17 CPI R17,0X0A BRCS WATTHR4 SUBI R17,0X0A STS RWATT1D,R17 LDS R17,RWATT2D INC R17 STS RWATT2D,R17 CPI R17,0X0A BRCS WATTHR4 SUBI R17,0X0A STS RWATT2D,R17 LDS R17,RWATT1 INC R17 STS RWATT1,R17 CPI R17,0X0A BRCS WATTHR4 SUBI R17,0X0A STS RWATT1,R17 LDS R17,RWATT2 INC R17 STS RWATT2,R17 CPI R17,0X0A BRCS WATTHR4 SUBI R17,0X0A STS RWATT2,R17 LDS R17,RWATT3 INC R17 STS RWATT3,R17 CPI R17,0X0A

BRCS WATTHR4 SUBI R17,0X0A STS RWATT3,R17 LDS R17,RWATT4 INC R17 STS RWATT4,R17 CPI R17,0X0A BRCS WATTHR4 SUBI R17,0X0A STS RWATT4,R17 LDS R17,RWATT5 INC R17 STS RWATT5,R17 WATTHR4: RJMP WATTHR2 WATTHRADJ: LDS R17,SWATT2S CPI R17,0X00 BREQ WATTHRADJB DEC R17 STS SWATT2S,R17 LDI R17,0X0A LDS R20,SWATT1S ADD R17,R20 STS SWATT1S,R17 RJMP WATTHR2 WATTHRADJB: LDS R17,SWATT1 CPI R17,0X00 BREQ WATTHRADJC DEC R17 STS SWATT1,R17 LDI R17,0X09 STS SWATT2S,R17 LDI R17,0X0A LDS R20,SWATT1S ADD R17,R20 STS SWATT1S,R17 RJMP WATTHR2 WATTHRADJC: LDS R17,SWATT2 CPI R17,0X00 BREQ WATTHRADJD DEC R17 STS SWATT2,R17 LDI R17,0X09 STS SWATT1,R17 STS SWATT2S,R17 LDI R17,0X0A LDS R20,SWATT1S ADD R17,R20 STS SWATT1S,R17

81

RJMP WATTHR2 WATTHRADJD: LDS R17,SWATT3 CPI R17,0X00 BREQ WATTHRADJE DEC R17 STS SWATT3,R17 LDI R17,0X09 STS SWATT2,R17 STS SWATT1,R17 STS SWATT2S,R17 LDI R17,0X0A LDS R20,SWATT1S ADD R17,R20 STS SWATT1S,R17 RJMP WATTHR2 WATTHRADJE: LDS R17,SWATT4 CPI R17,0X00 BREQ WATTHRADJEE DEC R17 STS SWATT4,R17 LDI R17,0X09 STS SWATT3,R17 STS SWATT2,R17 STS SWATT1,R17 STS SWATT2S,R17 LDI R17,0X0A LDS R20,SWATT1S ADD R17,R20 STS SWATT1S,R17 RJMP WATTHR2 WATTHRADJEE: LDS R17,SWATT5 CPI R17,0X00 BREQ WATTHRADJF DEC R17 STS SWATT5,R17 LDI R17,0X09 STS SWATT4,R17 STS SWATT3,R17 STS SWATT2,R17 STS SWATT1,R17 STS SWATT2S,R17 LDI R17,0X0A LDS R20,SWATT1S ADD R17,R20 STS SWATT1S,R17 RJMP WATTHR2 WATTHRADJF: LDS R17,RWATT1D LDS R20,WATT1D ADD R20,R17 STS WATT1D,R20 CPI R20,0X0A BRCS WATTHRADJG

SUBI R20,0X0A STS WATT1D,R20 LDS R20,WATT2D INC R20 STS WATT2D,R20 WATTHRADJG: LDS R17,RWATT2D LDS R20,WATT2D ADD R20,R17 STS WATT2D,R20 CPI R20,0X0A BRCS WATTHRADJH SUBI R20,0X0A STS WATT2D,R20 LDS R20,WATT1 INC R20 STS WATT1,R20 WATTHRADJH: LDS R17,RWATT1 LDS R20,WATT1 ADD R20,R17 STS WATT1,R20 CPI R20,0X0A BRCS WATTHRADJI SUBI R20,0X0A STS WATT1,R20 LDS R20,WATT2 INC R20 STS WATT2,R20 WATTHRADJI: LDS R17,RWATT2 LDS R20,WATT2 ADD R20,R17 STS WATT2,R20 CPI R20,0X0A BRCS WATTHRADJJ SUBI R20,0X0A STS WATT2,R20 LDS R20,WATT3 INC R20 STS WATT3,R20 WATTHRADJJ: LDS R17,RWATT3 LDS R20,WATT3 ADD R20,R17 STS WATT3,R20 CPI R20,0X0A BRCS WATTHRADJK SUBI R20,0X0A STS WATT3,R20 LDS R20,WATT4 INC R20 STS WATT4,R20 WATTHRADJK: LDS R17,RWATT4 LDS R20,WATT4 ADD R20,R17 STS WATT4,R20 CPI R20,0X0A BRCS WATTHRADJL

82

SUBI R20,0X0A STS WATT4,R20 LDS R20,WATT5 INC R20 STS WATT5,R20 WATTHRADJL: LDS R17,RWATT5 LDS R20,WATT5 ADD R20,R17 STS WATT5,R20 CPI R20,0X0A BRCS WATTHRADJEND SUBI R20,0X0A STS WATT5,R20 LDS R20,WATT6 INC R20 STS WATT6,R20 CPI R20,0X0A BRCS WATTHRADJEND SUBI R20,0X0A STS WATT6,R20 LDS R20,WATT7 INC R20 STS WATT7,R20 CPI R20,0X0A BRCS WATTHRADJEND SUBI R20,0X0A STS WATT7,R20 LDS R20,WATT8 INC R20 STS WATT8,R20 WATTHRADJEND: LDI R17,0X00 LDS R12,WATT1D RCALL SAVEMEM LDI R17,0X01 LDS R12,WATT2D RCALL SAVEMEM LDI R17,0X02 LDS R12,WATT1 RCALL SAVEMEM LDI R17,0X03 LDS R12,WATT2 RCALL SAVEMEM LDI R17,0X04 LDS R12,WATT3 RCALL SAVEMEM LDI R17,0X05 LDS R12,WATT4 RCALL SAVEMEM LDI R17,0X06

LDS R12,WATT5 RCALL SAVEMEM LDI R17,0X07 LDS R12,WATT6 RCALL SAVEMEM LDI R17,0X08 LDS R12,WATT7 RCALL SAVEMEM LDI R17,0X09 LDS R12,WATT8 RCALL SAVEMEM RJMP LCDWATTHR MULTIPLY: CLR R17 STS POW1,R17 STS POW2,R17 STS POW3,R17 STS POW4,R17 STS POW5,R17 LDS R17,SVOLT1 CPI R17,0X00 BRNE MULTIPLY2 LDS R17,SVOLT2 CPI R17,0X00 BRNE MULTIPLY2 LDS R17,SVOLT3 CPI R17,0X00 BRNE MULTIPLY2 RJMP MULTIPLYEND MULTIPLY2: LDS R17,SCURR1 CPI R17,0X00 BRNE MULTIPLY3 LDS R17,SCURR2 CPI R17,0X00 BRNE MULTIPLY3 LDS R17,SCURR3 CPI R17,0X00 BRNE MULTIPLY3 RJMP MULTIPLYEND MULTIPLY3D: RJMP MULTIPLYEND MULTIPLY3C: LDS R17,TEMP3 CPI R17,0X00 BREQ MULTIPLY3D DEC R17 STS TEMP3,R17 LDI R17,0X09 STS TEMP2,R17 STS TEMP1,R17

83

RJMP MULTIPLY4 MULTIPLY3B: LDS R17,TEMP2 CPI R17,0X00 BREQ MULTIPLY3C DEC R17 STS TEMP2,R17 LDI R17,0X09 STS TEMP1,R17 RJMP MULTIPLY4 MULTIPLY3: LDS R17,SCURR1 STS TEMP1,R17 LDS R17,SCURR2 STS TEMP2,R17 LDS R17,SCURR3 STS TEMP3,R17 MULTIPLY3CONTD: LDS R17,TEMP1 CPI R17,0X00 BREQ MULTIPLY3B DEC R17 STS TEMP1,R17 MULTIPLY4: LDS R17,SVOLT1 LDS R20,POW1 ADD R20,R17 STS POW1,R20 CPI R20,0X0A BRCS MULTIPLY4B SUBI R20,0X0A STS POW1,R20 LDS R20,POW2 INC R20 STS POW2,R20 MULTIPLY4B: LDS R17,SVOLT2 LDS R20,POW2 ADD R20,R17 STS POW2,R20 CPI R20,0X0A BRCS MULTIPLY4C SUBI R20,0X0A STS POW2,R20 LDS R20,POW3 INC R20 STS POW3,R20 MULTIPLY4C: LDS R17,SVOLT3 LDS R20,POW3 ADD R20,R17 STS POW3,R20 CPI R20,0X0A BRCS MULTIPLY5 SUBI R20,0X0A STS POW3,R20 LDS R20,POW4 INC R20

STS POW4,R20 CPI R20,0X0A BRCS MULTIPLY5 SUBI R20,0X0A STS POW4,R20 LDS R20,POW5 INC R20 STS POW5,R20 MULTIPLY5: RJMP MULTIPLY3CONTD MULTIPLYEND: LDI R18,0X00 LDI R16,0XC0 RCALL RSLOW LDS R18,POW5 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,POW4 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,POW3 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,POW2 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDI R18,0XE2 LDI R16,0X2E RCALL RSHIGH LDS R18,POW1 SWAP R18 LDI R16,0X30 RCALL RSHIGH RET PRESULT1: RCALL RESULTB LDI R17,0X0A ADD R17,R20 STS RESULT1,R17 RET RESULTB: CLR R17 STS DRESULT1,R17 STS DRESULT2,R17

84

LDS R20,RESULT1 RESULTC: LDI R17,0X64 SUB R20,R17 BRCC RESULTD RJMP RESULTE RESULTD: LDS R17,DRESULT2 INC R17 STS DRESULT2,R17 RJMP RESULTC RESULTF: LDI R17,0X64 ADD R20,R17 RESULTG: LDI R17,0X0A SUB R20,R17 BRCC RESCONT RET RESCONT: LDS R17,DRESULT1 INC R17 STS DRESULT1,R17 RJMP RESULTG RESULTE: LDS R17,RESULT2 CPI R17,0X00 BREQ RESULTF INC R20 LDI R17,0XFF ADD R20,R17 LDS R17,RESULT2 DEC R17 STS RESULT2,R17 RJMP RESULTD DELAY: NOP NOP NOP NOP NOP NOP NOP INC R19 BRNE DELAY RET DELAYMX: CLR R19 RCALL DELAY RET DELAYM3X: CLR R19 RCALL DELAY CLR R19 RCALL DELAY CLR R19

RCALL DELAY RET DELAYM: CLR R19 RCALL DELAY CLR R19 RCALL DELAY CLR R19 RCALL DELAY CLR R19 RCALL DELAY CLR R19 RCALL DELAY CLR R19 RCALL DELAY RET DELAYM2: RCALL DELAYM RCALL DELAYM RCALL DELAYM RCALL DELAYM RCALL DELAYM RCALL DELAYM RET DELAYM3: RCALL DELAYM2 RCALL DELAYM2 RCALL DELAYM2 RCALL DELAYM2 RCALL DELAYM2 RCALL DELAYM2 RET DELAYM4: RCALL DELAYM3 RCALL DELAYM3 RCALL DELAYM3 RCALL DELAYM3 RCALL DELAYM3 RCALL DELAYM3 RET RSLOW2: CBR R16,0X0C OUT PORTD,R16 RCALL DELAYM SBR R16,0X08 OUT PORTD,R16 RCALL DELAYM CBR R16,0X08 OUT PORTD,R16 RCALL DELAYM RET RSLOW: CBR R16,0X0C OUT PORTD,R16

85

RCALL DELAYMX SBR R16,0X08 OUT PORTD,R16 RCALL DELAYMX CBR R16,0X08 OUT PORTD,R16 RCALL DELAYM3X CBR R18,0X0C OUT PORTD,R18 RCALL DELAYMX SBR R18,0X08 OUT PORTD,R18 RCALL DELAYMX CBR R18,0X08 OUT PORTD,R18 RCALL DELAYM3X RET RSHIGH: SBR R16,0X04 CBR R16,0X08 OUT PORTD,R16 RCALL DELAYMX SBR R16,0X08 OUT PORTD,R16 RCALL DELAYMX CBR R16,0X08 OUT PORTD,R16 RCALL DELAYM3X SBR R18,0X04 CBR R18,0X08 OUT PORTD,R18 RCALL DELAYMX SBR R18,0X08 OUT PORTD,R18 RCALL DELAYMX CBR R18,0X08 OUT PORTD,R18 RCALL DELAYM3X

RET INTLCD: RCALL DELAYM4 LDI R16,0X20 RCALL RSLOW2 RCALL DELAYM4 LDI R18,0XC2 LDI R16,0X2C RCALL RSLOW RCALL DELAYM3 LDI R18,0XC0 LDI R16,0X0C RCALL RSLOW LDI R18,0X10 LDI R16,0X01 RCALL RSLOW RCALL DELAYM3 LDI R18,0X60 LDI R16,0X06 RCALL RSLOW LDI R18,0X08 LDI R16,0X80 RCALL RSLOW LDI R18,0X03 LDI R16,0X30 RCALL RSHIGH LDI R18,0X03 LDI R16,0X30 RCALL RSHIGH LDI R18,0X03 LDI R16,0X30 RCALL RSHIGH LDI R18,0X65 LDI R16,0X56 RCALL RSHIGH LDI R18,0X68 LDI R16,0X86 RCALL RSLOW LDI R18,0X03 LDI R16,0X30 RCALL RSHIGH

86

LDI R18,0XE2 LDI R16,0X2E RCALL RSHIGH LDI R16,0X30 RCALL RSHIGH LDI R18,0X03 LDI R16,0X30 RCALL RSHIGH LDI R18,0X14 LDI R16,0X41 RCALL RSHIGH RCALL LCDMIN RCALL MULTIPLYEND LCDWATTHR: LDI R18,0X70 LDI R16,0XC0 RCALL RSLOW LDS R18,WATT8 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,WATT7 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,WATT6 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,WATT5 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,WATT4 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,WATT3 SWAP R18 LDI R16,0X30 RCALL RSHIGH LDI R18,0XE2 LDI R16,0X2E RCALL RSHIGH LDS R18,WATT2

SWAP R18 LDI R16,0X30 RCALL RSHIGH LDS R18,WATT1 SWAP R18 LDI R16,0X30 RCALL RSHIGH RET SERIAL2: SBIS UCSRA,5 RJMP SERIAL2 OUT UDR,R17 RCALL DELAYM RET SERIAL2NEW: LDI R17,0X41 RCALL SERIAL2 LDI R17,0X54 RCALL SERIAL2 LDI R17,0X2B RCALL SERIAL2 LDI R17,0X43 RCALL SERIAL2 LDI R17,0X4D RCALL SERIAL2 LDI R17,0X47 RCALL SERIAL2 RET SERIAL2F: LDI R17,0X52 RCALL SERIAL2 RJMP SERIAL2G SERIAL2FA: LDI R17,0X44 RCALL SERIAL2 RJMP SERIAL2G SERIAL2G: LDI R17,0X3D RCALL SERIAL2 LDS R17,VALUE ORI R17,0X30 RCALL SERIAL2 LDI R17,0X0D RCALL SERIAL2 RET

87

SERIAL3: CLR R30 STS CC2,R30 STS CC,R30 LDI R31,0X01 SERIAL3A: LDS R17,CC SBRC R17,0 RET SBIS UCSRA,7 RJMP SERIAL3A IN R17, UDR ST Z+,r17 CPI R17,0X4B BREQ SERIAL3B RJMP SERIAL3A SERIAL3B: LDS R17,CC SBRC R17,0 RET SBIS UCSRA,7 RJMP SERIAL3B IN R17, UDR SERIAL3C: LDS R17,CC SBRC R17,0 RET SBIS UCSRA,7 RJMP SERIAL3C IN R17, UDR RCALL DELETE LDI R30,0X16 LDI R31,0X01 LD R17,Z CPI R17,0X32 BREQ SERIAL3CA RET SERIAL3CA: LDI R30,0X17 LD r17,Z CPI R17,0X32 BRNE SERIAL3CAA RJMP SERIAL3CA1 SERIAL3CAA: CPI R17,0X33 BRNE SERIAL3CAB RJMP SERIAL3CA2

SERIAL3CAB: CPI R17,0X35 BRNE SERIAL3CAC RJMP SERIAL3CA3 SERIAL3CAC: RET SERIAL3CA1: LDI R30,0X54 LD r17,Z+ CPI R17,0X34 BREQ SERIAL3CA1A RET SERIAL3CA1A: LD r17,Z+ CPI R17,0X46 BREQ SERIAL3CA1B RET SERIAL3CA1B: LD r17,Z+ CPI R17,0X32 BREQ SERIAL3CA1C RET SERIAL3CA1C: LD r17,Z+ CPI R17,0X37 BREQ SERIAL3CA1D RET SERIAL3CA1D: LDI R17,0X04 MOV R13,R17 MOV R12,R17 OR R17,R14 OUT PORTB,R17 LDI R17,0X0A RCALL SAVEMEM RET SERIAL3CA2: LDI R30,0X54 LD r17,Z+ CPI R17,0X34 BREQ SERIAL3CA2A RET SERIAL3CA2A: LD r17,Z+ CPI R17,0X46 BREQ SERIAL3CA2B RET SERIAL3CA2B: LD r17,Z+ CPI R17,0X41 BREQ SERIAL3CA2C RET

88

SERIAL3CA2C: LD r17,Z+ CPI R17,0X33 BREQ SERIAL3CA2D RET SERIAL3CA2D: LD r17,Z+ CPI R17,0X31 BREQ SERIAL3CA2E RET SERIAL3CA2E: LD r17,Z+ CPI R17,0X31 BREQ SERIAL3CA2F RET SERIAL3CA2F: LDI R17,0X10 MOV R13,R17 MOV R12,R17 OR R17,R14 OUT PORTB,R17 LDI R17,0X0A RCALL SAVEMEM RET SERIAL3CA3: LDI R30,0X54 LD r17,Z+ CPI R17,0X44 BREQ SERIAL3CA3A RET SERIAL3CA3A: LD r17,Z+ CPI R17,0X35 BREQ SERIAL3CA3B RET SERIAL3CA3B: LD r17,Z+ CPI R17,0X36 BREQ SERIAL3CA3C RET SERIAL3CA3C: LD r17,Z+ CPI R17,0X39 BREQ SERIAL3CA3D RET SERIAL3CA3D: LD r17,Z+ CPI R17,0X46 BREQ SERIAL3CA3E RET SERIAL3CA3E: LD r17,Z+ CPI R17,0X30 BREQ SERIAL3CA3F RET SERIAL3CA3F:

LD r17,Z+ CPI R17,0X35 BREQ SERIAL3CA3G RET SERIAL3CA3G: LD r17,Z+ CPI R17,0X38 BREQ SERIAL3CA3H RET SERIAL3CA3H: LD r17,Z+ CPI R17,0X30 BREQ SERIAL3CA3I RET SERIAL3CA3I: LD r17,Z+ CPI R17,0X34 BREQ SERIAL3CA3J RET SERIAL3CA3J: LDI R17,0X08 STS BOX,R17 MOV R14,R17 MOV R12,R17 OR R17,R13 OUT PORTB,R17 LDI R17,0X0B RCALL SAVEMEM RET DELETE: LDI R17,0X41 RCALL SERIAL2 LDI R17,0X54 RCALL SERIAL2 LDI R17,0X2B RCALL SERIAL2 LDI R17,0X43 RCALL SERIAL2 LDI R17,0X4D RCALL SERIAL2 LDI R17,0X47 RCALL SERIAL2 LDI R17,0X44 RCALL SERIAL2 LDI R17,0X3D RCALL SERIAL2 LDS R17,VALUE ORI R17,0X30 RCALL SERIAL2

89

LDI R17,0X0D RCALL SERIAL2 CLR R30 STS CC2,R30 STS CC,R30 SERIAL3DEL: LDS R17,CC SBRC R17,0 RET SBIS UCSRA,7 RJMP SERIAL3DEL IN R17, UDR CPI R17,0X4B BREQ SERIAL3DEL2 RJMP SERIAL3DEL SERIAL3DEL2: LDS R17,CC SBRC R17,0 RET SBIS UCSRA,7 RJMP SERIAL3DEL2 IN R17, UDR SERIAL3DEL3: LDS R17,CC SBRC R17,0 RET SBIS UCSRA,7 RJMP SERIAL3DEL3 IN R17, UDR RET SERIALSM: LDI R17,0X41 RCALL SERIAL2 LDI R17,0X54 RCALL SERIAL2 LDI R17,0X2B RCALL SERIAL2 LDI R17,0X43 RCALL SERIAL2 LDI R17,0X4D RCALL SERIAL2 LDI R17,0X47 RCALL SERIAL2 LDI R17,0X53 RCALL SERIAL2 LDI R17,0X3D

RCALL SERIAL2 LDI R17,0X33 RCALL SERIAL2 LDI R17,0X34 RCALL SERIAL2 LDI R17,0X0D RCALL SERIAL2 RET TIMING1A: CLR R17 STS CC2,R17 STS CC,R17 TIMING1AB: LDS R17,CC SBRS R17,0 RJMP TIMING1AB RET SERIAL4GEN0: LDI R17,0X30 RJMP SERIAL2 SERIAL4GEN1: LDI R17,0X31 RJMP SERIAL2 SERIAL4GEN2: LDI R17,0X32 RJMP SERIAL2 SERIAL4GEN3: LDI R17,0X33 RJMP SERIAL2 SERIAL4GEN4: LDI R17,0X34 RJMP SERIAL2 SERIAL4GEN5: LDI R17,0X35 RJMP SERIAL2 SERIAL4GEN6: LDI R17,0X36 RJMP SERIAL2 SERIAL4GEN7: LDI R17,0X37 RJMP SERIAL2 SERIAL4GEN8: LDI R17,0X38 RJMP SERIAL2 SERIAL4GEN9: LDI R17,0X39 RJMP SERIAL2 SERIAL4GENA: LDI R17,0X41 RJMP SERIAL2 SERIAL4GENB: LDI R17,0X42 RJMP SERIAL2 SERIAL4GENC:

90

LDI R17,0X43 RJMP SERIAL2 SERIAL4GEND: LDI R17,0X44 RJMP SERIAL2 SERIAL4GENE: LDI R17,0X45 RJMP SERIAL2 SERIAL4GENF: LDI R17,0X46 RJMP SERIAL2 SERIAL4: RCALL SERIAL4GEN0 RCALL SERIAL4GEN0 RCALL SERIAL4GEN0 RCALL SERIAL4GEN1 RCALL SERIAL4GEN0 RCALL SERIAL4GEN0 RCALL SERIAL4GEN0 RCALL SERIAL4GEND RCALL SERIAL4GEN9 RCALL SERIAL4GEN1 RCALL SERIAL4GEN3 RCALL SERIAL4GEN2 RET SERIAL5A: RCALL SERIAL4GEN8 RCALL SERIAL4GEN4 RCALL SERIAL4GEN8 RCALL SERIAL4GEN1 RCALL SERIAL4GEN5 RCALL SERIAL4GEN6 RCALL SERIAL4GEN9 RCALL SERIAL4GEN3 RCALL SERIAL4GEN9 RCALL SERIAL4GEN8 RCALL SERIAL4GENF RCALL SERIAL4GEN2 RET SERIAL5B: RCALL SERIAL4GEN8 RCALL SERIAL4GEN4 RCALL SERIAL4GEN3 RCALL SERIAL4GEN0 RCALL SERIAL4GEN0 RCALL SERIAL4GEN4 RCALL SERIAL4GEN9 RCALL SERIAL4GEN7 RCALL SERIAL4GEN4 RCALL SERIAL4GEN7 RCALL SERIAL4GENF RCALL SERIAL4GEN2 RET SERIAL6: RCALL SERIAL4GEN0 RCALL SERIAL4GEN0

RCALL SERIAL4GEN0 RCALL SERIAL4GEN0 RCALL SERIAL4GEN1 RCALL SERIAL4GEN6 RCALL SERIAL4GEN4 RCALL SERIAL4GEN9 RCALL SERIAL4GEN6 RCALL SERIAL4GEN2 RCALL SERIAL4GEN4 RCALL SERIAL4GENC RCALL SERIAL4GEN3 RCALL SERIAL4GEN6 RCALL SERIAL4GENA RCALL SERIAL4GEN3 RCALL SERIAL4GEN8 RCALL SERIAL4GEN1 RCALL SERIAL4GEN4 RCALL SERIAL4GEN0 RCALL MESSAGE RCALL PDUCON LDI R30,0X10 LDI R31,0X04 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RCALL PSERIAL4GEN2 RET PSERIAL4GEN2: LD R17,Z+ MOV R16,R17 SWAP R17 ANDI R17,0X0F

91

RCALL PSERIAL4GEN MOV R17,R16 ANDI R17,0X0F RCALL PSERIAL4GEN RET PSERIAL4GEN: CPI R17,0X00 BRNE PNEXT1 RJMP SERIAL4GEN0 PNEXT1: CPI R17,0X01 BRNE PNEXT2 RJMP SERIAL4GEN1 PNEXT2: CPI R17,0X02 BRNE PNEXT3 RJMP SERIAL4GEN2 PNEXT3: CPI R17,0X03 BRNE PNEXT4 RJMP SERIAL4GEN3 PNEXT4: CPI R17,0X04 BRNE PNEXT5 RJMP SERIAL4GEN4 PNEXT5: CPI R17,0X05 BRNE PNEXT6 RJMP SERIAL4GEN5 PNEXT6: CPI R17,0X06 BRNE PNEXT7 RJMP SERIAL4GEN6 PNEXT7: CPI R17,0X07 BRNE PNEXT8 RJMP SERIAL4GEN7 PNEXT8: CPI R17,0X08 BRNE PNEXT9 RJMP SERIAL4GEN8 PNEXT9: CPI R17,0X09 BRNE PNEXTA RJMP SERIAL4GEN9 PNEXTA: CPI R17,0X0A BRNE PNEXTB

RJMP SERIAL4GENA PNEXTB: CPI R17,0X0B BRNE PNEXTC RJMP SERIAL4GENB PNEXTC: CPI R17,0X0C BRNE PNEXTD RJMP SERIAL4GENC PNEXTD: CPI R17,0X0D BRNE PNEXTE RJMP SERIAL4GEND PNEXTE: CPI R17,0X0E BRNE PNEXTF RJMP SERIAL4GENE PNEXTF: CPI R17,0X0F BRNE PNEXTG RJMP SERIAL4GENF PNEXTG: RET PDUCONG2: LD R16,Z ROR R16 ROR R17 RET PDUCONG3: ROR R16 ROR R17 RET PDUCONG: ST Z,R17 MOV R17,R16 RET PDUCON: CLR R30 LDI R31,0X04 LD R17,Z ROL R17 LDI R30,0X01 RCALL PDUCONG2 LDI R30,0X10 RCALL PDUCONG ROL R17 ROL R17

92

LDI R30,0X02 RCALL PDUCONG2 RCALL PDUCONG3 LDI R30,0X11 RCALL PDUCONG ROL R17 ROL R17 ROL R17 LDI R30,0X03 RCALL PDUCONG2 RCALL PDUCONG3 RCALL PDUCONG3 LDI R30,0X12 RCALL PDUCONG ROL R17 ROL R17 ROL R17 ROL R17 LDI R30,0X04 RCALL PDUCONG2 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 LDI R30,0X13 RCALL PDUCONG ROL R17 ROL R17 ROL R17 ROL R17 ROL R17 LDI R30,0X05 RCALL PDUCONG2 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 LDI R30,0X14 RCALL PDUCONG ROL R17 ROL R17 ROL R17 ROL R17 ROL R17 ROL R17 LDI R30,0X06 RCALL PDUCONG2 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3

LDI R30,0X15 RCALL PDUCONG ROL R17 ROL R17 ROL R17 ROL R17 ROL R17 ROL R17 ROL R17 LDI R30,0X07 RCALL PDUCONG2 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 LDI R30,0X16 RCALL PDUCONG LDI R30,0X08 LD R17,Z ROL R17 LDI R30,0X09 RCALL PDUCONG2 LDI R30,0X17 RCALL PDUCONG ROL R17 ROL R17 LDI R30,0X0A RCALL PDUCONG2 RCALL PDUCONG3 LDI R30,0X18 RCALL PDUCONG ROL R17 ROL R17 ROL R17 LDI R30,0X0B RCALL PDUCONG2 RCALL PDUCONG3 RCALL PDUCONG3 LDI R30,0X19 RCALL PDUCONG ROL R17 ROL R17 ROL R17 ROL R17 LDI R30,0X0C RCALL PDUCONG2 RCALL PDUCONG3

93

RCALL PDUCONG3 RCALL PDUCONG3 LDI R30,0X1A RCALL PDUCONG ROL R17 ROL R17 ROL R17 ROL R17 ROL R17 LDI R30,0X0D RCALL PDUCONG2 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 RCALL PDUCONG3 LDI R30,0X1B RCALL PDUCONG ROL R17 ROL R17 ROL R17 ROL R17 ROL R17 ROL R17 CLC ROR R17 CLC ROR R17 CLC ROR R17 CLC ROR R17 CLC ROR R17 CLC ROR R17 LDI R30,0X1C RCALL PDUCONG RET SERIAL7: LDI R17,0X1A RJMP SERIAL2 SENDM: LDS R17,SETUP SBRS R17,0 RET LDS R17,BOX SBRS R17,3 RET LDI R17,0X00 STS BOX,R17 MOV R14,R17

MOV R12,R17 OR R17,R13 OUT PORTB,R17 LDI R17,0X0B RCALL SAVEMEM RCALL SERIALSM RCALL TIMING1A RCALL SERIAL4 RCALL SERIAL5A RCALL SERIAL6 RCALL SERIAL7 RCALL TIMING1A RCALL TIMING1A RCALL SERIAL4 RCALL SERIAL5B RCALL SERIAL6 RCALL SERIAL7 RET SAVEMEM: SBIC EECR,1 RJMP SAVEMEM OUT EEARL,R17 OUT EEDR,R12 SBI EECR,2 SBI EECR,1 SAVEMEM2A: SBIC EECR,1 RJMP SAVEMEM2A RET LOADMEM: SBIC EECR,1 RJMP LOADMEM OUT EEARL,R17 SBI EECR,0 IN R12,EEDR RET

94

APPENDIX II

SMS Service Commands