Sunteți pe pagina 1din 62

CONTENTS

I.ABSTRACT
Chapter No. Description Page No.
1 INTRODUCTION 1
1.1 Objective of the project 1
1.2 Block diagram 2
1.3 Embedded system 2
2 DESCRIPTION OF THE PROJECT 6
2.1 Circuit diagram 6
2.2 Working description 7
3 HARDWARE DESCRIPTION 8
3.1 Microcontroller 8
3.2 Power supply 23
3.3 RELAY 34
3.4 Electrodes 37
4 SOFTWARE DESCRIPTION 39
4.1 Introduction 39
4.2 Tools used 39
4.3 C51 Compiler & A51 Macro Assembler 40
4.4 vision 40
4.5 Creating Your Own Application in Vision 41
4.6 Flow chart 44
4.7 Assembly/KEIL C language 52

5 MERITS AND DEMERITS 54

6 CONCLUSION 55

7 BIBLIOGRAPHY AND REFERENCES 57

1
ABSTRACT

Now a days technology is running with time, it completely occupied the life style of
human beings. Even though there is such an importance for technology in our routine life
there are even people whose life styles are very far to this well-known term technology. So it
is our responsibility to design few reliable systems which can be even efficiently used by

2
them. Using the water in the farm for irrigation is one of the most water consumptions in the
planet. Irrigation water management requires timely application of the right amount of water.
In the world, water development for agriculture is a priority, but poorly designed and
planned irrigation water management procedures and practices undermines efforts to improve
livelihoods and exposes people and environment to risks. By far, one of the largest losses of
the plant materials in the farm is the direct result of the improper irrigation scheduling. There
are many types of irrigation control systems available in the market. These controllers are
based on the measurement of the soil water tension. Soil water tension, soil water suction, or
soil water potential are all terms describing the energy status of soil water.
Soil water tension is a measure of the amount of energy with which water is held in
the soil and represents the energy required to extract water from the soil. This is expressed in
negative pressure. There are many types of sensors in the market that can be used to measure
the soil tension. Some of these sensors are based on resistance principle and some based on
capacitance principle. Embedded system is a combination of software and hardware to
perform a dedicated task.

CHAPTER 1

INTORDUCTION

1.1 OBJECTIVE OF THE PROJECT

3
The Project presented here waters your plants regularly when you are out for
vocation. Soil probe is inserted in the soil to sense the whether the Soil is wet or
dry. The Microcontroller was used to control the whole system it monitors the
sensors and when more than two sensors sense the dry condition then the
microcontroller will switch on the motor and it will switch off the motor when all
the sensors are in wet. The microcontroller does the above job it receives the
signals from the sensors, and this signals operated under the control of software
which is stored in ROM.

HARDWARE:

1. MICRO CONTROLLER
2. POWER SUPPLY
3. ELECTRODES
4. RELAY
5. DC MOTOR

SOFTWARE:

1. EMBEDDED KEIL C LANGUAGE


2. ASSEMBLY LANGUAGE

1.2 BLOCKDIAGRAM:

4
Sensor Elec - Relay driver
trodes A
RELAY
T
8
9
RESET S
5
CRYSTAL 2
DC
Motor

1.3 EMBEDDED SYSTEMS

1.3.1 DEFINITIONS:

Embedded system is a combination of hardware and software; it is also


named as Firm ware.

An embedded system is a special purpose computer system, which is


completely encapsulated by the device it controls. It is a computer-controlled
system.

An embedded system is a specialized system that is a part of a larger


system or machine. As a part of a larger system it largely determines its
functionality. Embedded systems are electronic devices that incorporate
microprocessors with in their implementations. The main purpose of the
microprocessors are simplify the system design and improve flexibility. In the
embedded systems, the software is often stored in a read only memory (RAM)
chip.

5
Embedded systems provide several major functions including monitoring
of the analog environment by reading data from sensors and controlling
actuators.

Embedded

System

Inputs (sensor) Outputs (actuator)

Figure: A real time system interacts with environment

1.3.2 EXAMPLES OF EMBEDDED SYSTEMS:

Embedded systems are found in wide range of application areas. Originally


