You are on page 1of 50

Micro controller based automated irrigation system

OVERVIEW
1.1 Introduction:
Irrigation system uses valves to turn irrigation ON and OFF. These valves may be easily automated by using controllers and solenoids. Automating farm or nursery irrigation allows farmers to apply the right amount of water at the right time, regardless of the availability of labor to turn valves on and off. In addition, farmers using automation equipment are able to reduce runoff from over watering saturated soils, avoid irrigating at the wrong time of day, which will improve crop performance by ensuring adequate water and nutrients when needed. Automatic Drip Irrigation is a valuable tool for accurate soil moisture control in highly specialized greenhouse vegetable production and it is a simple, precise method for irrigation. It also helps in time saving, removal of human error in adjusting available soil moisture levels and to maximize their net profits.

Dept. Of E&C, MCE, Hassan

Page 1

Micro controller based automated irrigation system

Block Diagram:

Fig: 1.1 Block diagram

1.2 Problem Definition:


Farm Lands & Fields situated miles away from your home. Extensive travel required, sometimes several times in a day to start & stop the irrigation water pumps. Rough & Tough terrains and bad roads in country sides make the travel all the more tedious. Long walk-ways in remote agricultural lands also face associated threats from wild animals, bugs, bees, spiders, snakes, scorpions and other potential hazards from lightning or electrical shock. Hostile weather can play a havoc endangering the life of Farmers. Reaching pump house at times can turn out to be a night mare. Availability of non-stop power is scarce in many of the villages around India, resulting in several trips a day to

Dept. Of E&C, MCE, Hassan

Page 2

Micro controller based automated irrigation system operate the pumps. Protecting your equipment from theft and power fluctuations could also be a serious concern for many.

1.3 Methodology:
Implemented project is carried out using an ATMEL 89S52 microcontroller , which is programmed using the Keil microvision2 software .the LCD is connected to port0 of the micro controller to display the alert message. The microcontroller is connected to the GSM modem using DB9 cable. The sending of information across network via sms is possible using AT (attention) commands serially to the GSM module.

1.4 Working:
Here we have designed a module using a microcontroller and GSM. Once the three phase power comes module will send an SMS to authenticated users. If the farmer wants to switch on the motor he just needs to give a ring to the particular modem no which is implemented near the motor. microcontroller checks whether the call is coming from authenticated person, if it matches it will start the motor. If the password doesnt match means some other person is calling then no action will be taken. In every stage it will send the status to the farmer(authenticated user).i.e., whether the motor is on or off by the ring. If the motor is on by ring and the farmer needs to switch off he just needs to call back to the same number. The complete operation can be handled by sending SMS also that is by sending ON motor gets on, and by sending OFF motor gets OFF. As the farmers dont have sufficient knowledge for sending SMS we implemented calling future here. We have one more future called auto switch. If this switch is in ON STATE the motor gets on instantly the three phase power comes .i.e there is no need of calling or sending the SMS. Once the motor is on the module send sms like motor is on by auto switch. If the farmer wants to switch off he just needs to call back to the particular GSM number which we have implemented in module. Dept. Of E&C, MCE, Hassan Page 3

Micro controller based automated irrigation system

1.5 Limitation of the project:


The system works wherever there is coverage of a local Mobile Network (GSM). The loss of user cell phone would lead to the miss handling of the device.

1.6 Literature survey:


To carry out the project in a phased manner it is necessary to conduct the literature survey. To establish communication we use the concept of wireless communication. The fundamental concept and information about wireless communication is excellently described by Theodre S Rappaport. Mobile computing service creation are completely discussed by Asoke K Talukder, Roopa R Yavagal in Mobile computing, Technology Applications and Service creations. The information regarding the latest developments in GSM have been obtained from the websites www.gsmworld.com. Various websites have been visited to get necessary information. The project is implemented using Embedded C language. To develop the code for establishing communication between the terminals, we have refer to the books of The Complete Reference C. Knowledge about the usage of AT commands to exchange Short Message Service (SMS) was learnt from AT commands Manual. The information regarding programming in C was referred from Muhammed Ali Mazidi, Janice Gillispie Mazidi, Rollin D. Mc Kinlay, The 8051 Microcontroller and Embedded System using Assembly and C and the 8051 Microcontroller and Embedded System, by Kenneth J Ayala.

