You are on page 1of 43

CHAPTER-1

INTRODUCTION
1.1 HISTORY
Due to increasing population many water related problems like water
pollution, wastage of water, water scarcity, etc. is arising day by day. So there is a
need of sustainable utilisation of water resources in order to use them efficiently by
present generation as well as conserving it for the future generation. Monitoring and
controlling water level is an important task in homes and offices in order to reduce
wastage of water. Almost all aspects of human life have undergone rapid
development. This development is supported by the advance of electronics and
information technology. The job can be performed on schedule precisely and
efficiently by adopting this advance technology.

1.2 OBJECTIVE
In this project we show that how we monitor and control the overhead tank
using RF module technology. In this project we fit one module on the overhead water
tank and one module at the bottom near the motor.
With the help of wireless radio frequency signal we continuous monitor the
overhead tank position. If the tank water is very low down then circuit provide a
signal and connected motor is on. In the base circuit we use one seven segment
display to display the water level in numbers. Four LED to display the water level.
One manual switch to on/off the motor any time. In this, we show the water level
indicator, top level alarm, and auto motor off with the help of the micro controller.
With the help of this project we will not only display the level by led but at the same
time display the seven segment number also. If the water touches to the top level then
alarm is on for a time and motor is off automatically.

CHAPTER-2
1

BLOCK DIAGRAM

Figure 2.1: Block Diagram of Wireless Water Level Controller

The block diagram of wireless water level controller is shown in above figure.
This project uses radio frequency communication for transmission of the signal. The
water level sensing section senses the level of water in the tank and sends it wireless
to the receiver section containing Rf Receiver through the Rf Transmitter.
Receiver Section is connected to the controlling section, which process the
received information and controls the operation of the motor whenever required.RF
Transmitter consists of HT12E encoder and RF Receiver consists of HT12D Decoder.
Relay is kept to drive the motor to ON-OFF depending on the level of the water.

CHAPTER-3
2

HARDWARE COMPONENTS
3.1 POWER SUPPLY
The Power Supply is a primary requirement for the project work. The required
DC power supply for the base unit as well as for the recharging unit is derived from
the mains line. For this purpose centre tapped secondary of 12V-012V transformer is
used. From this transformer we getting 5V power supply.
In this +5V output is a regulated output and it is designed using 7805 positive
voltage regulator. This is a 3 Pin voltage regulator, can deliver current up to 800
milliamps. Rectification is a process of rendering an alternating current or voltage into
a unidirectional one. The component used for rectification is called Rectifier. A
rectifier perm its current to flow only during positive half cycles of the applied AC
voltage.
Thus, pulsating DC is obtained to obtain smooth DC power additional filter
circuits required. The power supply consists of a step down transformer, full wave
rectifier, capacitive filter, 7805 regulator.

3.1.1 BLOCK DIAGRAM

Figure 3.1: Block Diagram of Power Supply

3.1.2 CIRCUIT DIAGRAM


3

Figure 3.2: Circuit Diagram of Power Supply

3.1.3 RECTIFIER AND FILTER


A diode can be used as rectifier. There are various types of diodes. However,
semiconductor diodes are very popularly used as rectifiers. A semiconductor diode is
a solid-state device consisting of two elements is being an electron emitter or cathode,
the other an electron collector or anode. Since electrons in a semiconductor diode can
flow in one direction only-form emitter to collector-the diode provides the unilateral
conduction necessary for rectification.
The rectified Output is filtered for smoothening the DC, for this purpose
capacitor is used in the filter circuit. The filter capacitors are usually connected in
parallel with the rectifier output and the load. The AC can pass through a capacitor but
DC cannot, the ripples are thus limited and the output becomes smoothed. When the
voltage across the capacitor plates tends to rise, it stores up energy back into voltage
and current.
Thus, the fluctuation in the output voltage is reduced considerable. The
components used are: Capacitors of 100F/25v

and 2200F/25v, Step down

transformer of 230v / 12v- 0 -12v/ 500mA and Diodes of 1N4007.

3.1.4 LM7805 REGULATOR

A variable regulated power supply, also called a variable bench power supply,
is one where you can continuously adjust the output voltage to your requirements.
Varying the output of the power supply is the recommended way to test a project after
having double checked parts placement against circuit drawings and the parts
placement guide. While a dedicated supply is quite handy e.g. 5V or 12V, its much
handier to have a variable supply on hand, especially for testing. Most digital logic
circuits and processors need a 5 volt power supply.
To use these parts we need to build a regulated 5 volt source. Usually you start
with an unregulated power supply ranging from 9 volts to 24 volts DC (A 12 volt
power supply is included with the Beginner Kit and the Microcontroller Beginner
Kit.). To make a 5 volt power supply, we use a LM7805 voltage regulator IC
(Integrated Circuit). The 7805 IC is shown below:

Figure 3.3: LM7805 Regulator


