You are on page 1of 32

CHAPTER I

INTRODUCTION
Now-a-days electricity has become a basic need to humans. The consumption
of electricity has increased a lot compared to the past years. The theft of electricity
has also become a problem these days and there is no control over the loss due to theft
of electricity. In this project we present you the smart energy meter device used to
measure the consumption of the electricity by the individual and provide security
against theft of electricity.
A smart meter is usually an electrical meter that records consumption of
electric energy in intervals of an hour or less and communicates that information at
least daily back to the utility for monitoring and billing purposes.Smart meters enable
two-way communication between the meter and the central system. Unlike home
energy monitors, smart meters can gather data for remote reporting.
The term Smart meter often refers to an electricity meter, but it can
increasingly also mean a device measuring natural gas or water consumption.Smart
energy meter is software based, power efficient device that accurately tracks energy
consumption and performs computation. Meter readings can be transmitted to
distributors/utilities over wireless media; thus, eliminating the need of manual meter
reading collection process. The smart energy meter offers major benefits to both
customers and companies in terms of efficiency, reliability, and cost saving.
Imagine if you knew how much energy you were consuming at home at any
time of the day, and knew how much energy each device was using, will you stop
using those energy hog appliances? Or use them at the time of the day when the
energy is cheapest? In the economy turmoil we are currently in, I believe all of us are
willing to make those small sacrifices to lower down the bill numbers at the end of the
month.
Smart energy meters are devices that will sit on your home, monitor energy
data from your electricity meter, and let you know how much energy you are using
this put more control on your hands on how you spend your energy at home.
Conventional electricity meters are normally hidden somewhere on a wall on the
1

basement, and the only time you realize how much energy youve been spending is
when the bill hit the door.
The new smart meters will provide Indian consumers with information
regarding energy consumption that was not previously available with a traditional
meter. This system will allow the easy disconnection of defaulted customers and
power connections from a remote site. The new smart system is also able to instantly
detect tampering with the power lines and sends signals to security personnel if
necessary. Utility employees will also have the ability to change a customers billing
method from pre paid to post paid in a matter of seconds, without having to physically
visit the meter.

CHAPTER II
LITERATURE SURVEY
2.1 MOTIVATION:
The usage of electricity these days has been increased a lot and the theft of the
electricity has been increasing. Most of the worlds electricity is being produced by
using the natural resources (mostly fossil fuels) which are causing pollution and
affecting the earths atmosphere. So, there is a need to control the usage of electricity
as well as to provide security against thetheft of electricity. In our project we have
implemented and designed a meter which can be useful to reduce the consumption of
electricity by using a smart energy meter which keeps a track of the consumption of
the electricity and transmits the same to the customer through GSM module by which
the user can manage his usage and reduce the consumption of electricity. As we get
details of each and every user we can easily find out where the excess electricity is
flowing and take necessary actions to block the excess flow.

2.2 SCOPE:
The scope of the project work is to introduce advanced technology in
converting dc voltage in to ac voltage and introducing smart energy metering concept.
In future this project can be used to measuring natural gas or water
consumption. These meters can be connected to GSM module and data (i.e.
consumption) can be transmitted over GSM networks and the bills can be
automatically issued to the particular customer through SMS. By making small
modifications in the program (code) we can break the connection if user does not pay
the bills in time. There is no need for the electricity officials to visit the spot to
disconnect the connections i.e., everything can be controlled over the GSM module.
The user can also sell the electricity to the government which is created in his home
using solar cells. These meters can also be used as prepaid energy meters by slightly
modifying them.

2.3 PROBLEM DEFINATION:


Now-a-days electricity has become a basic need to humans. The consumption
of electricity has increased a lot compared to the past years. The electricity bills are
issued by a person going to each and every house of the locality with an instrument in
his hand. But lack of resources has made the government to take the help of the
private organizations who supply man power. These organizations are charging the
government a high amount for the supply of the man power which is causing the
government to lose its profits on selling the electricity. The theft of electricity has also
become a problem these days and there is no control over the loss due to theft of
electricity.
The solution to the above problems is Smart Energy Meter. By using Smart
Energy Meter we can directly issue the bills to the customers i.e., there is no need to
go to each every house of the locality for the issue of the bills. The consumers can
cut-off their electricity bills by reducing their power consumption. The theft of
electricity can be easily found as the consumption in every house is noted and
monitored.

2.4 Advantages:

More accurate bills


Lower bills
Track of energy usage
Sell energy back to the grid
Flexible tariffs
No more meter readings

CHAPTER III
DESIGN METHODLOGY
3.1 Introduction to SMART ENERGY METER EC Unit

Fig: 3.1 BLOCK DIAGRAM

3.2 SELECTION OF HARDWARE:


The hardware selected must be such a way that

Low cost
Low power consumption, small, fast