1.7 Merits:

Dept. Of E&C, MCE, Hassan

Page 4

Micro controller based automated irrigation system The main advantage of this module is the farmer can remotely switch on or off motor by using his mobile phone and he can be anywhere in the world. Saves time. No more spending long hours watering with a hose. You won't have to worry about remembering to move the hose every 20 minutes either. Your new systems will do all the remembering for you. 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. Your home's appearance is an important factor in determining its market value. An attractively landscaped exterior, with lush growth and healthy plants, helps your house project that fresh, well-maintained look.

2. HARDWARE DETAILS

Dept. Of E&C, MCE, Hassan

Page 5

Micro controller based automated irrigation system

2.1 Introduction to ATMEL 89S52 microcontroller:


The AT89S52 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pinout. The on chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89S52 is a low-power, high-performance CMOS 8-bit microcomputer with 4Kbytes of Flash programmable and erasable read only memory (EPROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcomputer which provides highly-flexible and cost-effective solution to many embedded control applications. The AT89S52 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition, the AT89S52 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

2.2 Pin Diagram

Dept. Of E&C, MCE, Hassan

Page 6

Micro controller based automated irrigation system

Fig: 2.1 Pin diagram of 89S52

2.3 Block Diagram

Dept. Of E&C, MCE, Hassan

Page 7

Micro controller based automated irrigation system

Fig: 2.2 Block diagram of 89S52

2.4 Ports
Dept. Of E&C, MCE, Hassan Page 8

Micro controller based automated irrigation system

Port 0 Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance inputs. Port 0 can 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 pullups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pullups are required during program verification. Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pullups. 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 pullups 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 pullups. 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 pullups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high byte internal pullups 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 pullups. 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 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

Dept. Of E&C, MCE, Hassan

Page 9

Micro controller based automated irrigation system Port 3 is an 8-bit bi-directional I/O port with internal pullups. 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 pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups. Port 3 also serves the functions of

Table 2.1 Port3 Pin Description

2.5 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 2.3. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Fig 2.4. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.

Dept. Of E&C, MCE, Hassan

Page 10

Micro controller based automated irrigation system

Fig: 2.3 Oscillator connection

Fig: 2.4 External clock drive configuration

2.6 RS 232 STANDARDS


To allow compatibility among data communication equipment made by various manufacturers, an interfacing standard called RS232 was set by the Electronics Industries Association (EAI) in 1960.In 1963 it was modified and called RS 232A, RS232B and RS232C.This standard is used in PCs and numerous types of equipment. However, since the standard was set long before the advent of TTL logic family, its input and output voltage levels are not TTL compatible. In RS 232, a 1is represented by -3 to -25 volt, while 0 bit is +3 to +25 v, making -3 to +3 undefined. For this reason, to connect any RS232 to

Dept. Of E&C, MCE, Hassan

Page 11

Micro controller based automated irrigation system microcontroller system we must use voltage converter such as MAX232 to convert the TTL logic level 2 to the RS232 voltage level, and vice versa. RS232 HANDSHAKING SIGNALING To ensure fast and reliable data transmission between two devices, data transfer must be coordinated. Just as in case of printer , due to the fact that in serial data communication the receiving device may have no room for the data, there must a way to inform the sender to stop sending data. Many of the pins of the RS232 connector are used for handshaking signals. DTR (data terminal ready).When the terminal (or a PC COM port) is turned on, after going through a self-test, it sends out signal DTR to indicate that it is ready for communication.

DSR (data set ready).When DC (modem) is turned on and has gone through the self-test, it asserts DSR to indicate that it is ready to communicate.

RTS(request to send).When the DTE device(such as PC)has a byte to transmit it asserts RTS to signal modem that it has byte or data to transmit.RTS is an activelow output from the DTE and an input to the modem.

CTS(clear to send ) .In response to RTS, when the modem has room for storing the data it is to receive, it sends out signal CTS to the DTE (PC) to indicate that it can receive data now.

Dept. Of E&C, MCE, Hassan

Page 12

Micro controller based automated irrigation system DCD (carrier detect, or DCD, data carrier detect).The modem asserts signal DCD to inform the DTE (PC) that a valid carrier has been detected and that contact between it and the other modem is established.

RI (ring indicator).An output from the modem (DCE) and an input to a PC (DTE) indicates that telephone is ringing and it goes on and off in synchronization with the ringing sound.

RS232 Pins: The pins and their labels for the RS232 cable, commonly referred to as DB 9 connector which uses 9 pins as shown in the figure. Pin
1 2 3 4 5 6 7 8 9

Description Data carrier detect [DCD] Receive data [RXD] Transmitted date [TXD] Data terminal ready [DTR] Signal ground [GND] Data set ready [DSR] Request to send [RTS] Clear to send [CTS] Ring indicator [RI]

Dept. Of E&C, MCE, Hassan

Page 13

Micro controller based automated irrigation system

Fig: 2.5 DB-9 9-PIN CONNECTOR The MAX232 has two sets of line drivers for transferring and receiving data, as shown in fig. 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. In MAX232 that the T1 line driver has designation of T1 IN and T1 OUT on pin no 11 and 14, respectively. The T1 IN pin is the TTL side and is connected to TxD of the microcontroller, while T1 OUT is the RS232 side that is connected to the RxD pin of RS232 DB connector. The R1 line driver has a designation of R1 IN and R1 OUT on pin no 13 and 12, respectively. R1 IN (pin 13) is the RS 232 side that is connected to the TxD pin of the RS232 DB connector and R! OUT (pin 12)is the TTL side that is connected to RxD pin of the microcontroller ,as shown in fig2.6. Max232 requires 4 capacitors ranging from 1 to 22 microfarad. The most widely used value for these capacitors is 22 microfarad.

Dept. Of E&C, MCE, Hassan

Page 14

Micro controller based automated irrigation system

Fig 2.6

INSIDE CONFIGURATION OF MAX232

Dept. Of E&C, MCE, Hassan

Page 15

Micro controller based automated irrigation system

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

Program Memory Lock Bits


Dept. Of E&C, MCE, Hassan Page 16

Micro controller based automated irrigation system

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

Lock Bit Protection Modes

Program Lock Bits LB1 1 U LB2 U LB3 U

Protection Type

No program lock features MOVC instructions executed from external program memory EA are is

disabled from fetching code bytes from internal memory, sampled and latched on reset, and further programming of the Flash is disabled. Same as mode 2, also verify is disabled Same as mode 3, also external execution is disabled.

3 4

P P

P P

U P

Table2.1: protection modes

Programming the Flash


The AT89S52 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 Dept. Of E&C, MCE, Hassan Page 17

Micro controller based automated irrigation system interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The low-voltage programming mode provides a convenient way to program the AT89S52 inside the users system, while the high-voltage programming mode is compatible with conventional third party Flash or EPROM programmers. The AT89S52 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 VPP = 12V AT89S52 xxxx Signature yyww (030H) = 1EH (031H) = 51H (032H) =F FH Table2.2: Device signature codes The AT89S52 code memory array is programmed byte-by byte in either programming mode. To program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased using the Chip Erase Mode. VPP = 5V AT89S52 xxxx-5 yyww (030H) = 1EH (031H) = 51H (032H) = 05H

Top-side Mark

Programming Algorithm
Before programming the AT89S52, the address, data and control signals should be set up according to the Flash programming mode table and Figure 3 and Figure 4. To program the AT89S52, take the following steps. Dept. Of E&C, MCE, Hassan Page 18

Micro controller based automated irrigation system Input the desired memory location on the address lines. Input the appropriate data byte on the data lines. Activate the correct combination of control signals. Raise EA/VPP to 12V for the high-voltage programming mode. 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 AT89S52 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: 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 1s. The chip erase operation must be executed before the code memory can be re-programmed.

Dept. Of E&C, MCE, Hassan

Page 19

Micro controller based automated irrigation system

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 89S52 (032H) = FFH indicates 12V programming (032H) = 05H indicates 5V programming

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.

Flash Programming Modes

Mode

RST

PSEN

ALE/PROG

EA/VPP

P2.6

P2.7

P3.6

P3.7

Dept. Of E&C, MCE, Hassan

Page 20

Micro controller based automated irrigation system

Write Code Data

H/12V

Read Code Data

Bit - 1 Write Lock Bit - 2

H/12V

H/12V

Bit - 3

H/12V

Chip Erase

L 1)

