74
1. INTRODUCTION 1.1 BACK GROUND “AUTOMATIC IRRIGATION SYSTEM” this Project mainly depends on embedded systems. 1.2 INTRODUCTION TO EMBEDDED SYSTEM An Embedded system is a special-purpose system in which the computer is completely encapsulated by or dedicated to the device or system it controls. Unlike a general-purpose computer, such as a personal computer, an embedded system performs one or a few predefined tasks, usually with very specific requirements. Since the system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product. Embedded systems are often mass-produced, benefiting from economies of scale. Personal digital assistants (PDAs) or handheld computers are generally considered embedded devices because of the nature of their hardware design, even though they are more expandable in software terms. This line of definition continues to blur as devices expand. With the introduction of the OQO Model 2 with the Windows XP operating system and ports such as a USB port both 1

Automatic Irrigation System

Embed Size (px)

DESCRIPTION

ECE Mini Projects...Uploaded by RS

Citation preview

Page 1: Automatic Irrigation System

1. INTRODUCTION

1.1 BACK GROUND

“AUTOMATIC IRRIGATION SYSTEM” this Project mainly depends on

embedded systems.

1.2 INTRODUCTION TO EMBEDDED SYSTEM

An Embedded system is a special-purpose system in which the computer is

completely encapsulated by or dedicated to the device or system it controls. Unlike a

general-purpose computer, such as a personal computer, an embedded system

performs one or a few predefined tasks, usually with very specific requirements. Since

the system is dedicated to specific tasks, design engineers can optimize it, reducing

the size and cost of the product. Embedded systems are often mass-produced,

benefiting from economies of scale.

Personal digital assistants (PDAs) or handheld computers are generally

considered embedded devices because of the nature of their hardware design, even

though they are more expandable in software terms. This line of definition continues

to blur as devices expand. With the introduction of the OQO Model 2 with the

Windows XP operating system and ports such as a USB port both features usually

belong to "general purpose computers", the line of nomenclature blurs even more.

Physically, embedded systems ranges from portable devices such as digital

watches and MP3 players, to large stationary installations like traffic lights, factory

controllers, or the systems controlling nuclear power plants.

In terms of complexity embedded systems can range from very simple with a

single microcontroller chip, to very complex with multiple units, peripherals and

networks mounted inside a large chassis or enclosure.

Examples of Embedded Systems:

Avionics, such as inertial guidance systems, flight

control hardware/software and other integrated

systems in aircraft and missiles

1

Page 2: Automatic Irrigation System

Cellular telephones and telephone switches

Engine controllers and antilock brake controllers for automobile

Home automation products, such as thermostats, air conditioners, sprinklers,

and security monitoring systems

Handheld calculators

Handheld computers

Household appliances, including microwave ovens, washing machines,

television sets, DVD players and recorder

Medical equipment

Personal digital assistant

Videogame consoles

Computer peripherals such as routers and printers.

1.3 BLOCK DIAGRAM

TO REQUIRED COMPONENTS

Fig 1.1: Block diagram of a Automatic Irrigation System

2

8051Micro

controller

LM324

RELAY

MOISTURESENSOR

WATER PUMP MOTOR

LCD DISPLAY

PowerSupply

Page 3: Automatic Irrigation System

1.4 BLOCK DIAGRAM EXPLANATION

POWER SUPPLY:

In this system we are using 5V power supply for microcontroller of

Transmitter section as well as receiver section. We use rectifiers for converting the

A.C. into D.C and a step down transformer to step down the voltage. The full

description of the Power supply section is given in this documentation in the

following sections i.e. hardware components.

MICRO CONTROLLER

In this project work the micro-controller is playing a major role. Micro-

controllers were originally used as components in complicated process-control

systems. However, because of their small size and low price, Micro-controllers are

now also being used in regulators for individual control loops. In several areas

Micro-controllers are now outperforming their analog counterparts and are cheaper as

well.

The purpose of this project work is to present control theory that is relevant to

the analysis and design of Micro-controller system with an emphasis on basic concept

and ideas. It is assumed that a Microcontroller with reasonable software is available

for computations and simulations so that many tedious details can be left to the

Microcontroller. The control system design is also carried out up to the stage of

implementation in the form of controller programs in assembly language OR in C-

Language.

LCD DISPLAY SECTION

This section is basically meant to show up the status of the project. This

project makes use of Liquid Crystal Display to display / prompt for necessary

information

3

Page 4: Automatic Irrigation System

LM234 OP AMP

This device consists of 14 pins. It consists of four independent, high gain,

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.

MOISTURE SENSOR

A soil moisture sensor is a water conservation accessory for conventional

automatic irrigation controllers or time clocks with the potential for eliminating

excessive irrigation cycles. The device connects to a typical residential system and

consists of a sensor that is buried in the root zone of the irrigated area and a control

unit that is placed near the irrigation time clock. The irrigation time clock is

programmed normally, but when irrigation is scheduled to occur, the soil moisture

sensor is queried.

DC MOTOR

An electric motor is a machine which converts electrical energy into

mechanical energy.

DC motors are configured in many types and sizes, including brush less,

servo, and gear motor types. A motor consists of a rotor and a permanent magnetic

field stator. The magnetic field is maintained using either permanent magnets or

electromagnetic windings. DC motors are most commonly used in variable speed and

torque.

MOTOR DRIVING CIRCUIT

Motor driving circuit is a relay is an electrical switch that opens and closes

under the control of another electrical circuit. In the original form, the switch is

operated by an electromagnet to open or close one or many sets of contacts.

4

Page 5: Automatic Irrigation System

2. LITERATURE SURVEY

A Microcontroller has a CPU (a microprocessor) in addition to a fixed amount

of RAM, ROM, I/O ports, and a timer all on a single chip. In other words, the

processor, the RAM, ROM, I/O ports and the timer are all embedded together on one

chip; therefore, the designer cannot add any external memory, I/O ports, or timer to it.

The fixed amount of on-chip ROM, RAM, and number of I/O ports in

Microcontrollers makes them ideal for many applications in which cost and space are

critical.

In many applications, for example a TV remote control, there is no need for

the computing power of a 486 or even an 8086 microprocessor. These applications

most often require some I/O operations to read signals and turn on and off certain bits.

In the Literature discussing microprocessors, we often see the term Embedded

System. Microprocessors and Microcontrollers are widely used in embedded system

products. An embedded system product uses a microprocessor (or Microcontroller) to