Continually reacts to changes in the systems environment

Must compute certain results in real-time without delay

Simple design
Easy maintainability and interoperability
Bug-free/Correctness, safety, many more

3.3 HARDWARE AND SOFTWARE SPECIFICATIONS


3.3.1 HARDWARE
1. P89C51RD2BN Microcontroller (IC)
2. Power supply
3. MAX 232 (IC)
4. RS 232 (female port)
5. 2x16 Display Liquid Crystal Display (JHD162A)
6. 4*4 matrix keypad
7. NE555 timer (IC)
8. IR Sensors (IR Transmitter and IR Receiver)
9. Resistors
10. Capacitors
11. Serial port connector
12. Crystal oscillator
3.4 8051 Microcontroller:
Microprocessors and microcontrollers are widely used in embedded systems
products. Microcontroller is a programmable device. A microcontroller has a CPU in
addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a
single chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in
microcontrollers makes them ideal for many applications in which cost and space are
critical.The Intel 8051 is Harvard architecture, single chip microcontroller (C) which
was developed by Intel in 1980 for use in embedded systems.
The microcontroller used here is P89C51RD2xx. This microcontroller is
manufactured by Philips. This microcontroller has 256 byte RAM and 64KB flash
memory. It has 4 timers, 1 serial port and 4 I/O ports (each 8 bit) on a single chip. It is
a flash type 8051. The present project is implemented on Keil vision. In order to
program the device, preload tool has been used to burn the program onto the
microcontroller or it can be connected to a computer through the serial port as the IC
has in-built ISP mode. The features, pin description of the microcontroller and the
software used are discussed below.
The 89C51RD2xx is a Single-Chip 8-Bit Microcontroller manufactured in advanced
CMOS process and is a derivative of the 80C51microcontroller family. The device also has 4 8-bit
6

I/O ports, 3 16-bit timer/event counters, 4 priority levels, nested interrupt structure, an enhanced
UART and on-chip oscillator and timing circuits.
The device contains a non-volatile 64kB Flash program memory that is both parallel
programmable and serial In-System and In-Application Programmable. In-System Programming
(ISP) allows the user to download new code while the microcontroller sits in the application. InApplication Programming (IAP) means that the microcontroller fetches new program code and
reprograms itself while in the system.
This device executes one machine cycle in 6 clock cycles, hence providing twice the speed
of a conventional 80C51. The added features of the P89C51RD2BN make it a powerful
microcontroller for applications that require pulse width modulation, high-speed I/O and up/down
counting capabilities such as motor control.
Registers:
8051has34generalpurposeorworkingregisters.TwoofthemA&B, holdresults of
manyinstructions,particularlymathematical and logical operationsof 8051 CPU.
The other 32 registersarranged as apart of internal RAM in 4banks RB0-RB3.
A

(accumulator)registerisusedformanyoperations-

Addition,Subtraction,integer multiplications &division and Booleanbitmanipulations.


RegisterBisusedwithregisterAformultiplication&divisionoperationsandalso for
datatransfer.
3.4.1 PROGRAMSTATUS WORD(PSW):

Fig: 3.3 Program Status Word Register


CY: Carryout fromaccumulator MSB ofALUoperand
AC: Auxiliarycarryfor BCDoperations
FO: Generalpurpose
RS1 & RS0: For register banksselection (RB0-RB3)
OV: Overflowflag
P: Parityof accumulatorset byhardware to1 if it containsodd no of1s

Auxiliary carry:
If

there

is

carry from

D3

to

D4

position

during

Add/Sub

operation,thisbitwillset. Otherwise, itiscleared.ThisflagisusedforBCD operations.


Parityflagreflectsthenumberof1sinA.IfAcontainsanoddnumberof1s,
P=1. ThereforeP=0,if Ahas an evennumber of1s.
7

then

Overflowflag:
Thisflagissetwhenevertheresultofasignednumberoperationis

too

largeto

beaccommodated in7 bits,causing thehigherorderbit to overflowinto thesign bit.


3.4.2 INTERRUPTS:
An Interrupt isan external or internal event that interrupts the microcontroller
to inform it that a device needs its service.
Whenever anydevice needs its service, the device notifies the microcontroller
bysending it an interrupt signal. Upon receiving an interrupt signal, the
microcontrollerinterrupts whatever it is doing and serves the device.
The programwhich is associated with theinterrupt is called theinterrupt service
routine (ISR)or interrupt handler. For every interrupt, there is a fixed location in
memory that holds the address of its ISR. The group of memory locations set aside to
hold the address of ISRs is called the interrupt vector table shown below.
3.4.2.1 Steps in Executing an Interrupt

C finishes the instruction it is executing and saves the address of the next
instruction (PC) on the stack

It saves the current status of all the interrupts internally