they were used only for expensive industrial control applications, but as
technology brought down the cost of dedicated processors, they began to appear
in moderately expensive applications such as automobiles, communication and
office equipment and television Today's embedded systems are so inexpensive
that they are used in almost every electronic product in our life. Embedded
systems are often designed for mass production.

Some examples of embedded systems:

Automatic Teller Machines


Cellular telephone and telephone switches
Computer network equipment
Computer printers
Disk drives
Engine controllers and antilock break controllers for automobiles

6
Home automation products
Handheld calculators
Household appliances
Medical equipment
Measurement equipment
Multifunction wrist watches
Multifunction printers
Mobile phones with additional capabilities
Programmable Logic Controllers.

1.3.3 MICROPROCESSOR AND MICROCONTROLLER:

Microprocessors and microcontrollers are used in embedded system


products. An embedded product uses a microprocessor (or microcontroller) to do
one task and one task only.

Microprocessor as the term come to be known is a general purpose digital


computer central processing unit. Although popularly known as a "computer on
chip", the microprocessor is in no sense a complete digital computer.
Microprocessor CPU contains Arithmetic Logical Unit, a program counter, a stack
pointer, some working registers, a clock timing circuits and interrupt circuit.

To make complete microcomputer memory must add, usually Read Only


Memory, Random Access Memory, memory decoders and an Input/output
devices. In addition special purpose devices such as interrupts, counters may be
added to relieve the CPU from time consuming counting or timing chores.

The hardware design of microprocessor CPU is arranged so that a small or


very large system can be configured around the CPU as the application demands.
The internal CPU architecture as well as the resultant machine level code that
operates that architecture is comprehensive but as flexible as possible.

The prime use of microprocessor is to read data perform extensive


calculations on that data and store those calculations in mass storage devices or

7
display the results for user use. The program is used by microprocessor are
stored in the mass storage devices and loaded into RAM as the user directs.

A microcontrollers is a computer on a single chip .Micro suggest that the


device is small and controller tells that the device is used to control objects,
process or events

Microcontroller is a highly integrated chip that contains all the devices


comprising a computer. Typically this includes a CPU, RAM, Input/ Output ports,
timers, interrupts. So microcontroller is also called as "true computer on a chip".
Unlike a general purpose computer which also includes all of these devices. A
microcontroller is designed for a very specific task to control a particular system.

A microcontroller is a general purpose device but one that is meant to


read data, performs limited calculations on that data and control its environment
based on those calculations.

The prime use of microcontroller is to control the operation of machine


using a fixed program that is stored in ROM that does not change over the life
time of the system.

The advantages of microcontroller over microprocessor are

cost is less
speed is more
power consumption is less
compact device
external components are minimum

1.3.4 MICROPROCESSOR VERSES MICROCONTROLLER:

The contrast between microprocessor and microcontroller is best


exemplified by the fact that:

Most microprocessor have operational codes for moving data from


external memory to CPU, microcontroller may have one or two.

8
Microprocessor may have one or two types of bit handling
instructions microcontroller will have many.
Microprocessor concerned with rapid movement of code and data
from external address to the chip, microcontroller is concerned with
rapid data movement of bits with in chip.

Microcontroller can function as a computer without addition of

external devices, but microprocessor must have many additions to

operate a computer.

CHAPTER 2

DESCRIPTION OF THE PROJECT

2.1 CIRCUIT DIAGRAM:

9
2.2. WORKING DESCRIPTION:

The system checks the moisture content in the soil, based on that
pumping motor will automatically pumps the water into the field. Here we are
using soil moisture sensor. By using this sensor, we can find whether the soil is
wet or dry. If it is dry, pumping motor will pump the water. In this system, the
main controlling device is microcontroller. Here soil sensor will give the status of
the soil to the microcontroller and switch on or off the pumping motor through
relay. The pumping motor will pump the water into the field by using drip water
system until the field is wet which is continuously monitor by the microcontroller.

10
In irrigation process, most parameter of monitoring is soil, so we have to
monitor the soil condition, whether the soil is dry or wet. If it is dry, then by using
pumping motor, water has to be pumped automatically. The main aim of our
system presenting here is to monitor the moisture content in the soil in
cultivating field. Based on soil moisture, pumping motor will be automatically
switch on or off through relay. This saves the water at the same time and on the
other hand the plant can get optimum level of water, so increasing productivity
of crop.