The LM7805 is simple to use. You simply connect the positive lead of your
unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin,
connect the negative lead to the Common pin and then when you turn on the power,
you get a 5 volt supply from the Output pin.

3.2 LEVEL SENSOR


5

For water level scan, we insert the one pipe in the tank. The bottom point of
the pipe is connected to the positive line. As the water is rises in the tank other points
on the pipe is in contact with the water and the positive voltage is also travel. We
connect all the output from sensor to the IC 4049 directly. Output from the IC 4049 is
inverted. IC 4049 is inverter cum buffer IC. Output from the IC 4049 is connected to
the port P1 directly. Processor gets a data from the port p1 and display on the seven
segment display. At the same time this data is display on the LED.
Motor is start by manually any time with the help of switch but off
automatically. We provide this solution because to switch on the motor manually is
suitable for every condition. It is our choice to switch on the motor or not. Once you
switch one the motor then motor is still on until tank is not filled. As the water is filled
in the tank motor is off automatically.

3.3 AT89C52 MICROCONTROLLER


The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer
with 4K bytes of Flash Programmable and Erasable Read Only Memory (PEROM).
The device is manufactured using Atmels high density non-volatile memory
technology and is compatible with the industry standard MCS-51 instruction set
and pin out. The on-chip Flash allows the program memory to be reprogrammed insystem or by a conventional non-volatile memory programmer. By combining a
versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a
powerful microcomputer which provides a highly flexible and cost effective solution
to many embedded control applications.
The AT89C52 provides the following standard features: 4K bytes of Flash,
128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, five vector two-level
interrupt architecture, a full duplex serial port, and on-chip oscillator and clock
circuitry. In addition, the AT89C52 is designed with static logic for operation down to
zero frequency and supports two software selectable power saving modes. The Idle
Mode stops the CPU while allowing the RAM, timer/counters, serial port and
interrupt system to continue functioning. The Power down Mode saves the RAM

contents but freezes the oscillator disabling all other chip functions until the next
hardware reset.

3.3.1 ARCHITECTURE

Figure 3.4: Architecture of AT89C52

3.3.1 PIN CONFIGURATION


The Micro Controller generic part number actually includes a whole family of
Micro Controllers that have numbers ranging from 8031to 8751 and are available in
N-Channel Metal Oxide Silicon (NMOS) and Complementary Metal Oxide Silicon
(CMOS) construction in a variety of package types.

Figure 3.5: Pin Diagram of AT89C52

3.3.2 PIN DESCRIPTION:


VCC: Supply voltage.
GND: Ground.
8

PORT 0:
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port each in
can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as
high impedance inputs. Port 0 may also be configured to be the multiplexed low order
address/data bus during accesses to external program and data memory. In this mode
P0 has internal pull-ups. Port 0 also receives the code bytes during Flash
programming, and outputs the code bytes during program verification. External pullups are required during program verification.

PORT 1:
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1
output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins
they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port
1 pins that are externally being pulled low will source current (IIL) because of the
internal pull-ups. Port 1 also receives the low-order address bytes during Flash
programming and verification.

PORT 2:
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2
output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins
they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port
2 pins that are externally being pulled low will source current (IIL) because of the
internal pull-ups.
Port 2 emits the high-order address byte during fetches from external program
memory and during accesses to external data memory that uses 16-bit addresses
(MOVX @ DPTR). In this application it uses strong internal pull-ups when emitting
1s. During accesses to external data memory that uses 8-bit addresses (MOVX @ RI),
Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the
high-order address bits and some control signals during Flash programming and
verification.
9

PORT 3:
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3
output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins
they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port
3 pins that are externally being pulled low will source current (IIL) because of the
pull-ups. Port 3 also receives some control signals for Flash programming and
verification.
Port 3 also serves the functions of various special features of the AT89C52 as
listed below:

Table 3.1: Functions of Port 3 pins

RST:
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.

ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input (PROG)
during Flash programming. In normal operation ALE is emitted at a constant rate of
10

1/6 the oscillator frequency, and may be used for external timing or clocking
purposes. Note, however, that one ALE pulse is skipped during each access to
external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of
SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC
instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has
no effect if the microcontroller is in external execution mode.

PSEN:
Program Store Enable is the read strobe to external program memory. When
the AT89C51 is executing code from external program memory, PSEN is activated
twice each machine cycle, except that two PSEN activations are skipped during each
access to external data memory.

EA/VPP:
External Access Enable. EA must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at 0000H up to
FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched
on reset. EA should be strapped to VCC for internal program executions. This pin also
receives the 12-volt programming enable voltage (VPP) during Flash programming,
for parts that require 12-volt VPP.

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

XTAL2:
Output from the inverting oscillator amplifier.
11

3.3.3 OSCILLATOR CHARACTERISTICS:


XTAL1 and XTAL2 are the input and output, respectively, an inverting
amplifier which can be configured for use as an on-chip oscillator, as shown in Figure
1. Either a quartz crystal or ceramic resonator may be used. To drive the device from
an external clock source, XTAL2 should be left unconnected while XTAL1 is driven
as shown in Figure 2. There are no requirements on the duty cycle of the external
clock signal, since the input to the internal clocking circuitry is through a divide-bytwo flip-flop, but minimum and maximum voltage high and low time specifications
must be observed.

Figure 3.6: Oscillator Connections

IDLE MODE:
In idle mode, the CPU puts itself to sleep while all the on chip peripherals
remain active. The mode is invoked by software. The content of the on-chip RAM and
all the special functions registers remain unchanged during this mode. The idle mode
can be terminated by any enabled interrupt or by a hardware reset. It should be noted
that when idle is terminated by a hard ware reset, the device normally resumes

12

program execution, from where it left off, up to two machine cycles before the
internal reset algorithm takes control.
On-chip hardware inhibits access to internal RAM in this event, but access to
the port pins is not inhibited. To eliminate the possibility of an unexpected write to a
port pin when Idle is terminated by reset, the instruction following the one that
invokes Idle should not be one that writes to a port pin or to external memory.

Figure 3.7: External Clock Drive Configuration

POWER DOWN MODE:


In the power down mode the oscillator is stopped, and the instruction that
invokes power down is the last instruction executed. The on-chip RAM and Special
Function Registers retain their values until the power down mode is terminated. The
only exit from power down is a hardware reset.
Reset redefines the SFRs but does not change the on-chip RAM. The reset
should not be activated before VCC is restored to its normal operating level and must
be held active long enough to allow the oscillator to restart and stabilize.

13

3.3.4 PROGRAMMING THE FLASH:


The AT89C52 is normally shipped with the on-chip Flash memory array in the
erased state (that is, contents = FFH) and ready to be programmed. The programming
interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program
enable signal.
The low voltage programming mode provides a convenient way to program
the AT89C52 inside the users system, while the high-voltage programming mode is
compatible with conventional third party Flash or EPROM programmers. The
AT89C52 is shipped with either the high-voltage or low-voltage programming mode
enabled. The respective top-side marking and device signature codes are listed in the
following table:

Table 3.2: Side Mark and Signature


The AT89C52 code memory array is programmed byte-by byte in either
programming mode. To program any nonblank byte in the on-chip Flash Memory, the
entire memory must be erased using the Chip Erase Mode.

14

PROGRAM MEMORY LOCK BITS:


On the chip there are three lock bits which can be left unprogrammed (U) or
can be programmed (P) to obtain the additional features listed in the table below:

Table 3.3: Features of Lock Bits


When lock bit 1 is programmed, the logic level at the EA pin is sampled and
latched during reset. If the device is powered up without a reset, the latch initializes to
a random value, and holds that value until reset is activated. It is necessary that the
latched value of EA be in agreement with the current logic level at that pin in order
for the device to function properly.

3.3.5 PROGRAMMING ALGORITHM:


Before programming the AT89C52, the address, data and control signals
should be set up according to the Flash programming mode table and Figures 3 and 4.
To program the AT89C52, take the following steps.

Input the desired memory location on the address lines.


Input the appropriate data byte on the data lines.
Activate the correct combination of control signals.
Raise EA/VPP to 12V for the high-voltage programming mode.
15

Pulse ALE/PROG once to program a byte in the Flash array or the lock bits.
The byte-write cycle is self-timed and typically takes no more than 1.5 ms.
Repeat steps 1 through 5, changing the address and data for the entire array or
until the end of the object file is reached.

DATA POLLING:
The AT89C52 features Data Polling to indicate the end of a write cycle.
During a write cycle, an attempted read of the last byte written will result in the
complement of the written datum on PO.7. Once the write cycle has been completed,
true data are valid on all outputs, and he next cycle may begin. Data Polling may
begin any time after a write cycle has been initiated.

READY/BUSY:
The progress of byte programming can also be monitored by the RDY/BSY
output signal. P3.4 is pulled low after ALE goes high during programming to indicate
BUSY. P3.4 is pulled high again when programming is done to indicate READY.

PROGRAM VERIFY:
If lock bits LB1 and LB2 have not been programmed, the programmed
code data can be read back via the address and data lines for verification. The lock
bits cannot be verified directly. Verification of the lock bits is achieved by observing
that their features are enabled.

CHIP ERASE:
The entire Flash array is erased electrically by using the proper combination of
control signals and by holding ALE/PROG low for 10 ms. The code array is written
with all 1s. The chip erase operation must be executed before the code memory can
be re-programmed.
16

READING THE SIGNATURE BYTES:


The signature bytes are read by the same procedure as a normal verification of
locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic
low. The values returned are as follows.
(030H) = 1EH indicates manufactured by Atmel
(031H) = 52H indicates 89C52
(032H) = FFH indicates 12V programming
(032H) = 05H indicates 5V programming