H/12V

Read Signature Byte

Table2.3: flash programming modes

2.7 Circuit Diagram

Dept. Of E&C, MCE, Hassan

Page 21

Micro controller based automated irrigation system

Dept. Of E&C, MCE, Hassan

Page 22

Micro controller based automated irrigation system

Fig 2.7: Programming the Flash

Dept. Of E&C, MCE, Hassan

Page 23

Micro controller based automated irrigation system

Fig 2.8: Verifying the Flash

Dept. Of E&C, MCE, Hassan

Page 24

Micro controller based automated irrigation system Flash Programming and Verification Waveforms - High-voltage Mode (VPP = 12V)

Flash Programming and Verification Waveforms - Low-voltage Mode (VPP = 5V)

Dept. Of E&C, MCE, Hassan

Page 25

Micro controller based automated irrigation system

3. GSM AND AT COMMANDS


3.1 Overview and GSM architecture
The GSM network was designed keeping in mind the voice activities of the user and its main purpose was to provide voice connectivity like Public Switched Telephone Networks but with mobility. So Call Processing activities were the major criteria to decide and fix the implementation standards of GSM. The data communication was of secondary importance to this network but to support this also, designers have considered the circuit switching itself the mechanism for transmitting data packets.

BSC SIM BTS ME BTS Um Mobile Station Abis A Base Station Subsystem BSC