CHAPTER 3

HARDWARE DESCRIPTION

11
3.1 MICROCONTROLLER:

3.1.1 A Brief history of 8051

In 1981, Intel Corporation introduced an 8 bit microcontroller called 8051.


this microcontroller had 128 bytes of RAM, 4K bytes of chip ROM, two timers, one
serial port, and four ports all on a single chip. At the time it was also referred as
A SYSTEM ON A CHIP.

The 8051 is an 8-bit processor meaning that the CPU can work only on 8
bits data at a time. Data larger than 8 bits has to be broken into 8 bits pieces to
be processed by the CPU. The 8051 has a total of four I\O ports each 8 bit wide.

There are many versions of 8051 with different speeds and amount of on-
chip ROM and they are all compatible with the original 8051. this means that if
you write a program for one it will run on any of them.

The 8051 is an original member of the 8051 family. There are two other
members in the 8051 family of microcontrollers. They are 8052 and 8031. All the
three microcontrollers will have the same internal architecture, but they differ in
the following aspects.

8031 has 128 bytes of RAM, two timers and 6 interrupts.


8051 has 4K ROM, 128 bytes of RAM, two timers and 6
interrupts.
8052 has 8K ROM, 128 bytes of RAM, three timers and 8
interrupts.
Of the three microcontrollers, 8051 is the most preferable. Microcontroller
supports both serial and parallel communication.

In the concerned project 8052 microcontroller is used. Here microcontroller


used is AT89C52, which is manufactured by ATMEL laboratories.

3.1.2 Description of 8952 Microcontroller

The AT89C52 provides the following standard features: 8Kbytes of Flash,


256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, six-vector two-level
interrupt architecture, a full duplex serial port, on-chip oscillator, and clock
circuitry. In addition, the AT89C52 is designed with static logic for operation down
to zero frequency and supports two software selectable power saving modes.

12
The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port,
and interrupt system to continue functioning. The Power down Mode saves the
RAM contents but freezes the oscillator, disabling all other chip functions until
the next hardware reset.

By combining a versatile 8-bit CPU with Flash on a monolithic chip, the


Atmel AT89C52 is a powerful microcomputer which provides a highly flexible and
cost effective solution to many embedded control applications.

3.1.3 Features of Microcontroller (8052)

Compatible with MCS-51 Products


8 Kbytes of In-System Reprogrammable Flash Memory
Endurance: 1,000 Write/Erase Cycles
Fully Static Operation: 0 Hz to 24 MHz
Three-Level Program Memory Lock
256 x 8-Bit Internal RAM
32 Programmable I/O Lines
Three 16-Bit Timer/Counters
Eight vector two level Interrupt Sources
Programmable Serial Channel
Low Power Idle and Power Down Modes

In addition, the AT89C52 is designed with static logic for operation down to
zero frequency and supports two software selectable power saving modes.

The Idle Mode stops the CPU while allowing the RAM, timer/counters,
serial port and interrupt system to continue functioning. The Power Down Mode
saves the RAM contents but freezes the oscillator disabling all other chip
functions until the next hardware reset.

13
3.1.4 Block Diagram of Microcontroller

14
15
Figure: Block Diagram Of 8052

Pin Configuration:

Figure : Pin Diagram of 8952

3.1.5 Pin Description

VCC

Pin 40 provides Supply voltage to the chip. The voltage source is +5v

GND.

Pin 20 is the grounded

16
Port 0

Port 0 is an 8-bit open drain bidirectional I/O port from pin 32 to 39. 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. 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 bidirectional I/O port with internal pull-ups from pin 1 to 8.

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 program verification.

Port 2

Port 2 is an 8-bit bidirectional I/O port with internal pull-ups from pin 21 to 28.

The Port 2 output buffers can sink / source four TTL inputs. When 1s are written

to Port 2 pins they are pulled high by the internal pull-ups and can be used as

inputs. As inputs, Port 2 pins that are externally being pulled low will source

current (IIL) because of the internal pull-ups. Port 2 emits the high-order address