PROGRAMMING INTERFACE:
Every code byte in the Flash array can be written and the entire array can be
erased by using the appropriate combination of control signals. The write operation
cycle is self-timed and once initiated, will automatically time itself to completion.
All major programming vendors offer worldwide support for the Atmel
microcontroller series. Please contact your local programming vendor for the
appropriate software revision.

3.3.6 MEMORY ORGANIZATION:


INTERNAL MEMORY:
The 89C52 has internal RAM and ROM memory for the functions. Additional
memory can be added externally using suitable circuits. This has a Hardware
architecture, which uses the same address, in different memories, for code and data.

INTERNAL RAM:

17

The 256-byte internal RAM. The upper 128 bytes occupy a parallel
address space to the Special Function Registers. Instructions that use indirect
addressing access the upper 128 bytes of RAM. Stack operations are examples of
indirect addressing.
Internal Data Memory addresses are always one byte wide, which implies
an address space of only 256 bytes. However, the addressing modes for internal RAM
can in fact accommodate 384 bytes, using a simple trick. Direct addresses higher than
7FH access one memory space, and indirect addresses higher than 7FH access a
different memory space. Thus Figure shows the Upper 128 and SFR space occupying
the same block of addresses, 80H through FFH, although they are physically separate
entities.
The Lower 128 bytes of RAM are present in all 89C52 devices as mapped
in Figure. The lowest 32 bytes are grouped into 4 banks of 8 registers. Program
instructions call out these registers as R0 through R7.
Two bits in the Program Status Word (PSW) select which register bank is in
use. This allows more efficient use of code space, since register instructions are
shorter than instructions that use direct addressing. The next 16 bytes above the
register banks form a block of bit addressable memory space. The 89C52 instruction
set includes a wide selection of single-bit instructions, and the 128 bits in this area can
be directly addressed by these instructions. The bit addresses in this area are 00H
through 7FH. All of the bytes in the Lower 128 can be accessed by either direct or
indirect addressing.
The Upper 128 can only be accessed by indirect addressing. SFRs include
the Port latches, timers, peripheral controls, etc. These registers can only be accessed
by direct addressing. Sixteen addresses in SFR space are both byte- and bitaddressable. The bit-addressable SFRs are those whose address ends in OH or 80H.

18

3.4 RELAY
A relay is usually an electromechanical device that is actuated by an electrical
current. The current flowing in one circuit causes the opening or closing of another
circuit. Relays are like remote control switches and are used in many applications
because of their relative simplicity, long life, and proven high reliability. Relays are

Figure 3.8: Relay Circuit


used in a wide variety of applications throughout industry, such as in telephone
exchanges, digital computers and automation systems. Highly sophisticated relays are
utilized to protect electric power systems against trouble and power blackouts as well
as to regulate and control the generation and distribution of power. In the home, relays
are used in refrigerators, washing machines and dishwashers, and heating and airconditioning controls.
For this work we connect a small dc motor base pump with the
microcontroller via two transistor circuit and connected to a relay circuit. The
collector of this transistor is connected with the relay circuit and the emitter is
grounded. Output of the controller is in active low output. So to get an output from the
controller we firstly connect a PNP transistor. Output of the PNP transistor is further
connected to the NPN transistor. Output of the NPN transistor is connected to the
small dc motor directly. The output of the relay circuit is connected with motor
pumps cable as a negative. The other side of motors cable connected with AC 220V
as positive voltage.
19

Advantages of relays:

Relays can switch AC and DC, transistors can only switch DC.

Relays can switch high voltages, transistors cannot.

Relays are a better choice for switching large currents (> 5A).

Relays can switch many contacts at once.

Disadvantages of relays:

Relays are bulkier than transistors for switching small currents.

Relays cannot switch rapidly (except reed relays), transistors can switch many
times per second.

Relays use more power due to the current flowing through their coil.

Relays require more current than many chips can provide, so a low power
transistor.

3.5 LCD (LIQUID CRYSTAL DISPLAY)


Liquid crystal displays (LCDs) have materials which combine the properties
of both liquids and crystals. Rather than having a melting point, they have a
temperature range within which the molecules are almost as mobile as they would be
in liquid, but are grouped together in an ordered form similar to a crystal.

Figure 3.9: Liquid Crystal Display


The LCDs are lightweight with only a few millimetres thickness. Since the
LCDs consume less power they are compatible with low power electronic circuits
and can be powered for long durations.

20

The LCDs are used extensively in watches, calculators and measuring


instruments is the simple seven-segment displays, having a limited amount of data.

3.5.1 INTERFACING LCD TO THE MICRO CONTROLLER:


This is the first interfacing example for the parallel port. We will start with
something simple. This example does not use the Bi-directional feature found on
newer ports, thus it should work with most, if no all Parallel Ports. It however does
not show the use of the status port as an input. So what are we interfacing? A 16
Character X 2 Line LCD Module to the Parallel Port. These LCD Modules are very
common these days, and are quite simple to work with, as all the logic required
running them is on board.

Features:

Interface with either 4-bit or 8-bit microprocessor.

Display data RAM

