You are on page 1of 60


1. INTRODUCTION…………………………………………………
 Objective Of The Project
 Block Diagram
 Block Diagram Description
 Circuit Diagram
 Circuit Description
 Microcontroller.
 Keypad
 Power Supply.
 Motor
 buzzer


In today’s world in many houses, offices, hotels where there is a requirement of

tank storage water one has to continuously track whether the tank is being empty or once
it is being on, to prevent the over flow of the water.

For sake of above problem much of the time is consumed and more over there
may be overflow of the water if at all someone forgets to off the motor in correct time.

But by using this scenario we can have the knowledge of the water present in the
tank and there is an indication and also if there is a any overflow of water is also
indicated using lcds and buzzer, with the help of microcontroller.
Block Diagram




Electrode 1 Controll
er LCD

Electrode 2 BUZZER



The circuit consists of tank,Microcontroller,lcd ,power supply and motor.

Depends upon on the sensor fuction it wills fill water in the tank alternatively motor
on and off state depends upon the water condition,here the lcd is used to see the
status of water in the tank



9 th pin is connected is to the Reset circuit as shown in the figure

18th and 19th pins are connected to the crystal oscillator of crystal frequency of 11.0592
mhz as shown in the diagram

40th pin is connected to the vcc power supply as shown in the diagram and 20th pin is
ground vss as shown in the diagram

Port pins P2.5,P2.6,P2.7 are connected to the control pins of the LCD namely RS,
R/W, E(Register select, read-write, and enable) used to operate different operations on


Port pins P0.0 to P0.7 are connected to the data pins of the LCD as shown in the
schematic diagram. Used to send the data from micro controller to the LCD.

Port 1:
Here the port pins p1.0 , P 1.1 are connected to the tank pins of empty and full
And also a manual ,on ,off switches are also connected to the microcontroller port
pins p1.3,p1.4,p1.5

Port 3:
Here the port pin 3.7 is connected to the motor

3.Power supply



A Micro controller consists of a powerful CPU tightly coupled with memory,

various I/O interfaces such as serial port, parallel port timer or counter, interrupt
controller, data acquisition interfaces-Analog to Digital converter, Digital to Analog
converter, integrated on to a single silicon chip.
If a system is developed with a microprocessor, the designer has to go for external
memory such as RAM, ROM, EPROM and peripherals. But controller is provided all
these facilities on a single chip. Development of a Micro controller reduces PCB size and
cost of design.
One of the major differences between a Microprocessor and a Micro controller is
that a controller often deals with bits not bytes as in the real world application.
Intel has introduced a family of Micro controllers called the MCS-51.

The Major Features:

• Compatible with MCS-51 products

• 4k Bytes of in-system Reprogrammable flash memory
• Fully static operation: 0HZ to 24MHZ
• Three level programmable clock
• 128 * 8 –bit timer/counters
• Six interrupt sources
• Programmable serial channel
• Low power idle power-down modes

Why AT 89C51

The system requirements and control specifications clearly rule out the use of 16,
32 or 64 bit micro controllers or microprocessors. Systems using these may be earlier to
implement due to large number of internal features. They are also faster and more reliable
but, the above application is satisfactorily served by 8-bit micro controller. Using an
inexpensive 8-bit Microcontroller will doom the 32-bit product failure in any competitive
market place.
Coming to the question of why to use AT89C51 of all the 8-bit microcontroller
available in the market the main answer would be because it has 4 Kb on chip flash
memory which is just sufficient for our application. The on-chip Flash ROM allows the
program memory to be reprogrammed in system or by conventional non-volatile memory
Programmer. Moreover ATMEL is the leader in flash technology in today’s market place
and hence using AT 89C51 is the optimal solution.


The 89C51 architecture consists of these specific features:

• Eight –bit CPU with registers A (the accumulator) and B

• Sixteen-bit program counter (PC) and data pointer (DPTR)
• Eight- bit stack pointer (PSW)
• Eight-bit stack pointer (Sp)
• Internal ROM or EPROM (8751) of 0(8031) to 4K (89C51)
• Internal RAM of 128 bytes:
1. Four register banks, each containing eight registers
2. Sixteen bytes, which maybe addressed at the bit level
3. Eighty bytes of general- purpose data memory
• Thirty –two input/output pins arranged as four 8-bit ports:p0-p3
• Two 16-bit timer/counters: T0 and T1
• Full duplex serial data receiver/transmitter: SBUF
• Control registers: TCON, TMOD, SCON, PCON, IP, and IE
• Two external and three internal interrupts sources.
• Oscillator and clock circuits.

Functional block diagram of micro controller

The 89C51 oscillator and clock:

The heart of the 89C51 circuitry that generates the clock pulses by which all the
internal all internal operations are synchronized. Pins XTAL1 And XTAL2 is provided
for connecting a resonant network to form an oscillator. Typically a quartz crystal and
capacitors are employed. The crystal frequency is the basic internal clock frequency of
the microcontroller. The manufacturers make 89C51 designs that run at specific
minimum and maximum frequencies typically 1 to 16 MHz.

