Sie sind auf Seite 1von 32

Project report

On
Major project
Electricity Theft

Submitted By:
Jasvir Kaur

Submitted To:
Proff. Gursewak Singh Brar

BABA BANDA SINGH BAHADUR ENGG. COLLEGE


FATEHGARH SAHIB

Acknowledgment
The authors gratefully acknowledge the guidance provided by the project
supervisor AP. Navpreet Singh Tungthroughout the development of the
project.
The authors also wish to thank the other faculty members for their valuable
suggestions and directions.
The authors also thank their batch mates for providing constant
encouragement,
support and valuable suggestions during the development of the project.

Contents
Objective
Introduction
Block Diagram
Circuit Diagram
Chapter 1
Chapter 2
Objective:
Electricity Theft Detection
Automatic Wireless Reading

INTRODUCTION:In this project we will use wireless technology to monitor theft in Electricity
meter. An electric meter is a device used for measuring the amount of
electrical energy supplied to a residential or commercial building. Due to the
increasing cost of electricity, tampering and security in electric meters has
become a major concern for government agencies across the globe.
Especially in populous countries like India and China tampering in electric
meter and energy theft have become quite common.
Electric meters can be manipulated, thus causing them to stop, underregister or even bypassing the meter. Consumers, who are tamper with
electric meter, effectively use power without paying for it. This theft or fraud
can be dangerous as well as dishonest. Electric meter security is looked upon
as major issue in many countries today.
Today, many power companies are installing remote-reporting meters which
are capable of detect any tampering in electric meters, and discover energy
theft. These smart power meters are particularly helpful in preventing energy
theft and encouraging security in electric meters.
A large portion of a countrys revenue is lost due to the high density of
tampering and security in electric meters. Hence it becomes very important
to detect tampering in electric meters to ensue proper billing. Electric meter
readers are trained to spot signs of tampering. The consumers who tamper
with electric meter may be charged each billing period with the maximum
rate until the tamper is removed, or in some cases the service may also be
disconnected.
A common method of tampering with electric meters is by attaching
magnets to the outside of the meter. These magnets prevent the alternating
current from forming eddy currents in the rotor, by saturating the coils or
current transformers.

Rectified DC loads causes mechanical but not electronic meters to underregister. As the DC currents do not cause the coils to make eddy currents in
the disk, thus causing reduced rotation and a lower bill. Other ways of
tampering in electric meters and playing with the electric meter security is to
use some combinations of capacitive and inductive load, which also result in
reduced or reverse motion.
Today, many modern meters can easily detect all of these effects. The owner
of the meter normally secures the meter against tampering. Newer
computerized meters usually have counter-measures against tampering. In
order to find and fix power distribution problems, power companies today
normally investigate discrepancies between the total billed and the total
generated These investigations are an effective method of discovering
tampering and security in electric meters.
Electricity distribution losses totalled Rs 70,000 crore in India.
In this project we will use remote monitoring method to prevent electricity
theft. We will also try to present our method to electricity department.
We will use Radio technology to monitor wirelessly meter reading . if there
will be difference in wirless reading and installed meter reading , then we
can easily detect theft. In digital data user cant change value.
In this project we use one lcd screen. LCD screen display the balance
amount every time, LCD screen not only show the balance amount but at the
same time lcd display the unit consumption. When the balance is zero then
output is off.
Now for continue the voltage we must need to recharge the unit from the
mobile phone.

In this project we made a digital energy meter. When energy meter


starts then it will transmit reading using RF technology. In the RF
receiver side when rf signal received then it will also show on
receiver side also. RF receiver will be provided to local substation
to get reading. With the help of this project when reading different
from subastion reading then we can easily detect user is doing
something with meter reading or not. Another benefit of this
project is meter reader will not have to collect reading from
customer end. He could take substation reading.

CKT DIAGRAM:-s

Block Diagram Installed System:

LCD
display

Power supply

RF
transmitter

Microcontroller
Unit

Encoding
ciruit

Relay
Circuit

Load Feed
back
Circuit

Block Diagram Remote System:


Power supply

LCD
display

Microcontroller
Unit

RF
Receiver

Decoding
ciruit

Advantages of Using Remote MethodOne time investment


It will save money of employees those are taking door to door
reading.
Its not possible to interrupt wireless data
Easy to implement
Flexible system
Our project is to be divided into 6 parts.
5 VOLT REGULATED POWER SUPPLY
MOBILE SIGNAL DECODER
BCD TO DECIMAL DECODER.
MICROCONTROLLER INTERFACE.
LCD INTERFACE .
RF Transmitter Circuit
RF receiver Circuit

Componets used in this project.