do one task only. A printer is an example of embedded system since the processor

inside it performs one task only; namely getting the data and printing it. Contrast this

with a Pentium based PC. A PC can be used for any number of applications such as

word processor, print-server, bank teller terminal, Video game, network server, or

Internet terminal. Software for a variety of applications can be loaded and run. of

course the reason a pc can perform myriad tasks is that it has RAM memory and an

operating system that loads the application software into RAM memory and lets the

CPU run it.

In an Embedded system, there is only one application software that is typically

burned into ROM. An x86 PC contains or is connected  to various embedded products

such as keyboard, printer, modem, disk controller, sound card, CD-ROM drives,

mouse, and so on..

PC contains or is connected  to various embedded products such as keyboard,

printer, modem, disk controller, sound card, CD-ROM drives, mouse, and so on. Each

one of these peripherals has a Microcontroller inside it that performs only one task.

For example, inside every mouse there is a Microcontroller to perform the task of

finding the mouse position and sending it to the PC.

5

Page 6: Automatic Irrigation System

3. PROBLEM IDENTIFICATION

The system requirements and control specifications clearly rule out the use of

16, 32 or 64 bit micro controllers or microprocessors. Systems using these may be

earlier to implement due to large number of internal features. They are also faster and

more reliable but, 8-bit micro controller satisfactorily serves the above application.

Using an inexpensive 8-bit Microcontroller will doom the 32-bit product failure in

any competitive market place.

Coming to the question of why to use AT89C51 of all the 8-bit

microcontroller available in the market the main answer would be because it has 4 Kb

on chip flash memory which is just sufficient for our application. The on-chip Flash

ROM allows the program memory to be reprogrammed in system or by conventional

non-volatile memory Programmer. Moreover ATMEL is the leader in flash

technology in today’s market place and hence using AT 89C51 is the optimal

solution.

4. IMPLEMENTATION DETAILS6

Page 7: Automatic Irrigation System

4.1. MICRO CONTROLLER

Introduction

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

various I/O interfaces such as serial port, parallel port timer or counter, interrupt

controller, data acquisition interfaces-Analog to Digital converter, Digital to Analog

converter, integrated on to a single silicon chip.

If a system is developed with a microprocessor, the designer has to go for

external memory such as RAM, ROM, EPROM and peripherals. But controller is

provided all these facilities on a single chip. Development of a Micro controller

reduces PCB size and cost of design.

One of the major differences between a Microprocessor and a Micro controller is that

a controller often deals with bits not bytes as in the real world application.

Intel has introduced a family of Micro controllers called the MCS-51.

The Major Features

Compatible with MCS-51 products

4k Bytes of in-system Reprogrammable flash memory

Fully static operation: 0HZ to 24MHZ

Three level programmable clock

128 * 8 –bit timer/counters

Six interrupt source

Programmable serial channel

Low power idle power-down modes

7

Page 8: Automatic Irrigation System

MICRO CONTROLLER (89C51)

4.1.1: AT89C51 MICROCONTROLLER ARCHITECTURE

The 89C51 architecture consists of these specific features:

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

Sixteen-bit program counter (PC) and data pointer (DPTR)

Eight- bit stack pointer (PSW)

Eight-bit stack pointer (Sp)

Internal ROM or EPROM (8751) of 0(8031) to 4K (89C51)

Internal RAM of 128 bytes:

Four register banks, each containing eight registers

Sixteen bytes, which maybe addressed at the bit level

Eighty bytes of general- purpose data memory

Thirty –two input/output pins arranged as four 8-bit ports:p0-p3

Two 16-bit timer/counters: T0 and T1

Full duplex serial data receiver/transmitter: SBUF

Control registers: TCON, TMOD, SCON, PCON, IP, and IE

Two external and three internal interrupts sources.

Oscillator and clock circuits.

8

Page 9: Automatic Irrigation System

Fig: 4.1.: Functional block diagram of micro controller

The 89C51 oscillator and clock:

The heart of the 89C51 circuitry that generates the clock pulses by which all

the internal all internal operations are synchronized. Pins XTAL1 And XTAL2 is

provided for connecting a resonant network to form an oscillator. Typically a quartz

crystal and capacitors are employed. The crystal frequency is the basic internal clock

frequency of the microcontroller. The manufacturers make 89C51 designs that run at

specific minimum and maximum frequencies typically 1 to 16 MHz.

Types of memory

The 89C51 have three general types of memory. They are on-chip memory,

external Code memory and external Ram. On-Chip memory refers to physically

existing memory on the micro controller itself. External code memory is the code

memory that resides off chip. This is often in the form of an external EPROM.

9

Page 10: Automatic Irrigation System

External RAM is the Ram that resides off chip. This often is in the form of standard

static RAM or flash RAM.

Code memory

Code memory is the memory that holds the actual 89C51 programs that is to

be run. This memory is limited to 64K. Code memory may be found on-chip or off-

chip. It is possible to have 4K of code memory on-chip and 60K off chip memory

simultaneously. If only off-chip memory is available then there can be 64K of off chip

ROM. This is controlled by pin provided as EA

Internal RAM

The 89C51 have a bank of 128 of internal RAM. The internal RAM is found

on-chip. So it is the fastest Ram available. And also it is most flexible in terms of

reading and writing. Internal Ram is volatile, so when 89C51 is reset, this memory is

cleared. 128 bytes of internal memory are subdivided. The first 32 bytes are divided

into 4 register banks. Each bank contains 8 registers. Internal RAM also contains 128

bits, which are addressed from 20h to 2Fh. These bits are bit addressed i.e. each

individual bit of a byte can be addressed by the user. They are numbered 00h to 7Fh.

The user may make use of these variables with commands such as SETB and CLR.

FLASH MEMORY

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

powered non volatile that can be erased and reprogrammed in units of memory called

blocks. It is a variation of electrically erasable programmable read-only memory

(EEPROM) which, unlike flash memory, is erased and rewritten at the byte level,

which is slower than flash memory updating. Flash memory is often used to hold

control code such as the basic input/output system (BIOS) in a personal computer.

When BIOS needs to be changed (rewritten), the flash memory can be written to in

block (rather than byte) sizes, making it easy to update. On the other hand, flash

memory is not useful as random access memory (RAM) because RAM needs to be

addressable at the byte (not the block) level.

10

Page 11: Automatic Irrigation System

Flash memory gets its name because the microchip is organized so that a

section of memory cells are erased in a single action or "flash." The erasure is caused