Fig 3.7.2: - Oscillator and timing circuit

Types of memory:

The 89C51 have three general types of memory. They are on-chip memory,
external Code memory and external Ram. On-Chip memory refers to physically existing
memory on the micro controller itself. External code memory is the code memory that
resides off chip. This is often in the form of an external EPROM. External RAM is the
Ram that resides off chip. This often is in the form of standard static RAM or flash

a) Code memory
Code memory is the memory that holds the actual 89C51 programs that is to be
run. This memory is limited to 64K. Code memory may be found on-chip or off-chip. It
is possible to have 4K of code memory on-chip and 60K off chip memory
simultaneously. If only off-chip memory is available then there can be 64K of off chip
ROM. This is controlled by pin provided as EA

b) Internal RAM

The 89C51 have a bank of 128 of internal RAM. The internal RAM is found on-
chip. So it is the fastest Ram available. And also it is most flexible in terms of reading
and writing. Internal Ram is volatile, so when 89C51 is reset, this memory is cleared. 128
bytes of internal memory are subdivided. The first 32 bytes are divided into 4 register
banks. Each bank contains 8 registers. Internal RAM also contains 128 bits, which are
addressed from 20h to 2Fh. These bits are bit addressed i.e. each individual bit of a byte
can be addressed by the user. They are numbered 00h to 7Fh. The user may make use of
these variables with commands such as SETB and CLR.


Flash memory (sometimes called "flash RAM") is a type of constantly-powered

non volatile that can be erased and reprogrammed in units of memory called blocks. It is
a variation of electrically erasable programmable read-only memory (EEPROM) which,
unlike flash memory, is erased and rewritten at the byte level, which is slower than flash
memory updating. Flash memory is often used to hold control code such as the basic
input/output system (BIOS) in a personal computer. When BIOS needs to be changed
(rewritten), the flash memory can be written to in block (rather than byte) sizes, making it
easy to update. On the other hand, flash memory is not useful as random access memory
(RAM) because RAM needs to be addressable at the byte (not the block) level.

Flash memory gets its name because the microchip is organized so that a section
of memory cells are erased in a single action or "flash." The erasure is caused by Fowler-
Nordheim tunneling in which electrons pierce through a thin dielectric material to remove
an electronic charge from a floating gate associated with each memory cell. Intel offers a
form of flash memory that holds two bits (rather than one) in each memory cell, thus
doubling the capacity of memory without a corresponding increase in price.
Flash memory is used in digital cellular phones, digital cameras, LAN switches,
PC Cards for notebook computers, digital set-up boxes, embedded controllers, and other

Figure 1: Memory Types

Memory Type Features
FLASH Low-cost, high-density, high-speed
architecture; low power; high reliability
ROM Mature, high-density, reliable, low cost;
Read-Only Memory time-consuming mask required, suitable
for high production with stable code
SRAM Highest speed, high-power, low-density
Static Random-Access Memory memory; limited density drives up cost
EPROM High-density memory; must be exposed
Electrically Programmable Read-Only to ultraviolet light for erasure
EEPROMorE2PROM Electrically byte-erasable; lower
Electrically Erasable Programmable reliability, higher cost, lowest density
Read-Only Memory

DRAM High-density, low-cost, high-speed,

Dynamic Random Access Memory high-power

Technical Overview of Flash Memory

Flash memory is a nonvolatile memory using NOR technology, which allows the user to
electrically program and erase information. Intel® Flash memory uses memory cells
similar to an EPROM, but with a much thinner, precisely grown oxide between the
floating gate and the source (see Figure 2). Flash programming occurs when electrons are
placed on the floating gate. The charge is stored on the floating gate, with the oxide layer
allowing the cell to be electrically erased through the source. Intel Flash memory is an
extremely reliable nonvolatile memory architecture.

Fig 3.7.3: - Pin diagram of AT89C51

Pin Description:

VCC: Supply voltage.

GND: Ground.
Port 0:
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin
can sink eight TTL inputs. When 1sare 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 pull-ups are required during
program verification.

Port 1:
Port 1 is an 8-bit bi-directional 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

Port 2:
Port 2 is an 8-bit bi-directional 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 memories that use 16-bit addresses (MOVX
@DPTR). In this application, it uses strong internal pull-ups when emitting 1s. During
accesses to external data memories that use 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.

Port 3:
Port 3 is an 8-bit bi-directional 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 serves the functions of various special features of the AT89C51 as listed
Port 3 also receives some control signals for Flash programming and verification

Tab 6.2.1 Port pins and their alternate functions

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

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 1/6the
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.

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.

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
Note, however, that if lock bit 1 is programmed, EA will be internally latched on
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.

Input to the inverting oscillator amplifier and input to the internal clock operating
Output from the inverting oscillator amplifier.
Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier which can be configured for use as an on-chip oscillator, as shown in Figs
6.2.3. 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 6.2.4.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-by-two flip-
flop, but minimum and maximum voltage high and low time specifications must be