byte during fetches from external program memory and during accesses to

external data memory that uses 16-bit addresses (MOVX @ DPTR). In this

application it uses strong internal pull-ups when emitting 1s. During accesses to

external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the

17
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 from pin 10 to 17.

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 below:

Table : Special Features of 89C5

Port 3 also receives some control signals for Flash programming and

programming verification.

RST

18
Pin 9 is the Reset input. It is active high. Upon applying a high pulse to this

pin, the microcontroller will reset and terminate all activities. A high on this pin

for two machine cycles while the oscillator is running resets the device.

ALE/PROG

Address Latch is an output pin and is active high. 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/6 the

oscillator frequency, and may be used for external timing or clocking purposes.

Note, however, that one ALE pulse is skipped during each access to external

Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR

location 8EH. With the bit set, ALE is active only during a MOVX or MOVC

instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit

has no effect if the microcontroller is in external execution mode.

PSEN

Program Store Enable is the read strobe to external program memory. When

the AT89C52 is executing code from external program memory, PSEN is activated

twice each machine cycle, except that two PSEN activations are skipped during

each access to external data memory.

EA/VPP

External Access Enable. EA must be strapped to GND in order to enable the

device to fetch code from external program memory locations starting at 0000H

up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally

latched on reset. EA should be strapped to VCC for internal program executions.

This pin also receives the 12-volt programming enable voltage (VPP) during Flash

programming, for parts that require 12-volt VPP.

19
XTAL1

Input to the inverting oscillator amplifier and input to the internal clock

operating circuit.

XTAL2

Output from the inverting oscillator amplifier.

3.1.6 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

Figure 5.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 5.4.

Figure : crystal connections

20
Figure : External

Clock Drive Configuration

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 observed.

3.1.7 TIMERS

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.

1. 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.

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 5.2. 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.

21
Table : Timer 2 Operating Modes

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.

There are no restrictions on the duty cycle of external input signal, but it

should for at least one full machine to ensure that a given level is sampled at

least once before it changes

3.1.8 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.

22
Figure : Interrupts source

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 shows that bit position IE.6 is unimplemented. In the

AT89C51, bit position IE.5 is also unimplemented. User software should not write

1s to these bit positions, since they may be used in future AT89 products.

23
Table: Interrupts Enable Register

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 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. Idle Mode

24
In idle mode, the CPU puts itself to sleep while all the on-chip peripherals

remain active. The mode is invoked by software. The content of the on-chip RAM

and all the special functions registers remain unchanged during this mode. The

idle mode can be terminated by any enabled interrupt or by a hardware reset. It

should be noted that when idle is terminated by a hardware reset, the device

normally resumes program execution, from where it left off, up to two machine

cycles before the internal reset algorithm takes control.

On-chip hardware inhibits access to internal RAM in this event, but access

to the port pins is not inhibited. To eliminate the possibility of an unexpected

write to a port pin when Idle is terminated by reset, the instruction following the

one that invokes Idle should not be one that writes to a port pin or to external

memory.

Power down Mode

In the power down mode the oscillator is stopped, and the instruction that

invokes power down is the last instruction executed. The on-chip RAM and

Special Function Registers retain their values until the power down mode is

terminated. The only exit from power down is a hardware reset. Reset redefines

the SFRs but does not change the on-chip RAM. The reset should not be activated

before VCC is restored to its normal operating level and must be held active long

enough to allow the oscillator to restart and stabilize.

Table: Status of External Pins During Idle and Power Down Mode

25
Program Memory Lock Bits

On the chip are three lock bits which can be left unprogrammed (U) or can

be programmed (P) to obtain the additional features listed in the table 5.4. When

lock bit 1 is programmed, the logic level at the EA pin is sampled and latched

during reset. If the device is powered up without a reset, the latch initializes to a

random value, and holds that value until reset is activated. It is necessary that

the latched value of EA be in agreement with the current logic level at that pin in

order for the device to function properly.

Table: Lock Bit Protection Modes

Programming the Flash

The AT89C51 is normally shipped with the on-chip Flash memory array in

the erased state (that is, contents = FFH) and ready to be programmed. The