It jumps to a fixed location in memory called the interrupt vector table

The microcontroller gets the address of the ISR from the interrupt vector table
and jumps to it and starts to execute the ISR until it reaches the last instruction
RETI

The microcontroller returns to the place where it was interrupted, it gets the
PC address from the stack by popping the top two bytes of the stack into the
PC and then it starts to execute from that address.

The 8051 provides five interrupt sources. These are listed below.

Timer 0 (TFO) and timer 1 (TF1) interrupt.

External hardware interrupts, INT0 and INT1.

Serial communication interrupt TI and RI

3.4.3 TCON (Timer/Counter) register


Pins, P 3.2 (pin number 12) and P 3.3 (pin number 13) in port 3 are used as
external hardware interrupts INT0 and INT1, respectively. The external Interrupts
INT0 and INT1 can each be either level-activated or transition-activated, depending
8

on bits IT0 and IT1 in Register TCON. The flags that actually generate these
interrupts are bits IEO and IE1 in TCON. When an external interrupt is generated, the
flag that generated it is cleared by the hardware when the service routine is vectored
to only if the interrupt was transition-activated. If the interrupt was level-activated,
then the external requesting source is what controls the request flag, rather than the
on-chip hardware.

3.4.4 TMOD Register:


TMOD register is an 8 bit register. The two timers T0 and T1 are controlled
through this register. The 8 bit register is divided into two identical halves. The upper
4 bits are used to control the timer1 while the lower 4 bits are used to control timer0.
The 4 bits of each half is assigned a task. The MSB bit in each part is taken as gate.
The next bit is used to toggle between timer mode and counter mode (C/!T). The
lower two bits are used to toggle between different modes of operation. There are 4
modes of operation for the timers.
The TMOD register is shown figure below.

Figure 3.4 TMOD Register


3.4.5PIN DIAGRAM OF P89C51RD2xx
3.4.5.1 Pin Description

Ground: 0 Vreference.
Power Supply: This is the powersupplyvoltage for normal, idle,and powerdown operation.
9

Port 0:
The pins 39-32 are considered as port0. Port 0is an open-drain,
bidirectional I/Oport.Port0 pins thathave1s written tothemfloat and canbe used
ashigh-impedance inputs.Port 0is alsothemultiplexed low-order address and
databus during accessesto externalprogramand data memory. In this

application,ituses stronginternal pull-ups when emitting 1s.


Port 1:
The pins 01-08 are considered as port1.Port 1is an 8-bit bidirectional
I/Oport withinternal pull-upson allpins.Port 1pins that have1s written to
themare pulled highbythe internal pull-ups and canbe used as inputs. Asinputs,
port 1pinsthat are externallypulled lowwill source current because ofthe

internal pull-ups.
Port 2:
The pins 21-28 are considered as port2.Port
bidirectionalI/Oport

withinternal

pull-ups.Port2

pins

2is
that

an

8-bit

have

1s

writtentothemare pulled highbytheinternal pull-ups and canbe used as inputs.


As inputs,port 2pinsthat are externallybeingpulled lowwill source current
because ofthe internal pull-up. Port 2 emitsthehigh-order address byte during
fetches fromexternalprogrammemoryand during accessesto externaldata
memorythatuses16-bit

addresses

(MOVX@DPTR).In

thisapplication,itusesstronginternal pull-ups when emitting1s.


Duringaccessesto

externaldata

memorythatuses

8-bit

addresses

(MOV@Ri), port2 emitsthe contents ofthe P2 special function register.

Port 3:
The pins 10-17 are considered as port3.Port 3is an 8-bit bidirectional
I/Oport withinternal pull-ups.Port3 pins that have 1s writtentothemare pulled
highby theinternal pull-ups and canbe used as inputs. As inputs,port 3pinsthat
are externallybeingpulled lowwill source current because ofthe pull-ups.Port3
also servesthespecial features ofthe P89C51RD2xx,arelisted in tablebelow:
Table: 3.3 Port 3 Alternate Functions

Reset:

10

Pin9 is the reset pin. It is an input and is active high. A high on this pin for
two machine cycles while the oscillator is running, resets the device. An internal
resistor to VSS permits a power-on reset using only an external capacitor to VCC.

Address Latch Enable:


Pin 30 is ALE. It is active high. This is an output pin. Output pulse for latching

the low byte of the address during an access to external memory. In normal
operation, ALE is emitted twice every machine cycle, and can be used for external
timing or clocking. Note that one ALE pulse is skipped during each access to
external data memory. ALE can be disabled by setting SFR auxiliary.0. With this
bit set, ALE will be active only during a MOVX instruction.

Program Store Enable:


Pin 29 is a PSEN. It is active low signal. This is an output pin.When executing
code from the external program memory, PSEN is activated twice each machine cycle,
except that two PSEN activations are skipped during each access to external data
memory. PSEN is not activated during fetches from internal program memory.