Fig 6.2.3 Oscillator Connections Fig 6.2.4 External Clock Drive Configuration

1. Under steady state (non-transient) conditions, IOL must be externally
limited as follows:
• Maximum IOL per port pin: 10 mA
• Maximum IOL per 8-bit port: Port 0: 26 mA
• Ports 1, 2, 3: 15 mA
• Maximum total IOL for all output pins: 71 mA
• If IOL exceeds the test condition, VOL may exceed the related
specification. Pins are not guaranteed to sink current greater than the listed
test conditions.
2. Minimum VCC for Power-down is 2V.


A liquid crystal is a material (normally organic for LCDs) that will flow like a
liquid but whose molecular structure has some properties normally associated with solids.
The Liquid Crystal Display (LCD) is a low power device. The power requirement is
typically in the order of microwatts for the LCD. However, an LCD requires an external
or internal light source. It is limited to a temperature range of about 0C to 60C and
lifetime is an area of concern, because LCDs can chemically degrade.

There are two major types of LCDs which are:

1. Dynamic-scattering LCDs and
2. Field-effect LCDs

Field-effect LCDs are normally used in such applications where source of energy
is a prime factor (e.g., watches, portable instrumentation etc.).They absorb considerably
less power than the light-scattering type. However, the cost for field-effect units is
typically higher, and their height is limited to 2 inches. On the other hand, light-scattering
units are available up to 8 inches in height. Field-effect LCD is used in the project for
displaying the appropriate information.

The turn-on and turn-off time is an important consideration in all displays. The
response time of LCDs is in the range of 100 to 300ms.The lifetime of LCDs is steadily
increasing beyond 10,000+hours limit. Since the color generated by LCD units is
dependent on the source of illumination, there is a wide range of color choice.

RS (Command / Data):

This bit is to specify weather received byte is command or data. So that LCD can
recognize the operation to be performed based on the bit status.

RS = 0 => Command
RS = 1 => Data

RW (Read / Write):-

RW bit is to specify weather controller wants READ from LCD or WRITE to

A K D7
LCD. The READ operation here is just ACK bit to know weather LCD is free or not.

RW = 0 => Write
RW = 1 => Read

EN (Enable LCD):-

EN bit is to ENABLE or DISABLE the LCD. When ever controller wants to write
some thing into LCD or READ acknowledgment from LCD it needs to enable the LCD.

EN = 0 => High Impedance

EN = 1 => Low Impedance

ACK (LCD Ready):-

ACK bit is to acknowledge the MCU that LCD is free so that it can send new
command or data to be stored in its internal Ram locations

ACK = 1 => Not ACK

ACK = 0 => ACK


Keyboards and LCDs are the most widely used input/output devices of the 8051, and a
basic understanding of them is essential. In this section, we first discuss keyboard
fundamentals, along with key press and key detection mechanisms, Then we show how a
keyboard is interfaced to an 8051.

Interfacing the Keyboard to the 8051

At the lowest level, keyboards are organized in a matrix of rows and columns. The CPU
accesses both rows and column through ports; therefore, with two 8-bit ports, an 8*8
matrix of keys can be connected to a microprocessor. When a key pressed, a row and
column make a connect; otherwise, there is no connection between row and column. In
IBM PC keyboards, a single micro controller (consisting of microprocessor, RAM and
EPROM, and several ports all on a single chip) takes care of software and hardware
interfacing of keyboard. In such systems it is the function of programs stored in the
EPROM of micro controller to scan the keys continuously, identify which one has been
activated, and present it to the motherboard. In this section we look at the mechanism by
which the 8051 scans and identifies the key.

Scanning and identifying the key

Figure13.5 shows a 4*4 matrix connected to two ports. 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 micro
controller to scan the keyboard continuously to detect and identify the key pressed. How
it is done is explained next.
Grounding rows and reading columns

To detect a pressed key, the micro controller grounds all rows by providing 0 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 key press has occurred.
For example, if D3-D0=1101, this means that a key in the D1 column has been pressed.
After a key press is detected, the micro controller will go through the process of
identifying the key. Starting with the top row, the micro controller grounds it by
providing a low to row D0 only; then it reads the columns. If the data read is all1s, 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. This should be easy since the
microcontroller knows at any time which row and column are being accessed.

Assembly language program for detection and identification of key activation is given
below. In this program, it is assumed that P1 and P2 are initialized as output and input,
respectively. Program13.1 goes through the following four major stages:

1. To make sure that the preceding key has been released, 0s are output to all rows at
once, and the columns are read and checked repeatedly until all the columns are high.
When all columns are found to be high, the program waits for a short amount of time
before it goes to the next stage of waiting for a key to be pressed.

2) To see if any key is pressed, the columns are scanned over and over in an infinite loop
until one of them has a 0 on it. Remember that the output latches connected to rows still
have their initial zeros (provided in stage 1), making them grounded. After the key press
detection, it waits 20ms for the bounce and then scans the columns again. This serves two
functions: (a) it ensures that the first key press detection was not an erroneous one due to
spike noise, and(b) the 20ms delay prevents the same key press from being interpreted as
a multiple key press. If after the 20-ms delay the key is still pressed, it goes to the next
stage to detect which row it belongs to; otherwise, it goes back into the loop to detect a
real key press