programming interface accepts either a high-voltage (12-volt) or a low-voltage

(VCC) program enable signal. The low voltage programming mode provides a

26
convenient way to program the AT89C51 inside the users system, while the

high-voltage programming mode is compatible with conventional third party

Flash or EPROM programmers.

The AT89C51 is shipped with either the high-voltage or low voltage

programming mode enabled. The respective top-side marking and device

signature codes are listed in the following table.

Table: Top side marking and Device Signature Codes

The AT89C52 code memory array is programmed byte-by-byte in either

programming mode. To program any non-blank byte in the on-chip Flash

Memory, the entire memory must be erased using the Chip Erase Mode.

3.1.9 Programming Algorithm

Before programming the AT89C52, the address, data and control signals

should be set up according to the Flash programming mode table and Figures 3

and 4. To program the AT89C52, take the following steps.

1. Input the desired memory location on the address lines.

2. Input the appropriate data byte on the data lines.

27
3. Activate the correct combination of control signals.

4. Raise EA/VPP to 12 V for the high-voltage programming mode.

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 1.5 ms. Repeat

steps 1 through 5, changing the address and data for the entire array or until the

end of the object file is reached.

Data Polling

The AT89C52 features Data Polling to indicate the end of a write cycle.

During a write cycle, an attempted read of the last byte written will result in the

complement of the written datum on PO.7. Once the write cycle has been

completed, true data are valid on all outputs, and 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.4 is pulled low after ALE goes high during programming to

indicate BUSY. P3.4 is pulled high again when programming is done to indicate

READY.

Program Verify

If lock bits LB1 and LB2 have not been programmed, the programmed

code data can be read back via the address and data lines for verification. The

lock bits cannot be verified directly. Verification of the lock bits is achieved by

observing that their features are enabled.

Chip Erase

28
The entire Flash array is erased electrically by using the proper

combination of control signals and by holding ALE/PROG low for 10 ms. The code

array is written with all "1"s. The chip erase operation must be executed before

the code memory can be re-programmed.

Reading the Signature Bytes

The signature bytes are read by the same procedure as a normal

verification of locations 030H, 031H, and 032H, except that P3.6 and P3.7 must

be pulled to a logic low.

The values returned are as follows.

(030H) = 1EH indicates manufactured by Atmel

(031H) = 51H indicates 89C51

(032H) = FFH indicates 12 V programming

(032H) = 05H indicates 5 V programming

3.1.10 Programming Interface

Every code byte in the Flash array can be written and the entire array can

be erased by using the appropriate combination of control signals. The write

operation cycle is self-timed and once initiated, will automatically time itself to

completion.

29
3.2 POWER SUPPLY:

3.2.1 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 electronic
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 can be shown as below

30
Fig: Block Diagram of a Regulated Power Supply System

Similarly 12v regulated supply can also be produced by suitable selection


of the individual elements. Each of the blocks is described in detail below and the
power supplies made from these blocks are described below with a circuit
diagram and a graph of their output:

3.2.2 Transformer:

A transformer steps down high voltage AC mains to low voltage AC. Here
we are using a center-tap transformer whose output will be sinusoidal with
36volts peak to peak value.

Fig: Output Waveform of transformer

The low voltage AC output is suitable for lamps, heaters and special AC
motors. It is not suitable for electronic circuits unless they include a rectifier and
a smoothing capacitor. The transformer output is given to the rectifier circuit.

3.2.3 Rectifier:

A rectifier converts AC to DC, but the DC output is varying. There are


several types of rectifiers; here we use a bridge rectifier.

The Bridge rectifier is a circuit, which converts an ac voltage to dc


voltage using both half cycles of the input ac voltage. The Bridge rectifier circuit
is shown in the figure. The circuit has four diodes connected to form a bridge.
The ac input voltage is applied to the diagonally opposite ends of the bridge. The
load resistance is connected between the other two ends of the bridge.

31
For the positive half cycle of the input ac voltage, diodes D1 and D3
conduct, whereas diodes D2 and D4 remain in the OFF state. The conducting
diodes will be in series with the load resistance R L and hence the load current
flows through RL.