80 8 bits (80 characters).

Character generator ROM

160 different 5 7 dot-matrix character patterns.

Character generator RAM

8 different users programmed 5 7 dot-matrix patterns.

Display data RAM and character generator RAM may be

Accessed by the microprocessor.

Numerous instructions

Clear Display, Cursor Home, Display ON/OFF, Cursor

ON/OFF, Blink Character, Cursor Shift, Display Shift.

Built-in reset circuit is triggered at power ON.

21

3.5.2 PIN DIAGRAM

Figure 3.10: Pin Diagram of LCD

3.5.3 PINS DEFINITION

Table 3.4: Pins Definition


22

In the above table Vcc and Vss are supply pins and VEE (Pin no.3) is used for
controlling LCD contrast. Pin No.4 is Rs pin for selecting the register, there are two
very important registers are there inside the LCD. The RS pin is used for their
selection as follows. If RS=0, the instruction command code register is selected,
allowing the user to send data to be displayed on the LCD. R/W is a read or writes
Pin, which allows the user to write information to the LCD or read information from
it. R/W=1 when reading R/W=0 when writing. The LCD to latch information
presented to its data pins uses the enable (E) pin. The 8-bit data pins, D0-D7, are used
to send information to the LCD or read the contents of the LCDs internal registers.
To display letters and numbers, we must send ASCII codes for the letters A-Z, and
number 0 -9 to these pins while making RS=1.

3.5.4 ABSOLUTE MAXIMUM RATINGS:

Table 3.5: Maximum Ratings

QUALITY CONTROL:
Some LCD panels have defective transistors, causing permanently lit or unlit
pixels which are commonly referred to as stuck pixels or dead pixels respectively.
Unlike integrated circuits (ICs), LCD panels with a few defective pixels are usually
still usable. It is also economically prohibitive to discard a panel with just a few
defective pixels because LCD panels are much larger than ICs.

23

COLOUR DISPLAYS:
In colour LCDs each individual pixel is divided into three cells, or sub pixels,
which are colour red, green, and blue, respectively, by additional filters (pigment
filters, dye filters and metal oxide filters). Each sub pixel can be controlled
independently to yield thousands or millions of possible colours for each pixel. CRT
monitors employ a similar 'sub pixel' structures via phosphors, although the analog
electron beam employed in CRTs do not hit exact 'sub pixels'.Colour components may
be arrayed in various pixel geometries, depending on the monitor's usage. If software
knows which type of geometry is being used in a given LCD, this can be used to
increase the apparent resolution of the monitor through sub pixel rendering. This
technique is especially useful for text anti-aliasing. To reduce smudging in a moving
picture when pixels do not respond quickly enough to colour changes, so-called pixel
overdrive may be used.

3.5.5 LCD INTERFACING

Figure 3.11: LCD Pin Configuration

24

LCD stands for Liquid Crystal Display. The most commonly used LCDs found
in the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller
and support at most of 80 characters.

DDRAM - DISPLAY DATA RAM


Display data RAM (DDRAM) stores display data represented in 8-bit
character codes. Its extended capacity is 80 X 8 bits, or 80 characters. The area in
display data RAM (DDRAM) that is not used for display can be used as general data
RAM. So whatever you send on the DDRAM is actually displayed on the LCD.

BF - BUSY FLAG
Busy Flag is a status indicator flag for LCD. When we send a command or
data to the LCD for processing, this flag is set (i.e. BF =1) and as soon as the
instruction is executed successfully this flag is cleared (BF = 0). This is helpful in
producing and exact amount of delay. For the LCD processing. To read Busy Flag, the
condition RS = 0 and R/W = 1 must be met and The MSB of the LCD data bus (D7)
act as busy flag. When BF = 1 means LCD is busy and will not accept next command
or data and BF = 0 means LCD is ready for the next command or data to process.

INSTRUCTION

REGISTER

(IR)

AND

DATA

REGISTER

(DR)

There are two 8-bit registers controller Instruction and Data register.
Instruction register corresponds to the register where you send commands to LCD e.g.
LCD shift command, LCD clear, LCD address etc. and Data register is used for
storing data which is to be displayed on LCD.
When send the enable signal of the LCD is asserted, the data on the pins is
latched in to the data register and data is then moved automatically to the DDRAM
and hence is displayed on the LCD.

COMMANDS AND INSTRUCTION SET:


25

Only the instruction register (IR) and the data register (DR) of the LCD can be
controlled by the MCU. Before starting the internal operation of the LCD, control
information is temporarily stored into these registers to allow interfacing with various
MCUs, which operate at different speeds, or various peripheral control devices. The
internal operation of the LCD is determined by signals sent from the MCU.

SENDING COMMANDS TO LCD


To send commands we simply need to select the command register. Everything
is same as we have done in the initialization routine. But we will summarize the
common steps and put them in a single subroutine. Following are the steps:
Move data to LCD port
Select command register
Select write operation
Send enable signal
Wait for LCD to process the command