External Access Enable/Programming Supply Voltage:


Pin 31 is EA. It is an active low signal. It is an input pin and must be connected to either
VCC or GND but it cannot be left unconnected. EA must be externally held low to enable
the device to fetch code from external program memory locations. If EA is held high, the
device executes from internal program memory. The value on the EA pin is latched
when RST is released and any subsequent changes have no effect. This pin also receives
the programming supply voltage (VPP) during Flash programming.

XTAL1 and XTAL2:


XTAL1 (19th pin) and

3.4.6 BLOCK DIAGRAM OF P89C51RD2xx MICROCONTROLLER


A timer module allows the microcontroller to perform tasks for certain time periods. A
serial I/O port is to allow data to flow between the microcontroller and other devices
such as a PC or another microcontroller. Port 0 acts as a multiplexed address/data bus
by sending the low byte of the program counter (PCL) as an address. Port 2 sends the
11

program counter high byte (PCH) directly to the external memory. The signal ALE
operates as in the 8085 to allow an external latch to store the PCL byte while
multiplexed bus is made ready to receive the code byte from the external memory.
Port 0 then switches function and becomes the data bus receiving the byte from
memory.
3.4.7 FEATURES

80C51 Central Processing Unit

On chip Flash Program Memory with In-System Programming (ISP) and InApplication Programming

Boot ROM contains low level Flash programming routines for downloading
via the UART

Can be programmed by the end-user application(IAP)

Supports 6-clock/12 clock mode via parallel programmer(default clock mode


after Chip Erase is 12-clock)

Speed up to 20MHz with 6-clock cycles per machine cycle


(40MHz equivalent performance), up to 33MHz with 12 clocks per machine
cycle

RAM expandable externally to 64Kbytes


Four interrupt priority levels
Seven interrupt sources
Four 8-bit I/O ports
Full-duplex enhanced UART
8-Bit ALU, with2 registers A&B
11bit program counter &data pointer
8-Bitprogramstatus word
8 bits tack pointer
4registersbanks,each containing 8 registers
16bytes , which may be addressed at bit level
80bytes of general purpose data
Two 16bit timer/counter T0 &T1

3.5SERIAL COMMUNICATION
3.5.1 Introduction
12

In order to connect microcontroller to a modem or a pc to modem a serial port


is used. Serial is a very common protocol for device communication that is standard
on almost every PC. Most computers include two RS-232 based serial ports. Serial is
also a common communication protocol that is used by many devices for
instrumentation; numerous GPIB-compatible devices also come with an RS232 port.
Furthermore, serial communication can be used for data acquisition in conjunction
with a remote sampling device.
Typically, serial is used to transmit ASCII data. Communication is completed
using 3 transmission lines.(1) Ground, (2) Transmit and (3) Receive. Since serial is
asynchronous, the port is able to transmit data on one line while receiving data on
another. Other lines are available for handshaking, but are not required. The important
serial characteristics are baud rate, data bits, stop bits, and parity. For two ports to
communicate, these parameters much match.
Serial communication is a popular means of transmitting data between a
computer and a peripheral device such as a programmable instrument or even another
one bit at a time, over a single communication line to a receiver. You can use this
method when data transfer rates are low or you must transfer data over long distances.
Serial communication is popular because most computers have one or more serial
ports, so no extra hardware is needed other than a cable to connect the instrument to
the computer or two computers together.
Any device you connect to the serial port will need the serial transmission
converted back to parallel so that it can be used. In serial communication, the data
will be sent from one system to another in bit by bit notation. Serial Ports come in two
sizes, there are the D-Type 25 pin connector and the D-Type 9 Pin connector both
of which are male on the back of the PC, and thus you will require a female connector
on your device. The RS-232 and RS-485 come under serial communication.

3.5.2 Baud Rate:


It is a speed measurement for communication. It indicates the number of bit
transfers per second. For example, 300 baud is 300 bits per second. When a clock
cycle is referred it means the baud rate. For example, if the protocol calls for a 4800
baud rate, then the clock is running at 4800Hz. This means that the serial port is
sampling the data line at 4800Hz. Common baud rates for telephone lines are 12200,
13

28800 and 33600. Baud rates greater than these are possible, but these rates reduce
the distance by which devices can be separated. These high baud rates are used for
device communication where the devices are located together, as is typically the case
with GPIB devices.

CHAPTER IV
14

PROJECT DESIGN
4.1 HARDWARE DESIGN:
POWER SUPPLY
The input to the circuit is applied from a 9V battery. This voltage is given to a
voltage regulator to obtain a pure constant dc voltage of 5V. The output voltage of the
voltage regulator is applied to the microcontroller circuit rails which are internally
connected to the microcontroller and other circuitry.
The block diagram of microcontroller is shown below:

Fig: 4.1 Power Supply Block Diagram


Voltage regulator:
As the name itself implies, it regulates the input applied to it. A voltage
regulator is an electrical regulator designed to automatically maintain a constant
voltage level. In this project, power supply of 5V is required. In order to obtain these
voltage levels, 7805 voltage regulator is used. The first number 78 represents positive
supply and the numbers 05 represent the required output voltage levels.

15

Fig: 4.2 LM 7805 Pinout

MAX 232:
Max232 IC is a specialized circuit which makes standard voltages as required by
RS232 standards. This IC provides best noise rejection and very reliable against discharges
and short circuits. MAX232 IC chips are commonly referred to as line drivers.

To ensure data transfer between PC and microcontroller, the baud rate and
voltage levels of Microcontroller and PC should be the same. The voltage levels of
microcontroller are logic1 and logic 0 i.e., logic 1 is +5V and logic 0 is 0V. But for
PC, RS232 voltage levels are considered and they are: logic 1 is taken as -3V to -25V
and logic 0 as +3V to +25V. So, in order to equal these voltage levels, MAX232 IC is
used. Thus this IC converts RS232 voltage levels to microcontroller voltage levels
and vice versa.
Pin Configuration:

Fig: 4.3 Pin diagram of MAX 232 IC

RS 232(Female Port)
RS-232 is the component which is used to connect system (pc) to
microcontroller.
RS-232 (Recommended Standard 232) is the traditional name for a series of
standards for serial binary single-ended data and control signals connecting between a
DTE (Data Terminal Equipment) and a DCE (Data Circuit- terminating Equipment). It
is commonly used in computer serial ports. The standard defines the electrical

16

characteristics and timing of signals, the meaning of signals, and the physical size and
pin out of connectors.
RS232 is limited to point-to-point connections between PC serial ports and
devices. RS 232 hardware can be used for serial communication up to distances of 50
feet.
Voltage levels:
The RS-232 standard defines the voltage levels that correspond to logical one
and logical zero levels for the data transmission and the control signal lines.
For data transmission lines (TxD, RxD and their secondary channel
equivalents) logic one is defined as a negative voltage, the signal condition is called
marking, and has the functional significance. Logic zero is positive and the signal
condition is termed spacing.
Table: 4.1 indicating voltage levels for DB 9 connector
Logic level
1
0

Voltage level
-10V
10V

PIN CONFIGURATION

17

Fig: 4.4 DB9 Connector with pinout


4.1.3.3 DB9 INTERFACING WITH MICROCONTROLLER USING MAX 232:

Fig: 4.5DB9 interfacing with microcontroller using MAX 232

Serial port connector:


The microcontroller is connected to the pc via a serial communication port. The serial
communication port is a combination of a female port and a male port. The male port
is connected to the DB-9 connector connected to the microcontroller while the female
port is connected to the serial port of the pc.

Fig:4.6Serial Port Connector

LIQUID CRYSTAL DISPLAY:


LCD stands for Liquid Crystal Display. LCD is finding wide spread use
replacing LEDs (seven segment LEDs or other multi segment LEDs) because of the
following reasons:
1.

The ability to display numbers, characters and graphics. This is in contrast to


LEDs, which are limited to numbers and a few characters.

18

2.

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


CPU of the task of refreshing the LCD. In contrast, the LED must be refreshed
by the CPU to keep displaying the data.

3.

Ease of programming for characters and graphics.

4.

These components are specialized for being used with the microcontrollers,
which means that they cannot be activated by standard IC circuits. They are
used for writing different messages on a miniature LCD.
In our project, we use a JHD162A LCD Display which has 2 rows and 16

characters. It has a better contrast and a wider viewing angle. This LCD can display
messages in two lines with 16 characters each. It displays all the alphabets, Greek
letters, punctuation marks, mathematical symbols etc. In addition, it is possible to
display symbols that user makes up on its own. Automatic shifting message on display
(shift left and right), appearance of the pointer, backlight etc. are considered as useful
characteristics.
Features
RS232 compatible serial interface (2400 & 9600 BaudSelectable)
Externally selectable serial polarities (Inverted & Non-Inverted)
Serially controllable contrast and backlight levels
8 user programmable custom characters
16 Byte serial receive buffer
Pin Configuration:
There are pins along one side of the small printed board used
for connection to the microcontroller. There are total of 16 pins
marked with numbers .Their function is described in the table below:
SPECIFICATIONS:

Number of Characters: 16 characters x 2 Lines

Character Table: English-European (RS in Datasheet)

Module dimension: 80.0mm x 36.0mm x 13.2mm(MAX)

View area: 66.0 x 16.0 mm


19

Active area: 56.2 x 11.5 mm

Dot size: 0.56 x 0.66 mm