by Fowler-Nordheim tunneling in which electrons pierce through a thin dielectric

material to remove an electronic charge from a floating gate associated with each

memory cell. Intel offers a form of flash memory that holds two bits (rather than one)

in each memory cell, thus doubling the capacity of memory without a corresponding

increase in price.

Flash memory is used in digital cellular phones, digital cameras, LAN

switches, PC Cards for notebook computers, digital set-up boxes, embedded

controllers, and other devices.

Memory Type

Features

FLASH Low-cost, high-density, high-speed

architecture; low power; high reliability

ROM

Read-Only Memory

Mature, high-density, reliable, low cost;

time-consuming mask required, suitable

for high production with stable code

SRAM

Static Random-Access Memory

Highest speed, high-power, low-density

memory; limited density drives up cost

EPROM

Electrically Programmable Read-Only

Memory

High-density memory; must be exposed

to ultraviolet light for erasure

EEPROMorE2PROM

Electrically Erasable Programmable

Read-Only Memory

Electrically byte-erasable; lower

reliability, higher cost, lowest density

DRAM

Dynamic Random Access Memory

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

high-power

Table 4.1: Types of memories

11

Page 12: Automatic Irrigation System

Pin diagram of AT89C51

Fig 4.2.: Pin diagram of AT89C51

Pin Description

VCC: Supply voltage.

GND: Ground.

Port 0:

Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each

pin can sink eight TTL inputs. When one’s 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.

12

Page 13: Automatic Irrigation System

Port 1

Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1

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

they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port

1 pins that are externally being pulled low will source current (IIL) because of the

internal pull-ups. Port 1 also receives the low-order address bytes during Flash

programming and verification.

Port 2

Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2

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

they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port

2 pins that are externally being pulled low will source current (IIL) because of the

internal pull-ups. Port 2 emits the high-order address byte during fetches from

external program memory and during accesses to external data memories that use 16-

bit addresses (MOVX @DPTR). In this application, it uses strong internal pull-ups

when emitting 1s. During accesses to external data memories that use 8-bit addresses

(MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2

also receives the high-order address bits and some control signals during Flash

programming and verification.

Port 3

Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3

output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins

they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port

3 pins that are externally being pulled low will source current (IIL) because of the

pull-ups.

Port 3 also serves the functions of various special features of the AT89C51 as listed

below:

Port 3 also receives some control signals for Flash programming and verification

13

Page 14: Automatic Irrigation System

Tab 4.1: Port pins and their alternate functions

RST:

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

running resets the device.

ALE/PROG:

Address Latch Enable output pulse for latching the low byte of the address

during accesses to external memory. This pin is also the program pulse input (PROG)

during Flash programming. In normal operation ALE is emitted at a constant rate of

1/6the oscillator frequency, and may be used for external timing or clocking purposes.

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

Memory.

If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With

the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the

pin is pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in

external execution mode.

PSEN

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

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

14

Page 15: Automatic Irrigation System

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

access to external data memory.

EA/VPP

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

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

FFFFH.

Note, however, that if lock bit 1 is programmed, EA will be internally latched

on reset.

EA should be strapped to VCC for internal program executions. This pin also receives

the 12-volt programming enable voltage (VPP) during Flash programming, for parts

that require 12-volt VPP.

XTAL1

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

operating circuit.

XTAL2

It is the Output from the inverting oscillator amplifier.

Oscillator Characteristics

XTAL1 and XTAL2 are the input and output, respectively, of an inverting

amplifier which can be configured for use as an on-chip oscillator, as shown in Fig

4.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 4.4There 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.

15

Page 16: Automatic Irrigation System

Fig 4.3: Oscillator Connections Fig 4.4: External Clock Drive Configuration

TIMERS

On-chip timing/counting facility has proved the capabilities of the

microcontroller for implementing the real time application. These includes pulse

counting, frequency measurement, pulse width measurement, baud rate generation,

etc,. Having sufficient number of timer/counters may be a need in a certain design

application. The 8051 has two timers/counters. They can be used either as timers to

generate a time delay or as counters to count events happening outside the

microcontroller. Let discuss how these timers are used to generate time delays and we

will also discuss how they are been used as event counters.

PROGRAMMING 8051 TIMERS

The 8051 has timers: Timer 0 and Timer1.they can be used either as timers or as

event counters. Let us first discuss about the timers’ registers and how to program the

timers to generate time delays.

BASIC RIGISTERS OF THE TIMER

Both Timer 0 and Timer 1 are 16 bits wide. Since the 8051 has an 8-bit

architecture, each 16-bit timer is accessed as two separate registers of low byte and

high byte.

16

Page 17: Automatic Irrigation System

TIMER 0 REGISTERS

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 the high byte register is referred to

as TH0(Timer 0 high byte).These register can be accessed like any other register, such

as A,B,R0,R1,R2,etc.for example, the instruction ”MOV TL0, #4F”moves the value

4FH into TL0,the low byte of Timer 0.These registers can also be read like any other

register.

TIMER 1 REGISTERS

Timer 1 is also 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 n the

same way as the register of Timer 0.

TMOD (timer mode) REGISTER

Both timers TIMER 0 and TIMER 1 use the same register, called TMOD, to

set the various timer operation modes. TMOD is an 8-bit register in which the lower 4

bits are set aside for Timer 0 and the upper 4 bits for Timer 1.in each case; the lower 2

bits are used to set the timer mode and the upper 2 bits to specify the operation.

17

Page 18: Automatic Irrigation System

MODES

M1, M0

M0 and M1 are used to select the timer mode. There are three modes: 0, 1,

2.Mode 0 is a 13-bit timer, mode 1 is a 16-bit timer, and mode 2 is an 8-bit timer. We

will concentrate on modes 1 and 2 since they are the ones used most widely. We will

soon describe the characteristics of these modes, after describing the reset of the

TMOD register.

GATE Gate control when set. The timer/counter is enabled only

While the INTx pin is high and the TRx control pin is.

Set. When cleared, the timer is enabled.

C/T Timer or counter selected cleared for timer operation

(Input from internal system clock).set for counter

Operation (input TX input pin).

M 1 Mode bit 1

M0 Mode bit 0

M1 M0 MODE Operating Mode

0 0 0 13-bit timer mode

8-bit timer/counter THx with TLx as

5 - Bit pre-scaler.

0 1 1 16-bit timer mode

16-bit timer/counters THx with TL are

Cascaded; there is no prescaler

1 0 2 8-bit auto reload

8-bit auto reload timer/counter; THx

Holds a value that is to be reloaded into

TLx each time it overflows.

1 1 3 Split timer mode.

18

Page 19: Automatic Irrigation System

C/T (clock/timer)

This bit in the TMOD register is used to decide whether the timer is used as a

delay generator or an event counter. If C/T=0, it is used as a timer for time delay

generation. The clock source for the time delay is the crystal frequency of the

8051.this section is concerned with this choice. The timer’s use as an event counter is

discussed in the next section.

Serial Communication

Computers can transfer data in two ways: parallel and serial. In parallel data

transfers, often 8 or more lines (wire conductors) are used to transfer data to a device

that is only a few feet away. Examples of parallel data transfer are printers and hard

disks; each uses cables with many wire strips. Although in such cases a lot of data

can be transferred in a short amount of time by using many wires in parallel, the

distance cannot be great. To transfer to a device located many meters away, the serial

method is used. In serial communication, the data is sent one bit at a time, in contrast

to parallel communication, in which the data is sent a byte or more at a time. Serial

communication of the 8051 is the topic of this chapter. The 8051 has serial

communication capability built into it, there by making possible fast data transfer

using only a few wires.

If data is to be transferred on the telephone line, it must be converted from 0s

and 1s to audio tones, which are sinusoidal-shaped signals. A peripheral device called

a modem, which stands for “modulator/demodulator”, performs this conversion.

Serial data communication uses two methods, asynchronous and synchronous.

The synchronous method transfers a block of data at a time, while the asynchronous

method transfers a single byte at a time.

In data transmission if the data can be transmitted and received, it is a duplex

transmission. This is in contrast to simplex transmissions such as with printers, in

which the computer only sends data. Duplex transmissions can be half or full duplex,

depending on whether or not the data transfer can be simultaneous. If data is

transmitted one way at a time, it is referred to as half duplex. If the data can go both

ways at the same time, it is full duplex. Of course, full duplex requires two wire

19

Page 20: Automatic Irrigation System

conductors for the data lines, one for transmission and one for reception, in order to

transfer and receive data simultaneously.

Asynchronous serial communication and data framing

The data coming in at the receiving end of the data line in a serial data transfer

is all 0s and 1s; it is difficult to make sense of the data unless the sender and receiver

agree on a set of rules, a protocol, on how the data is packed, how many bits

constitute a character, and when the data begins and ends.

Start and stop bits

Asynchronous serial data communication is widely used for character-oriented

transmissions, while block-oriented data transfers use the synchronous method. In the

asynchronous method, each character is placed between start and stop bits. This is

called framing. In the data framing for asynchronous communications, the data, such

as ASCII characters, are packed between a start bit and a stop bit. The start bit is

always one bit, but the stop bit can be one or two bits. The start bit is always a 0

(low) and the stop bit (s) is 1 (high).

Data transfer rate

The rate of data transfer in serial data communication is stated in bps (bits per

second). Another widely used terminology for bps is baud rate. However, the baud

and bps rates are not necessarily equal. This is due to the fact that baud rate is the

modem terminology and is defined as the number of signal changes per second. In

modems a single change of signal, sometimes transfers several bits of data. As far as

the conductor wire is concerned, the baud rate and bps are the same, and for this

reason we use the bps and baud interchangeably.

The data transfer rate of given computer system depends on communication

ports incorporated into that system. For example, the early IBMPC/XT could transfer

data at the rate of 100 to 9600 bps. In recent years, however, Pentium based PCS

20

Page 21: Automatic Irrigation System

transfer data at rates as high as 56K bps. It must be noted that in asynchronous serial

data communication, the baud rate is generally limited to 100,000bps.

RS232 Standards

To allow compatibility among data communication equipment made by

various manufacturers, an interfacing standard called RS232 was set by the

Electronics Industries Association (EIA) in 1960. In 1963 it was modified and called

RS232A. RS232B AND RS232C were issued in 1965 and 1969, respectively. Today,

RS232 is the most widely used serial I/O interfacing standard. This standard is used

in PCs and numerous types of equipment. However, since the standard was set long

before the advert of the TTL logic family, its input and output voltage levels are not

TTL compatible. In RS232, a 1 is represented by -3 to -25V, while a 0 bit is +3 to

+25V, making -3 to +3 undefined. For this reason, to connect any RS232 to a

microcontroller system we must use voltage converters such as MAX232 to convert

the TTL logic levels to the RS232 voltage levels, and vice versa. MAX232 IC chips

are commonly referred to as line drivers.

RS232 pins

RS232 cable is commonly referred to as the DB-25 connector. In labeling,

DB-25P refers to the plug connector (male) and DB-25S is for the socket connector

(female). Since not all the pins are used in PC cables, IBM introduced the DB-9

Version of the serial I/O standard, which uses 9 pins only, as shown in table.

DB-9 pin connector

1 2 3 4 5

6 7 8 9

21

Page 22: Automatic Irrigation System

Pin Description

1 Data carrier detect (DCD)

2 Received data (RXD)

3 Transmitted data (TXD)

4 Data terminal ready(DTR)

5 Signal ground (GND)

6 Data set ready (DSR)

7 Request to send (RTS)

8 Clear to send (CTS)

9 Ring indicator (RI)

Tab. 4.2: Pin Functions

Note: DCD, DSR, RTS and CTS are active low pins.

The method used by RS-232 for communication allows for a simple

connection of three lines: Tx, Rx, and Ground. The three essential signals for 2-way

RS-232

Communications are these:

TXD: carries data from DTE to the DCE.

RXD: carries data from DCE to the DTE

SG: signal ground

8051 connection to RS232

The RS232 standard is not TTL compatible; therefore, it requires a line driver

such as the MAX232 chip to convert RS232 voltage levels to TTL levels, and vice

versa. The interfacing of 8051 with RS232 connectors via the MAX232 chip is the

main topic.

The 8051 has two pins that are used specifically for transferring and

receiving data serially. These two pins are called TXD and RXD and a part of the port

3 group (P3.0 and P3.1). Pin 11 of the 8051 is assigned to TXD and pin 10 is

22

Page 23: Automatic Irrigation System

designated as RXD. These pins are TTL compatible; therefore, they require a line

driver to make them RS232 compatible. One such line driver is the MAX232 chip.

MAX232 converts from RS232 voltage levels to TTL voltage levels, and vice

versa. One advantage of the MAX232 chip is that it uses a +5V power source which,

is the same as the source voltage for the 8051. In the other words, with a single +5V

power supply we can power both the 8051 and MAX232, with no need for the power

supplies that are common in many older systems. The MAX232 has two sets of line

drivers for transferring and receiving data. The line drivers used for TXD are called

T1 and T2, while the line drivers for RXD are designated as R1 and R2. In many

applications only one of each is used.

Fig.4.5: CONNECTING μC to PC using MAX 232

4.2 REGULATED POWER SUPPLY

The power supplies are designed to convert high voltage AC mains electricity

to a suitable low voltage supply for electronics circuits and other devices. A RPS

(Regulated Power Supply) is the Power Supply with Rectification, Filtering and

Regulation being done on the AC mains to get a Regulated power supply for

Microcontroller and for the other devices being interfaced to it.

A power supply can by broken down into a series of blocks, each of which

performs a particular function. A d.c power supply which maintains the output voltage

constant irrespective of a.c mains fluctuations or load variations is known as

“Regulated D.C Power Supply”

For example a 5V regulated power supply system as shown below:

23

Page 24: Automatic Irrigation System

Fig.4.6 Components of a typical Linear supply

4.2.1 TRANSFORMER

A transformer is an electrical device which is used to convert electrical power

from one Electrical circuit to another without change in frequency.

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 in output voltage, step-down

transformers decrease in output voltage. Most power supplies use a step-down

transformer to reduce the dangerously high mains voltage to a safer low voltage. The

input coil is called the primary and the output coil is called the secondary. There is no

electrical connection between the two coils; instead they are linked by an alternating

magnetic field created in the soft-iron core of the transformer. The two lines in the

middle of the circuit symbol represent the core. Transformers waste very little power

so the power out is (almost) equal to the power in. Note that as voltage is stepped

down current is stepped up. The ratio of the number of turns on each coil, called the

turn’s ratio, determines the ratio of the voltages. A step-down transformer has a large

number of turns on its primary (input) coil which is connected to the high voltage

mains supply, and a small number of turns on its secondary (output) coil to give a low

output voltage.

24

Page 25: Automatic Irrigation System

Fig 4.7: An Electrical Transformer

Turns ratio = Vp/ VS = Np/NS

Power Out= Power In

VS X IS=VP X IP

Vp = primary (input) voltage

Np = number of turns on primary coil

Ip = primary (input) current    

4.2.2 RECTIFIER

A circuit which is used to convert a.c to dc is known as RECTIFIER. The

process of conversion a.c to d.c is called “rectification”

Types of rectifier

Half wave Rectifier

Full wave rectifier

Centre tap full wave rectifier.

Bridge type full bridge rectifier.

25

Page 26: Automatic Irrigation System

Parameter

Type of Rectifier

Half wave Full wave Bridge

Number of diodes 1 2 4

PIV of diodes Vm 2Vm Vm

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

Vdc, at no-load 0.318Vm 0.636Vm 0.636Vm

Ripple factor 1.21 0.482 0.482

Ripple frequency f 2f 2f

Rectification efficiency 0.406 0.812 0.812

Transformer Utilization

Factor(TUF) 0.287 0.693 0.812

RMS voltage Vrms Vm/2 Vm/√2 Vm/√2

Table 4.3: Comparison of rectifier circuits:

Full-wave rectifier

From the above comparison we came to know that full wave bridge rectifier as

more advantages than the other two rectifiers. So, in our project we are using full

wave bridge rectifier circuit.

Bridge rectifier:

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

full-wave rectification. This is a widely used configuration, both with individual

diodes wired as shown and with single component bridges where the diode bridge is

wired internally.

26

Page 27: Automatic Irrigation System

A bridge rectifier makes use of four diodes in a bridge arrangement as shown

in Fig 4.8 to achieve full-wave rectification. This is a widely used configuration, both

with individual diodes wired as shown and with single component bridges where the

diode bridge is wired internally.

Fig 4.8: bridge rectifier

Operation

During positive half cycle of secondary, the diodes D2 and D3 are in forward

biased while D1 and D4 are in reverse biased as shown in the figure 4.10. The current

flow direction is shown in the figure 4.10 with dotted arrows.

Fig 4.9: Positive operation of bridge rectifier

During negative half cycle of secondary voltage, the diodes D1 and D4 are in

forward biased while D2 and D3 are in reverse biased as shown in the Fig.4.12. The

current flow direction is shown in the Fig.4.11 with dotted arrows.

27

Page 28: Automatic Irrigation System

Fig.4.10: Negative operation of bridge rectifier

4.2.3 FILTERS

A Filter is a device which removes the a.c component of rectifier output but

allows the d.c component to reach the load.

Capacitor Filter

We have seen that the ripple content in the rectified output of half wave

rectifier is 121% or that of full-wave or bridge rectifier or bridge rectifier is 48%

such high percentages of ripples is not acceptable for most of the applications. Ripples

can be removed by one of the following methods of filtering.

(a) A capacitor, in parallel to the load, provides an easier by –pass for the ripples

voltage though it due to low impedance. At ripple frequency and leave the D.C. to

appear at the load.

(b) An inductor, in series with the load, prevents the passage of the ripple current (due

to high impedance at ripple frequency) while allowing the d.c (due to low resistance

to d.c).

(c) Various combinations of capacitor and inductor, such as L-section filter section

filter, multiple section filter etc. which make use of both the properties mentioned in

(a) and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and

another with full wave rectifier.

Filtering is performed by a large value electrolytic capacitor connected across

the DC supply to act as a reservoir, supplying current to the output when the varying

DC voltage from the rectifier is falling. The capacitor charges quickly near the peak

of the varying DC, and then discharges as it supplies current to the output. Filtering

28

Page 29: Automatic Irrigation System

significantly increases the average DC voltage to almost the peak value (1.4 × RMS

value).

To calculate the value of capacitor(C),

C = ¼*√3*f*r*Rl

Where,

f = supply frequency,

r = ripple factor,

Rl = load resistance

Note: In our circuit we are using 1000µF hence large value of capacitor is placed to

reduce ripples and to improve the DC component.

4.2.4 Regulators

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

variable output voltages. The maximum current they can pass also rates them.

Negative voltage regulators are available, mainly for use in dual supplies. Most

regulators include some automatic protection from excessive current ('overload

protection') and overheating ('thermal protection'). Many of the fixed voltage

regulators ICs have 3 leads and look like power transistors, such as the 7805 +5V 1A

regulator shown on the right. The LM7805 is simple to use. You simply connect the

positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC)

to the Input pin, connect the negative lead to the Common pin and then when you turn

on the power, you get a 5 volt supply from the output pin.

Fig4.11: A Three Terminal Voltage Regulator

78XX

The Bay Linear LM78XX is integrated linear positive regulator with three

terminals. The LM78XX offer several fixed output voltages making them useful in

wide range of applications. When used as a zener diode/resistor combination

29

Page 30: Automatic Irrigation System

replacement, the LM78XX usually results in an effective output impedance

improvement of two orders of magnitude, lower quiescent current. The LM78XX is

available in the TO-252, TO-220 & TO-263packages,

FEATURES:

Output Current of 1.5A

Output Voltage Tolerance of 5%

Internal thermal overload protection

Internal Short-Circuit Limited

Output Voltage 5.0V, 6V, 8V, 9V, 10V, 12V, 15V, 18V, 24V.

4.3 LIQUID CRYSTAL DISPLAY

4.3.1 Introduction to LCD

In recent years the LCD is finding widespread use replacing LED s (seven-

segment LED or other multi segment LED s). This is due to the following reasons:

The declining prices of LCD s.

The ability to display numbers, characters and graphics. This is in contract to LED s,

which are limited to numbers and a few characters.

Incorporation of a refreshing controller into the LCD, there by relieving the CPU of

the task of refreshing the LCD. In the contrast, the LED must be refreshed by the

CPU to keep displaying the data.

Ease of programming for characters and graphics.

USES:

The LCD s used exclusively in watches, calculators and measuring

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

data. The recent advances in technology have resulted in better legibility, more

information displaying capability and a wider temperature range. These have resulted

30

Page 31: Automatic Irrigation System

in the LCD s being extensively used in telecommunications and entertainment

electronics. The LCD s has even started replacing the cathode ray tubes (CRTs) used

for the display of text and graphics, and also in small TV applications.

S p e c i f i c a t i o n s :

Number of Characters: 16 characters x 2 Lines

Character Table: English-European (RS in Datasheet)

Module dimension: 80.0mm x 36.0mm x 13.2mm(MAX)

View area: 66.0 x 16.0 mm

Active area: 56.2 x 11.5 mm

Dot size: 0.56 x 0.66 mm

Dot pitch: 0.60 x 0.70 mm

Character size: 2.96 x 5.46 mm

Character pitch: 3.55 x 5.94 mm

LCD type: STN, Positive, Transflective, Yellow/Green

Duty: 1/16

View direction: Wide viewing angle

Backlight Type: yellow/green LED

RoHS Compliant: lead free

Operating Temperature: -20°C to + 70°C

4.3.2 LCD PIN description31

Page 32: Automatic Irrigation System

FIG4.12: LCD PIN DIAGRAM

LCD pin description

The LCD discussed in this section has 14 pins. The function of each pin is given in

table.

Pin Symbol I/O Description

1 Vss -- Ground

2 Vcc -- +5V power supply

3 VEE -- Power supply to

control contrast

4 RS I RS=0 to select

command register

RS=1 to select

data register

5 R/W I R/W=0 for write

R/W=1 for read

6 E I/O Enable

7 DB0 I/O The 8-bit data bus

8 DB1 I/O The 8-bit data bus

9 DB2 I/O The 8-bit data bus

10 DB3 I/O The 8-bit data bus

11 DB4 I/O The 8-bit data bus

12 DB5 I/O The 8-bit data bus

13 DB6 I/O The 8-bit data bus

14 DB7 I/O The 8-bit data bus

TABLE 4.4: Pin description for LCD

Code Command to LCD Instruction

32

Page 33: Automatic Irrigation System

(hex) Register

1 Clear display screen

2 Return home

4 Decrement cursor

6 Increment cursor

5 Shift display right

7 Shift display left

8 Display off, cursor off

A Display off, cursor on

C Display on, cursor off

E Display on, cursor on

F Display on, cursor blinking

10 Shift cursor position to left

14 Shift cursor position to right

18 Shift the entire display to the left

1C Shift the entire display to the right

80 Force cursor to beginning of 1st line

C0 Force cursor to beginning of 2nd line

38 2 lines and 5x7 matrix

TABLE 4.5: LCD Command Codes

LCD INTERFACING

Sending commands and data to LCD s with a time delay

33

Page 34: Automatic Irrigation System

To send any command from table 2 to the LCD, make pin RS=0. For data,

make RS=1.Then place a high to low pulse on the E pin to enable the internal latch of

the LCD.

4.4 RELAY

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 positions 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 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 relays with 4 sets of changeover contacts are readily

available. For further information about switch contacts and the terms used to

describe them please see the page on switches.

34

Page 35: Automatic Irrigation System

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 connections. 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 animated picture shows a working relay with its coil and switch contacts. You

can see a lever on the left being attracted by magnetism when the coil is switched on.

This lever moves the switch contacts. There is one set of contacts (SPDT) in the

foreground and another behind them, making the relay DPDT.

Fig4.13: Block diagram of Relay

The relay's switch connections are usually labeled as 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.

Choosing a relay

You need to consider several features when choosing a relay:

Physical size and pin arrangement If you are choosing a relay for an existing

PCB you will need to ensure that its dimensions and pin arrangement are suitable.

You should find this information in the supplier's catalogue.

Coil voltage the relay's coil voltage rating and resistance must suit the circuit

powering the relay coil. Many relays have a coil rated for a 12V supply but 5V and

35

Page 36: Automatic Irrigation System

24V relays are also readily available. Some relays operate perfectly well with a supply

voltage which is a little lower than their rated value.

Coil resistance the circuit must be able to supply the current required by the

relay coil. You can use Ohm's law to calculate the current:

Relay coil current   =    supply voltage  

  coil resistance

For example: A 12V supply relay with a coil resistance of 400 passes a

current of 30mA. This is OK for a 555 timer IC (maximum output current 200mA),

but it is too much for most ICs and they will require a transistor to amplify the

current.

Switch ratings (voltage and current) the relay's switch contacts must be

suitable for the circuit they are to control. You will need to check the voltage and

current ratings. Note that the voltage rating is usually higher for AC, for example:

"5A at 24V DC or 125V AC".

Switch contact arrangement (SPDT, DPDT etc). Most relays are SPDT or

DPDT which are often described as "single pole changeover" (SPCO) or "double pole

changeover" (DPCO). For further information please see the page on switches

Protection diodes for relays

Transistors and ICs (chips) must be protected from the brief high voltage

'spike' produced when the relay coil is switched off. The diagram shows how a signal

diode (e.g. 1N4148) is connected across the relay coil to provide this protection. Note

that the diode is connected 'backwards' so that it will normally not conduct.

Conduction only occurs when the relay coil is switched off, at this moment current

tries to continue flowing through the coil and it is harmlessly diverted through the

diode. Without the diode no current could flow and the coil would produce a

damaging high voltage 'spike' in its attempt to keep the current flowing.

Relays and transistors compared

Like relays, transistors can be used as an electrically operated switch. For

switching small DC currents (< 1A) at low voltage they are usually a better choice

than a relay. However transistors cannot switch AC or high voltages (such as mains

electricity) and they are not usually a good choice for switching large currents (> 5A).

In these cases a relay will be needed, but note that a low power transistor may still be

36

Page 37: Automatic Irrigation System

needed to switch the current for the relay's coil! The main advantages and

disadvantages of relays are listed below:

Advantages of relays:

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

Relays can switch high voltages, transistors cannot.

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

Relays can switch many contacts at once.

Disadvantages of relays:

Relays are bulkier than transistors for switching small currents.

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

per second.

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

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

transistor may be needed to switch the current for the relay's coil.

Details

These SPDT relays covers switching capacity of 10A in spite of miniature size for

PCB Mount.

Contact Rating

12A at 120VAC

10A at 120VAC

10A at 24VDC

Coil

Resistance400ohm12VDC

Life expectancy

Mechanical 10,000,000 operation sat no load

Electrical 100,000 at rated resistive load

Applications:

Domestic Appliances

Office Machines

Audio Equipment

37

Page 38: Automatic Irrigation System

4.5 LM324 OPERATIONAL AMPLIFIER:

This device consists of 14 pins. It consists of four independent, high gain,

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 operation amplifier 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.

The below is the figure of LM 324 quad operational device showing the function of

each pin

Fig 4.14. LM324 PIN DISCIPTION

38

Page 39: Automatic Irrigation System

4.6 MOISTURE SENSOR

A soil moisture sensor is a water conservation accessory for conventional

automatic irrigation controllers with the potential for eliminating excessive irrigation

cycles. Soil moisture sensor

Fig 4.15: Moisture Sensor

Soil moisture sensors measure the water contain in soil. A soil moisture probe

is made up of multiple soil moister sensors. One common type of soil moisture sensor

ins in commercial use & a frequency domain sensors such as a capacitance sensor.

Another sensor the neutron moister gauge, utilize the modulator properties of water

for neutron. By simply inserting the soil moisture sensors in the soil to be tested and

volumetric water content of soil is reported in percent. Soil moisture sensors are used

to conduct experiments in ecology, environmental science and agricultural science ,

horticulture , biology and more.

39

Page 40: Automatic Irrigation System

4.7. DC MOTOR

An electric motor is a machine which converts electrical energy into

mechanical energy.

DC motors are configured in many types and sizes, including brush less,

servo, and gear motor types. A motor consists of a rotor and a permanent magnetic

field stator. The magnetic field is maintained using either permanent magnets or

electromagnetic windings. DC motors are most commonly used in variable speed and

torque.

Motion and controls cover a wide range of components that in some way are

used to generate and/or control motion. Areas within this category include bearings

and bushings, clutches and brakes, controls and drives, drive components, encoders

and resolves, Integrated motion control, limit switches, linear actuators, linear and

rotary motion components, linear position sensing, motors (both AC and DC motors),

orientation position sensing, pneumatics and pneumatic components, positioning

stages, slides and guides, power transmission (mechanical), seals, slip rings, solenoids

springs.

Motors are the devices that provide the actual speed and torque in a drive

system.  This family includes AC motor types (single and multiphase motors,

universal, servo motors, induction, synchronous, and gear motor) and DC motors

(brush less, servo motor, and gear motor) as well as linear, stepper and air motors, and

motor contactors and starters.

In any electric motor, operation is based on simple electromagnetism. A

current-carrying conductor generates a magnetic field; when this is then placed in an

external magnetic field, it will experience a force proportional to the current in the

conductor, and to the strength of the external magnetic field. As you are well aware of

from playing with magnets as a kid, opposite (North and South) polarities attract,

while like polarities (North and North, South and South) repel. The internal

configuration of a DC motor is designed to harness the magnetic interaction between

a current-carrying conductor and an external magnetic field to generate rotational

motion.

40

Page 41: Automatic Irrigation System

Let's start by looking at a simple 2-pole DC electric motor (here red

represents a magnet or winding with a "North" polarization, while green represents a

magnet or winding with a "South" polarization).