HLR RR MSC

VLR PSTN, ISDN,PSPD N CSPDN

EIR

AuC

Network Subsystem

Fig. 3.1 GSM architecture

Dept. Of E&C, MCE, Hassan

Page 26

Micro controller based automated irrigation system

Mobile Station
The mobile station (MS) consists of the mobile equipment (the terminal) and a smart card called the Subscriber Identity Module (SIM). The SIM provides personal mobility, so that the user can have access to subscribed services irrespective of a specific terminal. By inserting the SIM card into another GSM terminal, the user is able to receive calls at that terminal, make calls from that terminal, and receive other subscribed services. The mobile equipment is uniquely identified by the International Mobile Equipment Identity (IMEI). The SIM card contains the International Mobile Subscriber Identity (IMSI) used to identify the subscriber to the system, a secret key for authentication, and other information. The IMEI and the IMSI are independent, thereby allowing personal mobility. The SIM card may be protected against unauthorized use by a password or personal identity number.

Base Station Subsystem


The Base Station Subsystem is composed of two parts, the Base Transceiver Station (BTS) and the Base Station Controller (BSC). These communicate across the standardized Abis interface, allowing (as in the rest of the system) operation between components made by different suppliers. The Base Transceiver Station houses the radio transceivers that define a cell and handles the radio-link protocols with the Mobile Station. In a large urban area, there will potentially be a large number of BTSs deployed, thus the requirements for a BTS are ruggedness, reliability, portability, and minimum cost. The Base Station Controller manages the radio resources for one or more BTSs. It handles radio-channel setup, frequency hopping, and handovers, as described below. The BSC is the connection between the mobile station and the Mobile service Switching centre (MSC).

Network Subsystem

Dept. Of E&C, MCE, Hassan

Page 27

Micro controller based automated irrigation system The central component of the Network Subsystem is the Mobile Switching Centre (MSC). It provides all the functionality needed to handle a mobile subscriber, such as registration, authentication, location updating, handovers, and call routing to a roaming subscriber. These services are provided in conjunction with several functional entities, which together from form the Network Subsystem. The MSC provides the connection to the fixed networks (such as the PSTN or ISDN). Signaling between functional entities in the Network Subsystem uses Signaling System Number 7(SS7), used for trunk signaling in ISDN and widely used in current public networks. The Home Location Register (HLR) and Visitor Location Register (VLR), together with the MSC, provide the call-routing and roaming capabilities of GSM. The HLR contains all the administrative information of each subscriber registered in the corresponding GSM network, along with the current location of the mobile. The location of the mobile is typically in the form of the signaling address of the VLR associated with the mobile station. The actual routing procedure will be described later. There is logically one HLR per network, although it may be implemented as a distributed database. The Visitor Location Register (VLR) contains selected administrative information from the HLR, necessary for call control and provision of the subscribed services, for each mobile currently located in the geographical area controlled by the VLR. Although each functional entity can be implemented as an independent unit, all manufacturers of switching equipment to date implement the VLR together with the MSC, so that the geographical area controlled by the MSC corresponds to that controlled by the VLR, thus simplifying the signaling required. Note that the MSC contains no information about particular mobile stations--- this information is stored in the location registers. The other two registers are used for authentication and security purposes. The Equipment Identity Register (EIR) is a database that contains a list of all valid mobile equipment on the network, where each mobile station is identified by its International Mobile Equipment Identity (IMEI). An IMEI is marked as invalid if it has been reported stolen or is not type approved. The Authentication Centre (AuC) is a protected database Dept. Of E&C, MCE, Hassan Page 28