3) To detect which row the key press belongs to, it grounds one row at a time, reading
the columns each time. If it finds that all columns are high, this means that the key press
cannot belong to that row; therefore, it grounds the next row and continues until it finds
the row the key press belongs to. Upon finding the row that the key press belongs to, it
sets up the starting address for the look-up table holding the scan codes (or the ASCII
value) for that row and goes to the next stage to identify the key.
4) To identify the key press, it rotates the column bits, one bit at a time, into the carry
flag and checks to see if it is low. Upon finding the zero, it pulls out the ASCII code for
that key from the look-up table; Otherwise, it increments the pointer to point to the next
element of the look-up table.

While the key press detection is standard for all keyboards, the process for determining
which key is pressed varies. The look-up table method shown in program can be
modified to work with any matrix up to 8*8.

There are IC chips such as National Semiconductors MM74C923 that incorporate

keyboard scanning and decoding all in one chip. Such chips use combinations of counters
and logic gates (No micro controller).
Power supply

There are many types of power supply. Most are designed

to convert high voltage AC mains electricity to a suitable low voltage supply for
electronics circuits and other devices. A power supply can by broken down into a series
of blocks, each of which performs a particular function.

For example a 5V regulated supply:


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.

This type of regulation is ideal for having a simple variable bench power supply. Actually
this is quite important because one of the first projects a hobbyist should undertake is the
construction of a variable regulated power supply. While a dedicated supply

Transformers convert AC electricity from one voltage to another with little loss of
power. Transformers work only with AC and this is one of the reasons why mains
electricity is AC. Step-up transformers increase voltage, step-down transformers reduce
voltage. Most power supplies use a step-down transformer to reduce the dangerously high
mains voltage to a safer low voltage. The input coil is called the primary and the output
coil is called the secondary. There is no electrical connection between the two coils,
instead they are linked by an alternating magnetic field created in the soft-iron core of the
transformer. The two lines in the middle of the circuit symbol represent the core.
Transformers waste very little power so the power out is (almost) equal to the power in.
Note that as voltage is stepped down current is stepped up. The ratio of the number of
turns on each coil, called the turns ratio, determines the ratio of the voltages. A step-down
transformer has a large number of turns on its primary (input) coil which is connected to
the high voltage mains supply, and a small number of turns on its secondary (output) coil
to give a low output voltage.
Fig 6.1.2 An Electrical Transformer

Turns ratio = Vp/VS = Np/NS

Power Out= Power In

Vp = primary (input) voltage
Np = number of turns on primary coil
Ip = primary (input) current

Full wave rectifier

Full wave rectifier circuit is shown below. the transformer secondary

has a centre-tap and each half give voltage of Vm. In each half there is one diode i.e. D1
and D2.the load resistance Rl is common to both halvesThis can be seen to comprise of
two half-wave circuits. on the positive half cycle, when the point is +ve w.r.tB,theDiode
D1 conducts and current i1 flows through Rl. During this half cycle, the point C is -ve
w.r.t.point B and hence the diode D2 does not conduct. Therefore i2=0.
On the negative half cycle the point C is +ve w.r.t. point B. hence the diode D2
conducts and current i2 flows through RL. During this half cycle. The point A is –ve
w.r.t.point B and hence the diode D1 does not conduct. Therefore i1=0
Fig.(b) and (c) shows the waveforms of currents i1 and i2 .since both i1 and i2
flow through the load RL, the current i through RL is i= i1+i2, which is obtained by
adding the two waveform and is shown in fig(d)


Ac B
supply RL


Fig2 (a) Full wave rectifier circuit

Advantages and disadvantages of full wave Rectifier:

(a) amount of ripple is much lower(r=0.482)as compared to half wave (r=1.21).

(b) Rectification efficiency is high (n=0.812)
(c) T.U.F is better (= 0.693) then that of half wave (=0.287).
(d) No problem of core saturation.
(e) Requires centre-tapped secondary of the transform
Comparison of rectifier circuits:

Type of Rectifier
Half wave full wave bridge
Number of diodes
1 2 3
PIV of diodes
Vm 2Vm Vm
Secondary voltage
(rms) V V-0-V V
Secondary voltage
Vm V-0-V Vm

D.C output voltage Vm/ 2Vm/ 2Vm/

Vdc,at 0.318Vm 0.636Vm 0.636Vm


Ripple factor 1.21 0.482 0.482

frequency f 2f 2f
efficiency 0.406 0.812 0.812
Utilization 0.287 0.693 0.812

Capacitor Filter:

We have seen that the ripple content in the rectified output of half wave rectifier is
121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high
percentages of ripples is not acceptable for most of the applications. Ripples can be
removed by one of the following methods of filtering:

(a) A capacitor, in parallel to the load, provides a easier by –pass for the ripples voltage
though it due to low impedance
At ripple frequency and leave the appears the load.