Fig:4.16. DC.Motor

Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator,

commutator, field magnet(s), and brushes. In most common DC motors (and all that

Beamers will see), the external magnetic field is produced by high-strength permanent

magnets1. The stator is the stationary part of the motor -- this includes the motor

casing, as well as two or more permanent magnet pole pieces. The rotor (together with

the axle and attached commutator) rotates with respect to the stator. The rotor consists

of windings (generally on a core), the windings being electrically connected to the

commutator. The above diagram shows a common motor layout -- with the rotor

inside the stator (field) magnets.

The geometry of the brushes, commutator contacts, and rotor windings are

such that when power is applied, the polarities of the energized winding and the stator

magnet(s) are misaligned, and the rotor will rotate until it is almost aligned with the

stator's field magnets. As the rotor reaches alignment, the brushes move to the next

commutator contacts, and energize the next winding. Given our example two-pole

motor, the rotation reverses the direction of current through the rotor winding, leading

to a "flip" of the rotor's magnetic field, and driving it to continue rotating.

Principle of operation

    It is based on the principle that when a current-carrying conductor is placed in a

magnetic field, it experiences a mechanical force whose direction is given by

Fleming's Left-hand rule and whose magnitude is given by

                     

41

Page 42: Automatic Irrigation System

Force, F = B I l Newton     

                   Where B is the magnetic field in weber/m2.

                   I is the current in amperes and  l is the length of the coil in meter.             