Micro controller based automated irrigation system that stores a copy of the secret key stored in each subscribers SIM card, which is used for authentication and encryption over the radio chanel.

3.2 The Switching System


The switching system (SS) is responsible for performing call processing and subscriber-related functions. The switching system includes the following functional units:

Home locations register (HLR)The HLR is a database used for storage and management of subscriptions. The HLR is considered the most important database, as it stores permanent data about subscribers, including a subscriber's service profile, location information, and activity status. When an individual buys a subscription from one of the PCS operators, he or she is registered in the HLR of that operator.

Mobile services switching center (MSC)The MSC performs the telephony switching functions of the system. It controls calls to and from other telephone and data systems. It also performs such functions as toll ticketing, network interfacing, common channel signaling, and others.

Visitor location register (VLR)The VLR is a database that contains temporary information about subscribers that is needed by the MSC in order to service visiting subscribers. The VLR is always integrated with the MSC. When a mobile station roams into a new MSC area, the VLR connected to that MSC will request data about the mobile station from the HLR. Later, if the mobile station makes a call,the VLR will have the information needed for call setup without having to interrogate the HLR each time.

Authentication center (AUC)A unit called the AUC provides authentication and encryption parameters that verify the user's identity and ensure the confidentiality of each call. The AUC protects network operators from different types of fraud found in today's cellular world.

Dept. Of E&C, MCE, Hassan

Page 29

Micro controller based automated irrigation system

Equipment identity register (EIR)The EIR is a database that contains information about the identity of mobile equipment that prevents calls from stolen, unauthorized, or defective mobile stations. The AUC and EIR are implemented as stand-alone nodes or as a combined AUC/EIR node.

The Base Station System (BSS)


All radio-related functions are performed in the BSS, which consists of base station controllers (BSCs) and the base transceiver stations (BTSs). BSC The BSC provides all the control functions and physical links between the MSC and BTS. It is a high-capacity switch that provides functions such as handover, cell configuration data, and control of radio frequency (RF) power levels in base transceiver stations. A number of BSCs are served by an MSC. BTSThe BTS handles the radio interface to the mobile station. The BTS is the radio equipment (transceivers and antennas) needed to service each cell in the network. A group of BTSs are controlled by a BSC.

Additional Functional Elements

Dept. Of E&C, MCE, Hassan

Page 30

Micro controller based automated irrigation system Message center (MXE)The MXE is a node that provides integrated voice, fax, and data messaging. Specifically, the MXE handles short message service, cell broadcast, voice mail, fax mail, e-mail, and notification. Mobile service node (MSN)The MSN is the node that handles the mobile intelligent network (IN) services. Gateway mobile services switching center (GMSC)A gateway is a node used to interconnect two networks. The gateway is often implemented in an MSC. The MSC is then referred to as the GMSC. GSM interworking unit (GIWU)The GIWU consists of both hardware and software that provides an interface to various networks for data communications.

3.3 AT commands

Dept. Of E&C, MCE, Hassan

Page 31

Micro controller based automated irrigation system

3.3.1 Send message +CMGS


Description: The <address> field is the address of the terminal to which the message is sent. To send the message, simply type, <ctrl-Z> character (ASCII 26). The text can contain all existing characters except <ctrl-Z> and <ESC> (ASCII 27). This command can be aborted using the <ESC> character when entering text. In PDU mode, only hexadecimal characters are used (09,AF). Syntax: Command syntax in text mode: AT+CMGS= <da> [ ,<toda> ] <CR> text is entered <ctrl-Z / ESC > Command syntax in PDU mode: AT+CMGS= <length> <CR> PDU is entered <ctrl-Z / ESC >