(b) An inductor, in series with the load, prevents the passage of the ripple current (due to
high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c)

(c) various combinations of capacitor and inductor, such as L-section filter section
filter, multiple section filter etc. which make use of both the properties mentioned in (a)
(b) Above.

Two cases of capacitor filter, one applied on half wave rectifier and another with full
wave rectifier.

Full-wave Rectifier with capacitor filter:

Fig 4(a) shows the circuit diagram, with a full wave rectifier comprising of a center-
tapped secondary winding and two diodes. All the analysis given in this section are also
valid for a bridge rectifier, which also gives full-wave rectification. The filter capacitor C
is connected in parallel with load resistance RL.

In a manner similar to half-wave circuit with capacitor filter, in this circuit also the
capacitor C will get charged during short periods and thereafter, discharge through the
load resistance RL. One notable difference here is that the discharge duration is shorter,
whereas in half-wave case the duration was longer due to the missing half –waves in
between. As a result, the average value of output voltage is higher.
Bridge Rectifier A bridge rectifier makes use of four diodes in a bridge arrangement to
achieve full-wave rectification. This is a widely used configuration, both with
individual diodes wired as shown and with single component bridges where the
diode bridge is wired internally.

A bridge rectifier makes use of four diodes in a bridge arrangement to achieve

full-wave rectification. This is a widely used configuration, both with individual diodes
wired as shown and with single component bridges where the diode bridge is wired

Fig 6.1.3 A Typical Bridge Rectifier Circuit

Current Flow in the Bridge Rectifier

Fig 6.1.4 Current Flow in the Bridge Rectifier

For both positive and negative swings of the transformer, there is a forward path through
the diode bridge. Both conduction paths cause current to flow in the same direction
through the load resistor, accomplishing full-wave rectification. While one set of diodes
is forward biased, the other set is reverse biased and effectively eliminated from the

Fig 6.1.5 Current Flow in the Bridge Rectifier


Smoothing is performed by a large value electrolytic capacitor connected across

the DC supply to act as a reservoir, supplying current to the output when the varying DC
voltage from the rectifier is falling. The diagram shows the unsmoothed varying DC
(dotted line) and the smoothed DC (solid line). The capacitor charges quickly near the
peak of the varying DC, and then discharges as it supplies current to the output.
Smoothing significantly increases the average DC voltage to almost the peak value (1.4 ×
RMS value). For example 6V RMS AC is rectified to full wave DC of about 4.6V RMS
(1.4V is lost in the bridge rectifier), with smoothing this increases to almost the peak
value giving 1.4 × 4.6 = 6.4V smooth DC. Smoothing is not perfect due to the capacitor
voltage falling a little as it discharges, giving a small ripple voltage. For many circuits a
ripple, which is 10% of the supply voltage, is satisfactory and the equation below gives
the required value for the smoothing capacitor. A larger capacitor will give less ripple.
The capacitor value must be doubled when smoothing half-wave DC.


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. To make a 5 volt power supply, we use a LM7805
voltage regulator IC (Integrated Circuit). The IC is shown below.

FIG 7.1
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.

Circuit features
Brief description of operation: Gives out well regulated +5V output, output current
capability of 100 mA
Circuit protection: Built-in overheating protection shuts down output when regulator IC
gets too hot
Circuit complexity: Very simple and easy to build
Circuit performance: Very stable +5V output voltage, reliable operation
Availability of components: Easy to get, uses only very common basic components
Design testing: Based on datasheet example circuit, I have used this circuit successfully
as part of many electronics projects
Applications: Part of electronics devices, small laboratory power supply
Power supply voltage: Unregulated DC 8-18V power supply
Power supply current: Needed output current + 5 mA
Component costs: Few dollars for the electronics components + the input transformer

Voltage regulator ICs is available with fixed (typically 5, 12 and 15V)

or variable output voltages. The maximum current they can pass also rates them.
Negative voltage regulators are available, mainly for use in dual supplies. Most regulators
include some automatic protection from excessive current ('overload protection') and
overheating ('thermal protection'). Many of the fixed voltage regulator ICs have 3 leads
and look like power transistors, such as the 7805 +5V 1A regulator shown on the right.
Fig 6.1.6 A Three Terminal Voltage Regulator
The Bay Linear LM78XX is integrated linear positive regulator with three
terminals. The LM78XX offer several fixed output voltages making them useful in wide
range of applications. When used as a zener diode/resistor combination replacement, the
LM78XX usually results in an effective output impedance improvement of two orders of
magnitude, lower quiescent current.
The LM78XX is available in the TO-252, TO-220 & TO-263packages,

• Output Current of 1.5A
• Output Voltage Tolerance of 5%
• Internal thermal overload protection
• Internal Short-Circuit Limited
• No External Component
• Output Voltage 5.0V, 6V, 8V, 9V, 10V,12V, 15V, 18V, 24V
• Offer in plastic TO-252, TO-220 & TO-263
• Direct Replacement for LM78XX