Dot pitch: 0.60 x 0.70 mm

Character size: 2.96 x 5.46 mm

Character pitch: 3.55 x 5.94 mm

LCD type: STN, Positive, Yellow/Green

Duty: 1/16

View direction: Wide viewing angle

LCD screen:LCD screen consists of two lines with 16 characters each. Each character
consists of 5*7 dot matrix. Contrast on display depends on the power supply voltage
and whether messages are displayed in one or two lines. For that reason, variable
voltage 0-Vdd is applied on pin marked as VEE. Trimmer potentiometer is usually used
for that purpose. Some versions of displays have built in backlight (blue or green
diodes). When used during operating, a resistor for current limitation should be used
(like with any LE diode)
To start with LCD the user should initialize it first which should be
programmed with its LCD commands. The LCD commands are given
Table 3.3 Commands for LCD
KEYPAD:
Keypads and LCDs are the most widely used input/output devices of the 8051
and a basic understanding of them is essential. Keypad is used in this project for the
purpose of Authentication of user such as user id, password, changing price, user
mobile number, etc. Therearevastvarietiesofkeypadsavailableinthemarket;amongthem
theoneis selectedas4*4matrix keyboard. Theselectedkeyboardisoflowinthecostandthe
resourceoccupationbythemicrocontrollerisalsominimalincount (I/Oportoccupation).
The keypad used in this project is 4*4 keypad.
20

Fig: 4.8 4*4 matrix keypad

SENSORS AND IC NE555 TIMER:


SENSOR:
A sensor is a combination of a transmitter and a receiver. A transmitter is used
to transmit the IR signals which are received at the receiver. The sensor unit is used
along with a 555 timer. Whenever the transmission is blocked the sensor unit sends an
interrupt signal to the microcontroller which then increments the counter.
Photo diode:
A photodiode is a type of photo-detector capable of converting light into
either current or voltage, depending upon the mode of operation.
Photodiodes are similar to regular semiconductor diodes except that they may
be either exposed (to detect vacuum UV or X-rays) or packaged with a window or
optical fiber connection to allow light to reach the sensitive part of the device. Many
diodes designed for use specifically as a photodiode will also use a PIN junction
rather than the typical PN junction.
21

Principle of Operation:
A photodiode is a PN junction or PIN structure. When a photon of sufficient
energy strikes the diode, it excites an electron thereby creating a mobile electron and a
positively charged electron hole. If the absorption occurs in the junction's depletion
region, or one diffusion length away from it, these carriers are swept from the junction
by the built-in field of the depletion region. Thus holes move toward the anode, and
electrons toward the cathode, and a photocurrent is produced.

Applications:
Photo diodes are used in

Consumer electronic devices such as compact disc players, smoke


detectors, and the receivers for remote controls in VCRs and television.

Accurate measurement of light intensity.

Detectors for computed tomography (coupled with scintillators) or


instruments to analyze samples (immunoassay), pulseoximeters.

Optical communications and in lighting regulation.

Astronomy, spectroscopy, night vision equipment and laser range finding.

IR Receiver:

22

IR receiver is used to receive the signals transmitted by the IR transmitter.IR


receiver is similar to an N-P-N transistor. It is a three terminal device but looks like a
two terminal device a base is connected internally. It is a nothing but a phototransistor.

Principle of Operation:
The electrons that are generated by photons in the base-collector junction are
injected into the base, and this current is amplified by the transistor operation. Note
that although phototransistors have a higher responsivity for light they are unable to
detect low levels of light any better than photodiodes. Phototransistors also have
slower response times.

Resistors:
A resistor is a two-terminal passive electronic component that implements
electrical resistance as a circuit element. When a voltage V is applied across the
terminals of a resistor, a current I will flow through the resistor in direct proportion to
that voltage. This constant of proportionality is called conductance, G. The reciprocal
of the conductance is known as the resistance R, since, with a given voltage V, a
larger value of R further "resists" the flow of current I as given by Ohm's law:

Fig: 4.12 Resistors

23

Practical resistors can be made of various compounds and films, as well as


resistance wire (wire made of a high-resistivity alloy, such as nickel-chrome).
Resistors are also implemented within integrated circuits, particularly analog devices,
and can also be integrated into hybrid and printed circuits.
Capacitors:
A capacitor (formerly known as condenser) is a device for storing electric charge. The
forms of practical capacitors vary widely, but all contain at least two conductors
separated by a non-conductor. Capacitors used as parts of electrical systems, for
example, consist of metal foils separated by a layer of insulating film.
A capacitor is a passive electronic component consisting of a pair of conductors separated by
a dielectric (insulator). When there is a potential difference (voltage) across the conductors, a
static electric field develops across the dielectric, causing positive charge to collect on one
plate and negative charge on the other plate. Energyis stored in the electrostatic field. An ideal
capacitor is characterized by a single constant value, capacitance, measured in farads. This is
the ratio of the electric charge on each conductor to the potential difference between them.