For the negative half cycle of the input ac voltage, diodes D2 and D4
conduct whereas, D1 and D3 remain OFF. The conducting diodes D2 and D4 will
be in series with the load resistance R L and hence the current flows through R L in
the same direction as in the previous half cycle. Thus a bi-directional wave is
converted into unidirectional.

Fig: Block diagram of the rectifier

32
The varying DC output is suitable for lamps, heaters and standard motors.
It is not suitable for electronic circuits unless they include a smoothing capacitor.

3.2.4 Smoothing:

The smoothing block smoothes the DC from varying greatly to a small


ripple. The ripple voltage is defined as the deviation of the load voltage from its
DC value. Smoothing is also named as filtering.

Filtering is frequently effected by shunting the load with a capacitor.


The action of this system depends on the fact that the capacitor stores energy
during the conduction period and delivers this energy to the loads during the no
conducting period. In this way, the time during which the current passes through
the load is prolongated, and the ripple is considerably decreased. The action of
the capacitor is shown with the help of waveform.

Fig: The waveform of the rectified output after smoothing is given


below.

33
3.2.5 Regulator:

Regulator eliminates ripple by setting DC output to a fixed voltage. Voltage


regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output
voltages. Negative voltage regulators are also available.

Many of the fixed voltage regulator ICs has 3 leads (input, output and high
impedance). They include a hole for attaching a heat sink if necessary. Zener
diode is an example of fixed regulator which is shown here.

34
Fig: Regulator

Transformer + Rectifier + Smoothing + Regulator:

3.3. RELAY

3.3.1 Overview

A relay is an electrically operated switch. Current flowing through the coil


of the relay creates a magnetic field which attracts a lever and changes the
switch contacts. The coil current can be ON or OFF so relays have two switch
position and they are double throw (changeover) switches.

Relays allow one circuit to switch a second circuit which can be


completely separate from the first. For example a low voltage battery circuit can

35
use a relay to switch a 230V AC mains circuit. There is no electrical connection
inside the relay between the two circuits; the link is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a
12V relay, but it can be as much as 100mA for relays designed to operate from
lower voltages. Most ICs (chips) cannot provide this current and a transistor is
usually used to amplify the small IC current to the larger value required for the
relay coil. The maximum output current for the popular 555 timer IC is 200mA so
these devices can supply relay coils directly without amplification.

Relays are usually SPDT or DPDT but they can have many more sets of
switch contacts, for example relay with 4 sets of changeover contacts are readily
available. Most relays are designed for PCB mounting but you can solder wires
directly to the pins providing you take care to avoid melting the plastic case of
the relay.

The supplier's catalogue should show you the relay's connection. The coil
will be obvious and it may be connected either way round. Relay coils produce
brief high voltage 'spikes' when they are switched off and this can destroy
transistors and ICs in the circuit. To prevent damage you must connect a
protection diode across the relay coil.

The relays switch connections are usually contains COM, NC and NO.

COM = Common, always connect to this; it is the moving part of the switch.

NC = Normally Closed, COM is connected to this when the relay coil is off.

NO = Normally Open, COM is connected to this when the relay coil is on.

Connect to COM and NO if you want the switched circuit to be on when the relay
coil is on.

Connect to COM and NC if you want the switched circuit to be on when the relay
coil is off.

Most relays are SPDT or DPDT which are often described as "single pole
changeover" (SPCO)

Or "double pole changeover"(DPCO).

36
This is a Single Pole Double Throw relay. Current will flow between the
movable contact and one fixed contact when the coil is energized and between
the movable contact and the alternate fixed contact when the relay coil is
energized. The most commonly used relay in car audio, the Bosch relay, is a
SPDT relay.

This relay is a Double Pole Double Throw relay. It operates like the SPDT
relay but has twice as many contacts. There are two completely isolated sets of
contacts.

37
3.3.2 Relay Construction:

Relays are amazingly simple devices. There are four parts in every relay :

Electromagnet

Armature (that can be attracted by the electromagnet )

Spring

Set of electrical contacts.

A relay consists of two separate and completely independent circuits. The