Table: 3.1 Send message commands The message reference, <mr>, which is returned to the application is allocated by the product. This number begins with 0 and is incremented by one for each outgoing message (successful and failure cases); it is cyclic on one byte (0 follows 255). Note: This number is not a storage number. Outgoing messages are not stored.

3.3.2 Read message +CMGR

Dept. Of E&C, MCE, Hassan

Page 32

Micro controller based automated irrigation system Description: This command allows the application to read stored messages. The messages are read from the memory selected by +CPMS command. Syntax: Command syntax: AT+CMGR=<index> Response syntax for text mode: +CMGR:<stat>,<oa>,[<alpha>,] <scts> [,<tooa>,<fo>, <pid>,<dcs>,<sca>,<tosca>,<length>] <CR><LF> <data> (for SMS-DELIVER only) +CMGR: <stat>,<da>,[<alpha>,] [,<toda>,<fo>,<pid>,<dcs>, [<vp>], <sca>, <tosca>,<length>]<CR><LF> <data> (for SMS-SUBMIT only) +CMGR: <stat>,<fo>,<mr>,[<ra>],[<tora>],<scts>,<dt>,<st> (for SMS-STATUS REPORT only) Response syntax for PDU mode: +CMGR: <stat>, [<alpha>] ,<length> <CR><LF> <pdu> A message read with status REC UNREAD will be updated in memory with the status REC READ. Note: The <stat> parameter for SMS Status Reports is always READ. Example:

Table:3.2 read message commands

3.3.3 Write Message to Memory +CMGW

Dept. Of E&C, MCE, Hassan

Page 33

Micro controller based automated irrigation system Description: This command stores a message in memory (either SMS-SUBMIT or SMS-DELIVERS). The memory location <index> is returned (no choice possible as with phonebooks +CPBW). Text or PDU is entered as described for the Send Message +CMGS command. Syntax: Command syntax in text mode : (<index> is returned in both cases) AT+CMGW= <oa/da> [,<tooa/toda> [,<stat> ] ] <CR> enter text <ctrl-Z / ESC> Command syntax in PDU mode : AT+CMGW= <length> [,<stat>] <CR> give PDU <ctrl-Z / ESC> Response syntax: +CMGW: <index> or +CMS ERROR: <err> if writing fails

Table:3.3 Write Message to Memory commands

Defined values:

Dept. Of E&C, MCE, Hassan

Page 34

Micro controller based automated irrigation system Parameter Definition: <oa/da> : Originating or Destination Address Value in string format. <tooa/toda> : Type of Originating / Destination Address. <stat> : Integer type in PDU mode (default 2 for +CMGW), or string type in text mode (default STO UNSENT for +CMGW). Indicates the status of message in memory. If <stat> is omitted, the stored message is considered as a message to send. <stat> 0: REC UNREAD 1: REC READ 2: STO UNSENT 3: STO SENT <length> Length of the actual data unit in octets

Delete message +CMGD

Dept. Of E&C, MCE, Hassan

Page 35

Micro controller based automated irrigation system Description: This command deletes one or several messages from preferred message storage (BM SMS CB RAM storage, SM SMSPP storage SIM storage or SR SMS Status-Report storage).

Syntax: Command syntax: AT+CMGD=<Index> [,<DelFalg>]

Table:3.4 Delete message commands

Defines values <index> Dept. Of E&C, MCE, Hassan Page 36

Micro controller based automated irrigation system (1-20) When the preferred message storage is BM Integer type values in the range of location numbers of SIM Message memory when the preferred message storage is SM or SR. <DelFlag> 0 Delete message at location <index>. 1 Delete All READ messages 2 Delete All READ and SENT messages 3 Delete All READ, SENT and UNSENT messages 4 Delete All messages. Note: When the preferred message storage is SR, as SMS status reports are assumed to have a READ status, if <DelFlag> is greater than 0, all SMS status reports will be deleted.

Send Message From Storage +CMSS


Description: Dept. Of E&C, MCE, Hassan Page 37

Micro controller based automated irrigation system This command sends a message stored at location value <index>.