The force, current and the magnetic field are all in different directions. 

    If an Electric current flows through two copper wires that are between the poles of

a magnet, an upward force will move one wire up and a downward force will move

the other wire down.     

   

Figure 4.17: Force in DC MotorFigure 4.18 :Magnetic Field in DC

Motor

Figure 4.19:  Torque in DC

Motor

Figure 4.20 : Current Flow in DC

Motor

   

The loop can be made to spin by fixing a half circle of copper which is known

as commutator, to each end of the loop. Current is passed into and out of the loop by

brushes that press onto the strips. The brushes do not go round so the wire do not get

twisted. This arrangement also makes sure that the current always passes down on the

42

Page 43: Automatic Irrigation System

right and back on the left so that the rotation continues. This is how a simple Electric

motor is made.

5. SCHEMATIC DIAGRAM

Fig.5.1. Circuit Diagram OF AUTOMATIC IRRIGATION SYSTEM

43

Page 44: Automatic Irrigation System

6. EXECUTION DETAILS

6.1 µ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.

Building an Application in µVision2

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

Select Project - (for example, 166\EXAMPLES\HELLO\HELLO.UV2).

Select Project - Rebuild all target files or Build target.

5.2. STEPS FOR SOURCE CODE CREATION

µVision2 compiles, assembles, and links the files in your project.