3.6 RF 433MHZ COMMUNICATION


An RF module (radio frequency module) is a (usually) small electronic circuit
used to transmit and/or receive radio signals on one of a number of carrier
frequencies. RF modules are widely used in electronic design owing to the difficulty
of designing radio circuitry. Good electronic radio design is notoriously complex
because of the sensitivity of radio circuits and the accuracy of components and
layouts required for achieving operation on a specific frequency. Design engineers
will design a circuit for an application which requires radio communication and then
"drop in" a radio module rather than attempt a discrete design, saving time and money
on development.
RF modules are most often used in medium and low volume products for
consumer applications such as garage door openers, wireless alarm systems, industrial
remote controls, smart sensor applications, and wireless home automation systems.
26

They are sometimes used to replace older infra-red communication designs as they
have the advantage of not requiring line-of-sight operation. Several carrier frequencies
are commonly used in commercially-available RF modules, including 433.92 MHz,
315 MHz, 868 MHz and 915 MHz These frequencies are used because of national and
international regulations governing the use of radio for communication.

Figure 3.12: RF Module Pin Architecture


A wireless radio frequency (RF) transmitter and receiver can be easily made
using HT12D Decoder, HT12E Encoder and ASK RF Module. Wireless transmission
can be done by using 433 MHz or 315MHz ASK RF Transmitter and Receiver
modules. In these modules digital data is represented by different amplitudes of the
carrier wave, hence this modulation is known as Amplitude Shift Keying (ASK).
Radio Frequency (RF) transmission is more strong and reliable than Infrared (IR)
transmission due to following reasons:

Radio Frequency signals can travel longer distances than Infrared.

Only line of sight communication is possible through Infrared while radio


frequency signals can be transmitted even when there is an obstacle.

27

Infrared signals will get interfered by other IR sources but signals on one
frequency band in RF will not interfered by other frequency RF signals.

3.6.1 RF Transmitter
In the transmitter circuit we insert one plastic probe in the overhead tank. On
this plastic probe we connect few connecting wires. We connect five wires. Out of
these five wires, four wires are connected with the overhead tank and one wire with
the common positive voltage. As the water is to be raise in the tank. Positive voltage
on the bottom is also to be transfer from lower point to higher point. Now positive
voltage from the bottom is to be connected to other point of the probe. Voltage from
the probe is connected to the IC 4049 hex inverter IC. Hex inverter IC gets the data
from probe and connected to the encoder chip directly. Here we use HT 12 E encoder
IC to convert the parallel data in serial. Output of the HT 12 E is connected to RF
transmitter. Here we use 433 MHz transmitter to transmit the data in air.

Figure 3.13: RF Transmitter

28

Level Sensor module is made of with HT12E encoder and ASK (Amplitude
Shift Keying) RF transmitter. This circuit is placed near the water tank.
HT12E Encoder IC will convert the 4 bit parallel data given to pins D0 D3
to serial data and will be available at DOUT. This output serial data is given to ASK
RF Transmitter. Address inputs A0 A7 can be used to provide data security and can
be connected to GND (Logic ZERO) or left open (Logic ONE). Status of these
Address pins should match with status of address pins in the receiver for the
transmission of the data. Data will be transmitted only when the Transmit Enable pin
(TE) is LOW. 1.1M resistor will provide the necessary external resistance for the
operation of the internal oscillator of HT12E.

3.6.2 TWS-434
The transmitter output is up to 8mW at 433.92MHz with a range of
approximately 400 foot (open area) outdoors. Indoors, the range is approximately 200
foot, and will go through most walls.
The TWS-434 transmitter accepts both linear and digital inputs can operate
from 1.5 to 12 Volts-DC, and makes building a miniature hand-held RF transmitter
very easy. The TWS-434 is approximately the size of a standard postage stamp.

3.6.3 RF Receiver
In the receiver circuit first of all we use one receiver module to receive the
data from transmitter. Data from the receive module is serially output. Output from
the RF module is connect to the decoder IC. Output of the RF module is connected to
the pin no.14 of the IC. Pin no.1 to 8 is address line and connected to the ground pin.
We set the same address line of the transmitter and receiver.
Pin no.15 and 16 of the IC is connected to the external resistance to provide
an oscillation circuit. Output from the decoder is connected to the pin no.5, 6, 7, 8 of

29

the microcontroller directly. Pin no.18 and 19 is connected to the external crystal
oscillator o provide an external clock to the circuit.
Pin no. 40 of the controller is connected to the positive 5 volt supply. For this
positive 5 volt supply we use one step down transformer to step down the voltage
from 220 volt ac to 9 volt ac. This AC is further converted into DC with the help of
the full wave rectifier circuit.

Figure 3.14: RF Receiver

Output of the rectifier is further converted in smooth dc with the help of the
filter capacitor. Output of rectifier is further converted into smooth dc with the help of
the 7805 regulator. IC 7805 regulator provide a regulated 5 volt dc to the circuit. This
supply is connected to the pin no.18 of the decoder IC and pin no.40 of the controller
IC. Seven segment display is connected to the pin no. 39 to 32 of the controller to
30