Fig: 4.13Capacitors
Capacitors are widely used in electronic circuits for blocking direct current
while allowing alternating current to pass, in filter networks, for smoothing the output
of power supplies, in the resonant circuits that tune radios to particular frequenciesand
for many other purposes.
The capacitor is a reasonably general model for electric fields within electric
circuits. An ideal capacitor is wholly characterized by a constant capacitance C,
defined as the ratio of charge Q on each conductor to the voltage V between them:

24

25

CHAPTER V
IMPLEMENTATION
5.1 HARDWARE IMPLEMENTATION:

Fig: 5.1 Schematicof Smart Energy Meter


In this schematic we observe the following connections of microcontroller
with LCD, keypad, sensors and MAX 232.
Microcontroller P89C51RD2XX connections:
It includes Keypad interfacing, LCD interfacing, MAX 232 connections and
RS232 connections, IR transceiver connections.

The 5V DC supply from the power supply circuit is given to the pins 40(VCC)

& 20pin (GND) of P89C51RD2XX for its working.


The Oscillatory circuit with crystal frequency 11.0592MHz is give to the
18(XTAL2) & 19(XTAL1) pins of P89C51RD2BN. The frequency 11.0592 is

used particularly for setting the proper baud rate for serial data transfer.
The 9(RST) pin is connected to reset circuit consisting of a 4 pin switch a
resistor (8.2K) & capacitor (10f). The 8.2K resistor is grounded through 1
pin, the10f capacitor is connected between VCC and one of other 3 pins, one
pin is connected to VCC and the remaining pin is connected to 9 th pin of
26

microcontroller. We should take care that the connections are such that resistor
is connected to VCC and the 9th pin is connected to VCC through the capacitor.

This circuit enables to reset the system to the original configuration.


The Port 1 is used to interface the keypad. In this Port1 the pins P1.0, P1.1,
P1.2 and P1.3 are used for detection of rows, and pins P1.4, P1.5, P1.6 and

P1.7 are used to detect columns.


The Port0 is used to interface LCD data lines. Through this Port the

P89C51RD2BN can send the command and data bytes.


The Port 2.5 is connected to RS pin of LCD, and Port 2.6 is connected to RW
pin of LCD, Port 2.7 is connected to EN pin of LCD. These pins enable the

LCD to operate in different modes.


The pins P3.0 (RxD) and P3.1 (TxD) are connected to the 11, 12 pins of MAX
232 which is used as a level translator. Through these pins the data is

transmitted between microcontroller and MAX 232.


The pins 2(RxD), 3(TxD) of RS 232 is connected to 13(TxD) and 14(RxD)

pins of MAX 232 for data transmission.


The P3.2 (INT0) pin is connected to IR Receiver through resistors.
The 29th pin is connected to a 3 pin switch which is used to toggle between
program execution (high) and code dumping (low).

LCD CONNECTIONS:

The LCD used is JHD162A, it is a 16 pin LCD


The 1st and 2nd pins are connected to ground and VCC respectively.
The 3rd pinis connected to a variable resistor or a potentiometer to

adjust the contrast.


The 4th, 5th ,6th pins are connected to 26th (P 2.5), 27th (P 2.6), 28th (P

2.7) pins of the microcontroller respectively.


The 7th to 14th pins are data pins and are connected to the 39th (P 0.0) to

32nd (P 0.7) pins of the microcontroller respectively.


The 15th and 16th pins are used for backlight purpose. 15 th pin is
connected to VCC and 16th pin to ground.

CONTRAST CONTROL:

27

To have a clear view of the characters on the LCD, contrast should be


adjusted. To adjust the contrast, the voltage should be varied. For this, a preset is used
which can behave like a variable voltage device. As the voltage of this preset is
varied, the contrast of the LCD can be adjusted.

Fig: 5.2 Variable Resistor


The LCD connections are as shown in figure below:

Fig: 5.3 LCD Connections

KEYPAD CONNECTIONS:

The keypad used is 4*4 keypad


The pins 1, 2, 3, 4 which are connected to columns of the keypad are
connected to 1, 2, 3, 4(P1.0 to P1.3) pins of the microcontroller
respectively.

28

The pins 5, 6, 7, 8 which are connected to rows of the keypad are


connected to 5, 6, 7, 8(P1.4 to P1.7) pins of the microcontroller
respectively.

INTERFACING THE KEYPAD TO 8051:


At the lowest level, keyboards are organized in a matrix of rows and columns.
The CPU accesses both rows and columns through ports. Therefore, with one 8-bit
port, a4*4 matrix of keys can be connected to a microprocessor. When a key is
pressed, a row and a column make a contact otherwise there is no connection
between rows and columns. It is the function of programs stored in EPROM of the
microcontroller to scan the keys continuously, identify which one has been
activated and present it to the microcontroller.