Creating Your Own Application in µVision2

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

Select Project - New Project.

Select a directory and enter the name of the project file.

Select Project - Select Device and select an 8051, 251, or C16x/ST10 device

from the Device Database™.

Create source files to add to the project.

44

Page 45: Automatic Irrigation System

Select Project - Targets, Groups, Files, Add/Files, select Source Group1, and

add the source files to the project.

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.

Select Project - Rebuild all target files or Build target.

Debugging an Application in µVision2

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

Select Debug - Start/Stop Debug Session.

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.

Open the Serial Window using the Serial #1 button on the toolbar.

Debug your program using standard options like Step, Go, Break, and so on.

Starting µVision2 and creating a Project

µVision2 is a standard Windows application and started by clicking on the

program icon. To create a new project file select from the µVision2 menu

Project –

New Project…. This opens a standard Windows dialog that asks you for the

new project file name.

We suggest that you use a separate folder for each project. You can simply use

the icon Create New Folder in this dialog to get a new empty folder. Then select this

folder and enter the file name for the new project, i.e. Project1.

µVision2 creates a new project file with the name PROJECT1.UV2 which contains a

default target and file group name. You can see these names in the Project

Window Files

Now use from the menu Project – Select Device for Target and select a CPU

for your project. The Select Device dialog box shows the µVision2 device database.