Syntax: Command syntax: AT+CMSS=<index>[,<da> [,<toda>] ] Response syntax: +CMSS : <mr> or +CMS ERROR: <err> if sending fails If a new recipient address <da> is given, it will be used instead of the one stored with the message

Table:3.5 Send Message From Storage commands

4. FLOW CHART

Dept. Of E&C, MCE, Hassan

Page 38

Micro controller based automated irrigation system

5. SOFTWARE DETAILS
In this project we use two software.

Dept. Of E&C, MCE, Hassan

Page 39

Micro controller based automated irrigation system 1. Keil Software. 2. Atmel Flash Programmer.

5.1 KEIL SOFTWARE: Configuring uVision2 to Use Any Drive


uVision2 places all files in the drive:/folder specified by the user when a New Project is defined. The drive used must be one that can be written to. Identify or create a new folder on the desired drive and start uVision2. Open the Projects menu and select New Project. A Create New Project Window will appear with a Save in box where the project files are to be stored. Browse until the desired disk and folder are found and type in a project name. Click the Save button. A uVision2 project (.UV2) file has now been created in the folder, along with a project log (.PLG) file.

Fig5.1:Snapshot showing the creation of new project

Dept. Of E&C, MCE, Hassan

Page 40

Micro controller based automated irrigation system The Files window will show a "Target 1" folder, and a "Select Device for Target 'Target 1' " window will appear. Browse to the Intel folder, open it, and select 89S52. Expanding the Target 1 folder in the Files window shows that it contains a sub-folder named "Source Group 1. Open the project menu. In that select the Targets, Groups, Files. Select the Groups/add files which pop up the Add files to Group Source Group 1 window.

Fig5.2:Snapshot showing the edition of source file to project Unless a C code source program with the same name as the one typed into the File name box exists, it must be created. (A red "X" next to the source file name indicated uVision2 cannot find it).

Dept. Of E&C, MCE, Hassan

Page 41

Micro controller based automated irrigation system

EPROM Programming Using uVision2 HEX Output Files If EPROMs are to be programmed, a project.HEX file must be created by uVision2. Go to the Project menu and select Options for Target 'name'. From the Options window, select the Output tab and check the Create HEX File box before closing the window.

Fig5.3: selecting output as HEX format

Dept. Of E&C, MCE, Hassan

Page 42

Micro controller based automated irrigation system

To compile the code open the project menu. In that select the build target option. The HEX file will be created at the specified location.

Fig5.4: compiled output Variables within a processor are represented by either bits, bytes, words or long words, corresponding to 1, 8, 16 and 32-bits per variable. C51 variables are similarly based, for example: Bit = 1 bit char = 8 bits unsigned char = 8 bits int = 16 bits unsigned int = 16 bits long = 32 bits unsigned long = 32 bits float = 32 bits 0-1 0 - +/- 127 0 - 255 0 - +/-32768 0 - 65535 0 - +/- 2.147483648x109 0 - 4.29496795x109 +/-1.176E-38 to +/-3.4E+38 Page 43

Dept. Of E&C, MCE, Hassan

Micro controller based automated irrigation system pointer = 24/16/8 bits Variable address

5.2 Atmel Flash Programmer:


Flash programmer is a software used to load program into the memory of microcontroller. It can be used for all 8051 family.

PROCEDURE
Connect the burner to the PC port. Load the HEX file created by the Keil software into the Flash programmer.
Select the type of micro controller (AT89S52).

Lock the program bit to avoid any accidental changes (bit 1 & bit 2). Now burn the HEX file by selecting write key.

Dept. Of E&C, MCE, Hassan

Page 44

Micro controller based automated irrigation system

Fig5.5: snapshot showing the flash programmer window

6. Conclusion
6.1 Summary
In our project we have designed an model to help the farmers in rural zones. Our Remote Controller could be installed on existing pump sets for a nominal cost. Operating our Remote Controller does not require any special skills. It is as simple as sending a SMS or a missed call.

Dept. Of E&C, MCE, Hassan

Page 45

Micro controller based automated irrigation system The user can send a SMS message from anywhere in the world to operate this equipment. The security feature in the software will make sure that it works only with pre-assigned phone numbers. The system has various add-on features. It can notify you by return SMS, when the pump starts or trips. It can even alert you if someone breaks into your pump room to steal the equipment.