LCD FOR DISPLAY PURPOSE DISPLAY THE BALANCE AMOUNT
AND UNIT CONSUME ( 2 LINE AND 16 CHARACTER)
MICROCONTROLLER. 89C51, 40 PIN CONTROLLER, 128 BYTE
RAM, 4 K BYTE RAM. USED HERE FOR LCD DISPLAY AND START
STOP FUNCTION. CHECK THE BALANCE AND CONTROL THE
LOAD AS PER THE BALANCE.
IC 8870 , DTMF DECODER IC.
IC 8870 PROVIDE A GSM INTERFACE WITH THIS CIRCUIT. DUE TO
THIS IC WE DECODE THE CALL THE PROVIDE A BALANCE IN
THE ENERGY METER AUTOMATICALLY.
IC 74154 IS A BCD TO DECIMAL DECODER ATTACH WITH THE
MICROCONTROLLER TO INTERFACE WITH THE DTMF DECODER

5 VOLT REGULATED POWER SUPPLY TO PROVIDE A REGULATED


VOLTAGE TO THE MICROCONTROLLER UNIT.
.

5 VOLT REGULATED POWER SUPPLY CIRCUIT.


In this project firstly we use one step down transformer. Step down transformer step
down the voltage from 220 volt Ac to 12 volt Ac. This Ac voltage is further converted
into DC with the help of rectifier circuit. In rectifier circuit we use four diode. All the
diodes are arranges as a bridge rectifier circuit. Output of this rectifier is pulsating Dc.
To convert this pulsating DC into smooth dc we use one capacitor as a filter components.
Capacitor converts the pulsating Dc into smooth DC with the help of its charging and
discharging effect.
Output of the rectifier is now regulated with the help of IC regulator circuit. In this
project we use positive voltage regulator circuit. Here we use three pin regulator. Output
of this regulator is regulated voltage. If we use 7805 regulator then its means its is 5 volt
regulator and if we use 7808 regulator then its means that it is 8 volt regulator circuit. In
this project we use 5 volt dc regulated power supply for the complete circuit. Separate 9
volt dc power supply is used for the relay coil

TRANSFORMER
Transformer works on the principle of mutual inductance. We know that if
two coils or windings are placed on the core of iron, and if we pass
alternating current in one winding, back emf or induced voltage is produced
in the second winding. We know that alternating current always changes
with the time. So if we apply AC voltage across one winding, a voltage will
be induced in the other winding. Transformer works on this same principle.
It is made of two windings wound around the same core of iron. The
winding to which AC voltage is applied is called primary winding. The other
winding is called as secondary winding.

Voltage and current relationship:


Let V1 volts be input alternating voltage applied to primary winding. I1 Amp
is input alternating current through primary winding. V2 volt is output
alternating voltage produced in the secondary. I2 amp be the current flowing
through the secondary.
Then relationship between input and output voltages is given by
V1/V2 = N1/N2
Relationship between input and output currents is
I1/I2 = N2/N1
(Where N1 is no. of turns of coil in primary and N2 is number of turns in
secondary )
We know that Power = Current X Voltage. It is to be noted that input power
is equal to output power. Power is not changed. If V2 is greater than V1, then
I2 will be less than I1. This type of transformer is called as step up
transformer. If V1 is
greater than V2, then I1 will be less than I2. This type of transformer is called
as step down transformer.
For step up transformer, N2>N1, i.e., number of turns of secondary winding
is more than those in primary.
For step down transformer, N1>N2, i.e., numbers of turns of primary winding
is more than those in secondary.
DTMF DECODER
In the DTMF decoder circuit we use one DTMF decoder circuit to
interface the mobile unit with this project. We dial the number of the phone
connected to the energy meter then phone is automatic on and no we press a
button 1 or button 2 to enter a value of 50 to 100 Rs in the meter. For this
purpose we must need a mobile interface circuit with out project. . In this
interface circuit we use one main ic 8870. This ic 8870 decode the dtmf
pulses into bcd pulse . This bcd pulses is further converted into decimal unit
with the help of bcd to decimal decoder circuit.. For the bcd to decimal
decoder circuit we use ic 74154 to decode the bcd signal to decimal signal.

PIN DESCRIPTION
IC 8870 is a DTMF (dual tone multiple frequency) decoder .It converts dtmf
pulse into the equivalent BCD signal. Pin no. 18 and 10 of this IC are
connected to the positive supply. This positive supply is from the 5 volt
regulator circuit. Pin no. 9,5,6 are connected to the negative supply. Signal
from the telephone line is in the form of dtmf pulse is applied to pin no. 2 of
this IC through 2.2k ohm resistor and .1mfd capacitor. This signal is also
connected to pin no. 3 through 100k ohm resistor. Pin no. 7 and 8 are
connected to a crystal of frequency 3.7945 mh. Pin no. 16 and 17 of this IC
is reset pin. Pin no. 11,12,13,14 are the BCD output of this IC.
Substitute ICs: 9170, 3170

IC 74154
24

23

22

21

20

19

18

17

16

15

14

13

10

11

12