Just select the microcontroller you use. We are using for our examples the Philips

45

Page 46: Automatic Irrigation System

80C51RD+ CPU. This selection sets necessary tool options for the 80C51RD+ device

and simplifies in this way the tool Configuration

Building Projects and Creating a HEX Files

Typical, the tool settings under Options – Target are all you need to start a

new application. You may translate all source files and line the application with a

click on the Build Target toolbar icon. When you build an application with syntax

errors, µVision2 will display errors and warning messages in the Output

Window – Build page. A double click on a message line opens the source file on the

correct location in a µVision2 editor window.

Once you have successfully generated your application you can start debugging.

After you have tested your application, it is required to create an Intel HEX

file to download the software into an EPROM programmer or simulator. µVision2

creates HEX files with each build process when Create HEX files under Options for

Target – Output is enabled. You may start your PROM programming utility after the

make process when you specify the program under the option Run User Program #1.

CPU Simulation

µVision2 simulates up to 16 Mbytes of memory from which areas can be

mapped for read, write, or code execution access. The µVision2 simulator traps and

reports illegal memory accesses being done.

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.

46

Page 47: Automatic Irrigation System

Start Debugging

You start the debug mode of µVision2 with the Debug – Start/Stop Debug

Session command. Depending on the Options for Target – Debug Configuration,

µVision2 will load the application program and run the startup code µVision2 saves

the editor screen layout and restores the screen layout of the last debug session. If the

program execution stops, µVision2 opens an editor window with the source text or

shows CPU instructions in the disassembly window. The next executable statement is

marked with a yellow arrow. During debugging, most editor features are still

available.

For example, you can use the find command or correct program errors.

Program source text of your application is shown in the same windows. The µVision2

debug mode differs from the edit mode in the following aspects:

The “Debug Menu and Debug Commands” described on page 28 are

Available. The additional debug windows are discussed in the following.

The project structure or tool parameters cannot be modified. All build

Commands are disabled.

Disassembly Window

The Disassembly window shows your target program as mixed source and

assembly program or just assembly code. A trace history of previously executed

instructions may be displayed with Debug – View Trace Records. To enable the trace

history, set Debug – Enable/Disable Trace Recording.

If you select the Disassembly Window as the active window all program step

commands work on CPU instruction level rather than program source lines. You can

select a text line and set or modify code breakpoints using toolbar buttons or the

context menu commands.

You may use the dialog Debug – Inline Assembly… to modify the CPU

instructions. That allows you to correct mistakes or to make temporary changes to the

target program you are debugging.

47

Page 48: Automatic Irrigation System

7.FUTURE SCOPE

We can implement this module in golf fields and public gardens. Electronic

Gardner is a prototype for an automatic irrigation system that can be used in wide

landscapes. The main advantage of this module is with out observation of farmer the

motor pump automatically switch on or off motor by using the moisture sensors.

Saves time, Saves water. An automatic irrigation system can save you literally

thousands of gallons of water a year simply by remembering to turn itself off at the

right time. Protects your financial investment. An attractively landscaped exterior,

with lush growth and healthy plants, helps your house project that fresh.

48

Page 49: Automatic Irrigation System

8. CONCLUSION

In present days especially farmers are facing major problems in watering

their agriculture fields, it’s because they have no proper idea about when the power is

available so that they can pump water. Even after then they need to wait until the field

is properly watered, which makes them to stop doing other activities. Here is an idea

which helps not only farmers even for watering the gardens also, which senses the soil

moisture and switches the pump automatically when the power is ON.

Electronic Gardner is a prototype for an automatic irrigation system that can

be used in wide landscapes. Properly installed, maintain and managed system can be

implemented in large fields like public gardens, lawns, golf fields etc.

49

Page 50: Automatic Irrigation System

50

Page 51: Automatic Irrigation System

9. BIBLOGRAPHY

1. 8051-mirocontrolar and embedded system.

-Mohd. Mazidi.

2. Micro processor Architecture, Programming & Applications

-Ramesh S.Gaonkar.

3. Electronic Components

-D.V.Prasad.

4. www.atmel.com

5. www.microsoftsearch.com

6. www.kiel.com

7. www.wikipedia.com

51