display the water level in digit. Water level LED is connected to the pin no.1, 2, 3, 4
of the controller.
Positive point of the LED is connected to common positive and cathode point
of the LED is connected to the controller via 470 ohm resistor. Start switch is
connected to pin no. 13 of the controller. Switch is connected with the ground voltage.
As we press the switch motor is to be start. With the help of this switch we on/off the
motor when we require. As the water level is very low down then motor is to be start
automatically. Receiver Module is made of with HT12D decoder and ASK RF
receiver. The data transmitted by the Sensor module is received by this module and is
given to the Controlling Module.
ASK RF Receiver receives the data transmitted using ASK RF Transmitter.
HT12D decoder will convert the received serial data to 4 bit parallel data D0 D3.
The status of these address pins A0-A7 should match with status of address pin in the
HT12E at the transmitter for the transmission of data. The LED connected to the
above circuit glows when valid data transmission occurs from transmitter to
receiver. 51K resistor will provide the necessary resistance required for the internal
oscillator of the HT12D.

3.6.4 RWS-434
The receiver also operates at 433.92MHz, and has a sensitivity of 3uV. The
RWS-434 receiver operates from 4.5 to 5.5 volts-DC, and has both linear and digital
outputs.
.

31

CHAPTER-4
SOFTWARE
4.1 SOFTWARE DESCRIPTION
The Vision from Keil combines project management, make facilities, source
code editing, program debugging, and complete simulation in one powerful
environment. The Vision development platform is easy-to-use and helping you
quickly create embedded programs that work. The Vision editor and debugger are
integrated in a single application that provides a seamless embedded project
development environment. The Vision IDE is the easiest way for most developers to
create embedded applications using the Keil development tools. To launch Vision,
click on the icon on your desktop or select Keil Vision4 from the Start Menu.
A Project is the collection of all the source files as well as the compiler, assembler,
and linker settings required to compile and link a program. Vision includes several
robust features that make project management easy.
The source files in your Vision project display in a Project Workspace.

Each Project can be configured to generate one or more Targets.


Each Target has its own option settings and output file name that you may
define. You may create one Target for testing with the simulator and
another Target for a release version of your application that will be

programmed into Flash ROM.


Within a Target, you may have one of more file Groups which allow you to
associate source files together. Groups are useful for grouping files into
functional blocks or for identifying engineers in a software team.

The Project Workspace window displays the target (AT91M55800A in this


case) along with all file groups and source files that comprise your project.

The Project menu provides access to all dialogs for project management
including...

New Project... which creates a new project.

32

Targets, Groups, Files... which add components to a project. The Local menu
in the Project window allows you to add files to the project.

Open Project... which opens an existing project.

You may double-click on an error or warning to immediately begin editing the


file with the problem--even while Vision continues compiling your source files in
the background. The line numbers for errors and warnings are synchronized even
after you make changes to the source file(s).
To get more information about a particular error message, select the message
and press F1 for full help text.
If you enable global optimizations, Vision re-compiles your source files to
achieve the most optimal global use of registers. Vision provides run controls to
start, stop, and step through your embedded application. You may use breakpoints
and trace memory to conditionally halt program execution and review previously
executed program code.
DEBUGGER FUNCTIONS
The Vision debugger incorporates a C function language you can use to
respond to program output and create input stimulus. A number of built-in debugger
functions, like printf, memset, and rand, are available.
You may create:

Signal functions to simulate analog and digital inputs to the CPU.


User functions that extend the command scope of the debugger and combine
repetitive actions.
Signal functions describe the behaviour of external hardware and supply input

to the microcontroller's I/O pins. Signal functions run in the background while the
Vision debugger simulates your target program.
There are several ways you can invoke debugger functions:

From the Command Line in the Output Window


From a button in the Toolbox
From a breakpoint definition
33

TOOLBOX FUNCTIONS
The Vision Debugger Toolbox contains user-configurable buttons you may
assign to user or signal functions or to debugger commands.
Click the Toolbox button on the toolbar to display the Toolbox Window.
When you click on a Toolbox button, the debugger executes the associated function
or command. Toolbox buttons may be used at any time, even while executing your
target program.
You may define Buttons for the Toolbox in the Command window.

Figure 4.1: Tool box


After converting to hex output, the code is dumped into the micro controller
using top-win software. It helps directly to dump the code into micro-controller with
and in the form of hex code.

4.2 PROGRAM CODE


#include<reg51.h>
# define lcd_data P0
sbit rs = P2^7;
sbit rw = P2^6;
sbit en = P2^5;
34