PIN DESCRIPTION
IC 74154 is a BCD to Decimal converter. This IC is a 24 pin IC. Pin
no.20,21, 22,23 are the BCD input pins of this IC,pin no.
2,3,4,5,6,7,8,9,10,11, are the output pins, pin no.24 is connected to the
positive 5 volt supply and pin no.12 is the negative supply pin. Pin no. 18
and pin no. 19 of this IC is enable pin. If the data available on the pin no. 19
is negative then output is negative for a time. The negative pulse is given by
the NPN transistor collector point. IC 74154 is a special package may be
used to provide a 1 low output out of 16 outputs or may be used to send
input data to one selected output of 16, the remaining 15 staying high.

MICROCONTROLLER 89C51.

89c51 microcontroller is a main ic of this project. To drive the lcd, to check


the balance amount and balance comparison all this activity is done in the
this ic. Here we use microcontroller for this purpose. We wrote a program
for this ic. Program is to be written in the ASM codes and then this code is
converted into hex code with the help of the assembler. In this project we use
8051 ide software to assemble the asm codes into hex code. Once the code
is converted into hex code then we tranfer this code in the blank ic with the
help of program kit connected with the computer. After transfer the hex code
in the blank ic our ic is ready for the project .

Relay Interface Circuit:


In Relay Interface circuit we will make load control and feedback system .
In this circuit we will check load is connected or not. If load is not connected
then it will not give signal to microcontroller and meter will stop. If we will
charge any amount then microcontroller will give low output at pin no 22 of
microcontroller. Pin 21 p2.1 is connected to pnp transsitor bc 547 or 558
whose conllector connected to base of npn transistor. Emitter of pnp is
connected to +ve of 5v. then when pnp get low , it will give high to npn. Npn
will get activated . whose emitter connected to ground, collector connected
to relay .

RELAY :
Relay have 5pins. Check resistance of pins . those pins will give maximum
resistance those are coil pins. Connect one end of coil to npn transistors
collector and other end to +12v. when relay will get ve from npn transsitor
then it will get activate and will work as a switch .
Electricity logic: Now 220 v AC have two wires one neutral and phase. We
will use two transformer for stepdown voltage. We will use primary for input
. one end of primary will connect to bulb. Other to neutral directly to
primary of transformer. Output of transformer connected to optocoupler
which will get activated when load connected .
Optocoupler will be nconnected to tarnssitor which will give signal to
Mircoontroller.
Mirocontroller will get input at pin p3.3.

RELAY DRIVER LOGIC.


In the relay drive logic we interface the micrcontroller with the load . If the
balance is shown on the lcd then microcontroller gives a output from the
output on any pre decided pin. On this negative data is available. To
interface the negative data to control the relay we use two transistor circuit.
Output from the microcontroller is connected to the PNP transistor through 1
k ohm resisitor and output of the PNP transistor is connected to the base of
the npn transistor through 1 k ohm resisitor. Output of the npn transistor is
directly connected to relay driver coil. Relay is a electromagnetic switch
when switch on by the npn transitor then relay transfer the main supply to
the receiver unit directly.

THE RELAY
V. Ryan 2002

A relay is an electromagnetic switch. In other words it is activated


when a current is applied to it. Normally a relay is used in a
circuit as a type of switch (as you will see below). There are
different types of relays and they operate at different voltages.
When you build your circuit you need to consider the voltage that
will trigger it.

RELAY SYMBOLS

The main part of a relay is the coil at the centre. A small current
flowing through the coil in the relay creates a magnetic field that
pulls one switch contact against or away from another. Putting it
simply, when current is applied to the contacts at one side of the
relay the coil allows the contacts at the other side to work.
Usually relays are used to turn on a second circuit. The first
circuit activates the relay which then turns on the second circuit.

EXAMPLE CIRCUIT
This simple circuit activates the relay only when the LDR is dark
(covered). This could be used as part of an automatic animal
feeder. For instance, if the animal was fed at night the circuit
above would activate the relay. A second circuit, connected to the
other side of the relay releases food into a dish.

COMPONENTS USED:
STEP DWON TRANSFORMER.

220 TO 9 VOLT AC 1 PC

DIODE

IN 4007

2 PC

CAPACITOR

1000mfd

1PC

9170DTMF DECODER.
74154 BCD TO DECIMAL DECODER.
89C51 MICROCONTROLLER.
LCD

2 BY 16

TRANSISTOR:
BC 548
BC 558

NPN
PNP

RELAY
12 VOLT DC SINGLE POLE SINGLE THROW

REGULATOR
7805.
P.C.B COPPER CLAD BOARD ( GENERAL)
LED (3)
CRYSTAL.
3.58 Mhz
12 MHz

MICROCONTROLLER
Look around. Notice the smart intelligent systems? Be it the T.V, washing machines,
video games, telephones, automobiles, aero planes, power systems, or any application
having a LED or a LCD as a user interface, the control is likely to be in the hands of a
micro
controller!
Measure and control, thats where the micro controller is at its best.
Micro controllers are here to stay. Going by the current trend, it is obvious that micro
controllers will be playing bigger and bigger roles in the different activities of our lives.
So
where
does
this
scenario
leave
us?
Think
about
it
The