• Post regulator for switching DC/DC converter
• Bias supply for analog circuits
Electrical Characteristics (LM7805)
(VI=10V, IO=500mA, 0°C ≤TJ≤125 °C, unless otherwise specified. (Note 1)

Tab 6.1.1 Electrical Characteristics (7805)

Electrical Characteristics (LM7812)

(VI=19V, IO=500mA, 0°C ≤TJ≤125 °C, unless otherwise specified. (Note 1)
Tab 6.1.2 Electrical Characteristics (LM7812)

DC Motor
DC motors are configured in many types and sizes, including brush less,
servo, and gear motor types. A motor consists of a rotor and a permanent magnetic field
stator. The magnetic field is maintained using either permanent magnets or
electromagnetic windings. DC motors are most commonly used in variable speed and
Motion and controls cover a wide range of components that in some way
are used to generate and/or control motion. Areas within this category include bearings
and bushings, clutches and brakes, controls and drives, drive components, encoders and
resolves, Integrated motion control, limit switches, linear actuators, linear and rotary
motion components, linear position sensing, motors (both AC and DC motors),
orientation position sensing, pneumatics and pneumatic components, positioning stages,
slides and guides, power transmission (mechanical), seals, slip rings,solenoids,springs.

Motors are the devices that provide the actual speed and torque in a drive
system. This family includes AC motor types (single and multiphase motors, universal,
servo motors, induction, synchronous, and gear motor) and DC motors (brush less, servo
motor, and gear motor) as well as linear, stepper and air motors, and motor contactors and
In any electric motor, operation is based on simple electromagnetism. A
current-carrying conductor generates a magnetic field; when this is then placed in an
external magnetic field, it will experience a force proportional to the current in the
conductor, and to the strength of the external magnetic field. As you are well aware of
from playing with magnets as a kid, opposite (North and South) polarities attract, while
like polarities (North and North, South and South) repel. The internal configuration of a
DC motor is designed to harness the magnetic interaction between a current-carrying
conductor and an external magnetic field to generate rotational motion.

Let's start by looking at a simple 2-pole DC electric motor (here red represents a
magnet or winding with a "North" polarization, while green represents a magnet or
winding with a "South" polarization).

Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator,
commutator, field magnet(s), and brushes. In most common DC motors (and all that
Beamers will see), the external magnetic field is produced by high-strength permanent
magnets1. The stator is the stationary part of the motor -- this includes the motor casing,
as well as two or more permanent magnet pole pieces. The rotor (together with the axle
and attached commutator) rotates with respect to the stator. The rotor consists of
windings (generally on a core), the windings being electrically connected to the
commutator. The above diagram shows a common motor layout -- with the rotor inside
the stator (field) magnets.
The geometry of the brushes, commutator contacts, and rotor windings are such
that when power is applied, the polarities of the energized winding and the stator
magnet(s) are misaligned, and the rotor will rotate until it is almost aligned with the
stator's field magnets. As the rotor reaches alignment, the brushes move to the next
commutator contacts, and energize the next winding. Given our example two-pole motor,
the rotation reverses the direction of current through the rotor winding, leading to a "flip"
of the rotor's magnetic field, and driving it to continue rotating.
In real life, though, DC motors will always have more than two poles (three
is a very common number). In particular, this avoids "dead spots" in the commutator.
You can imagine how with our example two-pole motor, if the rotor is exactly at the
middle of its rotation (perfectly aligned with the field magnets), it will get "stuck" there.
Meanwhile, with a two-pole motor, there is a moment where the commutator shorts out
the power supply (i.e., both brushes touch both commutator contacts simultaneously).
This would be bad for the power supply, waste energy, and damage motor components as
well. Yet another disadvantage of such a simple motor is that it would exhibit a high
amount of torque” ripple" (the amount of torque it could produce is cyclic with the
position of the rotor).

So since most small DC motors are of a three-pole design, let's tinker with the
workings of one via an interactive animation (JavaScript required):
You'll notice a few things from this -- namely, one pole is fully energized at a
time (but two others are "partially" energized). As each brush transitions from one
commutator contact to the next, one coil's field will rapidly collapse, as the next coil's
field will rapidly charge up (this occurs within a few microsecond). We'll see more about
the effects of this later, but in the meantime you can see that this is a direct result of the
coil windings' series wiring:

There's probably no better way to see how an average dc motor is put together,
than by just opening one up. Unfortunately this is tedious work, as well as requiring the
destruction of a perfectly good motor. This is a basic 3-pole dc motor, with 2 brushes
and three commutator contacts.

A buzzer or beeper is a signalling device, usually electronic, typically used in
automobiles, household appliances such as a microwave oven, or game shows. It most
commonly consists of a number of switches or sensors connected to a control unit that
determines if and which button was pushed or a preset time has lapsed, and usually
illuminates a light on the appropriate button or control panel, and sounds a warning in the
form of a continuous or intermittent buzzing or beeping sound. Initially this device was
based on an electromechanical system which was identical to an electric bell without the
metal gong (which makes the ringing noise). Often these units were anchored to a wall or
ceiling and used the ceiling or wall as a sounding board. Another implementation with
some AC-connected devices was to implement a circuit to make the AC current into a
noise loud enough to drive a loudspeaker and hook this circuit up to a cheap 8-ohm
speaker. Nowadays, it is more popular to use a ceramic-based piezoelectric sounder like a
Sonalert which makes a high-pitched tone. Usually these were hooked up to "driver"
circuits, which varied the pitch of the sound or pulsed the sound, on and off.