first is at the bottom and drives the electromagnet. In this circuit a switch is
controlling power to the electromagnet. When the switch is on, the
electromagnet is on, and it attracts the armature. The armature is acting as a
switch in the second circuit. When the electromagnet is energized, the armature
completes the second circuit and the light is on. When the electromagnet is not
energized, the spring pulls the armature away and the circuit is not complete. In
that case, the light is dark.

When you purchase relays, you generally have control over several variables:

The voltage and current that is needed to activate the armature

The maximum voltage and current that can run through the armature and
the armature contacts

The number of armatures (generally one or two)

The number of contacts for the armature (generally one or two -- the relay
shown here has two, one of which is unused)

Whether the contact (if only one contact is provided) is normally open
(NO) or normally closed(NC)

3.3.3 Relay Applications:

38
In general, the point of a relay is to use a small amount of power in the
electromagnet coming, say, from a small dashboard switch or a low-power
electronic circuit -- to move an armature that is able to switch a much larger amount
of power. For example, you might want the electromagnet to energize using 5 volts
and 50 milliamps (250 mill watts), while the armature can support 120V AC at 2
amps (240 watts).

Relays are quite common in home appliances where there is an electronic


control turning on something like a motor or a light. They are also common in
cars, where the 12V supply voltage means that just about everything needs a
large amount of current. In later model cars, manufacturers have started
combining relay panels into the fuse box to make maintenance easier.

In places where a large amount of power needs to be switched, relays are


often cascaded. In this case, a small relay switches the power needed to drive a
much larger relay, and that second relay switches the power to drive the load.

Relays can also be used to implement Boolean logic.

3.3.4 Advantages of Relay:

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

Relays can switch high voltages, transistors cannot.

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

Relays can switch many contacts at once.

3.4 ELECTRODES:

This water level sensor is conducive for liquids that have a conductivity of
equal to or more than 25m Siemens. It is your best choice for a water level
switch. The system is economical to install as no special cable is required for
signal transmission. The level probe and the evaluation unit can be connected
using a long cable. The AC is provided on the probe for preventing electrode
deterioration. You can choose from among a variety of level control and
installation systems such as

39
Two point sensors for independent switching and automatic control of
pump.

Four point switching with two pump control logic.

Three point switching: two for pump control logic and one independent
point with or without a settable delay (for probe covered or uncovered).

A variety of probes is available for your specific process.

Applications:

The SLW... series water level switches work to maintain a constant water
level avoiding material wastage in your process plant. Common applications also
include switching pumps on and off to avoid overflow, dry running and indicating
water level in an empty tank to avoid wear and tear and production stoppage.
Many of our customers in the Food, Power, Chemicals, Sugar, Detergent, Steel,
Minerals and Textile industry have used the SLW... series water level indicator
/sensor. Principle A low AC voltage is applied between the probe electrode and
the tank wall (or reference electrode in case of insulated tank). When the
water/liquid comes in contact with the electrode tip, a conductive path is
established between the sense electrode and the tank wall/reference electrode.
This current is sensed, amplified and made to operate a relay whose contacts in
turn can be used for annunciation/control.

40
CHAPTER 4

SOFTWARE DESCRIPTION

4.1 INTRODUCTION:

In this chapter the software used and the language in which the program
code is defined is mentioned and the program code dumping tools are explained.
The chapter also documents the development of the program for the application.
This program has been termed as Source code. Before we look at the source
code we define the two header files that we have used in the code.

41
4.2 TOOLS USED:

Figure: Keil Software- internal stages

Keil development tools for the 8051 Microcontroller Architecture support


every level of software developer from the professional applications

4.3 C51 COMPILER & A51 MACRO ASSEMBLER:

Source files are created by the Vision IDE and are passed to the C51
Compiler or A51 Macro Assembler. The compiler and assembler process source
files and create replaceable object files.

42
The Keil C51 Compiler is a full ANSI implementation of the C programming
language that supports all standard features of the C language. In addition,
numerous features for direct support of the 8051 architecture have been added.

4.4 VISION

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 Vision3 and can be used in parallel with Vision3.

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
Interface.
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.

43
Additional example programs not listed here are provided for each device
architecture.

BUILDING AN APPLICATION IN VISION

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

1 Select Project -(forexample,166\EXAMPLES\HELLO\HELLO.UV2).


