Professional Documents
Culture Documents
CHAPTER- 1
Introduction:
Improving irrigation efficiency of crop can contribute greatly to reducing production
costs, making the industry more competitive and sustainable. Through proper irrigation,
average wheat yields can be maintained (or increased) while minimizing environmental
impacts caused by excess applied water and subsequent agrichemical leaching. An
automatic irrigation control system is a potential solution to optimize water management
by sensing soil water conditions and site-specifically controlling irrigation sprinklers.
Recent technological advances have made soil water sensors available for efficient and
automatic operation of irrigation systems Automatic soil water sensor-based irrigation
seeks to maintain a desired soil water range in the root zone that is optimal for plant
growth. The target soil water status is usually set in terms of volumetric moisture
(expressed in percent of water volume in a volume of undisturbed soil).
Irrigation is the key to a successful garden. Long gone are the days of manual
Watering or relying on a friend to water when you are on vacation or away on Business.
The objective of this project is to describe a user-friendly simple and cheap design for
continuous monitoring of soil water level and automatically irrigate the plants according
1
VCET B. Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
to their needs of previously set water level. The system consists of humidity sensor,
sensor driver, and water controller.
The Project presented here waters your plants regularly when you are out for
vacation. The circuit comprises sensor parts built using op-amp ICLM324. Op-amp is
configured here as a comparator. Two stiff copper wires are inserted in the soil to sense
the whether the Soil is wet or dry. The comparator monitors the sensors and when sensors
sense the dry condition then the project will switch on the motor and it will switch off the
motor when the sensors are in wet. The comparator does the above job it receives the
signals from the sensors. A transistor is used to drive the relay during the soil wet
condition. 5V double Pole – double through relay is used to control the water pump. LED
indication is
Provided for visual identification of the relay / load status. A switching diode is
connected across the relay to neutralize the reverse EMF. This project works with 5V
regulated power supply. Power on LED is connected for visual identification of power
status. This project uses regulated 5V, 750mA power supply. 7805 three terminal voltage
Regulator is used for voltage regulation. Bridge type full wave rectifier is used to rectify
the ac output of secondary of 230/18V step down transformer.
2
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Hardware Tools:
AT89C52 Microcontroller unit
Sensors
OP AMP LM-324
3
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Voltage Regulators
4
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
CHAPTER-2
AT89C52
2.1 Features:
Description
Key Parameters
Parameter Value
Flash (Kbytes) :8
ISP : SPI
F.max (MHz) : 33
I/O Pins : 32
UART :1
16-bit Timers :3
Watchdog : Yes
2.2 BLOCK
6
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
7
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
PIN DIAGRAM:
PIN DESCRIPTION:
8
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
outputs the code bytes during program verification. External pull-ups 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.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count
input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown
in the following table. Port 1 also receives the low-order address bytes 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
9
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
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
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.
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
input (PROG) during Flash programming. In normal operation, ALE is emitted at a
constant rate of 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 (PSEN) is the read strobe to external program memory.
When the AT89S52 is executing code from external program memory, PSEN is activated
10
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
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.
XTAL1: Input to the inverting oscillator amplifier and input to the internal clock
operating circuit. XTAL2: Output from the inverting oscillator amplifier.
2.2 REGISTERS:
8052 is a collection of 8 and 16 bit registers and 8 bit memory locations. These registers
and memory locations can be made to operate using the software instructions. The
program instructions control the registers and digital data paths that are contained inside
the 8052, as well as memory locations that are located outside the 8052.
Register are used to store information temporarily, while the information could be a
byte of data to be processed, or an address pointing to the data to be fetched. The vast
majority of 8051 register are 8-bit registers.
Generally there are two types of registers. They are General purpose Registers
(GPR’s) and Special Function Registers (SFR’s)
11
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
PSW register, also referred to as the flag register, is an 8 bit register Only 6 bits are
used These four are CY (carry), AC (auxiliary carry), P (parity), and OV (overflow)
12
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
They are called conditional flags, meaning that they indicate some conditions that
resulted after an instruction was executed. The PSW3 and PSW4 are designed as RS0 and
RS1, and are used to change the bank. The two unused bits are user-definable
The Atmel 80C5 Microcontrollers implement two general purpose, 16-bit timers/
counters. They can be used either as timers to generate a time delay or as a counter to
count events happening outside the microcontroller. The microcontroller has two 16-bit
wide timers. They are identified as Timer 0 and Timer 1 and Timer 2, and can be
independently configured to operate in a variety of modes as a timer or as an event
counter. When operating as a timer, the timer/counter runs for a programmed length of
time, and then issues an interrupt request. When operating as a counter, the timer/counter
counts negative transitions on an external pin. After a preset number of counts, the
counter issues and interrupt request. Register pairs (TH0, TL0), (TH1, TL1), and (TH2,
TL2) are the 16-bit counting registers for Timer/Counters 0, 1, and 2, respectively.
13
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Timer 1 Timer 0
GATE When TRx (in TCON) is set and GATE=1, Timer/CounterX will run only while
INTx pin is high (hardware control). When GATE=0,
Timer/Counter will run only while TRx=1 (software
control).
C/T Timer or Counter selector. Cleared for Timer operation (input from internal
system clock). Set for Counter operation (input from TX input
pin).
M1 Mode selector bit.
M0 Mode selector bit.
M1 M0 Mode Operating Mode
0 0 0 13-bit Timer (8048 compatible) (TH1)
0 1 1 16-bit Timer/Counter
1 0 2 8-bit Auto-Reload Timer/Counter (TL1).
Reloaded from TH1 at overflow.
1 1 3 timer 1 halted. Retains count.
1 1 3 (Timer 1) Timer/Counter 1 stopped.
Bit Addressable.
14
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
IE0 External Interrupt 0 edge flag. Set by hardware when External Interrupt edge
is detected. Cleared by hardware when interrupt is processed.
IT0 Interrupt 0-type control bit. Set/cleared by software to specify falling edge/low
level triggered External Interrupt.
2.3 INTERRUPTS:
Interrupts: The AT89C52 has a total of six interrupt vectors: two external interrupts
(INT0 and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt.
These interrupts are all shown in Figure 13-1. Each of these interrupt sources can be
individually enabled or disabled by setting or clearing a bit in Special Function Register
IE. IE also contains a global disable bit, EA, which disables all interrupts at once. Note
that Table 13-1 shows that bit position IE.6 is unimplemented. User software should not
write a 1 to this bit position, since it may be used in future AT89 products. Timer 2
interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON.
Neither of these flags is cleared by hardware when the service routine is vectored to. In
15
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
fact, the service routine may have to determine whether it was TF2 or EXF2 that
generated the interrupt, and that bit will have to be cleared in software. The Timer 0 and
Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow.
The values are then polled by the circuitry in the next cycle. However, the Timer 2 flag,
TF2, is set at S2P2 and is polled in the same cycle in which the timer overflows.
For every interrupt, there must be an interrupt service routine (ISR). Or interrupt handler.
When an interrupt is invoked, the microcontroller runs the interrupt service routine. For
every interrupt, there is a fixed location in memory that holds the address of its ISR. The
group of memory locations set aside to hold the addresses of the ISRs is called interrupt
vector table.
1. Reset : When the reset pin is activated, the 8052 jumps to address location 0000
2. Two interrupts are set aside for the timers: one for the Timer 0 and one for
Timer1.
3. Two interrupts are set aside for hardware external interrupts : one for INT0 and
one for INT1
4. Serial communication has a single interrupt that belongs to both receive and
transmit.
16
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
(8052 only)
Low-priority interrupt wait until 8051 has finished servicing the high-priority interrupt.
17
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
-- IP.7 Reserved
-- IP.6 Reserved
Timer 0 and 1:
Timer 0 and Timer 1 in the AT89C52 operate the same way as Timer 0 and Timer 1 in
the AT89C51 and AT89C52.
Timer 0 Register
The 16-bit register of Timer 0 is accessed as low byte and high byte. The low byte
register is called TL0 (Timer 0 low byte) and high byte register is referred to as TH0
(Timer 0 high byte). These registers can be accessed like any other register, such as A, B,
R0, R1, R2, etc.
Timer 1 Register:
Timer 1 is also 16-bits, and its 16-bit register is split into two bytes, referred to as TL1
(Timer 1 low byte) and TH1 (Timer 1 high byte). These registers are accessible in the
same way as the registers of timer 0.
Timer 2 Registers:
18
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Control and status bits are contained in registers T2CON (shown in Table 5- 2) and
T2MOD (shown in Table 10-2) for Timer 2. The register pair (RCAP2H, RCAP2L) is the
Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.
Timer 2:
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event
counter. The type of operation is selected by bit C/T2 in the SFR T2CON (shown in
Table 5-2). Timer 2 has three operating modes: capture, auto-reload (up or down
counting), and baud rate generator. The modes are selected by bits in T2CON, as shown
in Table 10-1. Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer
function, the TL2 register is incremented every machine cycle. Since a machine cycle
consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency. In the
Counter function, the register is incremented in response to a 1-to-0 transition at its
corresponding external input pin, T2. In this function, the external input is sampled
during S5P2 of every machine cycle. When the samples show a high in one cycle and a
low in the next cycle, the count is incremented. The new count value appears in the
register during S3P1 of the cycle following the one in which the transition was detected.
Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0
transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that a
given level is sampled at least once before it changes, the level should be held for at least
one full machine cycle.
operation, but a 1-to-0 transition at external input T2EX also causes the current value in
TH2 and TL2 to be captured into RCAP2H and RCAP2L, respectively. In addition, the
transition at T2EX causes bit EXF2 in T2CON to be set. The EXF2 bit, like TF2, can
generate an interrupt. The capture mode is illustrated in Figure 10-1.
Auto-reload (Up or Down Counter):
Timer 2 can be programmed to count up or down when configured in its 16-bit auto-
reload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located in
the SFR T2MOD (see Table 10-2). Upon reset, the DCEN bit is set to 0 so that timer 2
will default to count up. When DCEN is set, Timer 2 can count up or down, depending on
the value of the T2EX pin.
20
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
21
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
22
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
MCS-51 devices have a separate address space for Program and Data Memory. Up to
64K bytes each of external Program and Data Memory can be addressed.
Program Memory:
If the EA pin is connected to GND, all program fetches are directed to external
memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses
0000H through 1FFFH are directed to internal memory and fetches to addresses 2000H
through FFFFH are to external memory.
Data Memory:
The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a
parallel address space to the Special Function Registers. This means that the upper 128
bytes have the same addresses as the SFR space but are physically separate from SFR
space. When an instruction accesses an internal location above address 7FH, the address
mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of
RAM or the SFR space. Instructions which use direct addressing access the SFR space.
For example, the following direct addressing instruction accesses the SFR at location
0A0H (which is P2). MOV 0A0H, #data Instructions that use indirect addressing access
the upper 128 bytes of RAM. For example, the following indirect addressing instruction,
where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose
address is 0A0H). MOV @R0, #data Note that stack operations are examples of indirect
addressing, so the upper 128 bytes of data RAM are available as stack space.
Watchdog Timer (One-time Enabled with Reset-out):
The WDT is intended as a recovery method in situations where the CPU may be
subjected to software upsets. The WDT consists of a 14-bit counter and the Watchdog
Timer Reset (WDTRST) SFR. The WDT is defaulted to disable from exiting reset. To
enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register
23
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
(SFR location 0A6H). When the WDT is enabled, it will increment every machine cycle
while the oscillator is running. The WDT timeout period is dependent on the external
clock frequency. There is no way to disable the WDT except through reset (either
hardware reset or WDT overflow reset). When WDT over-flows, it will drive an output
RESET HIGH pulse at the RST pin.
2.5 UART:
The UART in the AT89C52 operates the same way as the UART in the AT89C51
The Timer can be configured for either timer or counter operation. In most applications, it
is con-figured for timer operation (CP/T2 = 0). The timer operation is different for Timer
2 when it is used as a baud rate generator. Normally, as a timer, it increments every
machine cycle (at 1/12 the oscillator frequency). As a baud rate generator, however, it
increments every state time (at 1/2 the oscillator frequency). The baud rate formula is
given below.
24
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit
unsigned integer. Timer 2 as a baud rate generator is shown in Figure 11-1. This figure is
valid only if RCLK or TCLK = 1 in T2CON. Note that a rollover in TH2 does not set
TF2 and will not generate an interrupt. Note too, that if EXEN2 is set, a 1-to-0 transition
in T2EX will set EXF2 but will not cause a reload from (RCAP2H, RCAP2L) to (TH2,
TL2). Thus, when Timer 2 is in use as a baud rate generator, T2EX can be used as an
extra external interrupt. Note that when Timer 2 is running (TR2 = 1) as a timer in the
baud rate generator mode, TH2 or TL2 should not be read from or written to. Under these
conditions, the Timer is incremented every state time, and the results of a read or write
may not be accurate. The RCAP2 registers may be read but should not be written to,
because a write might overlap a reload and cause write and/or reload errors. The timer
should be turned off (clear TR2) before accessing the Timer 2 or RCAP2 registers.
25
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
26
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
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. The latched value of EA must agree
with the current logic level at that pin in order for the device to function properly.
2.9 Programming the Flash – Parallel Mode
The AT89C52 is shipped with the on-chip Flash memory array ready to be
programmed. The programming interface needs a high-voltage (12-volt) program enable
signal and is compatible with conventional third-party Flash or EPROM programmers.
The AT89C52 code memory array is programmed byte-by-byte.
27
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Programming Algorithm:
Before programming the AT89S52, the address, data, and control signals should be set
up according to the “Flash Programming Modes” (Table 22-1) and Figure 22-1 and
Figure 22-2. To program the AT89S52, take the following steps: 1. Input the desired
memory location on the address lines. 2. Input the appropriate data byte on the data lines.
3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12V. 5. 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 50 μs. 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 AT89S52 features Data Polling to indicate the end of a byte
write cycle. During a write cycle, an attempted read of the last byte written will result in
the complement of the written data on P0.7. Once the write cycle has been completed,
true data is valid on all outputs, and the 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.0 is pulled low after ALE goes high during programming to
indicate BUSY. P3.0 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 status of the individual lock bits can be verified directly by reading them back.
Reading the Signature Bytes: The signature bytes are read by the same procedure as
a nor-mal verification of locations 000H, 100H, and 200H, except that P3.6 and P3.7
must be pulled to a logic low. The values returned are as follows. (000H) = 1EH indicates
manufactured by Atmel (100H) = 52H indicates AT89S52 (200H) = 06H
Chip Erase: In the parallel programming mode, a chip erase operation is initiated by
using the proper combination of control signals and by pulsing ALE/PROG low for
duration of 200 ns - 500 ns. In the serial programming mode, a chip erase operation is
initiated by issuing the Chip Erase instruction. In this mode, chip erase is self-timed and
28
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
takes about 500 ms. During chip erase, a serial read from any address location will return
00H at the data output.
29
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
CHAPTER-3
HARDWARE
Sensors
OP AMP LM-324
Comparator Test Circuit
Relay
Microcontroller-AT2051/8051
LCD
HT12E & HT12D Encoder and Decoder IC for RF Modules
3.2 Sensors:
A sensor is a device that measures a physical quantity and converts it into a signal
which can be read by an observer or by an instrument. For example, a mercury-in-glass
thermometer converts the measured temperature into expansion and contraction of a
liquid which can be read on a calibrated glass tube. A thermocouple converts temperature
to an output voltage which can be read by a voltmeter. For accuracy, all sensors need to
be calibrated against known standards.
Sensors are used in everyday objects such as touch-sensitive elevator buttons (tactile
sensor) and lamps which dim or brighten by touching the base. There are also
innumerable applications for sensors of which most people are never aware. Applications
include cars, machines, aerospace, medicine, manufacturing and robotics.
A sensor is a device which receives and responds to a signal or stimulus. Here, the
term "stimulus" means a property or a quantity that needs to be converted into electrical
30
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
form. Hence, sensor can be defined as a device which receives a signal and converts it
into electrical form which can be further used for electronic devices. A sensor differs
from a transducer in the way that a transducer converts one form of energy into other
form whereas a sensor converts the received signal into electrical form only.
A sensor's sensitivity indicates how much the sensor's output changes when the measured
quantity changes. For instance, if the mercury in a thermometer moves 1 cm when the
temperature changes by 1 °C, the sensitivity is 1 cm/°C. Sensors that measure very small
changes must have very high sensitivities. Sensors also have an impact on what they
measure; for instance, a room temperature thermometer inserted into a hot cup of liquid
cools the liquid while the liquid heats the thermometer. Sensors need to be designed to
have a small effect on what is measured; making the sensor smaller often improves this
and may introduce other advantages.
Ideal sensors are designed to be linear. The output signal of such a sensor is linearly
proportional to the value of the measured property. The sensitivity is then defined as the
ratio between output signal and measured property. For example, if a sensor measures
temperature and has a voltage output, the sensitivity is a constant with the unit [V/K]; this
sensor is linear because the ratio is constant at all points of measurement. Here in Our
Project the Sensors Used are Copper Wires.
31
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
32
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Features:
The LM324 series consists of four independent, high gains; internally frequency
compensated operational amplifiers which were designed specifically to operate from a
single power supply over a wide range of voltages. Operation from split power supplies is
also possible and the low power supply current drain is independent of the magnitude of
the power supply voltage. Application areas include transducer amplifiers, DC gain
blocks and all the conventional op amp circuits which now can be more easily
implemented in single power supply systems. For example, the LM324 series can be
directly operated off of the standard +5V power supply voltage which is used in digital
systems and will easily provide the required interface electronics without requiring the
additional ±15V power supplies.
33
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Unique Characteristics:
• In the linear mode the input common-mode voltage range includes ground and the
output voltage can also swing to ground, even though operated from only a single
power supply voltage
• The unity gain cross frequency is temperature compensated
• The input bias current is also temperature compensated
Advantages:
• Eliminates need for dual supplies
• Four internally compensated op amps in a single package
• Allows directly sensing near GND and VOUT also goes to GND
• Compatible with all forms of logic
• Power drain suitable for battery operation
34
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Comparator is an analog circuit with two inputs and one output. It watches and
compares two voltages at the inputs and decides if the output should change or not based
on the inputs. For example, if the voltage on one of the inputs goes above a fixed trigger
voltage on the other input, the output could go from LOW to HIGH. This is only one
configuration. There are lots of other possibilities, and the test circuit will help you
understand them. Comparators are good at "conditioning" analog signals and turning
them into digital signals. The output can be hooked up directly to any logic input on
another chip, a BASIC Stamp, SSR etc. You can hook it up to a transistor (i.e.
TIP120/122 or TIP125/127) to drive relays, motors, solenoids etc.We are going to use the
LM324 quad operational amplifier (op−amp). There are four general purpose op−amps in
the LM324. Each of them can be used as a comparator. We’ll start with just one, so
connect all unused inputs to ground.
Build this circuit on your breadboard to learn how comparators work. The pots can
be any value, but 10K or more is best. The pots supply adjustable voltages to the
35
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
inputs. Measure and set them with a DMM as described. One pot sets a trip point
(reference voltage) called Vref. Another pot simulates a fluctuating voltage signal,
called Vin. In your projects Vin could be from a photocell, flex sensor,
microphone etc .A comparator is an analog circuit with two inputs and one output.
It watches and compares two voltages at the inputs and decides if the output should
change or not based on the inputs. For example, if the voltage on one of the
inputs goes above a fixed trigger voltage on the other input, the output could go
from LOW to HIGH. This is only one configuration. There are lots of other
possibilities, and the test circuit will help you understand them. Comparators are
good at "conditioning" analog signals and turning them into digital signals. The
output can be hooked up directly to any logic input on another chip, a BASIC
Stamp, SSR etc. You can hook it up to a transistor (i.e. TIP120/122 or
TIP125/127) to drive relays, motors, solenoids etc. We are going to use the LM324
quad operational amplifier (op−amp). There are four general purpose op−amps in
the LM324. Each of them can be used as a comparator. We’ll start with just one, so
connect all unused inputs to ground.
36
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Non-inverting Comparator:
1. In this example POT1 is used to set the reference voltage (Vref) and POT2 supplies the
Input voltage (Vin).
2. Use the DMM to measure Vref at TEST POINT A. Turn POT1 to set it. You can set it
to whatever you need, but for now let’s set it to 3 volts.
3. Now measure Vin at TEST POINT B. Turning POT2 changes the voltage up and
down.
4. Whenever Vin is HIGHER than 3 volts (Vref) the output is HIGH (LED turns on).
Whenever Vin is LOWER than 3 volts (Vref) the output is LOW (LED turns off).
Inverting Comparator:
When a coil of wire is wound on a non magnetic material such as plastic, paper etc.,
it is called a air-core solenoid or simply a solenoid .if a soft iron core is inserted into the
coil, it becomes an electromagnet. This electromagnet is the basic component for relay
and many other electromechanical devices such as electric bell, circuit breaker etc,.
Operation:
When a current flows through the coil, the resulting magnetic field attracts an
armature that is mechanically linked to a moving contact. The movement either makes or
breaks a connection with a fixed contact. When the current to the coil is switched off, the
37
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
armature is returned by a force approximately half as strong as the magnetic force to its
relaxed position. Usually this is a spring, but gravity is also used commonly in industrial
motor starters. Most relays are manufactured to operate quickly. In a low voltage
application, this is to reduce noise. In a high voltage or high current application, this is to
reduce arcing.
If the coil is energized with DC, a diode is frequently installed across the coil, to
dissipate the energy from the collapsing magnetic field at deactivation, which would
otherwise generate a spike of voltage and might cause damage to circuit components.
Some automotive relays already include that diode inside the relay case. If the coil is
designed to be energized with AC, a small copper ring can be crimped to the end of the
solenoid. This "shading ring" creates a small out-of-phase current, which increases the
minimum pull on the armature during the AC cycle.[1]
38
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Normally-open (NO) contacts connect the circuit when the relay is activated; the
circuit is disconnected when the relay is inactive. It is also called a Form A contact or
"make" contact.
Normally-closed (NC) contacts disconnect the circuit when the relay is activated; the
circuit is connected when the relay is inactive. It is also called a Form B contact or
"break" contact.
Change-over, or double-throw, contacts control two circuits: one normally-open contact
and one normally-closed contact with a common terminal. It is also called a Form C
contact or "transfer" contact.
39
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
These have two terminals which can be connected or disconnected. Including two for
the coil, such a relay has four terminals in total. It is ambiguous whether the pole is
normally open or normally closed. The terminology "SPNO" and "SPNC" is sometimes
used to resolve the ambiguity.
40
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
3.6 LCD:
An 8051 program must interact with the outside world using input and output devices
that communicate directly with a human being. One of the most common devices
attached to an 8051 is an LCD display. Some of the most common LCDs connected to
the 8051 are 16x2 and 20x2 displays. This means 16 characters per line by 2 lines and 20
characters per line by 2 lines, respectively.
The standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus.
The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data
bus. If a 4-bit data bus is used the LCD will require a total of 7 data lines (3 control lines
41
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a total
of 11 data lines (3 control lines plus the 8 lines for the data bus).
We will now look into the common steps to send data/command to LCD when working
in 4-bit mode. In 4-bit mode data is sent nibble by nibble, first we send higher nibble
and then lower nibble. This means in both command and data sending function we need
to separate the higher 4-bits and lower 4-bits.
The common steps are:
• Mask lower 4-bits
• Send to the LCD port
• Send enable signal
• Mask higher 4-bits
• Send to LCD port
• Send enable signal
The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable." This control line is used to tell the LCD that you are
sending it data. To send data to the LCD, your program should make sure this line is low
(0) and then set the other two control lines and/or put data on the data bus. When the
other lines are completely ready, bring EN high (1) and wait for the minimum amount of
time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing
it low (0) again.
The RS line is the "Register Select" line. When RS is low (0), the data is to be treated
as a command or special instruction (such as clear screen, position cursor, etc.). When RS
is high (1), the data being sent is text data which should be displayed on the screen. For
example, to display the letter "T" on the screen you would set RS high.
42
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
The RW line is the "Read/Write" control line. When RW is low (0), the information
on the data bus is being written to the LCD. When RW is high (1), the program is
effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a
read command. All others are write commands--so RW will almost always be low.
Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected
by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2,
DB3, DB4, DB5, DB6, and DB7.
Before you may really use the LCD, you must initialize and configure it. This is
accomplished by sending a number of initialization instructions to the LCD. The first
instruction we send must tell the LCD whether we'll be communicating with it with an 8-
bit or 4-bit data bus. We also select a 5x8 dot character font. These two options are
selected by sending the command 38h to the LCD as a command. As you will recall from
the last section, we mentioned that the RS line must be low if we are sending a command
to the LCD.There are also instruction command codes that can be sent to the LCD to
clear the display or force the cursor to the home position or blink the cursor. Table lists
the instruction command code.
43
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
The HT 12E Encoder ICs are series of CMOS LSIs for Remote Control system
applications. They are capable of Encoding 12 bit of information which consists of N
address bits and 12-N data bits. Each address/data input is externally trinary
programmable if bonded out.
The HT 12D ICs are series of CMOS LSIs for remote control system applications. This
ICs are paired with each other. For proper operation a pair of encoder/decoder with the
same number of address and data format should be selected. The Decoder receive the
serial address and data from its corresponding decoder, transmitted by a carrier using an
RF transmission medium and gives output to the output pins after processing the data.
44
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Features:
Encoder:
• 18 PIN DIP
• Operating Voltage : 2.4V ~ 12V
• Low Power and High Noise Immunity CMOS Technology
• Low Standby Current and Minimum Transmission Word
• Built-in Oscillator needs only 5% Resistor
• Easy Interface with and RF or an Infrared transmission medium
• Minimal External Components
Decoder:
45
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Applications:
• Burglar Alarm, Smoke Alarm, Fire Alarm, Car Alarm, Security System
• Garage Door and Car Door Controllers
• Cordless telephone
• Other Remote Control System
Compatibility:
• Compatible with RF Modules 433 MHz Link :RF Modules (Tx + Rx Pair) 433
MHz ASK
Voltage Regulators
46
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
3.11Transformer:
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.
A step down power transformer is used to step down the AC voltage from the Line
voltage of 110 VAC or 220 VAC i.e., it converts higher voltage at the input side to a
lower voltage at the output.
47
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
3.12 Rectifier:
There are several ways of connecting diodes to make a rectifier to convert AC to DC.
The bridge rectifier is the most important and it produces full-wave varying DC.
Alternate pairs of diodes conduct, changing over (using the entire AC wave)
3.13 Filter:
48
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
3.14 Regulator:
This is a simple DC regulated supply project using 7805 voltage regulator to obtain a
variable DC voltage range from 5V to 15V.
Fig 3.14.Regulator
1. Unregulated voltage in
49
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
2. Ground
If you need other voltages than +5V, you can modify the circuit by replacing the 7805
chips with another regulator with different output voltage from regulator 78xx chip
family. The last numbers in the chip code tells the output voltage. Remember that the
input voltage must be at least 3V greater than regulator output voltage ot otherwise the
regulator does not work well.
50
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
CHAPTER- 4
51
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Automatic plant irrigation system is a closed loop system which monitors the moisture
condition. When the moisture is dry then that will be sensed using two long copper wires
which are inserted into the soil. Depending on this the op amp-LM324 will generate a
high signal and the information will be passed to the micro controller. Microcontroller
depending on the program it will send signals to relay circuit to switch on the motor. The
motor will be switched on. Now the sensor will continuously sense the moisture
condition when it becomes wet then depending on it the op amp-LM324 will generate a
low signal which is given to microcontroller which will send signal to relay circuit to
switch off the circuit. Here op amp-LM324 is operated as a comparator. The comparator
will compare the preset resistance value with the detected or sensed resistance value. If
the detected value is less than the preset values then it will generate high signal (i.e.
output will be +5v). If the detected value is less than the preset value then it will generate
low signal (i.e. output will be 0v). Like this first from sensor to comparator, from
comparator to microcontroller, from microcontroller to finally motor.
By using this system we can protect the fields without getting over watered. It is even
very cheap. By using this system one can reduce the amount of water, power, and man
power.
Below is the tabular form of different types of soil resistance values in wet and dry
conditions
S:NO DRY SOIL WET SOIL
2 128K 217K
3 148K 70.4K
4 144.7K 65.4K
5 170.6K 130.7K
6 156K 124K
52
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
7 84.3K 51.6K
8 80.7K 49.2K
With the reference to this the preset value of resistance is taken as 68k ohms for wet
condition of soil( i.e. 0-68k ohms resistance level will be treated as moisture is in wet
state and above 68k ohms is treated as moisture is in dry state). So if the sensed level is
more than 68k ohms then the motor will be switched ON or else it is in OFF state.
• Uniform germination
• Fine droplets and shorter irrigation intervals creates micro climatic conditions,
• Frost protection
• Being a versatile system , can be used for 2-3 crops each year
53
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
The circuit diagram of the automatic plant irrigation system is as shown below:
54
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
55
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
CONCLUSION
56
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Highly sensitive
Works according to the soil condition
Fit and Forget system
Low cost and reliable circuit
Complete elimination of manpower
Can handle heavy loads up to 7A
System can be switched into manual mode whenever required
Applications:
Roof Gardens
Lawns
Agriculture Lands
Home Gardens
Added Feature:
The added feature in this project is that we can even know the status of plants whenever
the family goes out .This can be done with the help of RF communication. The status of
the system is encoded and transmitted via RF link. A remote RF receiver will get the
status and this will be decoded to drive LEDs
57
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
BIBLIOGRAPHY
www.8051projects.net/downloads118.htm
www.docstoc.com/docs/.../Automatic-Plant-Irrigation-System
www.freepatentsonline.com/6845588.html
www.littlegreenhouse.com/accessory/mist2.shtm
www.ehow.com › Plant Care
www.crazyengineers.com/.../34317-intelligent-smoke-fire-detector-
automatic-water-sprinkler-system.html -
ww.indiamart.com › Plant & Machinery › Agricultural Machinery
ww.gizmag.com/aquarius-intelligent-automated-sprinkler.../9986
www.projectideas.co.in/resources/Embedded-project-list.pdf
www.alibaba.com › Showroom
58
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
SOFTWARE CODING
#include<stdio.h>
Sbit mag1=p1_0;
Sbit mag2=p1_1;
Sbit led1=p1_2;
Sbit rs=p1_7;
Sbit rw=p1_6;
Sbit e=p1_5;
sbit ldata=p3 ;
void lcdcmd(unsigned char);
void lcddata(unsigned char);
void delay(unsigned int);
void main( )
{
Unsigned char a[ ]={0X38,0X01,0X06,0X0e};
For(i=0;i<=4;i++)
{
Lcdcmd(a[i]);
}
For(j=0;b[j]!=’\0’;j++)
{
Lcddata(b[j]);
}
For(j=0;c[j]!=’\0’;j++)
{
Lcddata(c[j]);
}
While(1)
{
59
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
If(mag1==0)
{
Lcdcmd(0*80);
For(k=0;msg1[k]!=’\0’;k++)
{
Lcddata(msg1[k]);
}
Led1=1;
}
Else id(mag2===0)
{
Lcdcmd(0*80);
For(l=0;msg!=’\0’;l++)
{
Lcddata(msg2[1]);
}
led1=0;
}
}
}
60
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
Unsigned int i, j;
For(i=0;i<=t;i++)
For(j=0;j<=25;j++)
}
61
VCET B.Tech(E.C.E)
07BT1A0452 AUTOMATIC WATER SPRINKLER
62
VCET B.Tech(E.C.E)