Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
Many times we forget to switch off the motor pushing water into the overhead tank (OHT) in our
households. As a result, water keeps overflowing until we notice the overflow and switch the
pump off. As the OHT is usually kept on the topmost floor, it is cumbersome to go up frequently
to check the water level in the OHT.
This Project explains how to detect and control the water level in an OHT or any other
container. This system monitors the water level of the tank and automatically switches ON the
motor when ever tank is empty. The motor is switched OFF when the overhead tank or container
is FULL. Here the water level of the tank is indicated on LCD (Liquid crystal Display). Using
this system, we can avoid the overflow of the water. Here we are designing the circuit which is
used to detect and control the water level automatically in overhead tank using 8051 micro
controller. In this system water sensing can be done by using a set of 4 wires which are placed at
different levels in tank. DC supply probe is placed at the base of the tank.
Chapter II
Water Level Controller
Automatic water level controller came to existence because of human error and
inconsistence that is associated with manually operated water pumping machine. This is because
it takes time for individual who is manually operating the water pump to turn off the pumping
machine and this may cause water spillage and at times the individual might not know that the
water level has drop so low until the tank is completely empty. This was the problem that leads to
the development of the idea of an automatic water level controller.
List of Components
AT89C51 controller
16*2 LCD
5V Relay
Resistors (1K) 4
AC Motor
Pot 10k
Programming cable
Connecting wires
Block Diagram
2
Micro Controller (AT89S52) is interfaced with 16x2 LCD. LCD indicates the water level through
its display. Level sensors are connected to the controller to indicate the water level by resistance
variation. Relay is connected to motor and is interfaced with the micro controller. When LCD
displays tank is full, motor stops automatically.
Circuit Diagram
Circuit Description
The main heart of this project is AT89C51 microcontroller. The water level probes (level sensors)
are connected to the P3.0, P3.1, P3.2, and P3.3 through the transistors. Port P2 connected to the
data pins of LCD and control pins RS, RW and EN of LCD are connected to the P1.0, P1.1, and
P1.2 respectively.
Initially when tank is empty, LCD will display the message EMPTY and motor runs
automatically. When water level reaches to quarter level, now LCD displays QUARTER and still
motor runs. For further levels, LCD displays the messages HALF and FULL.
When tank is full, LCD displays FULL and motor automatically stops. Again motor runs when
tank is empty.
4
First configure the controller pins P3.0, P3.1, P3.2 and P3.3 as inputs and P3.4 as output.
Continuously check the water level input pins P3.0, P3.1, P3.2, and P3.3
If all the pins are low then display tank is empty on LCD and make P3.4 pin high to run
the motor automatically.
High pulse on the pin P3.0 indicates quarter level, display the same thing on LCD.
If P3.3 is high then tank is full, now make P3.4 pin is low to turn off the motor
automatically.
2.
3.
While giving the connections, make sure that there is no common connection between
AC and DC supplies.
4.
Place the 4 water level indicating wires into the small tank.
5.
Switch on the supply, now the motor will run automatically as there is no water in the
tank.
6.
Now pour the water, when it reaches to quarter level then LCD displays QUARTER on
LCD.
7.
8.
Still if you pour the water then LCD displays FULL and motor turns off automatically
when the tank is full.
9.
Human effort is reduced as the system controls the motor automatically based on the
water level.
Chapter III
Components Description
Micro Controller (AT89S52)
Features:
1. Description
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes
of in-system programmable Flash Memory. The device is manufactured using Atmels highdensity nonvolatile memory technology and is compatible with the industry-standard 80C51
9
instruction set and pin out. The on-chip Flash allows the program memory to be
reprogrammed in-system or by a conventional nonvolatile memory programmer. By
combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip,
the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and costeffective solution to many embedded control applications.
10
11
Pin Description
VCC
Supply Voltage
GND
Ground
Port 0
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can
sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as
high-impedance inputs.
12
Alternate Functions
P1.0
P1.1
P1.5
P1.6
P1.7
Port 2
13
Port 2 is an 8-bit 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 memory that use 16-bit addresses
(MOVX@DPTR). In this application, Port 2 uses strong internal pull-ups when
emitting 1s. During accesses to external data memory 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 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 (I IL) because of the
pull-ups.
Port 3 receives some control signals for Flash programming and verification.
Port 3 also serves the functions of various special features of the AT89S52, as
shown in the following table.
Port Pin
Alternate Functions
P3.0
P3.1
P3.2
14
(external interrupt 0)
P3.3
P3.4
P3.5
P3.6
P3.7
(external interrupt 0)
WR
(external data memory write strobe)
RD
(external data memory read strobe)
RST
Reset input. A high on this pin for two machines cycles while the oscillator is
running resets the device. This pin drives high for 98 oscillator periods after the
watchdog times out. The DISTO bit in SFR AUXR (address 8EH) can be used to
disable this feature. In the default state of bit DISTRO, the RESET HIGH out
feature is enabled.
ALE/ PROG
Address Latch Enable (ALE) is an output pulse for latching the low byte of the
address during accesses to external memory. This pin is also the program pulse
EA
/VPP
15
EA
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
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2
Output from the inverting oscillator amplifier.
Data Memory
The AT89S52 implements 256bytes of on-chip RAM. The upper 128bytes occupy
Parallel address space to the Special Function Registers. This means that the
upper 128bytes have the same addresses as the SFR space but are physically
separate from SFR space.
except through reset (either hardware reset or WDT overflow reset). When WDT
overflows, it will drive an output RESET HIGH pulse at the RST pin.
LCD (Liquid Crystal display) screen is an electronic display module. A 16x2 LCD
display is very basic module and is very commonly used in various devices and circuits.
These modules are preferred over seven segments and other multi segment LEDs. The
reasons are being:
Economical
Easily Programmable
17
Have no limitation of displaying special & even custom characters (unlike in seven
segments)
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this
LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely,
Command and Data.
The Command register stores the command instructions given to the LCD. A command is an
instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the
cursor position, controlling display etc. The data register strores the data to be displayed on the
LCD. The data is the ASCII value of the character to be displayed on the LCD.
Pin Diagram
18
Pin Description
Return Home
10
14
18
1C
80
C0
38
Capacitors
Capacitor is a basic storage device to store electrical charges and release it as it is
required by the circuit. Capacitors are widely used in electronic circuits to perform variety of
tasks, such as smoothing, filtering, bypassing etc. One type of capacitor may not be suitable
for all applications. Ceramic capacitors are generally superior than other types and therefore can
be used in a vast ranges of application. The following superior than other types and therefore can
be used in a vast ranges of application. The following is the typical capacitor application in
electronics industries.
DC blocking capacitor:
In this application the capacitor blocks the passage of DC current (after completely
charged) and yet allows the AC to pass at certain portion of a circuit.
Capacitor as a filter:
Capacitors are the main elements of filters. There are several types of filters that are used
in electronic circuits, such as LPF (Low Pass Filter), HPF (high Pass Filter), BPF (Band Pass
Filter), etc. Since the reactance of the capacitor is inversely related to the frequency, therefore
it can be used to increase or decrease the impedance of the circuit at certain frequencies and
therefore does the filtration job.
Capacitor as a discharge unit:
20
Capacitors used as a charging unit and the release of the charge (discharge energy) is used
for triggering, ignition, and in high scale as a power source.
By Pass capacitor:
The reactance of capacitor decreases as the frequency increases. Therefore in certain
application it is used in parallel with other components to bypass it at a specified frequency.
Coupling capacitor:
The ability of capacitor to pass AC signal, allows it to couple a section of an electronic
circuit to another circuit.
Decoupling capacitor:
In high speed electronic logic switching causes draw of significant amount of current
which in turn would cause disturbance in the logic voltage level. Decoupling capacitor is
typically located very close to the IC output and serves as a local energy source to provide the
needed extra current and therefore minimizes the noise and disturbances to the logic signal.
21
Snubber capacitor:
In some application, relays or SCR (Silicon controlled rectifier) are to drive a high
inductance loads. In these circumstances, when the relay or the SCR opens, a major transient
voltage could be induced in the contact of the relay or across the junction of SCR, which in turn
either shows as an arc on the relay contacts or may damage the internal SCR junction. Therefore
snubber capacitor is used to limit the high voltage transient across the circuit. There are also
other applications such as Tuned circuits, signal processing, etc...
Formula for Capacitance
The capacitance (C) is a measure of the amount of charge (Q) stored on each plate for a
given potential difference or voltage (V) which appears between the plates
C = Q/V
Resistors
22
A resistor is a passive two terminal electrical component that opposes current flow by
lowering the voltage levels within the circuits. In electronic circuits, resistors are used to limit
current flow, to adjust signal level, bias active elements and terminate transmission lines among
other uses. High-power resistors, that can dissipate many watts of electrical power as heat, may
be used as part of motor controls, in power distribution systems, or as test loads for generators.
The electrical resistance is equal to the voltage across the resistor divided by the current
through resistor.
R = V/I
Fixed resistors have resistances that only change slightly with temperature, time or
operating voltage. Variable resistors can be used to adjust circuit elements (such as a volume
control or a lamp dimmer), or as sensing devices for heat, light, humidity, force, or chemical
activity.
Identifying Resistors
Most axial resistors use a pattern of colored stripes to indicate resistance. Surface-mount
ones are marked numerically. Resistance can also be calculated using multimeter.
Electronic Color code
Four-band identification is the most commonly used color coding scheme on all resistors. It
consists of four colored bands that are painted around the body of the resistor. The first two
numbers are the first two significant digits of the resistance value, the third is a multiplier, and
the fourth is the tolerance of the value. Each color corresponds to certain number as shown
below.
23
Transistors
A transistor is a semiconductor device, commonly used as an amplifier or an electrically
controlled switch. The transistor is the fundamental building block of the circuitry in computers,
cellular phones, and all other modern electronic devices.
Because of its fast response and accuracy, the transistor is used in a wide variety of digital and
analog functions, including amplification, switching, voltage regulation, signal modulation, and
oscillators. Transistors may be packaged individually or as part of an integrated circuit.
24
Diode
A diode is a two-terminal electronic component that conducts primarily in one direction
(asymmetric conductance) it has low (ideally zero) resistance to the flow of current in one
direction, and high (ideally infinite) resistance in the other. A semiconductor diode is a crystalline
piece of semiconductor with a p-n junction connected to two electrical terminals. A vacuum tube
has two electrodes, a plate (anode) and a heated (cathode).
The most common function of a diode is to allow an electric current to pass in one
direction (called the diodes forward direction), while blocking current in the opposite direction
(the reverse direction). Thus, the diode can be viewed as an electronic version of a check valve.
This unidirectional behavior is called rectification, and is used to convert alternating current to
25
direct current, including extraction of modulation from radio signals in radio receivers these
diodes are forms of rectifiers.
Diodes can have more complicated behavior than this simple on-off action, due to their nonlinear
current-voltage characteristics. Semiconductor diodes begin conducting electricity only if a
certain threshold voltage or cut-in voltage is present in the forward direction (a state in which the
diode is said to be forward-biased). The voltage drop across a forward-biased diode varies only a
little with the current, and is a function of temperature, this effect can be used as a temperature
sensor or as a voltage reference.
Relay
26
Relay is an electromagnetic device which is used to isolate two circuits electrically and
connect them magnetically. They are very useful devices and allow one circuit to switch another
one while they are completely separate. They are often used to interface an electronic circuit
(working at a low voltage) to an electrical circuit which works at very high voltage. For example,
a relay can make a 5V DC battery circuit to switch a 230V AC mains circuit. Thus a small sensor
circuit can drive, say, a fan or an electric bulb.
A relay switch can be divided into two parts: input and output. The input section has a
coil which generates magnetic field when a small voltage from an electronic circuit is applied to
it. This voltage is called the operating voltage. Commonly used relays are available in different
configuration of operating voltages like 6V, 9V, 12V, 24V etc. The output section consists of
contactors which connect or disconnect mechanically. In a basic relay there are three contactors:
normally open (NO), normally closed (NC) and common (COM). At no input state, the COM is
connected to NC. When the operating voltage is applied the relay coil gets energized and the
COM changes contact to NO. Different relay configurations are available like SPST, SPDT and
DPDT etc., which have different number of changeover contacts. By using proper combination
of contactors, the electrical circuit can be switched on and off. Get inner details about structure
of a relay switch.
27
POWER SUPPLY:
The power supplies are designed to convert high voltage AC mains electricity to
a suitable low voltage supply for electronic circuits and other devices. A RPS (Regulated
Power Supply) is the Power Supply with Rectification, Filtering and Regulation being done
on the AC mains to get a Regulated power supply for Microcontroller and for the other
devices being interfaced to it.
A power supply can be broken down into a series of blocks, each of which
performs a particular function. A D.C power supply which maintains the output voltage
constant irrespective of A.C mains fluctuations or load variations is known as Regulated
D.C Power Supply.
Transformer:
The transformer is a device that transfers electrical energy from one electrical circuit to
another electrical circuit through the medium of magnetic field and without a change in the
frequency. The electric circuit which receives energy from the supply mains is called primary
winding and the other circuit which delivers electric energy to the load is called the secondary
winding.
28
With it, the voltage and current can be multiplied and divided in AC circuits.
Transformer is of two types step up and step down. In this project a step down transformer is
used. A step down transformer: is one whose secondary voltage is less than its primary voltage.
It is designed to reduce the voltage from the primary winding to the secondary winding. This
kind of transformer steps down the voltage applied to it.
As a step-down unit, the transformer converts high-voltage, low-current power into low-voltage,
high-current power. The larger-gauge wire used in the secondary winding is necessary due to the
increase in current. The primary winding, which doesnt have to conduct as much current, may
be made of smaller-gauge wire.
Bridge Rectifier
A bridge rectifier is an arrangement of four or more diodes in a bridge circuit
configuration which provides the same output polarity for either input polarity. It is used for
converting an alternating current (AC) input into a direct current (DC) output.
29
Voltage Regulators:
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
30
('thermal protection'). Many of the fixed voltage regulators ICs have 3 leads and look like
power transistors, such as the 7805 +5V 1A regulator shown on the right. 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.
Chapter IV
31
Hardware Designing
Proteus7.7 Tool
Proteus7.7 best simulation software for various designs with microcontroller. It is mainly
popular because of availability of almost all microcontrollers in it. So it is a handy tool to test
programs and embedded designs for electronics. You can simulate your programming of
microcontroller in Proteus7.7 Simulation Software.
After simulating your circuit in Proteus 7.7 Software you can directly make PCB design with it
so it could be a all in one package.
Software Implementation
Keil IDE
32
The Keil 8051 Development Tools are designed to solve the complex problems facing
embedded software developers.
Keil IDE is basically an assembler and a compiler. Assembly or C language code can be
written and compiled in Keil. Furthermore, it supports many of the 8051 variants.
The Keil Vision Debugger accurately simulates on-chip peripherals (IC, CAN, UART,
SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of your 8051
device. Simulation helps you understand hardware configurations and avoids time wasted on
setup problems. Additionally, with simulation, you can write and test applications before target
hardware is available.
testing
If simulation results are perfect the .hex file is loaded into real-time micro controller chip.
Soldering iron
33
Wire Stripper:
Wire stripper is used to strip off wire insulator from its conductor before it is
used to connect to another wire or soldered into the printed circuit board. Some wire
stripper or wire cutter has a measurement engraved on it to indicate the length that will be
stripped.
Side-Cutting Plier:
A 4-inch side cutting plier will come in handy as one
of the electronic tools when one need to trim off excess
component leads on the printed circuit board. It can also be used
to cut wires into shorter length before being used. Tweezer
Small tweezer is used to hold small components especially when doing
soldering and de-soldering of surface mount components.
34
excess copper is removed from the PCB. After etching, the PCB is kept in clean water for about
half an hour in order to get PCB away from acidic field, which may cause poor performance of
the circuit. After the PCB has been thoroughly washed, paint is removed by soft piece of cloth
dipped I thinner or turbine. Then PCB is checked as per the layout, now the PCB is ready for use.
Soldering
Soldering is the process of joining two metallic conductor the joint where two metal
conductors are to be join or fused is heated with a device called soldering iron and then as allow
of tin and lead called solder is applied which melts and converse the joint. The solder cools and
solidifies quickly to ensure is good and durable connection between the joined metal converting
the joint solder also present oxidation.
Soldering And Desoldering Techniques.
There are basically two soldering techniques.
References
37