6.2 Limitations
The system works wherever there is coverage of a local Mobile Network (GSM). The loss of user cell phone would lead to the miss handling of the device.

6.3 Future work


You can also incorporate a feature to turn-ON a flood-light remotely or initiate a siren in case of a theft attempt.

APPENDIX A
INTERFACING AN LCD DISPLAY In recent years the LCD is finding a wide spread use replacing LEDs. This is due to declining prices of LCDs, the ability to display numbers, characters, and graphics. This is in contrast to LEDs which are limited to numbers and a few characters. Due to incorporation of refreshing controller into the LCD there by leaving the CPU from refreshing and ease of programming for characters and graphics makes LCD more popular.

Dept. Of E&C, MCE, Hassan

Page 46

Micro controller based automated irrigation system

BLOCK DIAGRAM

DB0~DB7 7-14 E 6 LCD R/W RS VLCD VDD VSS 1 5 controlle r 4 3 2

Fig- lcd block diagram

PIN ASSIGNMENT

Pin No. 1 2 3 4

Symbol VSS VDD VLCD RS

Function Ground Power supply Power Supply for LCD Select Display Data("H") or Instructions("L") Page 47

Dept. Of E&C, MCE, Hassan

Micro controller based automated irrigation system Read or Write Select Signal Read/Write Enable Signal

5 6 7 8 9 10 11 12 13 14 15 16

R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 K A

Display Data Signal

Cathode of Backlight Anode of Backlight Table: Pin description

LIST OF LCD COMMANDS

Dept. Of E&C, MCE, Hassan

Page 48

Micro controller based automated irrigation system

Command

RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 L L L L L L L L L L L L L L L L L L L L L L L H L H I/D H X SH

Execution time (fosc=270KHz)

Remark

clear Display Return home Entry mode set

1.53ms 1.53ms 39us Cursor move to first digit I/D:set cursor move direction I/D H Increase l Decrease SH:Specifies shift of display SH H Display is shifted L Display is not shifted Display D Cursor C Blinking B H L H L H L H L H L H L Blinking on Blinking off Display shift Cursor move Right shift Left shift 8bits interface 4bits interface 2 line display 1 line display Display on Display off H L Cursor on Cursor off H L Display on Display off

Display on/off control

39us

Cursor or
Display Shift

S/C R/L

39us

SC R/L

function Set

DL

39us

DL N F

Set CGRAM address Set DDRAM address Read busy flag& address

L L L

L L H

L H

AC5 AC4 AC3 AC2 AC1 AC0

39us 39us 0us

AC6 AC5 AC4 AC3 AC2 AC1 AC0

CGRAM data is sent and received after this setting DDRAM data is sent and received after this setting H Busy L Ready -Reads BF indication internal operating is being performed -Reads address counter contents Write data into DDRAM or CGRAM Read data from DDRAM or CGRAM BF

BF AC6 AC5 AC4 AC3 AC2 AC1 AC0

Write data to RAM Read data from RAM

H H

L H

D7 D7

D6 D6

D5 D5

D4 D4

D3 D3

D2 D2

D1 D1

D0 D0

43us 43us

Table: LCD Commands

REFERENCES
Dept. Of E&C, MCE, Hassan Page 49

Micro controller based automated irrigation system

[1]

Asoke K Talukder, Roopa R Yavagal, TMH, 2006 Mobile computing, technology, application and service creation.

[2]

Atmel 8 bit microcontroller with 8k bytes in system programmable Flash [pdf], http:// www.Atmel.com .

[3] [4] [5]

GSM World: http://www.gsmworld.com . www.8052.com Muhammad Ali Mazidi and Janice Gillispie Mazidi, Pearson Education The 8051 Microcontroller and Embedded Systems, Pearson Education, 2003.

[6]

Overview of Global System for Mobile Communication, http://www.wikipedia.com .

[7] [8] [9]

Theodre S Rappaport Wireless Communications, Principles and Practice. www.MicroDigitalEd.com Kennreth J Ayala The 8051 Microcontroller Architecture, Programming & Applications, Penram International, 1996

Dept. Of E&C, MCE, Hassan

Page 50

You might also like