2 Select Project - Rebuild all target files or Build target.
Vision3 compiles, assembles, and links the files in your project.

4.5 Creating Your Own Application in Vision

To create a new project in Vision3, 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 Vision3

To debug an application created using Vision3, 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.

44
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 Vision3 and creating a Project

Vision3 is a standard Windows application and started by clicking on the


program icon. To create a new project file select from the Vision3 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.

Vision3 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 Vision3 device database.
Just select the microcontroller 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, Vision3 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

45
location in a Vision3 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. Vision3
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

Vision3 simulates up to 16 Mbytes of memory from which areas can be mapped


for read, write, or code execution access. The Vision3 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 Vision3 with the Debug Start/Stop Debug

Session command. Depending on the Options for Target Debug

Configuration, Vision3 will load the application program and run the startup

46
code Vision3 saves the editor screen layout and restores the screen layout of
the last debug session. If the program execution stops, Vision3 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
Vision3 debug mode differs from the edit mode in the following aspects:

The Debug Menu and Debug Commands described below 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 debugging.

4.6 FLOW CHART

47
PROCEDURE:

1. Click on the Keil u vision 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

48
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

49
9. Select AT89C51 as shown below

10. Then Click on OK


11. The Following fig will appear

50
12. Then Click either YES or NOmostly 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

51
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

52
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.

53
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

54
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.

55
29. Now keep Pressing function key F11 slowly and observe.
30. You are running your program successfully

4.7 KEIL C PROGRAM / CODE

#include <REG51.H>

Sbit input1=P1^0;

Sbit input2=P1^1;

Sbit motor1=P1^2;

Sbit motor2=P1^3;

main ( )

56
while (1)

if(input1==1)

motor1=1;

if(input2==1)

motor2=1;

if (input1==0)

Motor1=0;

if (input1==0)

Motor2=0

57
CHAPTER 5

MERITS AND DEMERITS

MERITS:

This system reduces the risk of electric shocks, deaths due to poisonous
creatures in the fields.
Temperature sensor based fan speed control.
Visual display using LCD display unit.
Watering depends on the moisture level present in the field.
Automatic controlling of water pump.
Efficient and low cost design.
Fast response.
User friendly.

DEMERITS:

Placing of the soil moisture sensor in the fields is very sensitive.

58
CHAPTER 6

CONCLUSION

The Automatic Plant irrigation has been achieved successfully using


microcontroller unit. The circuit has been tested and verified. We Developed
Automatic motor control (ON/OFF). programmed by using the microcontroller.
And the program has been successfully tested and verified for several specified
loads. This proposed technique is designed to operate a water pump
automatically based on the soil moisture sensor detection of sufficient water to
the plant or in fields and also temperature sensor based fan speed control. The
switching mechanism can be done automatically with the help of microcontroller
using relays.

59
The proposed controller eliminates the manual switching mechanism used
by the farmers to ON/OFF the irrigation system. The system is also designed for
temperature sensor based fan speed control. Integrating features of all the
hardware components used have been developed in 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 ICs with the help of
growing technology, the project has been successfully implemented.

CHAPTER 7

BIBLIOGRAPHY AND REFERENCES

BIBILOGRAPHY:

POWER SUPPLY WWW.KPSEC.FREEUK.COM

MICRO CONTROLLER WWW.ATMEL.COM

ULN2003 WWW.ALLEGRO.COM

WWW.ALLEGROMICRO.COM

60
WWW.BAYLINEAR.COM

CRYSTAL OSCILLATOR SILICON STORAGE TECHNOLOGY,INC

REFERENCES

1. "The 8051 Microcontroller Architecture, Programming & Applications" by


Kenneth J Ayala.

2. "The 8051 Microcontroller & Embedded Systems" by Mohammed Ali Mazidi


and Janice Gillespie Mazidi

3. "Power Electronics by M D Singh and K B Khanchandan

4. "Linear Integrated Circuits by D Roy Choudary & Shail Jain

5. "Electrical Machines by S K Bhattacharya

6. "Electrical Machines II by B L Thereja

7. www.8051freeprojectsinfo.com.

61

S-ar putea să vă placă și