Electronic symbol for a buzzer.

Metal disk with piezoelectric disk attached, as found in a buzzer

In game shows it is also known as a "lockout system," because when one person signals
("buzzes in"), all others are locked out from signalling.Several game shows have large
buzzer buttons which are identified as "plungers".

The word "buzzer" comes from the rasping noise that buzzers made when they were
electromechanical devices, operated from stepped-down AC line voltage at 50 or 60
cycles. Other sounds commonly used to indicate that a button has been pressed are a ring
or a beep.
Circuit description:
In this project we required operating voltage for Microcontroller 89C51 is 5V. Hence the
5V D.C. power supply is needed for the IC’s. This regulated 5V is generated by stepping
down the voltage from 230V to 18V now the step downed a.c voltage is being rectified
by the Bridge Rectifier using 1N4007 diodes. The rectified a.c voltage is now filtered
using a ‘C’ filter. Now the rectified, filtered D.C. voltage is fed to the Voltage Regulator.
This voltage regulator provides/allows us to have a Regulated constant Voltage which is
of +5V. The rectified; filtered and regulated voltage is again filtered for ripples using an
electrolytic capacitor 100μF. Now the output from this section is fed to 40 th pin of 89C51
microcontroller to supply operating voltage. The microcontroller 89C51 with Pull up
resistors at Port0 and crystal oscillator of 11.0592 MHz crystal in conjunction with
couple of 30-33pf capacitors is placed at 18th & 19th pins of 89C51 to make it work
(execute) properly.
In today’s world in many houses, offices, hotels where there is a requirement
of storage any liquid one has to continuously track whether the tank is being empty
or once it is being on, to prevent the over flow of the water.
For sake of above problem much of the time is consumed and more over
there may be overflow of the water or liquid if at all some one forgets to off the
motor in correct time.
But by using this scenario we can have the knowledge of the liquid present in
the tank and there is an indication and also if there is a any overflow of liquid is also
indicated using buzzer, with the help of microcontroller.

Software’s used are:
*Keil software for c programming
*Express PCB for lay out design
*Express SCH for schematic design

What's New in µVision3?

µVision3 adds many new features to the Editor like Text Templates, Quick Function
Navigation, and Syntax Coloring with brace high lighting Configuration Wizard for
dialog based startup and debugger setup. µVision3 is fully compatible to µVision2 and
can be used in parallel with µVision2.

What is µVision3?

µVision3 is an IDE (Integrated Development Environment) that helps you write, compile,
and debug embedded programs. It encapsulates the following components:
• A project manager.
• A make facility.
• Tool configuration.
• Editor.
• A powerful debugger.
To help you get started, several example programs (located in the \C51\Examples,
\C251\Examples, \C166\Examples, and \ARM\...\Examples) are provided.
• HELLO is a simple program that prints the string "Hello World" using the Serial
• MEASURE is a data acquisition system for analog and digital systems.
• TRAFFIC is a traffic light controller with the RTX Tiny operating system.
• SIEVE is the SIEVE Benchmark.
• DHRY is the Dhrystone Benchmark.
• WHETS is the Single-Precision Whetstone Benchmark.
Additional example programs not listed here are provided for each device architecture.

Building an Application in µVision2

To build (compile, assemble, and link) an application in µVision2, you must:

1. Select Project -(forexample,166\EXAMPLES\HELLO\HELLO.UV2).
2. Select Project - Rebuild all target files or Build target.
µVision2 compiles, assembles, and links the files in your project.

Creating Your Own Application in µVision2

To create a new project in µVision2, you must:

1. Select Project - New Project.
2. Select a directory and enter the name of the project file.
3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from
the Device Database™.
4. Create source files to add to the project.
5. Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and add
the source files to the project.
6. Select Project - Options and set the tool options. Note when you select the target
device from the Device Database™ all special options are set automatically. You
typically only need to configure the memory map of your target hardware. Default
memory model settings are optimal for most applications.
7. Select Project - Rebuild all target files or Build target.

Debugging an Application in µVision2

To debug an application created using µVision2, you must:

1. Select Debug - Start/Stop Debug Session.
2. Use the Step toolbar buttons to single-step through your program. You may enter
G, main in the Output Window to execute to the main C function.
3. Open the Serial Window using the Serial #1 button on the toolbar.
Debug your program using standard options like Step, Go, Break, and so on.
Starting µVision2 and Creating a Project
µVision2 is a standard Windows application and started by clicking on the program icon.
To create a new project file select from the µVision2 menu
Project – New Project…. This opens a standard Windows dialog that asks you
for the new project file name.
We suggest that you use a separate folder for each project. You can simply use
the icon Create New Folder in this dialog to get a new empty folder. Then
select this folder and enter the file name for the new project, i.e. Project1.
µVision2 creates a new project file with the name PROJECT1.UV2 which contains
a default target and file group name. You can see these names in the Project
Window – Files.
Now use from the menu Project – Select Device for Target and select a CPU
for your project. The Select Device dialog box shows the µVision2 device
database. Just select the micro controller you use. We are using for our examples the
Philips 80C51RD+ CPU. This selection sets necessary tool
options for the 80C51RD+ device and simplifies in this way the tool Configuration
Building Projects and Creating a HEX Files
Typical, the tool settings under Options – Target are all you need to start a new
application. You may translate all source files and line the application with a
click on the Build Target toolbar icon. When you build an application with
syntax errors, µVision2 will display errors and warning messages in the Output
Window – Build page. A double click on a message line opens the source file
on the correct location in a µVision2 editor window.
Once you have successfully generated your application you can start debugging.

After you have tested your application, it is required to create an Intel HEX file to
download the software into an EPROM programmer or simulator. µVision2 creates HEX
files with each build process when Create HEX files under Options for Target – Output is
enabled. You may start your PROM programming utility after the make process when
you specify the program under the option Run User Program #1.
CPU Simulation
µVision2 simulates up to 16 Mbytes of memory from which areas can be
mapped for read, write, or code execution access. The µVision2 simulator traps
and reports illegal memory accesses.
In addition to memory mapping, the simulator also provides support for the
integrated peripherals of the various 8051 derivatives. The on-chip peripherals
of the CPU you have selected are configured from the Device
Database selection
you have made when you create your project target. Refer to page 58 for more
Information about selecting a device. You may select and display the on-chip peripheral
components using the Debug menu. You can also change the aspects of each peripheral
using the controls in the dialog boxes.
Start Debugging
You start the debug mode of µVision2 with the Debug – Start/Stop Debug
Session command. Depending on the Options for Target – Debug
Configuration, µVision2 will load the application program and run the startup
code µVision2 saves the editor screen layout and restores the screen layout of the last
debug session. If the program execution stops, µVision2 opens an
editor window with the source text or shows CPU instructions in the disassembly
window. The next executable statement is marked with a yellow arrow. During
debugging, most editor features are still available.
For example, you can use the find command or correct program errors. Program source
text of your application is shown in the same windows. The µVision2 debug mode differs
from the edit mode in the following aspects:
_ The “Debug Menu and Debug Commands” described on page 28 are
Available. The additional debug windows are discussed in the following.
_ The project structure or tool parameters cannot be modified. All build
Commands are disabled.
Disassembly Window
The Disassembly window shows your target program as mixed source and assembly
program or just assembly code. A trace history of previously executed instructions may
be displayed with Debug – View Trace Records. To enable the trace history, set Debug –
Enable/Disable Trace Recording.
If you select the Disassembly Window as the active window all program step commands
work on CPU instruction level rather than program source lines. You can select a text line
and set or modify code breakpoints using toolbar buttons or the context menu commands.
You may use the dialog Debug – Inline Assembly… to modify the CPU
instructions. That allows you to correct mistakes or to make temporary changes to the
target program you are debuggin


1. Click on the Keil uVision Icon on Desktop

2. The following fig will appear

3. Click on the Project menu from the title bar

4. Then Click on New Project

5. Save the Project by typing suitable project name with no extension in u r own
folder sited in either C:\ or D:\
6. Then Click on Save button above.

7. Select the component for u r project. i.e. Atmel……

8. Click on the + Symbol beside of Atmel

9. Select AT89C51 as shown below

10. Then Click on “OK”

11. The Following fig will appear

12. Then Click either YES or NO………mostly “NO”

13. Now your project is ready to USE

14. Now double click on the Target1, you would get another option “Source
group 1” as shown in next page.

15. Click on the file option from menu bar and select “new”

16. The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
17. Now start writing program in either in “C” or “ASM”

18. For a program written in Assembly, then save it with extension “. asm” and
for “C” based program save it with extension “ .C”

19. Now right click on Source group 1 and click on “Add files to Group Source”
20. Now you will get another window, on which by default “C” files will appear.

21. Now select as per your file extension given while saving the file

22. Click only one time on option “ADD”

23. Now Press function key F7 to compile. Any error will appear if so happen.
24. If the file contains no error, then press Control+F5 simultaneously.

25. The new window is as follows

26. Then Click “OK”

27. Now Click on the Peripherals from menu bar, and check your required port as
shown in fig below
28. Drag the port a side and click in the program file.

29. Now keep Pressing function key “F11” slowly and observe.

30. You are running your program successfully


The project “water level monitoring and

controlling system” has been successfully designed and tested. Integrating features of all
the hardware components used have developed it. Presence of every module has been
reasoned out and placed carefully thus contributing to the best working of the unit.
Secondly, using highly advanced IC’s and with the help of growing technology the
project has been successfully implemented.



Mohd. Mazidi.


David .E. Simon.