world

of

Micro

controllers

What is the primary difference between a microprocessor and a micro controller? Unlike
the microprocessor, the micro controller can be considered to be a true Computer on a
chip.
In addition to the various features like the ALU, PC, SP and registers found on a
microprocessor, the micro controller also incorporates features like the ROM, RAM,
Ports,
timers,
clock
circuits,
counters,
reset
functions
etc.
While the microprocessor is more a general-purpose device, used for read, write and
calculations on data, the micro controller, in addition to the above functions also controls
the
environment.
We have used a whole lot of technical terms already! Dont get worried about the
meanings at this point. We shall understand these terms as we proceed further
For now just be aware of the fact, that all these terms literally mean what they say.
Bits

and

Bytes

Before starting on the 8051, here is a quick run through on the bits and bytes. The basic
unit of data for a computer is a bit. Four bits make a nibble. Eight bits or two nibbles
make a byte. Sixteen bits or four nibbles or two bytes make a word.

1024 bytes make a kilobyte or 1KB, and 1024 KB make a Mega Byte or
1MB.
Thus when we talk of an 8-bit register, we mean the register is capable of holding data of
8
bits
only.
The
8051
The 8051 developed and launched in the early 80`s, is one of the most popular micro
controller in use today. It has a reasonably large amount of built in ROM and RAM. In
addition
it
has
the
ability
to
access
external
memory.
The generic term `8x51` is used to define the device. The value of x defining the kind of
ROM, i.e. x=0, indicates none, x=3, indicates mask ROM, x=7, indicates EPROM and
x=9
indicates
EEPROM
or
Flash.
A
note
on
ROM
The early 8051, namely the 8031 was designed without any ROM. This device could run
only with external memory connected to it. Subsequent developments lead to the
development of the PROM or the programmable ROM. This type had the disadvantage of

being
highly
unreliable.
The next in line, was the EPROM or Erasable Programmable ROM. These devices used
ultraviolet light erasable memory cells. Thus a program could be loaded, tested and
erased using ultra violet rays. A new program could then be loaded again.
An improved EPROM was the EEPROM or the electrically erasable PROM. This does
not require ultra violet rays, and memory can be cleared using circuits within the chip
itself.
Finally there is the FLASH, which is an improvement over the EEPROM. While the
terms EEPROM and flash are sometimes used interchangeably, the difference lies in the
fact that flash erases the complete memory at one stroke, and not act on the individual
cells. This results in reducing the time for erasure.
Understanding the basic features of the 8051 core
Lets now move on to a practical example. We shall work on a simple practical
application and using the example as a base, shall explore the various features of the 8051
microcontroller.
Consider an electric circuit as follows,

The positive side (+ve) of the battery is connected to one side of a switch. The other side
of the switch is connected to a bulb or LED (Light Emitting Diode). The bulb is then
connected to a resistor, and the other end of the resistor is connected to the negative (-ve)
side of the battery.
When the switch is closed or switched on the bulb glows. When the switch is open or
switched off the bulb goes off
If you are instructed to put the switch on and off every 30 seconds, how would you do it?
Obviously you would keep looking at your watch and every time the second hand crosses
30 seconds you would keep turning the switch on and off.
Imagine if you had to do this action consistently for a full day. Do you think you would
be able to do it? Now if you had to do this for a month, a year??
No way, you would say!
The next step would be, then to make it automatic. This is where we use the
Microcontroller.
But if the action has to take place every 30 seconds, how will the microcontroller keep
track of time?
Execution time
Look at the following instruction,
clr p1.0
This is an assembly language instruction. It means we are instructing the microcontroller
to put a value of zero in bit zero of port one. This instruction is equivalent to telling the
microcontroller to switch on the bulb. The instruction then to instruct the microcontroller
to switch off the bulb is,
Setb p1.0

This instructs the microcontroller to put a value of one in bit zero of port one.
Dont worry about what bit zero and port one means. We shall learn it in more detail as
we proceed.
There are a set of well defined instructions, which are used while communicating with
the microcontroller. Each of these instructions requires a standard number of cycles to
execute. The cycle could be one or more in number.
How is this time then calculated?
The speed with which a microcontroller executes instructions is determined by what is
known as the crystal speed. A crystal is a component connectedexternally to the
microcontroller. The crystal has different values, and some of the used values are 6MHZ,
10MHZ, and 11.059 MHz etc.
Thus a 10MHZ crystal would pulse at the rate of 10,000,000 times per second.
The time is calculated using the formula
No of cycles per second = Crystal frequency in HZ / 12.
For a 10MHZ crystal the number of cycles would be,
10,000,000/12=833333.33333 cycles.
This means that in one second, the microcontroller would execute 833333.33333 cycles.
Therefore for one cycle, what would be the time? Try it out.
The instruction clr p1.0 would use one cycle to execute. Similarly, the instruction setb
p1.0
also
uses
one
cycle.
So go ahead and calculate what would be the number of cycles required to be executed to
get
a
time
of
30
seconds!
Getting back to our bulb example, all we would need to do is to instruct the
microcontroller to carry out some instructions equivalent to a period of 30 seconds, like
counting from zero upwards, then switch on the bulb, carry out instructions equivalent to
30
seconds
and
switch
off
the
bulb.
Just put the whole thing in a loop, and you have a never ending on-off sequence.
Simple
isnt
it?
Let us now have a look at the features of the 8051 core, keeping the above example as a
reference,
1.
8-bit
CPU.(
Consisting
of
the
A
and
B
registers)
Most of the transactions within the microcontroller are carried out through the A
register, also known as the Accumulator. In addition all arithmetic functions are carried
out generally in the A register. There is another register known as the B register, which
is
used
exclusively
for
multiplication
and
division.
Thus an 8-bit notation would indicate that the maximum value that can be input into these
registers
is
11111111.
Puzzled?
The value is not decimal 111, 11,111! It represents a binary number, having an equivalent
value of FF in Hexadecimal and a value of 255 in decimal.
We shall read in more detail on the different numbering systems namely the Binary and
Hexadecimal
system
in
our
next
module.
2.
4K
on-chip
ROM
Once you have written out the instructions for the microcontroller, where do you put

these
instructions?
Obviously you would like these instructions to be safe, and not get deleted or changed

during execution. Hence you would load it into the ROM


The size of the program you write is bound to vary depending on the
application, and the number of lines. The 8051 microcontroller gives you
space to load up to 4K of program size into the internal ROM.
4K, thats all? Well just wait. You would be surprised at the amount of stuff
you
can
load
in
this
4K
of
space.
Of course you could always extend the space by connecting to 64K of
external ROM if required.
3.
128
bytes
on-chip
RAM
This is the space provided for executing the program in terms of moving
data,
storing
data
etc.
4. 32 I/O lines. (Four- 8 bit ports, labeled P0, P1, P2, P3)
In our bulb example, we used the notation p1.0. This means bit zero of port
one.
One
bit
controls
one
bulb.
Thus port one would have 8 bits. There are a total of four ports named p0,
p1, p2, p3, giving a total of 32 lines. These lines can be used both as input or
output.
5.
Two
16
bit
timers
/
counters.
A microcontroller normally executes one instruction at a time. However
certain applications would require that some event has to be tracked
independent
of
the
main
program.
The manufacturers have provided a solution, by providing two timers. These
timers execute in the background independent of the main program. Once
the required time has been reached, (remember the time calculations
described above?), they can trigger a branch in the main program.
These timers can also be used as counters, so that they can count the number
of events, and on reaching the required count, can cause a branch in the main
program.
6.
Full
Duplex
serial
data
receiver
/
transmitter.
The 8051 microcontroller is capable of communicating with external devices
like the PC etc. Here data is sent in the form of bytes, at predefined speeds,
also
known
as
baud
rates.
The transmission is serial, in the sense, one bit at a time
7. 5- interrupt sources with two priority levels (Two external and three
internal)
During the discussion on the timers, we had indicated that the timers can
trigger a branch in the main program. However, what would we do in case

we would like the microcontroller to take the branch, and then return back to
the main program, without having to constantly check whether the required
time
/
count
has
been
reached?
This is where the interrupts come into play. These can be set to either the
timers, or to some external events. Whenever the background program has
reached the required criteria in terms of time or count or an external event,
the branch is taken, and on completion of the branch, the control returns to
the
main
program.
Priority levels indicate which interrupt is more important, and needs to be
executed first in case two interrupts occur at the same time.
8.
On-chip
clock
oscillator.
This represents the oscillator circuits within the microcontroller. Thus the
hardware is reduced to just simply connecting an external crystal, to achieve
the
required
pulsing
rate.

LCD DETAIL:Frequently, an 8051 program must interact with the outside world using
input and output devices that communicate directly with a human being. One
of the most common devices attached to an 8051 is an LCD display. Some of
the most common LCDs connected to the 8051 are 16x2 and 20x2 displays.
This means 16 characters per line by 2 lines and 20 characters per line by 2
lines, respectively.
Fortunately, a very popular standard exists which allows us to communicate
with the vast majority of LCDs regardless of their manufacturer. The
standard is referred to as HD44780U, which refers to the controller chip
which receives data from an external source (in this case, the 8051) and
communicates directly with the LCD.
The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable." This control line is used to tell the LCD that
you are sending it data. To send data to the LCD, your program should first
set this line high (1) and then set the other two control lines and/or put data
on the data bus. When the other lines are completely ready, bring EN low (0)
again. The 1-0 transition tells the 44780 to take the data currently found on
the other control lines and on the data bus and to treat it as a command.
The RS line is the "Register Select" line. When RS is low (0), the data is to
be treated as a command or special instruction (such as clear screen, position
cursor, etc.). When RS is high (1), the data being sent is text data which
should be displayed on the screen. For example, to display the letter "T" on
the screen you would set RS high.

The RW line is the "Read/Write" control line. When RW is low (0), the
information on the data bus is being written to the LCD. When RW is high
(1), the program is effectively querying (or reading) the LCD. Only one
instruction ("Get LCD status") is a read command. All others are write
commands--so RW will almost always be low.
Finally, the data bus consists of 4 or 8 lines (depending on the mode of
operation selected by the user). In the case of an 8-bit data bus, the lines are
referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.
AN EXAMPLE HARDWARE CONFIGURATION
As we've mentioned, the LCD requires either 8 or 11 I/O lines to communicate with. For
the sake of this tutorial, we are going to use an 8-bit data bus--so we'll be using 11 of the
8051's I/O pins to interface with the LCD.
Let's draw a sample psuedo-schematic of how the LCD will be connected to the 8051.

INITIALIZING THE LCD


Before you may really use the LCD, you must initialize and configure it. This is
accomplished by sending a number of initialization instructions to the LCD.
The first instruction we send must tell the LCD whether we'll be communicating with it
with an 8-bit or 4-bit data bus. We also select a 5x8 dot character font. These two options
are selected by sending the command 38h to the LCD as a command. As you will recall
from the last section, we mentioned that the RS line must be low if we are sending a
command to the LCD. Thus, to send this 38h command to the LCD we must execute the
following 8051 instructions:
SETB
EN
CLR
RS
MOV
DATA,#38h
CLR
EN
LCALL WAIT_LCD
Programming Tip: The LCD command 38h is really the sum of a number of option bits.
The instruction itself is the instruction 20h ("Function set"). However, to this we add the
values 10h to indicate an 8-bit data bus plus 08h to indicate that the display is a two-line
display.

We've now sent the first byte of the initialization sequence. The second byte of the
initialization sequence is the instruction 0Eh. Thus we must repeat the initialization code
from above, but now with the instruction. Thus the next code segment is:
SETB EN
CLR RS
MOV DATA,#0Eh
CLR EN
LCALL WAIT_LCD
Programming Tip: The command 0Eh is really the instruction 08h plus 04h to turn the
LCD on. To that an additional 02h is added in order to turn the cursor on.
The last byte we need to send is used to configure additional operational parameters of
the LCD. We must send the value 06h.
SETB EN
CLR RS
MOV DATA,#06h
CLR EN
LCALL WAIT_LCD
Programming Tip: The command 06h is really the instruction 04h plus 02h to configure
the LCD such that every time we send it a character, the cursor position automatically
moves to the right.
So, in all, our initialization code is as follows:
INIT_LCD:
SETB EN
CLR RS
MOV DATA,#38h
CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV DATA,#0Eh
CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV DATA,#06h
CLR EN
LCALL WAIT_LCD
RET
Having executed this code the LCD will be fully initialized and ready for us to send
display data to it.
CLEARING THE DISPLAY

When the LCD is first initialized, the screen should automatically be cleared
by the 44780 controller. However, it's always a good idea to do things
yourself so that you can be completely sure that the display is the way you

want it. Thus, it's not a bad idea to clear the screen as the very first opreation
after the LCD has been initialiezd.
An LCD command exists to accomplish this function. Not suprisingly, it is
the command 01h. Since clearing the screen is a function we very likely will
wish to call more than once, it's a good idea to make it a subroutine:
CLEAR_LCD:
SETB EN
CLR RS
MOV DATA,#01h
CLR EN
LCALL WAIT_LCD
RET

How that we've written a "Clear Screen" routine, we may clear the LCD at
any time by simply executing an LCALL CLEAR_LCD.
Programming Tip: Executing the "Clear Screen" instruction on the LCD also
positions the cursor in the upper left-hand corner as we would expect.
WRITING TEXT TO THE LCD
Now we get to the real meat of what we're trying to do: All this effort is
really so we can display text on the LCD. Really, we're pretty much done.
Once again, writing text to the LCD is something we'll almost certainly want
to do over and over--so let's make it a subroutine.
WRITE_TEXT:
SETB
SETB
MOV
CLR
LCALL
RET

EN
RS
DATA,A
EN
WAIT_LCD

The WRITE_TEXT routine that we just wrote will send the character in the
accumulator to the LCD which will, in turn, display it. Thus to display text
on the LCD all we need to do is load the accumulator with the byte to
display and make a call to this routine. Pretty easy, huh?
A "HELLO WORLD" PROGRAM
Now that we have all the component subroutines written, writing the classic
"Hello World" program--which displays the text "Hello World" on the LCD
is a relatively trivial matter. Consider:
LCALL
INIT_LCD
LCALL
CLEAR_LCD
MOV
A,#'H'
LCALL
WRITE_TEXT
MOV
A,#'E'
LCALL
WRITE_TEXT

MOV
A,#'L'
LCALL
WRITE_TEXT
MOV
A,#'L'
LCALL
WRITE_TEXT
MOV
A,#'O'
LCALL
WRITE_TEXT
MOV
A,#'
'
LCALL
WRITE_TEXT
MOV
A,#'W'
LCALL
WRITE_TEXT
MOV
A,#'O'
LCALL
WRITE_TEXT
MOV
A,#'R'
LCALL
WRITE_TEXT
MOV
A,#'L'
LCALL
WRITE_TEXT
MOV
A,#'D'
LCALL WRITE_TEXT
The above "Hello World" program should, when executed, initialize the
LCD, clear the LCD screen, and display "Hello World" in the upper lefthand corner of the display.
CURSOR POSITIONING
The above "Hello World" program is simplistic in the sense that it prints its
text in the upper left-hand corner of the screen. However, what if we wanted
to display the word "Hello" in the upper left-hand corner but wanted to
display the word "World" on the second line at the tenth character? This
sounds simple--and actually, it is simple. However, it requires a little more
understanding of the design of the LCD.

LCD COMMAND CODES.


1.

CLEAR DISPLAY SCREEN

2.

RETURN HOME

DECREMENT CURSOR ( SHIFT CURSOR TO LEFT)

SHIFT DISPLAY RIGHT.

6.

INCREMENT CURSOR ( SHIFT CURSOR TO RIGHT)

7.

SHIFT DISPLAY LEFT

8.

DISPLAY OFF, CURSOR OFF

DISPLAY OFF CURSOR ON

DISPLAY ON CURSOR OFF

DISPLAY ON CURSOR BLINKING

F.

DISPLAY ON CURSOR BLINKING.

10.

SHIFT CURSOR POSITION TO LEFT

14.

SHIFT CURSOR POSITION TO RIGHT

18.

SHIFT THE ENTIRE DISPLAY TO THE LEFT

1C

SHIFT THE ENTIRE DISPLAY TO THE RIGHT

80

FORCE CURSOR TO BEGINNING OF IST LINE

C0

FORCE CURSOR TO BEGINNING OF 2ND LINE

2 LINES AND 5 X 7 MATRIX


RF Transmitter Circuit

Discription about transmitter section


In this circuits sensors are used that will detect wheather accident happen or not. Is
accident occur then these sensors give signal to to the IC ht-12E ic. Then this signal is
encoded and fed it to the RF module. Rf module work as a wireless data transmission
system. In this Rf module operate on 433.92Mhz frequency.
The remote control is built using RF encoder chip HT12E that will generate different
codes. These codes will be transmitted by 434 MHz RF transmitter. At the receiving side
these codes will be received by 434 MHz RF receiver and decoded by RF decoder chip
HT12D. in the transmitter side which will attach with car we will sensor for accident
detection. Sensors will give signal to HT12E . HT12E is a 18 pin ic. It converts bit data
input to serial output. It has 12 address lines to send data to particular receiver.
In this project we make attendance system using RFID. In this project we used 433Mhz
RF transmitter and Receiver. We used 89s51 . LCD 16*2 connected to MCU at port 0 of

MCU. Output of HT12D connected to MCU at port pin no 1 tp 4. Pot 1 pin 5 to 8


connected to four switches to check total attendance of each candidate. In this project we
are using UHF frequencies of RF. LEDs connected at port 2 pin p2.0,p2.1,p2.2,and p2.6.
LCD rs, rw ,en connected to p2.5,p2.4 and p2.3.HT12 E and HT12D s pin 1 to 9
connected to ground giving low. These are address pins of HT12E and HT12D. Pin no 10
to 14 of HT12 E are inputs of IC and 17 no pin is output pin. Pin no 10 -14 of HT12D is
ouput pin and 14 is input pin. Crystal pin of HT12E is 15 and 16 .this project we will
make one transmitter and RF receiver. RF remote control which is built using HT12E and
HT12D chips. The remote control is built using RF encoder chip HT12E that will
generate different codes. These codes will be transmitted by 434 MHz RF transmitter. At
the receiving side these codes will be received by 434 MHz RF receiver and decoded by
RF decoder chip HT12D. These codes are fed to 89C51 to take a controlling action on
moon walker. We will use 16*2 LCD display.there will be RFID for each transmitter. RF
transmitter will give signal to

For the regulated power supply we use ic 7805 as a regulator to provide a fix
5 volt power supply.
. Here we use pc 817 ( 4 pin opto coupler) to interface the micro controller
with the motor circuit.
In this project we will make a transmitter for RF data transmission. Pin no
1of RF tx module is ground . second is for data , third for VCC and fourth
for antenna Transmitter
Block diagram Receiver
Micro
Controller
circuit

5 v dc
circuit

LCD 16*2 display

Circuit Diagram:

Ht 12 d
Decoder chip

Buzzer circuit

RF
Modeule

antenna

CIRCUIT DIAGRAM OF TRANSMITTER:

Advantages:
Low Cost
Easy to make
Portable
Flexible
Disadvantages:
RF jammer could create problem.

PROGRAMCODE FOR THE PREPAID ENERGY METER


;******************************************************************
;------ PROGRAM: PREPAID ENERGY METER ------------;------ RECHARGE COUPEN THROUGH MOBILE -----------; P0 : LCD(8 BIT)
; P2.5 - P2.7- CONTROL BITS FOR LCD(RS, R/W, ENABLE)
; P1.0: ENTER AMOUNT OF COUPEN1(50Rs)
; P1.1: ENTER AMOUNT OF COUPEN2(100Rs)
; P2.0: LED BLINKING
; P2.1: RELAY
;******************************************************************
RS BIT P2.6
RW BIT P2.5
E BIT P2.7
FL BIT P0.7
CP1 BIT P1.0
CP2 BIT P1.1
LED BIT P2.0
RELAY BIT P2.1
LCD EQU P0
C1 EQU 31H
C2 EQU 32H
C3 EQU 33H
AM1 EQU 50 ;AMOUNT OF COUPEN1
AM2 EQU 100 ;AMOUNT OF COUPEN2
UNIT EQU 2 ;PULSE RATE FOR UNIT
BAL EQU 2 ;UNIT RATE FOR BALANCE DETECTION
ORG 00H
AJMP START
ORG 30H
START:
MOV LCD,#00H
MOV C1,#0
MOV C2,#0
MOV C3,#0
MOV BAL,#0
MOV R0,#0
MOV R1,#0
MOV R2,#2
MOV R3,#2
MOV A,#38H
;2*16 MATRIX
ACALL COMMAND
MOV A,#02
;RETURN HOME
ACALL COMMAND

MOV A,#01
;CLEAR DISPLAY SCREEN
ACALL COMMAND
MOV A,#0CH
;DISPLAY ON CURSOR OFF
ACALL COMMAND
MOV A,#80H
;MOVE CURSOR TO FIRST LINE SECOND COLOUMN
ACALL COMMAND
MOV DPTR,#TABLE1
;DISPLAY ERP
ACALL DISPLAY
SETB LED
SETB RELAY
ACALL DELAY
MAIN: JNB CP1 COUPEN1
JNB CP2 COUPEN2
SJMP MAIN
COUPEN1:
MOV R0,#AM1
SJMP METER
COUPEN2:
MOV R0,#AM2
METER:
CLR RELAY
CLR LED
ACALL TIMER
SETB LED
ACALL TIMER
DJNZ R3,NX1
INC R1
MOV R3,#UNIT
DJNZ R2,NX1
MOV R2,#BAL
DJNZ R0,NX1
SETB RELAY
SETB LED
ACALL READING
JMP MAIN
NX1: SJMP METER
READING:
ACALL LCDCLR
MOV A,#80H
ACALL COMMAND
MOV DPTR,#TABLE2
ACALL DISPLAY
MOV A,R0
ACALL OUT
MOV DPTR,#TABLE3
ACALL DISPLAY

MOV A,#0C0H
ACALL COMMAND
MOV DPTR,#TABLE4
ACALL DISPLAY
MOV A,R1
ACALL HTD
ACALL OUT
RET
AGAIN1: MOV TH1,#0D0H
MOV TL1,#0BFH
SETB TR1
AGAIN2: JNB TF1,AGAIN2
CLR TR1
CLR TF1
DJNZ R4,AGAIN1
RET
HTD:;CONVERT HEX(BINARY) TO ASCII
MOV B,#10
DIV AB
MOV C1,B
MOV B,#10
DIV AB
MOV C2,B
MOV C3,A
RET
OUT:
MOV A,C3
ORL A,#30H
ACALL WRITE
MOV A,C2
ORL A,#30H
ACALL WRITE
MOV A,C1
ORL A,#30H
ACALL WRITE
RET
LCDCLR:
MOV A,#01H
;CLEAR DISPLAY SCREEN
ACALL COMMAND
RET; DISPLAY DATA ON LCD
DISPLAY:
CLR A
MOVC A,@A+DPTR
JZ NEXT
ACALL WRITE
INC DPTR

JMP DISPLAY
NEXT: RET
WRITE:
ACALL CHKBUSY
MOV LCD,A
SETB RS
CLR RW
SETB E
CLR E
RET
COMMAND:
ACALL CHKBUSY
MOV LCD,A
CLR RS
CLR RW
SETB E
CLR E
RET
CHKBUSY:
SETB FL
SETB RW
CLR RS
CHECK4: CLR E
SETB E
JB FL,CHECK4
RET
DELAY:
MOV R6,#255
AGAIN: MOV R7,#255
BACK: DJNZ R7, BACK
DJNZ R6,
AGAIN RET
TABLE1: DB 'PREPAID E.METER',0
TABLE2: DB 'BALANCE ',0
TABLE3: DB 'Rs',0
TABLE4: DB 'UNIT ',0

Das könnte Ihnen auch gefallen