Scanning and identifying the key:


The rows are connected to an output port and the columns are connected to an
input port. If no key has been pressed, reading the input port will yield 1s for all
columns since they are all connected to high (Vcc). If all the rows are grounded and a
key is pressed, one of the columns will have 0 since the key pressed provides the path
to ground. It is the function of the microcontroller to scan the keypad continuously to
detect and identify the key pressed.
Grounding rows and reading the columns:

Fig: 5.5 initializing rows with 0s and columns with 1s


To detect a pressed key, the microcontroller grounds all rows by providing 0
(zero) to the output latch and then it reads the columns. If the data read from the
columns is D3-D0 =1111, no key has been pressed and the process continues until a
key press is detected. However, if one of the column bits has a zero, this means that a
29

key press has occurred i.e., for example, if D3-D0=1110, this means that a key in the
D0 column has been pressed. After a key press is detected, the microcontroller will go
through a process of identifying the key. Starting with the top row, the microcontroller
grounds it by providing a low to row D0 only and then it reads the columns. If the
data read is all 1s, no key in that row is activated and the process is moved to the next
row. It grounds the next row, reads the columns and checks for any zero. This process
continues until the row is identified. After identification of the row in which the key
has been pressed, the next task is to find out which column the pressed key belongs to.
Now this will be easy since the microcontroller knows at any time which row and
column are being accessed.
The keypad connections are shown in figure below:
Fig: 5.6 Matrix Keypad schematic
555 TIMER and IR transmitter connections:

The sensor is designed using a 555 timer, a IR transmitter and a IR

receiver.
The 555 timer is operated in astable mode of operation.
The 1st pin is grounded.
The 2nd pin and 6th pin are shorted, 2nd pin is connected to VCC through
the 10K and 220K pot, IR receiver is connected to 2 nd pin in reverse

bias.
The pin 3 of 555 timer is an output pin which is connected to the 12 th

pin (P 3.2) of the microcontroller.


The 4th pin and 8th pin are shorted, 8th pin is connected to VCC and 0.1f

capacitor is connected between 8th pin and ground.


The 5th pin is grounded through 0.01f capacitor.
The IR transmitter is connected between VCC and ground through 270
ohm resistor. It is connected in forward bias.

If there is obstruction between transmitter and receiver, the receiver


output gives 3V to 5V.

Whenever there is an obstruction of current between transmitter and


receiver, the current passed to receiver decreases and hence the voltage
across voltage divider decreases. As a result a short pulse is applied to
the port pin of the 8051 sensor circuit, the controller increments the
counter which indicates the consumption of electricity.
30

CONCLUSION
Since the inception of electricity deregulation and market-driven pricing
throughout the world, utilities have been looking for a means to match consumption
with generation. Smart meters are also believed to be a less costly alternative to
traditional interval or time-of-use meters and are intended to be used on a wide scale
with all customer classes, including residential customers
Supporting Consumers: a) An end to estimate bills, which are a major source
of complaints for many customers b)A tool to help consumers better manage their
energy use - smart meters with a display can provide up to date information on
electricity consumption in the currency of that country and in doing so help people to
better manage their energy use and reduce their energy bills and carbon emissions .c)
voltage levels, and power events can be tracked and logged across the entire customer
base.
Supports Power Grid: The Ability to remotely turn power on or off to a
customer, read usage information from a meter, detect a service outage, detect the
unauthorized use of electricity, know the maximum amount of electricity that a
customer can demand at any time. It is projected to reduce the staff required to read
meter data across the customer base.
The billing is through HyperTerminal or GSM, so lot of paper can be saved
.So Cutting of Trees can be avoided. It is believed that billing customers by time of
day will encourage consumers to adjust their consumption habits to be more
responsive to market prices thereby saving the power by which natural resources are
protected.

31

BIBILOGRAPHY:

Janci Gillespie Mazidi, Muhammad Ali Mazidi,The 8051micro controller and


Embedded

systems,

PHI

Prentice

hall

India,

Eastern

Economy

Edition,www.phindia.com

Kenneth J. Ayala, The 8051 Microcontroller, architecture, Programming and


Applications, Pen ram international publishing Pvt. Ltd. 1996

Arnold S. Berger, Embedded systems design, an introduction to process, tools and


Techniques, CMP Books, 2005. www.cmpbooks.com

Yashvant Kanetkar, Let Us C, BPB Publications, 1999 www.bpbpub.com

Dreamtech Software Team, Programming for Embedded systems, WILEY Publishing,


Inc, 2003.
WEBSITES:
http://www.8051.com/
http://www.8051projects.net/
http://www.wikipedia.org/

32

You might also like