sbit l1 = P1^0;
sbit l2 = P1^1;
sbit l3 = P1^2;
sbit l4 = P1^3;
sbit rly = P1^4;
void delay(unsigned int del);
void lcdini();
void check_level();
void cmd_wri(unsigned char cmd);
void dat_wri(unsigned char dat);
void disp_str(unsigned char *str);
void pump_on();
int flag=0;
void main()
{
P0=0X00;
P2=0XFF;
P1=0XFF;
rly=0;
lcdini();
cmd_wri(0x80);
disp_str("WIRELESS WATER..");
cmd_wri(0xc0);
disp_str("LEVEL INDICATOR ");
delay(500);
cmd_wri(0x80);
disp_str("LEVEL INDICATOR ");
35

cmd_wri(0xc0);
disp_str("LEVEL AT :

");

while(1)
{
check_level();
}
}
void check_level()
{
if((l2==1)&&(l1==1)&&(l3==1)&&(l4==1))
{
cmd_wri(0xcA);
disp_str("FULL");
flag=0;
}
if((l1==0)&&(l2!=0)&&(l3!=0)&&(l4!=0))
{
cmd_wri(0xcA);
disp_str("2

");

}
if((l1==0)&&(l2==0)&&(l3!=0)&&(l4!=0))
{
cmd_wri(0xcA);
disp_str("3

");

}
if((l1==0)&&(l2==0)&&(l3==0)&&(l4!=0))
{
36

cmd_wri(0xcA);
disp_str("4

");

pump_on();
}
if((l2==0)&&(l1==0)&&(l3==0)&&(l4==0))
{
cmd_wri(0xcA);
disp_str("EMPTY");
delay(500);
pump_on();
}
}
void pump_on()
{
flag=1;
while(flag==1)
{
rly=1;
cmd_wri(0xc0);
disp_str("MOTOR RUNNING ..");
if((l2==1)&&(l1==1)&&(l3==1)&&(l4==1))
{
rly=0;
cmd_wri(0xc0);
disp_str("LEVEL AT :
cmd_wri(0xcA);
disp_str("FULL");
37

");

flag=0;
}
}
}
void lcdini()
{
cmd_wri(0x30);
cmd_wri(0x30);
cmd_wri(0x30);
cmd_wri(0x38);
cmd_wri(0x01);
cmd_wri(0x01);
cmd_wri(0x01);
cmd_wri(0x02);
cmd_wri(0x0c);
cmd_wri(0x1c);
cmd_wri(0x38);
cmd_wri(0x06);
cmd_wri(0x01);
}
void cmd_wri(unsigned char cmd)
{
lcd_data = cmd;
rs = 0;
rw = 0;
en = 1;
delay(1);
38

en = 0;
delay(1);
}
void dat_wri(unsigned char dat)
{
lcd_data = dat;
rs = 1;
rw = 0;
en = 1;
delay(1);
en = 0;
delay(1);
}
void disp_str(unsigned char *str)
{
unsigned char *p;
for(p=str;*p;*p++)
dat_wri(*p);
}
void delay(unsigned int del)
{
unsigned int i,j;
for(i=0;i<del;i++)
{
for(j=0;j<1275;j++);
}
}
39

RESULT

With this implemented system, it is possible to monitor the water level in an


over-head tank, switch on the water pump when the tank is empty and switch off the
same pump when the tank is full without any need for human intervention. By so
doing, the incidence of water wastage is eliminated and abrupt cut-off of water supply
is equally also eliminated.
The microcontroller has passed various tests with various components being
interfaced to it. As described in the previous sections of the paper the controller is the
heart of this project work as all the control signals are passed and processed by the
microcontroller. The LCD was interfaced to the microcontroller in order to display the
status of the system as it operates. The LCD data port is connected to the port 2 of the
microcontroller and through this port the microcontroller is able to send information
or instruction codes to the LCD. The microcontroller processes the data received and
used it to control the pump based on the written flow or control algorithm stored in its
ROM.

40

CONCLUSION

Water is precious for life. As we know that water is used in day to day work
like cleaning, bathing, washing etc. It is known that only 2-3% water is applicable for
drinking on earth. Water is also useful to make electricity. So we can learn that water
is precious for us.
In this paper wireless monitoring and controlling of water tank makes the
switching of device fully automatically and wirelessly thus we conclude that by using
the RF module technology our work of switching becomes very easy. Through this
project we understood the basics of microcontroller and the concept of RF trans
receiver. It is best applicable for residential application. Our range is covering upto
15m. These systems can be linked to relays which can automatically control the
switching of gates by allowing excess water to flow. It has no problem such as
breakage of wire arising after installation.

41

FUTURE SCOPE
Timely actions are taken accordingly by preventing the overflow of water.
Human intervention is low. This can be implemented almost in all houses and it is a
great advantage to the residents who go for work. The main drawback of automatic
water management system is that motor should be repaired manually in case of any
malfunction.
RF for motor control can also be implemented in SOC(System On Chip )for
even more sophistication and very useful for the society[2].SOC technology is the
packaging of all the obligatory electronic circuits and parts of a system on a single
integrated circuit(IC)generally known as micro chip.

42

REFERENCES

43

You might also like