Sei sulla pagina 1di 92

www.final-yearproject.com | www.finalyearthesis.

com

CHAPTER 1 INTRODUCTION
1.1 Introduction
The purpose of this project is to monitor and control the water flow to an irrigation system using Mobile Phone. This can be achieved by the use of soil moisture sensor, which senses the water content in the soil. This sensor output is given to a Microcontroller based control system for further data processing.

1.2 Aim of the project


The aim of this project is to provide an efficient solution for automatic control of irrigation motor with soil moisture sensor. Now a days technology is running with time, it completely occupied the life style of human beings. Even though there is such an importance for technology in our routine life there are even people whose life styles are very far to this well known term technology. So it is our responsibility to design few reliable systems which can be even efficiently used by them. This basic idea gave birth to the project GSM controlled soil moisture sensor. Here the automation process is done through the micro controller based technology. In our project we make use of one microcontroller, which is dedicated at the water pump. The microcontroller forms the heart of the device and there are also soilmoisture sensors, which are meant for detecting the moisture in the soil. Also GSM modem which will operates the soil moisture sensor. Here we are going to operate the soil moisture sensor. For this we will use GSM technology. To operate the sensor we should send a message to the GSM modem which one at the soil moisture sensor. That modem will receive the message it will sends the information to the micro controller through decoder, the micro controller will operate the sensor i.e., ON/OFF. The sensor will operate the motor according to the quantity of moisture in the soil. This process will be continued until we stop the sensor. Here we get the feedback of motor status i.e., ON/OFF in the form of message from the GSM modem present at the motor end.

www.final-yearproject.com | www.finalyearthesis.com

The design of this system is very much sensitive and should be handled with utmost care because the microcontroller is a 5 volts device and it is employed to monitor the house hold power consumption per day where it should be interfaced with a 240 volts energy meter. So every small parameter should be given high importance while designing the interfacing circuit between the controller and the water motor. Features: 1. Controls high voltage water pumps. 2. Feedback generated with the help of LED indicator. 3. Highly sensitive. 4. Power saving. 5. Low cost. 6. Remote control from any where in the world. 7. Automatic moisture/water sensing. 8. We can know the motor status. Applications: 1. Utilized for irrigation purpose. 2. Can be operated from any place in the world. 3. No need of manual check for moisture level in soil. 4. User friendly. This project provides exposure to the following technologies: 1. Microcontroller. 2. Embedded C programming for microcontroller. 3. GSM modem. 4. Design of PCB. 5. Soil-moisture sensor. 6. Soil-moisture sensor and micro controller interface.
2

www.final-yearproject.com | www.finalyearthesis.com

1.3 Methodology
The major building blocks of this project are: 1. Microcontroller based control system with regulated power supply. 2. Soil moisture sensor. 3. Electromagnetic relay to control the electrical motor (pump) 4. Relay driver. 5. GSM modem attached to Microcontroller for remote communication. 6. LED Indicators.

www.final-yearproject.com | www.finalyearthesis.com

BlockDiagram:

1.4 Significance of the work


Here we are going to operate the soil moisture sensor. For this we will use GSM technology. To operate the sensor we should send a message to the GSM modem which one at the soil moisture sensor. That modem will receive the message it will sends the information to the micro controller through decoder, the micro controller will operate the sensor i.e., ON/OFF. The sensor will operate the motor according to the quantity of moisture in the soil. This process will be continued until
4

www.final-yearproject.com | www.finalyearthesis.com

we stop the sensor. Here we get the feedback of motor status i.e., ON/OFF in the form of message from the GSM modem present at the motor end.

CHAPTER 2 POWER SUPPLY


5

www.final-yearproject.com | www.finalyearthesis.com

2.1. Power supply


Power supply is the major concern for every electronic device .Since the controller and other devices used are low power devices there is a need to step down the voltage and as well as rectify the output to convert the output to a constant dc. The block diagram of regulated power supply is as shown in figure below.

Figure 2.1 shows the components of a typical linear power supply

2.2 Transformer
A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled conductors with out changing its frequency. A varying current in the first or primary winding creates a varying magnetic flux in the transformer's core, and thus a varying magnetic field through the secondary winding. This varying magnetic field induces a varying electromotive force (EMF) or "voltage" in the secondary winding. This effect is called mutual induction. If a load is connected to the secondary, an electric current will flow in the secondary winding and electrical energy will be transferred from the primary circuit through the transformer to the load. This field is made up from lines of force and has the same shape as a bar magnet.

www.final-yearproject.com | www.finalyearthesis.com

If the current is increased, the lines of force move outwards from the coil. If the current is reduced, the lines of force move inwards. If another coil is placed adjacent to the first coil then, as the field moves out or in, the moving lines of force will "cut" the turns of the second coil. As it does this, a voltage is induced in the second coil. With the 50 Hz AC mains supply, this will happen 50 times a second. This is called MUTUAL INDUCTION and forms the basis of the transformer. The input coil is called the PRIMARY WINDING; the output coil is the SECONDARY WINDING.

The voltage induced in the secondary is determined by the TURNS RATIO. Primary voltage = Number of primary turns

---------------------------Secondary voltage

------------------------------------------

Number of secondary turns

For example, if the secondary has half the primary turns; the secondary will have half the primary voltage. Another example is if the primary has 5000 turns and the secondary has 500 turns, then the turns ratio is 10:1. If the primary voltage is 240 volts then the secondary voltage will be x 10 smaller = 24 volts. Assuming a perfect transformer, the power provided by the

www.final-yearproject.com | www.finalyearthesis.com

primary must equal the power taken by a load on the secondary. If a 24-watt lamp is connected across a 24 volt secondary, then the primary must supply 24 watts. If it is a 240-volt primary then the current in it must be 0.1 amp. (Watts = volts x amps). To aid magnetic coupling between primary and secondary, the coils are wound on a metal CORE. Since the primary would induce power, called EDDY CURRENTS, into this core, the core is LAMINATED. This means that it is made up from metal sheets insulated from each other. Transformers to work at higher frequencies have an iron dust core, or no core at all. Note that the transformer only works on AC, which has a constantly changing current and moving field. DC has a steady current and therefore a steady field and there would be no induction. Some transformers have an electrostatic screen between primary and secondary. This is to prevent some types of interference being fed from the equipment down into the mains supply, or in the other direction. Transformers are sometimes used for IMPEDANCE MATCHING. We can use the transformers as step up or step down. In case of step up transformer, primary windings are every less compared to secondary windings. Because of having more turns secondary winding accepts more energy, and it releases more voltage at the output side. Incase of step down transformer, Primary winding induces more flux than the secondary winding, and secondary winding is having less number of turns because of that it accepts less number of flux, and releases less amount of voltage.

2.3 Rectifiers

www.final-yearproject.com | www.finalyearthesis.com

A rectifier is an electrical device that converts alternating current (AC) to direct current (DC), a process known as rectification. Rectifiers have many uses including as components of power supplies and as detectors of radio signals. Rectifiers may be made of solid-state diodes, vacuum tube diodes, mercury arc valves, and other components. A device that it can perform the opposite function (converting DC to AC) is known as an inverter. When only one diode is used to rectify AC (by blocking the negative or positive portion of the waveform), the difference between the term diode and the term rectifier is merely one of usage, i.e., the term rectifier describes a diode that is being used to convert AC to DC. Almost all rectifiers comprise a number of diodes in a specific arrangement for more efficiently converting AC to DC than is possible with only one diode. Before the development of silicon semiconductor rectifiers, vacuum tube diodes and copper (I) oxide or selenium rectifier stacks were used.

2.3.1 Half-wave rectification


In half wave rectification, either the positive or negative half of the AC wave is passed, while the other half is blocked. Because only one half of the input waveform reaches the output, it is very inefficient if used for power transfer. Halfwave rectification can be achieved with a single diode in a one-phase supply, or with three diodes in a three-phase supply.

Input

Output

www.final-yearproject.com | www.finalyearthesis.com

The output DC voltage of a half wave rectifier can be calculated with the following two ideal equations.

2.3.2 Full wave rectifier


Full wave rectifier is available in two ways like center-tapped full-wave rectifier and bridge full-wave rectifier. The Bridge rectifier is a circuit, which converts an ac voltage to dc voltage using both half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure. The circuit has four diodes connected to form a bridge. The ac input voltage is applied to the diagonally opposite ends of the bridge. The load resistance is connected between the other two ends of the bridge. For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with the load resistance RL and hence the load current flows through RL.

10

www.final-yearproject.com | www.finalyearthesis.com

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

Input

Output

Fig: Graetz bridge rectifier: a full-wave rectifier using 4 diodes

2.3.3 Center Tapped Full wave rectifier


For single-phase AC, if the transformer is center-tapped, then two diodes back-to-back (i.e. anodes-to-anode or cathode-to-cathode) can form a full-wave rectifier. Twice as many windings are required on the transformer secondary to obtain the same output voltage compared to the bridge rectifier above. For the positive half cycle of the input ac voltage, diodes D1 will conducts, whereas diodes D2 is in the OFF state. The conducting diodes D1 will be in series with the load resistance RL and hence the load current flows through RL.
11

www.final-yearproject.com | www.finalyearthesis.com

For the negative half cycle of the input ac voltage, diodes D2 will conduct, whereas diodes D1 is in the OFF state. The conducting diodes D2 will be in series with the load resistance RL and hence the load current flows through RL.

Input

Output

Fig: Center tapped Full-wave rectifier using a transformer and 2 diodes.

2.4 DB107
Now a days Bridge rectifier is available in IC with a number of DB107. In our project we are using an IC in place of bridge rectifier. FEATURES: Good for automation insertion Surge overload rating - 30 amperes peak Ideal for printed circuit board Reliable low cost construction utilizing molded Glass passivated device Polarity symbols molded on body Mounting position: Any Weight: 1.0 gram

12

www.final-yearproject.com | www.finalyearthesis.com

Fig: DB107

2.5 Filters
Electronic filters are electronic circuits, which perform signal-processing functions, specifically to remove unwanted frequency components from the signal, to enhance wanted ones. Passive filters Passive implementations of linear filters are based on combinations of resistors (R), inductors (L) and capacitors (C). These types are collectively known as passive filters, because they do not depend upon an external power supply and/or they do not contain active components such as transistors. Inductors block high-frequency signals and conduct low-frequency signals, while capacitors do the reverse. A filter in which the signal passes through an inductor, or in which a capacitor provides a path to ground, presents less attenuation to low-frequency signals than high-frequency signals and is a low-pass filter. If the signal passes through a capacitor, or has a path to ground through an inductor, then the filter presents less attenuation to high-frequency signals than low-frequency signals and is a high-pass filter. Resistors on their own have no frequency-selective properties, but are added to inductors and capacitors to determine the time-constants of the circuit, and therefore the frequencies to which it responds. The inductors and capacitors are the reactive elements of the filter. The number of elements determines the order of the filter. In this context, an LC tuned circuit being used in a band-pass or band-stop filter is considered a single element
13

www.final-yearproject.com | www.finalyearthesis.com

even though it consists of two components.At high frequencies (above about 100 megahertz), sometimes the inductors consist of single loops or strips of sheet metal, and the capacitors consist of adjacent strips of metal. These inductive or capacitive pieces of metal are called stubs. Introduction to Capacitors The Capacitor or sometimes referred to as a Condenser is a passive device, and one which stores energy in the form of an electrostatic field which produces a potential (Static Voltage) across its plates. In its basic form a capacitor consists of two parallel conductive plates that are not connected but are electrically separated either by air or by an insulating material called the Dielectric. When a voltage is applied to these plates, a current flows charging up the plates with electrons giving one plate a positive charge and the other plate an equal and opposite negative charge. This flow of electrons to the plates is known as the Charging Current and continues to flow until the voltage across the plates (and hence the capacitor) is equal to the applied voltage Vcc. At this point the capacitor is said to be fully charged and this is illustrated below. Capacitor Construction

The parallel plate capacitor is the simplest form of capacitor and the equal area of the plates and the distance or separation between them fixes its capacitance value. Altering any two of these values alters the value of its capacitance and this forms the
14

www.final-yearproject.com | www.finalyearthesis.com

basis of operation of the variable capacitors. Also, because capacitors store the energy of the electrons in the form of an electrical charge on the plates the larger the plates and/or smaller their separation the greater will be the charge that the capacitor holds for any given voltage across its plates. By applying a voltage to a capacitor and measuring the charge on the plates, the ratio of the charge Q to the voltage V will give the capacitance value of the capacitor and is therefore given as: C = Q/V this equation can also be re-arranged to give the more familiar formula for the quantity of charge on the plates as: Q = C x V The unit of capacitance is the Farad (abbreviated to F) named after the British physicist Michael Faraday and is defined as a capacitor has the capacitance of One Farad when a charge of One Coulomb is stored on the plates by a voltage of One volt. Capacitance, C is always positive and has no negative units. However, the Farad is a very large unit of measurement to use on its own so sub-multiples of the Farad is generally used such as microfarads, nano-farads and Pico-farads, for example. Units of Capacitance: Microfarad (F) 1F = 1/1,000,000 = 0.000001 = 10-6 F Nanofarad (nF) 1nF = 1/1,000,000,000 = 0.000000001 = 10-9 F Pico farad (pF) 1pF = 1/1,000,000,000,000 = 0.000000000001 = 10-12 F How does a Capacitor Work? Think of water flowing through a pipe. If we imagine a capacitor as being a storage tank with an inlet and an outlet pipe, it is possible to show approximately how an electronic capacitor works. First, let's consider the case of a "coupling capacitor" where the capacitor is used to connect a signal from one part of a circuit to another but without allowing any direct current to flow.

15

www.final-yearproject.com | www.finalyearthesis.com

If the current flow is alternating between zero and a maximum, our "storage tank" capacitor will allow the current waves to pass through.

However, if there is a steady current, only the initial short burst will flow until the "floating ball valve" closes and stops further flow.

A coupling capacitor is represented like this So a coupling capacitor allows "alternating current" to pass through because the ball valve doesn't get a chance to close as the waves go up and down. However, a steady current quickly fills the tank so that all flow stops. A capacitor will pass alternating current but (apart from an initial surge) it will not pass d.c.

Where a capacitor is used to decouple a circuit, the effect is to "smooth out ripples". Any ripples, waves or pulses of current are passed to ground while d.c. Flows smoothly.

A decoupling capacitor is represented like this

Active filters
16

www.final-yearproject.com | www.finalyearthesis.com

Active filters are implemented using a combination of passive and active (amplifying) components, and require an outside power source. Operational amplifiers are frequently used in active filter designs. These can have high Q, and can achieve resonance without the use of inductors. However, their upper frequency limit is limited by the bandwidth of the amplifiers used.

2.6 Regulators
A voltage regulator (also called a regulator) with only three terminals appears to be a simple device, but it is in fact a very complex integrated circuit. It converts a varying input voltage into a constant regulated output voltage. Voltage Regulators are available in a variety of outputs like 5V, 6V, 9V, 12V and 15V. The LM78XX series of voltage regulators are designed for positive input. For applications requiring negative input, the LM79XX series is used. Fig. 1 shows the pin configuration of a 5V 7805 regulator. Using a pair of voltage-divider resistors can increase the output voltage of a regulator circuit. It is not possible to obtain a voltage lower than the stated rating. You cannot use a 12V regulator to make a 5V power supply. Voltage regulators are very robust. These can withstand over-current draw due to short circuits and also over-heating. In both cases, the regulator will cut off before any damage occurs. The only way to destroy a regulator is to apply reverse voltage to its input. Reverse polarity destroys the regulator almost instantly.

17

www.final-yearproject.com | www.finalyearthesis.com

Fig: Regulator

Variable Voltage Regulator: The LM117 series of adjustable 3-terminal positive voltage regulators is capable of supplying in excess of 1.5A over a 1.2V to 37V output range. They are exceptionally easy to use and require only two external resistors to set the output voltage. Further, both line and load regulations are better than standard fixed regulators. Also, the LM117 is packaged in standard transistor packages, which are easily mounted and handled. In addition to higher performance than fixed regulators, the LM117 series offers full overload protection available only in IC's. Included on the chip are current limit, thermal overload protection and safe area protection. All overload protection circuitry remains fully functional even if the adjustment terminal is disconnected. Normally, no capacitors are needed unless the device is situated more than 6 inches from the input filter capacitors in which case an input bypass is needed. An optional output capacitor can be added to improve transient response. The adjustment terminal can be bypassed to achieve very high ripple rejection ratios, which are difficult to achieve with standard 3-terminal regulators. Besides replacing fixed regulators, the LM117 is useful in a wide variety of other applications. Since the regulator is floating and sees only the input-to-output differential voltage, supplies of several hundred volts can be regulated as long as the maximum input to output differential is not exceeded, i.e., avoid short-circuiting the output. Also, it makes an especially simple adjustable switching regulator, a programmable output regulator, or by connecting a fixed resistor between the adjustment pin and output, the LM117 can be used as a precision current regulator. Supplies with electronic shutdown can be achieved by clamping the adjustment terminal to ground, which programs the output to 1.2V where most loads draw little current.
18

www.final-yearproject.com | www.finalyearthesis.com

2.7 LED
LED stands for Light Emitting Diode, which are for flashlights Working: The structure of the LED light is completely different than that of the light bulb. Amazingly, the LED has a simple and strong structure. The beauty of the structure is that it is designed to be versatile, allowing for assembly into many different shapes. The light-emitting semiconductor material is what determines the LED's color. As indicated by its name, the LED is a diode that emits light. A diode is a device that allows current to flow in only one direction. Almost any two conductive materials will form a diode when placed in contact with each other. When electricity is passed through the diode the atoms in one material (within the semiconductor chip) are excited to a higher energy level. The atoms in that first material have too much energy and need to release that energy. The energy is then released as the atoms shed electrons to the other material within the chip. During this energy release light is created. The color of the light from the LED is a function of the ingredients (materials) and recipes (processes) that make up the chip. LED lights have a variety of advantages over other light sources: High-levels of brightness and intensity High-efficiency Low-voltage and current requirements Low radiated heat High reliability (resistant to shock and vibration) No UV Rays Long source life Can be easily controlled and programmed

19

www.final-yearproject.com | www.finalyearthesis.com

Why are LED lights becoming so popular? Over the past decade, LED technology has advanced at light speed. In the past, lack of colors and the low intensity made LEDs useful only as indicator lights. As manufacturing methods and technology improved, the LED quickly found homes in more and more applications. These days, the LED is becoming a preferred light source for many more than simple indicators. LED light sources are also gaining popularity due to the growing energy conservation movement. According to the U.S. Department Energy, no other lighting technology offers as much potential to save energy and enhance the quality of our building environments. There are two basic types of circuits: Series and Parallel?" When LEDs are placed in a series, the voltage is dispersed between the LEDs, meaning less voltage goes to each LED. This can be very useful. For example, if a 12 volt adapter were powering one LED, there'd be 12V going through that LED which is way too much for any LED to handle and would result in a rather unpleasant burning smell. However, if you take that same 12V power source and put 4 LEDs in series, there would be 3V going to each LED and (assuming the LEDs are made to run off 3V) each would be powered and just dandy. Check out this illustration:

20

www.final-yearproject.com | www.finalyearthesis.com

It's important to notice how the LEDs are positioned: (-) (+), (-) (+), etc. making sure that the end (-) connects to the (-) wire and the end (+) connects to the (+) wire, if any LEDs are backwards nothing bad will happen, they just won't turn on. If three LEDs were in series with a 12V source, each would receive 4V, if six were in series, each would receive 2V, etc. Let's say you wanted to power three of your brand new LEDs off a 3V battery pack (two 1.5V AA's in series, make sense?) you found lying around. If you were to series the three LEDs there'd be 1V going to each (3 Volts / 3 LEDs = 1V for each LED). That's not enough to power your LEDs! You want them to have the full 3V going to each. Here's how:

21

www.final-yearproject.com | www.finalyearthesis.com

How this works is that while every LED receives the same amount of voltage, the current of the source is dispersed between the LEDs. What this means for you is that you have 20 LEDs paralleled off a battery, it's going to drain the battery a lot quicker than if you only had 2 LEDs in parallel. If you're paralleling off a wall adapter, for instance though, the source can constantly renew itself so you can essentially parallel as many as you'd like without fear of draining the wall. To use resistors in a parallel circuit, say if you'd like each LED above to receive 2.5V instead of 3V, use an LED calculator (make sure you're in the parallel section) to find the right ohm age and then stick it somewhere in the circuit! Why do the LEDs have to be the same color? If you mix colors, say if you paralleled a red (~2.3V) and two blue (~3.5V), the blue LEDs would not light. Why's this? Because the electricity is going to take the easiest path it can to complete the circuit and in this scenario the red LED requires less energy, leaving the two blue un-powered and lonely. To fix this you would need to stick a resistor onto the leg of each LED to 'equalize' all of the LEDs. Note illustration:

22

www.final-yearproject.com | www.finalyearthesis.com

To find the resistor you'd need for each LED, use the 'Single LED' portion of an LED calculator, type in the supply voltage, LED's voltage and 20mA for each LED and there you go. Now each LED will turn on and each will receive it's desired amount of power. Thanks to Mike Moores for pointing this out, "The resistors act like 'shocks' in a car, they give the power source some 'squish' and let each LED find its happy place (forward voltage)."

23

www.final-yearproject.com | www.finalyearthesis.com

CHAPTER 3 MICROCONTROLLER.
3.1 Introduction Circumstances that we find ourselves in today in the field of microcontrollers had their beginnings in the development of technology of integrated circuits. This development has made it possible to store hundreds of thousands of transistors into one chip. That was a prerequisite for production of microprocessors, and the first computers were made by adding external peripherals such as memory, input-output lines, timers and other. Further increasing of the volume of the package resulted in creation of integrated circuits. These integrated circuits contained both processor and peripherals. That is how the first chip containing a microcomputer, or what would later be known as a microcontroller came about. History It was year 1969, and a team of Japanese engineers from the BUSICOM Company arrived to United States with a request that a few integrated circuits for calculators be made using their projects. The proposition was set to INTEL, and Marcian Hoff was responsible for the project. Since he was the one who has had experience in working with a computer (PC) PDP8, it occurred to him to suggest a fundamentally different solution instead of the suggested construction. This solution presumed that the function of the integrated circuit is determined by a program stored in it. That meant that configuration would be simpler, but that it would require far more memory than the project that was proposed by Japanese engineers would require. After a while, though Japanese engineers tried finding an easier solution, Marcian's idea won, and the first microprocessor was born. In transforming an idea into a ready made product, Frederico Faggin was a major help to INTEL. He transferred to INTEL, and in only 9 months had succeeded in making a product from its first conception. INTEL obtained the rights to sell this integral block in 1971. First, they bought the license from the BUSICOM company who had no idea what treasure they had. During that year, there appeared on the market a microprocessor called 4004. That was the first 4-bit microprocessor with the speed of 6 000 operations per second. Not long after that, American company CTC requested from INTEL and Texas Instruments to make an 824

www.final-yearproject.com | www.finalyearthesis.com

bit microprocessor for use in terminals. Even though CTC gave up this idea in the end, Intel and Texas Instruments kept working on the microprocessor and in April of 1972, first 8-bit microprocessor appeared on the market under a name 8008. It was able to address 16Kb of memory, and it had 45 instructions and the speed of 300 000 operations per second. That microprocessor was the predecessor of all today's microprocessors. Intel kept their developments up in April of 1974, and they put on the market the 8-bit processor under a name 8080 which was able to address 64Kb of memory, and which had 75 instructions, and the price began at $360. In another American company Motorola, they realized quickly what was happening, so they put out on the market an 8-bit microprocessor 6800. Chief constructor was Chuck Peddle, and along with the processor itself, Motorola was the first company to make other peripherals such as 6820 and 6850. At that time many companies recognized greater importance of microprocessors and began their own developments. Chuck Peddle leaved Motorola to join MOS Technology and kept working intensively on developing microprocessors. At the WESCON exhibit in United States in 1975, a critical event took place in the history of microprocessors. The MOS Technology announced it was marketing microprocessors 6501 and 6502 at $25 each, which buyers could purchase immediately. This was so sensational that many thought it was some kind of a scam, considering that competitors were selling 8080 and 6800 at $179 each. As an answer to its competitor, both Intel and Motorola lowered their prices on the first day of the exhibit down to $69.95 per microprocessor. Motorola quickly brought suit against MOS Technology and Chuck Peddle for copying the protected 6800. MOS Technology stopped making 6501, but kept producing 6502. The 6502 was a 8-bit microprocessor with 56 instructions and a capability of directly addressing 64Kb of memory. Due to low cost , 6502 becomes very popular, so it was installed into computers such as: KIM-1, Apple I, Apple II, Atari, Comodore, Acorn, Oric, Galeb, Orao, Ultra, and many others. Soon appeared several makers of 6502 (Rockwell, Sznertek, GTE, NCR, Ricoh, and Comodore takes over MOS Technology) which was at the time of its prosperity sold at a rate of 15 million processors a year! Others were not giving up though. Frederico Faggin leaves Intel, and starts his own Zilog Inc.
25

www.final-yearproject.com | www.finalyearthesis.com

In 1976 Zilog announced the Z80. During the making of this microprocessor, Faggin made a pivotal decision. Knowing that a great deal of programs have been already developed for 8080, Faggin realized that many would stay faithful to that microprocessor because of great expenditure which redoing of all of the programs would result in. Thus he decided that a new processor had to be compatible with 8080, or that it had to be capable of performing all of the programs which had already been written for 8080. Beside these characteristics, many new ones have been added, so that Z80 was a very powerful microprocessor in its time. It was able to address directly 64 Kb of memory, it had 176 instructions, a large number of registers, a built in option for refreshing the dynamic RAM memory, single-supply, greater speed of work etc. Z80 was a great success and everybody converted from 8080 to Z80. It could be said that Z80 was without a doubt commercially most successful 8-bit microprocessor of that time. Besides Zilog, other new manufacturers like Mostek, NEC, SHARP, and SGS also appeared. Z80 was the heart of many computers like Spectrum, Partner, TRS703, Z-3 . In 1976, Intel came up with an improved version of 8-bit microprocessor named 8085. However, Z80 was so much better that Intel soon lost the battle. Altough a few more processors appeared on the market (6809, 2650, SC/MP etc.), everything was actually already decided. There weren't any more great improvements to make manufacturers convert to something new, so 6502 and Z80 along with 6800 remained as main representatives of the 8-bit microprocessors of that time. Microcontrollers versus Microprocessors Microcontroller differs from a microprocessor in many ways. First and the most important is its functionality. In order for a microprocessor to be used, other components such as memory, or components for receiving and sending data must be added to it. In short that means that microprocessor is the very heart of the computer. On the other hand, microcontroller is designed to be all of that in one. No other external components are needed for its application because all necessary peripherals are already built into it. Thus, we save the time and space needed to construct devices.

26

www.final-yearproject.com | www.finalyearthesis.com

3.2 Memory unit


Memory is part of the microcontroller whose function is to store data. The easiest way to explain it is to describe it as one big closet with lots of drawers. If we suppose that we marked the drawers in such a way that they can not be confused, any of their contents will then be easily accessible. It is enough to know the designation of the drawer and so its contents will be known to us for sure.

Memory components are exactly like that. For a certain input we get the contents of a certain addressed memory location and that's all. Two new concepts are brought to us: addressing and memory location. Memory consists of all memory locations, and addressing is nothing but selecting one of them. This means that we need to select the desired memory location on one hand, and on the other hand we need to wait for the contents of that location. Beside reading from a memory location, memory must also provide for writing onto it. This is done by supplying an additional line called control line. We will designate this line as R/W (read/write). Control line is used in the following way: if r/w=1, reading is done, and if opposite is true then writing is done on the memory location. Memory is the first element, and we need a few operation of our microcontroller .

3.3 Central Processing Unit


Let add 3 more memory locations to a specific block that will have a built in capability to multiply, divide, subtract, and move its contents from one memory
27

www.final-yearproject.com | www.finalyearthesis.com

location onto another. The part we just added in is called "central processing unit" (CPU). Its memory locations are called registers.

Registers are therefore memory locations whose role is to help with performing various mathematical operations or any other operations with data wherever data can be found. Look at the current situation. We have two independent entities (memory and CPU) which are interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for example, we wish to add the contents of two memory locations and return the result again back to memory, we would need a connection between memory and CPU. Simply stated, we must have some "way" through data goes from one block to another. Bus That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires There are two types of buses: address and data bus. The first one consists of as many lines as the amount of memory we wish to address, and the other one is as wide as data, in our case 8 bits or the connection line. First one serves to transmit address from CPU memory, and the second to connect all blocks inside the microcontroller.

28

www.final-yearproject.com | www.finalyearthesis.com

As far as functionality, the situation has improved, but a new problem has also appeared: we have a unit that's capable of working by itself, but which does not have any contact with the outside world, or with us! In order to remove this deficiency, let's add a block which contains several memory locations whose one end is connected to the data bus, and the other has connection with the output lines on the microcontroller which can be seen as pins on the electronic component. Input-output unit Those locations we've just added are called "ports". There are several types of ports : input, output or bidirectional ports. When working with ports, first of all it is necessary to choose which port we need to work with, and then to send data to, or take it from the port.

When working with it the port acts like a memory location. Something is simply being written into or read from it, and it could be noticed on the pins of the microcontroller.
29

www.final-yearproject.com | www.finalyearthesis.com

3.4 Serial communication


Beside stated above we've added to the already existing unit the possibility of communication with an outside world. However, this way of communicating has its drawbacks. One of the basic drawbacks is the number of lines which need to be used in order to transfer data. What if it is being transferred to a distance of several kilometers? The number of lines times number of kilometers doesn't promise the economy of the project. It leaves us having to reduce the number of lines in such a way that we don't lessen its functionality. Suppose we are working with three lines only, and that one line is used for sending data, other for receiving, and the third one is used as a reference line for both the input and the output side. In order for this to work, we need to set the rules of exchange of data. These rules are called protocol. Protocol is therefore defined in advance so there wouldn't be any misunderstanding between the sides that are communicating with each other. For example, if one man is speaking in French, and the other in English, it is highly unlikely that they will quickly and effectively understand each other. Let's suppose we have the following protocol. The logical unit "1" is set up on the transmitting line until transfer begins. Once the transfer starts, we lower the transmission line to logical "0" for a period of time (which we will designate as T), so the receiving side will know that it is receiving data, and so it will activate its mechanism for reception. Let's go back now to the transmission side and start putting logic zeros and ones onto the transmitter line in the order from a bit of the lowest value to a bit of the highest value. Let each bit stay on line for a time period which is equal to T, and in the end, or after the 8th bit, let us bring the logical unit "1" back on the line which will mark the end of the transmission of one data. The protocol we've just described is called in professional literature NRZ (Non-Return to Zero).

30

www.final-yearproject.com | www.finalyearthesis.com

As we have separate lines for receiving and sending, it is possible to receive and send data (info.) at the same time. So called full-duplex mode block which enables this way of communication is called a serial communication block. Unlike the parallel transmission, data moves here bit by bit, or in a series of bits what defines the term serial communication comes from. After the reception of data we need to read it from the receiving location and store it in memory as opposed to sending where the process is reversed. Data goes from memory through the bus to the sending location, and then to the receiving unit according to the protocol.

3.5 Timer unit


Since we have the serial communication explained, we can receive, send and process data.

However, in order to utilize it in industry we need a few additionally blocks. One of those is the timer block which is significant to us because it can give us information about time, duration, protocol etc. The basic unit of the timer is a free-run counter which is in fact a register whose numeric value increments by one in even intervals, so that by taking its value during periods T1 and T2 and on the basis of their difference we can determine how much time has elapsed. This is a very important part of the microcontroller whose understanding requires most of our time. Watchdog One more thing is requiring our attention is a flawless functioning of the microcontroller during its run-time. Suppose that as a result of some interference (which often does occur in industry) our microcontroller stops executing the program, or worse, it starts working incorrectly.

31

www.final-yearproject.com | www.finalyearthesis.com

Of course, when this happens with a computer, we simply reset it and it will keep working. However, there is no reset button we can push on the microcontroller and thus solve our problem. To overcome this obstacle, we need to introduce one more block called watchdog. This block is in fact another free-run counter where our program needs to write a zero in every time it executes correctly. In case that program gets "stuck", zero will not be written in, and counter alone will reset the microcontroller upon achieving its maximum value. This will result in executing the program again, and correctly this time around. That is an important element of every program to be reliable without man's supervision.

3.6 Analog to Digital Converter


As the peripheral signals usually are substantially different from the ones that microcontroller can understand (zero and one), they have to be converted into a pattern which can be comprehended by a microcontroller. This task is performed by a block for analog to digital conversion or by an ADC. This block is responsible for converting an information about some analog value to a binary number and for follow it through to a CPU block so that CPU block can further process it.

Finnaly, the microcontroller is now completed, and all we need to do now is to assemble it into an electronic component where it will access inner blocks through the outside pins. The picture below shows what a microcontroller looks like inside.

32

www.final-yearproject.com | www.finalyearthesis.com

Physical configuration of the interior of a microcontroller Thin lines which lead from the center towards the sides of the microcontroller represent wires connecting inner blocks with the pins on the housing of the microcontroller so called bonding lines. Chart on the following page represents the center section of a microcontroller.

33

www.final-yearproject.com | www.finalyearthesis.com

Microcontroller outline with its basic elements and internal connections For a real application, a microcontroller alone is not enough. Beside a microcontroller, we need a program that would be executed, and a few more elements which make up a interface logic towards the elements of regulation (which will be discussed in later chapters). Program Program writing is a special field of work with microcontrollers and is called "programming". Try to write a small program in a language that we will make up ourselves first and then would be understood by anyone. START REGISTER1=MEMORY REGISTER2=MEMORY PORTA=REGISTER1 END The program adds the contents of two memory locations, and views their sum on port A. The first line of the program stands for moving the contents of memory location "A" into one of the registers of central processing unit. As we need the other data as well, we will also move it into the other register of the central processing unit. The next instruction instructs the central processing unit to add the contents of those two registers and send a result to port A, so that sum of that addition would be visible to the outside world. For a more complex problem, program that works on its solution will be bigger. Programming can be done in several languages such as Assembler, C and Basic which are most commonly used languages. Assembler belongs to lower level languages that are programmed slowly, but take up the least amount of space in memory and gives the best results where the speed of program execution is concerned. As it is the most commonly used language in programming microcontrollers it will be discussed in a later chapter. Programs in C language are easier to be written, easier to be understood, but are slower in executing from assembler programs. Basic is the easiest one to learn and its instructions are nearest a man's way of reasoning, but like C programming
34

LOCATION_A LOCATION_B + REGISTER2

www.final-yearproject.com | www.finalyearthesis.com

language it is also slower than assembler. In any case, before you make up your mind about one of these languages you need to consider carefully the demands for execution speed, for the size of memory and for the amount of time available for its assembly. After the program is written, we would install the microcontroller into a device and run it. In order to do this we need to add a few more external components necessary for its work. First we must give life to a microcontroller by connecting it to a power supply (power needed for operation of all electronic instruments) and oscillator whose role is similar to the role that heart plays in a human body. Based on its clocks microcontroller executes instructions of a program. As it receives supply microcontroller will perform a small check up on itself, look up the beginning of the program and start executing it. How the device will work depends on many parameters, the most important of which is the skillfulness of the developer of hardware, and on programmer's expertise in getting the maximum out of the device with his program.

What is a microcontroller?
A microcontroller is a compact standalone computer, optimized for control applications. Entire processor, memory and the I/O interfaces are located on a single piece of silicon so, it takes less time to read and write to external devices.

Why are microcontrollers used?


Following are the reasons why microcontrollers are incorporated in control systems: Cost: Microcontrollers with the supplementary circuit components are much cheaper than a computer with an analog and digital I/O Size and Weight: Microcontrollers are compact and light compared to computers Simple applications: If the application requires very few number of I/O and the code is relatively small, which do not require extended amount of memory and a simple LCD display is sufficient as a user interface, a microcontroller would be suitable for this application. Reliability: Since the architecture is much simpler than a computer it is less likely to fail.

35

www.final-yearproject.com | www.finalyearthesis.com

Speed: All the components on the microcontroller are located on a single piece of silicon. Hence, the applications run much faster than it does on a computer.

3.7 Introduction to PIC16F877A What is PIC16F877A?


PIC16F877A is a small piece of semiconductor integrated circuits. The package type of these integrated circuits is DIP package. DIP stand for Dual Inline Package for semiconductor IC. This package is very easy to be soldered onto the strip board. However using a DIP socket is much easier so that this chip can be plugged and removed from the development board.

Why PIC16F877A is very popular?


This is because PIC16F877A is very cheap. Apart from that it is also very easy to be assembled. Additional components that you need to make this IC work are just a 5V power supply adapter, a 20MHz crystal oscillator and 2 units of 22pF capacitors.

What are the advantages of PIC16F877A?


This IC can be reprogrammed and erased up to 10,000 times. Therefore it is very good for new product development phase.

3.7.1 Microcontroller Specification


RAM EEPROM FlashProgramMemory OperatingFrequency I/Oport PortA,B,C,D,E This is the specification for PIC16F877A from Microchip. A single microcontroller which is very brilliant and useful. Also this microcontroller is very easy to be assembled, program and also the price is very cheap. It cost less than 10 dollar. The good thing is that single unit can be purchased at that 10 dollar price. Unlike some other Integrated Circuit that must be bought at a minimum order quantity
36

368bytes 256bytes 8kwords DCto20MHz

www.final-yearproject.com | www.finalyearthesis.com

such as 1000 units or 2000 units or else you wont be able to purchase it. One unit of PIC16F877A microcontroller can be programmed and erased so many times. Some said about 10 000 times. If you are doing programming and downloading your code into the PIC 20 times a day, that means you can do that for 500 days which is more than a year!The erasing time is almost unnoticeable because once new program are loaded into the PIC, the old program will automatically be erased immediately. During my time of Degree study, I did not use PIC but I use other type of microcontroller. I have to wait for about 15 to 30 minutes to erase the EEPROM before I can load a new program and test the microcontroller. One day I can only modify my code and test it for less than 10 times. 10x15 minutes = 150 minutes. PIC16F877A already made with 368 bytes of Random Access Memory (RAM) inside it. Any temporary variable storage that we wrote in our program will be stored inside the RAM. Using this microcontroller you dont need to buy any external RAM. 256 bytes of EEPROM are available also inside this microcontroller. This is very useful to store information such as PIN Number, Serial Number and so on. Using EEPROM is very important because data stored inside EEPROM will be retained when power supply is turn off. RAM did not store data permanently. Data inside RAM is not retained when power supply is turn off. The size of program code that can be stored is about 8k words inside PIC16F877A ROM. 1 word size is 14 bits. By using the free version of the CCS C compiler only 2k words of program can be written and compiled. To write 8k words of C program you have to purchase the original CCS C compiler and it cost less than 700 dollar. The crystal oscillator speed that can be connected to the PIC microcontroller range from DC to 20Mhz. Using the CCS C compiler normally 20Mhz oscillator will be used and the price is very cheap. The 20Mhz crystal oscillator should be connected with about 22pF capacitor. Please refer to my circuit schematic. There are 5 input/output port on PIC microcontroller namely port A, port B, port C, port D and port E. Each port has different function. Most of them can be used as I/O port.
37

www.final-yearproject.com | www.finalyearthesis.com

The PIC16F877A CMOS FLASH-based 8-bit microcontroller is upward compatible with the PIC16C5x, PIC12Cxxx and PIC16C7x devices. It features 200 ns instruction execution, 256 bytes of EEPROM data memory, self-programming, an ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions, a synchronous serial port that can be configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a Parallel Slave Port.

3.7.2 High-Performance RISC CPU


Lead-free; RoHS-compliant Operating speed: 20 MHz, 200 ns instruction cycle Operating voltage: 4.0-5.5V Industrial temperature range (-40 to +85C) 15 Interrupt Sources 35 single-word instructions All single-cycle instructions except for program branches (two-cycle)

3.7.3 Special Microcontroller Features


Flash Memory: 14.3 Kbytes (8192 words)

Data SRAM: 368 bytes Data EEPROM: 256 bytes Self-reprogrammable under software control In-Circuit Serial Programming via two pins (5V) Watchdog Timer with on-chip RC oscillator Programmable code protection Power-saving Sleep mode Selectable oscillator options

38

www.final-yearproject.com | www.finalyearthesis.com

In-Circuit Debug via two pins

3.7.4 Peripheral Features


33 I/O pins; 5 I/O ports Timer0: 8-bit timer/counter with 8-bit prescaler Timer1: 16-bit timer/counter with prescaler Can be incremented during Sleep via external crystal/clock Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler Two Capture, Compare, PWM modules 16-bit Capture input; max resolution 12.5 ns 16-bit Compare; max resolution 200 ns 10-bit PWM Synchronous Serial Port with two modes: SPI Master I2C Master and Slave USART/SCI with 9-bit address detection Parallel Slave Port (PSP) 8 bits wide with external RD, WR and CS controls Brown-out detection circuitry for Brown-Out Reset Analog Features 10-bit, 8-channel A/D Converter Brown-Out Reset

39

www.final-yearproject.com | www.finalyearthesis.com

3.7.5 Analog Comparator module


2 analog comparators Programmable on-chip voltage reference module Programmable input multiplexing from device inputs and internal VREF Comparator outputs are externally accessible

Following are the major blocks of PIC Microcontroller.

40

www.final-yearproject.com | www.finalyearthesis.com

41

www.final-yearproject.com | www.finalyearthesis.com

Figure 3.7.5 shows Architecture of microcontroller Program memory (FLASH) is used for storing a written program. Since memory made in FLASH technology can be programmed and cleared more than once, it makes this microcontroller suitable for device development. EEPROM - data memory that needs to be saved when there is no supply. It is usually used for storing important data that must not be lost if power supply suddenly stops. For instance, one such data is an assigned temperature in temperature regulators. If during a loss of power supply this data was lost, we would have to make
42

www.final-yearproject.com | www.finalyearthesis.com

the adjustment once again upon return of supply. Thus our device looses on selfreliance. RAM - Data memory used by a program during its execution.In RAM are stored all inter-results or temporary data during run-time. PORTS are physical connections between the microcontroller and the outside world. PIC16F877A has five I/O Ports and 33 pins in all 5 ports. FREE-RUN TIMER is an 8-bit register inside a microcontroller that works independently of the program. On every fourth clock of the oscillator it increments its value until it reaches the maximum (255), and then it starts counting over again from zero. As we know the exact timing between each two increments of the timer contents, timer can be used for measuring time which is very useful with some devices. CENTRAL PROCESSING UNIT has a role of connective element between other blocks in the microcontroller. It coordinates the work of other blocks and executes the user program.

Figure 2.5 shows block diagram of Harvard and Von Neumann architecture

CISC, RISC

43

www.final-yearproject.com | www.finalyearthesis.com

It has already been said that PIC16F877A has a RISC architecture. This term is often found in computer literature, and it needs to be explained here in more detail. Harvard architecture is a newer concept than von-Neumann's. It rose out of the need to speed up the work of a microcontroller. In Harvard architecture, data bus and address bus are separate. Thus a greater flow of data is possible through the central processing unit, and of course, a greater speed of work. Separating a program from data memory makes it further possible for instructions not to have to be 8-bit words. PIC16F877A uses 14 bits for instructions which allows for all instructions to be one word instructions. It is also typical for Harvard architecture to have fewer instructions than von-Neumann's, and to have instructions usually executed in one cycle. Microcontrollers microcontrollers". RISC with Harvard for architecture Reduced are also called Set "RISC stands Instruction Computer.

Microcontrollers with von-Neumann's architecture are called 'CISC microcontrollers'. Title CISC stands for Complex Instruction Set Computer. Since PIC16F877A is a RISC microcontroller, that means that it has a reduced set of instructions, more precisely 35 instructions. (Ex. Intel's and Motorola's microcontrollers have over hundred instructions) All of these instructions are executed in one cycle except for jump and branch instructions. According to what its maker says, PIC16F877A usually reaches results of 2:1 in code compression and 4:1 in speed in relation to other 8-bit microcontrollers in its class.

3.7.6 Applications
PIC16F877A perfectly fits many uses, from automotive industries and controlling home appliances to industrial instruments, remote sensors, electrical door locks and safety devices. It is also ideal for smart cards as well as for battery supplied devices because of its low consumption. EEPROM memory makes it easier to apply microcontrollers to devices where permanent storage of various parameters is needed (codes for transmitters, motor speed, receiver frequencies, etc.). In System Programmability of this chip (along with using only two pins in data transfer) makes possible the flexibility of a product, after assembling and testing have been completed. This capability can be used to create assembly-line production, to store calibration data available only after final testing, or it can be used to improve programs on finished products.
44

www.final-yearproject.com | www.finalyearthesis.com

3.7.7 Clock / instruction cycle


Clock is microcontroller's main starter, and is obtained from an external component called an "oscillator". If we want to compare a microcontroller with a time clock, our "clock" would then be a ticking sound we hear from the time clock. In that case, oscillator could be compared to a spring that is wound so time clock can run. Also, force used to wind the time clock can be compared to an electrical supply. Clock from the oscillator enters a microcontroller via OSC1 pin where internal circuit of a microcontroller divides the clock into four even clocks Q1, Q2, Q3, and Q4 which do not overlap. These four clocks make up one instruction cycle (also called machine cycle) during which one instruction is executed.

Figure 2.6shows Clock/Instruction cycle of microcontroller Execution of instruction starts by calling an instruction that is next in string. Instruction is called from program memory on every Q1 and is written in instruction register on Q4. Decoding and execution of instruction are done between the next Q1 and Q4 cycles. On the following diagram we can see the relationship between instruction cycle and clock of the oscillator (OSC1) as well as that of internal clocks Q1-Q4. Program counter (PC) holds information about the address of the next instruction. Pipelining Instruction cycle consists of cycles Q1, Q2, Q3 and Q4. Cycles of calling and executing instructions are connected in such a way that in order to make a call, one instruction cycle is needed, and one more is needed for decoding and execution. However, due to pipelining, each instruction is effectively executed in one cycle. If instruction causes a change on program counter, and PC doesn't point to the following but to some other address (which can be the case with jumps or with calling subprograms), two cycles are needed for executing an instruction. This is so because
45

www.final-yearproject.com | www.finalyearthesis.com

instruction must be processed again, but this time from the right address. Cycle of calling begins with Q1 clock, by writing into instruction register (IR). Decoding and executing begins with Q2, Q3 and Q4 clocks.

Figure 3.7.7shows Instruction pipeline flow TCY0 reads in instruction MOVLW 55h (it doesn't matter to us what instruction was executed, because there is no rectangle pictured on the bottom). TCY1 executes instruction MOVLW 55h and reads in MOVWF PORTB. TCY2 executes MOVWF PORTB and reads in CALL SUB_1. TCY3 executes a call of a subprogram CALL SUB_1, and reads in instruction BSF PORTA, BIT3. As this instruction is not the one we need, or is not the first instruction of a subprogram SUB_1 whose execution is next in order, instruction must be read in again. This is a good example of an instruction needing more than one cycle. TCY4 instruction cycle is totally used up for reading in the first instruction from a subprogram at address SUB_1.TCY5 executes the first instruction from a subprogram SUB_1 and reads in the next one.

3.8 Pin description

46

www.final-yearproject.com | www.finalyearthesis.com

PIC16F877A has a total of 40 pins. It is most frequently found in a DIP40 type of case but can also be found in SMD case which is smaller from a DIP. DIP is an abbreviation for Dual In Package. SMD is an abbreviation for Surface Mount Devices suggesting that holes for pins to go through when mounting aren't necessary in soldering this type of a component.

Figure 3.8 pin diagram of PIC microcontroller Pins on PIC16F877A microcontroller have the following meaning: There are 40 pins on PIC16F877A. Most of them can be used as an IO pin. Others are already for specific functions. These are the pin functions. 1. MCLR to reset the PIC 2. RA0 port A pin 0 3. RA1 port A pin 1 4. RA2 port A pin 2 5. RA3 port A pin 3 6. RA4 port A pin 4 7. RA5 port A pin 5 8. RE0 port E pin 0 9. RE1 - port E pin 1

47

www.final-yearproject.com | www.finalyearthesis.com

10. RE2 port E pin 2 11. VDD power supply 12. VSS ground 13. OSC1 connect to oscillator 14. OSC2 connect to oscillator 15. RC0 port C pin 0 16. RC1 port C pin 0 17. RC2 port C pin 0 18. RC3 port C pin 0 19. RD0 - port D pin 0 20. RD1 - port D pin 1 21. RD2 - port D pin 2 22. RD3 - port D pin 3 23. RC4 - port C pin 4 24. RC5 - port C pin 5 25. RC6 - port C pin 6 26. RC7 - port C pin 7 27. RD4 - port D pin 4 28. RD5 - port D pin 5 29. RD6 - port D pin 6 30. RD7 - port D pin 7 31. VSS - ground 32. VDD- power supply 33. RB0 - port B pin 0 34. RB1 - port B pin 1 35. RB2 - port B pin 2 36. RB3 - port B pin 3 37. RB4 - port B pin 4 38. RB5 - port B pin 5 39. RB6 - port B pin 6 40. RB7 - port B pin 7

By utilizing all of this pin so many application can be done such as:
48

www.final-yearproject.com | www.finalyearthesis.com

1. LCD connect to Port B pin. 2. LED connect to any pin declared as output. 3. Relay and Motor - connect to any pin declared as output. 4. External EEPROM connect to I2C interface pin RC3 and RC4 (SCL and SDA) 5. LDR, Potentiometer and sensor connect to analogue input pin such as RA0. 6. GSM modem dial up modem connect to RC6 and RC7 the serial communication interface using RS232 protocol.

3.8.1 Clock generator oscillator


Oscillator circuit is used for providing a microcontroller with a clock. Clock is needed so that microcontroller could execute a program or program instructions. Types of oscillators: PIC16F877A can work with four different configurations of an oscillator. Since configurations with crystal oscillator and resistor-capacitor (RC) are the ones that are used most frequently, these are the only ones we will mention here. Microcontroller type with a crystal oscillator has in its designation XT, and a microcontroller with resistor-capacitor pair has a designation RC. XT Oscillator Crystal oscillator is kept in metal housing with two pins where you have written down the frequency at which crystal oscillates. One ceramic capacitor of 30pF whose other end is connected to the ground needs to be connected with each pin. Oscillator and capacitors can be packed in joint case with three pins. Such element is called ceramic resonator and is represented in charts like the one below. Center pins of the element are the ground, while end pins are connected with OSC1 and OSC2 pins on the microcontroller. When designing a device, the rule is to place an oscillator nearer a microcontroller, so as to avoid any interference on lines on which microcontroller is receiving a clock.RC Oscillator. In applications where great time precision is not necessary, RC oscillator offers additional savings during purchase. Resonant frequency of RC oscillator depends on supply voltage rate, resistance R, capacity C and working temperature. It

49

www.final-yearproject.com | www.finalyearthesis.com

should be mentioned here that resonant frequency is also influenced by normal variations in process parameters, by tolerance of external R and C components, etc. Above diagram shows how RC oscillator is connected with PIC16F877A. With value of resistor R being below 2.2k, oscillator can become unstable, or it can even stop the oscillation. With very high value of R (ex.1M) oscillator becomes very sensitive to noise and humidity. It is recommended that value of resistor R should be between 3 and 100k. Even though oscillator will work without an external capacitor (C=0pF), capacitor above 20pF should still be used for noise and stability. No matter which oscillator is being used, in order to get a clock that microcontroller works upon, a clock of the oscillator must be divided by 4. Oscillator clock divided by 4 can also be obtained on OSC2/CLKOUT pin, and can be used for testing or synchronizing other logical circuits.

Figure 2.9 relationships between a clock and a number of instruction cycles Following a supply, oscillator starts oscillating. Oscillation at first has an unstable period and amplitude, but after some period of time it becomes stabilized.

Figure 2.10 Signal of an oscillator clock after receiving the supply of microcontroller
50

www.final-yearproject.com | www.finalyearthesis.com

To prevent such inaccurate clock from influencing microcontroller's performance, we need to keep the microcontroller in reset state during stabilization of oscillator's clock. Diagram above shows a typical shape of a signal which microcontroller gets from the quartz oscillator. Reset Reset is used for putting the microcontroller into a 'known' condition. That practically means that microcontroller can behave rather inaccurately under certain undesirable conditions. In order to continue its proper functioning it has to be reset, meaning all registers would be placed in a starting position. Reset is not only used when microcontroller doesn't behave the way we want it to, but can also be used when trying out a device as an interrupt in program execution, or to get a microcontroller ready when loading a program. In order to prevent from bringing a logical zero to MCLR pin accidentally (line above it means that reset is activated by a logical zero), MCLR has to be connected via resistor to the positive supply pole. Resistor should be between 5 and 10K. This kind of resistor, whose function is to keep a certain line on a logical one as a preventive, is called a pull up. Microcontroller PIC16F877A knows several sources of resets: a) Reset during power on, POR (Power-On Reset) b) Reset during regular work by bringing logical zero to MCLR microcontroller's pin. c) Reset during SLEEP regime d) Reset at watchdog timer (WDT) overflow e) Reset during at WDT overflow during SLEEP work regime.

The most important reset sources are a) and b). The first one occurs each time a power supply is brought to the microcontroller and serves to bring all registers to a starting position initial state. The second one is a product of purposeful bringing in of a logical zero to MCLR pin during normal operation of the microcontroller. This second one is often used in program development.

51

www.final-yearproject.com | www.finalyearthesis.com

During a reset, RAM memory locations are not being reset. They are unknown during a power up and are not changed at any reset. Unlike these, SFR registers are reset to a starting position initial state. One of the most important effects of a reset is setting a program counter (PC) to zero (0000h) , which enables the program to start executing from the first written instruction. Reset at supply voltage drop below the permissible. Impulse for resetting during voltage voltage-up is generated by microcontroller itself when it detects an increase in supply Vdd (in a range from 1.2V to 1.8V). That impulse lasts 72ms which is enough time for an oscillator to get stabilized. These 72ms are provided by an internal PWRT timer which has its own RC oscillator. Microcontroller is in a reset mode as long as PWRT is active. However, as device is working, problem arises when supply doesn't drop to zero but falls below the limit that guarantees microcontroller's proper functioning. This is a likely case in practice, especially in industrial environment where disturbances and instability of supply are an everyday occurrence. To solve this problem we need to make sure that microcontroller is in a reset state each time supply falls below the approved limit. If, according to electrical specification, internal reset circuit of a microcontroller cannot satisfy the needs, special electronic components can be used which are capable of generating the desired reset signal. Beside this function, they can also function in watching over supply voltage. If voltage drops below specified level, a logical zero would appear on MCLR pin which holds the microcontroller in reset state until voltage is not within limits that guarantee accurate performance.

52

www.final-yearproject.com | www.finalyearthesis.com

Figure 2.11 shows the voltage supply drop Central Processing Unit Central processing unit (CPU) is the brain of a microcontroller. This part is responsible for finding and fetching the right instruction which needs to be executed, for decoding that instruction, and finally for its execution. Central processing unit connects all parts of the microcontroller into one whole. Surely, its most important function is to decode program instructions. When programmer writes a program, instructions have a clear form like MOVLW 0x20. However, in order for a microcontroller to understand that, this 'letter' form of an instruction must be translated into a series of zeros and ones which is called an 'opcode'. This transition from a letter to binary form is done by translators such as assembler translator (also known as an assembler). Instruction thus fetched from program memory must be decoded by a central processing unit. We can then select from the table of all the instructions a set of actions which execute a assigned task defined by instruction. As instructions may within themselves contain assignments which require different transfers of data from one memory into another, from memory onto ports, or some other calculations, CPU must be connected with all parts of the microcontroller. This is made possible through a data bus and an address bus. Arithmetic logic unit is responsible for performing operations of adding, subtracting, moving (left or right within a register) and logic operations. Moving data
53

www.final-yearproject.com | www.finalyearthesis.com

inside a register is also known as 'shifting'. PIC16F877A contains an 8-bit arithmetic logic unit and 8-bit work registers. In instructions with two operands, ordinarily one operand is in work register (W register), and the other is one of the registers or a constant. By operand we mean the contents on which some operation is being done, and a register is any one of the GPR or SFR registers. GPR is an abbreviation for 'General Purposes Registers', and SFR for 'Special Function Registers'. In instructions with one operand, an operand is either W register or one of the registers. As an addition in doing operations in arithmetic and logic, ALU controls status bits (bits found in STATUS register). Execution of some instructions affects status bits, which depends on the result itself. Depending on which instruction is being executed, ALU can affect values of Carry (C), Digit Carry (DC), and Zero (Z) bits in STATUS register.

3.9 Ports
Term "port" refers to a group of pins on a microcontroller which can be accessed simultaneously, or on which we can set the desired combination of zeros and ones, or read from them an existing status. Physically, port is a register inside a microcontroller which is connected by wires to the pins of a microcontroller. Ports represent physical connection of Central Processing Unit with an outside world. Microcontroller uses them in order to monitor or control other components or devices. Due to functionality, some pins have twofold roles like PA4/TOCKI for instance, which is in the same time the fourth bit of port A and an external input for free-run counter. Selection of one of these two pin functions is done in one of the configuration registers. An illustration of this is the fifth bit T0CS in OPTION register. By selecting one of the functions the other one is disabled. All port pins can be designated as input or output, according to the needs of a device that's being developed. In order to define a pin as input or output pin, the right combination of zeros and ones must be written in TRIS register. If the appropriate bit of TRIS register contains logical "1", then that pin is an input pin, and if the opposite is true, it's an output pin. Every port has its proper TRIS register. Thus, port A has TRISA, and port B has TRISB. Pin direction can be changed during the course of work which is particularly fitting for one-line communication where data flow constantly changes direction. PORTA and PORTB state registers are located in bank
54

www.final-yearproject.com | www.finalyearthesis.com

0, while TRISA and TRISB pin direction registers are located in bank 1.

55

www.final-yearproject.com | www.finalyearthesis.com

CHAPTER 4 GSM
4.1. GSM History
During the early 1980s, analog cellular telephone systems were experiencing rapid growth in Europe, particularly in Scandinavia and the United Kingdom, but also in France and Germany. Each country developed its own system, which was incompatible with everyone else's in equipment and operation. This was an undesirable situation, because not only was the mobile equipment limited to operation within national boundaries, which in a unified Europe were increasingly unimportant, but there was also a very limited market for each type of equipment, so economies of scale and the subsequent savings could not be realized. The Europeans realized this early on, and in 1982 the Conference of European Posts and Telegraphs (CEPT) formed a study group called the Groupe Spcial Mobile (GSM) to study and develop a pan-European public land mobile system. The proposed system had to meet certain criteria:

Good subjective speech quality Low terminal and service cost Support for international roaming Ability to support handheld terminals Support for range of new services and facilities Spectral efficiency ISDN compatibility

Pan-European means European-wide. ISDN throughput at 64Kbs was never envisioned, indeed, the highest rate a normal GSM network can achieve is 9.6kbs. Europe saw cellular service introduced in 1981, when the Nordic Mobile Telephone System or NMT450 began operating in Denmark, Sweden, Finland, and Norway in the 450 MHz range. It was the first multinational cellular system. In 1985 Great Britain started using the Total Access Communications System or TACS at 900 MHz.

www.final-yearproject.com | www.finalyearthesis.com

Later, the West German C-Netz, the French Radiocom 2000, and the Italian RTMI/RTMS helped make up Europe's nine analog incompatible radio telephone systems. Plans were afoot during the early 1980s, however, to create a single European wide digital mobile service with advanced features and easy roaming. While North American groups concentrated on building out their robust but increasingly fraud plagued and featureless analog network, Europe planned for a digital future. Link to my mobile telephone history series In 1989, GSM responsibility was transferred to the European Telecommunication Standards Institute (ETSI), and phase I of the GSM specifications were published in 1990. Commercial service was started in mid-1991, and by 1993 there were 36 GSM networks in 22 countries [6]. Although standardized in Europe, GSM is not only a European standard. Over 200 GSM networks (including DCS1800 and PCS1900) are operational in 110 countries around the world. In the beginning of 1994, there were 1.3 million subscribers worldwide [18], which had grown to more than 55 million by October 1997. With North America making a delayed entry into the GSM field with a derivative of GSM called PCS1900, GSM systems exist on every continent, and the acronym GSM now aptly stands for Global System for Mobile communications. According to the GSM Association as of 2002, here are the current GSM statistics:

No. of Countries/Areas with GSM System (October 2001) - 172 GSM Total Subscribers - 590.3 million (to end of September 2001) World Subscriber Growth - 800.4 million (to end of July 2001) SMS messages sent per month - 23 Billion (to end of September 2001) SMS forecast to end December 2001 - 30 Billion per month GSM accounts for 70.7% of the World's digital market and 64.6% of the World's wireless market

The developers of GSM chose an unproven (at the time) digital system, as opposed to the then-standard analog cellular systems like AMPS in the United States and TACS in the United Kingdom. They had faith that advancements in compression algorithms and digital signal processors would allow the fulfillment of the original criteria and the continual improvement of the system in terms of quality and cost. The over 8000 pages of GSM recommendations try to allow flexibility and competitive innovation

www.final-yearproject.com | www.finalyearthesis.com

among suppliers, but provide enough standardization to guarantee proper interworking between the components of the system. This is done by providing functional and interface descriptions for each of the functional entities defined in the system. The United States suffered no variety of incompatible systems as in the different countries of Europe. Roaming from one city or state to another wasn't difficult . Your mobile usually worked as long as there was coverage. Little desire existed to design an all digital system when the present one was working well and proving popular. To illustrate that point, the American cellular phone industry grew from less than 204,000 subscribers in 1985 to 1,600,000 in 1988. And with each analog based phone sold, chances dimmed for an all digital future. To keep those phones working (and producing money for the carriers) any technological system advance would have to accommodate them. GSM was an all digital system that started new from the beginning. It did not have to accommodate older analog mobile telephones or their limitations. American digital cellular, first called IS-54 and then IS-136, still accepts the earliest analog phones. American cellular networks evolved slowly, dragging a legacy of underperforming equipment with it. Advanced fraud prevention, for example, was designed in later for AMPS, whereas GSM had such measures built in from the start. GSM was a revolutionary system because it was fully digital from the beginning.

4.2. Services provided by GSM


From the beginning, the planners of GSM wanted ISDN compatibility in terms of the services offered and the control signalling used. However, radio transmission limitations, in terms of bandwidth and cost, do not allow the standard ISDN Bchannel bit rate of 64 kbps to be practically achieved. Isn't this a shame? What many wireless customers need most is a high speed data connection and this is what GSM provides least. Only 9.6kbs if everything works right. It is possible the GSM designers in the early 1980s never envisioned the need for such bandwidth. It may be true, too, that in most countries the radio spectrum needed to give every caller a 64kbs channel was never available. The add on

www.final-yearproject.com | www.finalyearthesis.com

technology EDGE (external link) promises higher data speed rates in the near to midterm for GSM. Highest data rates will come in the long term when GSM changes into a radio service based on wide band code division multiple access, and not TDMA. Using the ITU-T definitions (external link), telecommunication services can be divided into bearer services, teleservices, and supplementary services. The most basic teleservice supported by GSM is telephony. As with all other communications, speech is digitally encoded and transmitted through the GSM network as a digital stream. There is also an emergency service, where the nearest emergency-service provider is notified by dialing three digits (similar to 911).

Bearer services: Typically data transmission instead of voice. Fax and SMS are examples. Teleservices: Voice oriented traffic. Supplementary services: Call forwarding, caller ID, call waiting and the like.

A variety of data services is offered. GSM users can send and receive data, at rates up to 9600 bps, to users on POTS (Plain Old Telephone Service), ISDN, Packet Switched Public Data Networks, and Circuit Switched Public Data Networks using a variety of access methods and protocols, such as X.25 or X.32. Since GSM is a digital network, a modem is not required between the user and GSM network, although an audio modem is required inside the GSM network to interwork with POTS. GSM is an all digital network but many machines are still analog, as is most of the local loop. Thus, we need a modem, even though we are dealing with digital. A FAX machine's digital signal processor converts an analog image into an instantaneous digital representation; a series of bits, all 0s and 1s. A modulator then turns these bits into audio tones representing the digital values. An analog FAX machine at the other end converts the tones received back into digital bits and then into an image. This tedious process was required initially because local loops were and are primarily analog. In addition, digital services such as T1, fractional T1, or ISDN, where available, was and is extremely expensive. All digital equipment, such as Group 4 Fax

www.final-yearproject.com | www.finalyearthesis.com

machines, are far higher priced than their analog counterparts. The local loop will remain primarily analog for some time. Other data services include Group 3 facsimile, as described in ITU-T recommendation T.30, which is supported by use of an appropriate fax adaptor. A unique feature of GSM, not found in older analog systems, is the Short Message Service (SMS). SMS is a bidirectional service for short alphanumeric (up to 160 bytes) messages. Messages are transported in a store-and-forward fashion. For pointto-point SMS, a message can be sent to another subscriber to the service, and an acknowledgement of receipt is provided to the sender. SMS can also be used in a cellbroadcast mode, for sending messages such as traffic updates or news updates. Messages can also be stored in the SIM card for later retrieval. Supplementary services are provided on top of teleservices or bearer services. In the current (Phase I) specifications, they include several forms of call forward (such as call forwarding when the mobile subscriber is unreachable by the network), and call barring of outgoing or incoming calls, for example when roaming in another country. Many additional supplementary services will be provided in the Phase 2 specifications, such as caller identification, call waiting, multi-party conversations.

4.3.Architecture of the GSM network


A GSM network is composed of several functional entities, whose functions and interfaces are specified. Figure 1 shows the layout of a generic GSM network. The GSM network can be divided into three broad parts. The Mobile Station is carried by the subscriber. The Base Station Subsystem controls the radio link with the Mobile Station. The Network Subsystem, the main part of which is the Mobile services Switching Center (MSC), performs the switching of calls between the mobile users, and between mobile and fixed network users. The MSC also handles the mobility management operations. Not shown is the Operations and Maintenance Center, which oversees the proper operation and setup of the network. The Mobile Station and the Base Station Subsystem communicate across the Um interface, also known as the air interface or radio link. The Base Station Subsystem communicates with the Mobile services Switching Center across the A interface.

www.final-yearproject.com | www.finalyearthesis.com

As John states, he presents a generic GSM architecture. Lucent, Ericsson, Nokia, and others feature their own vision in their own diagrams. But they all share the same main elements and parts from different vendors should all work together. The links below show how these vendors picture the GSM architecture. You can remember the different terms much better by looking at all these diagrams. Lucent GSM architecture/ Ericsson GSM architecture / Nokia GSM architecture / Siemen's GSM architecture

Figure General architecture of a GSM network

1.

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

www.final-yearproject.com | www.finalyearthesis.com

GSM phones use SIM cards, or Subscriber information or identity modules. Memory modules. They're the biggest difference a user sees between a GSM phone or handset and a conventional cellular telephone. With the SIM card and its memory the GSM handset is a smart phone, doing many things a conventional cellular telephone cannot. Like keeping a built in phone book or allowing different ringtones to be downloaded and then stored. Conventional cellular telephones either lack the features GSM phones have built in, or they must rely on resources from the cellular system itself to provide them. Let me make another, important point. With a SIM card your account can be shared from mobile to mobile, at least in theory. Want to try out your neighbor's brand new mobile? You should be able to put your SIM card into that GSM handset and have it work. The GSM network cares only that a valid account exists, not that you are using a different device. You get billed, not the neighbor who loaned you the phone. This flexibility is completely different than AMPS technology, which enables one device per account. No swtiching around. Conventional cellular telephones have their electronic serial number burned into a chipset which is permanently attached to the phone. No way to change out that chipset or trade with another phone. SIM card technology, by comparison, is meant to make sharing phones and other GSM devices quick and easy.

www.final-yearproject.com | www.finalyearthesis.com

On the left above: Front of a Pacific Bell GSM phone. In the middle above: Same phone, showing the back. The SIM card is the white plastic square. It fits into the grey colored holder next to it. On the right above. A new and different idea, a holder for two SIM cards, allowing one phone to access either of two wireless carriers. Provided you have an account with both. :-) The Sim card is to the left of the body.

4.5 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 tranceivers 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 BTS or Base Transceiver Station is also called an RBS or Remote Base station. Whatever the name, this is the radio gear that passes all calls coming in and going out of a cell site. The base station is under direction of a base station controller so traffic gets sent there first. The base station controller, described below, gathers the calls from many base stations and passes them on to a mobile telephone switch. From that switch come and go the calls from the regular telephone network. Some base stations are quite small, the one pictured here is a large outdoor unit. The large number of base stations and their attendant controllers, are a big difference between GSM and IS-136.

www.final-yearproject.com | www.finalyearthesis.com

The Base Station Controller 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 Center (MSC).

Another difference between conventional cellular and GSM is the base station controller. It's an intermediate step between the base station transceiver and the mobile switch. GSM designers thought this a better approach for high density cellular networks. As one anonymous writer penned, "If every base station talked directly to the MSC, traffic would become too congested. To ensure quality communications via traffic management, the wireless infrastructure network uses Base Station Controllers as a way to segment the network and control congestion. The result is that MSCs route their circuits to BSCs which in turn are responsible for connectivity and routing of calls for 50 to 100 wireless base stations."

Many GSM descriptions picture equipment called a TRAU, which stands for Transcoding Rate and Adaptation Unit. Of course. Also known as a TransCoding Unit or TCU, the TRAU is a compressor and converter. It first compresses traffic coming from the mobiles through the base station controllers. That's quite an achievement because voice and data have already been compressed by the voice coders in the handset. Anyway, it crunches that data down even further. It then puts the traffic into a format the Mobile Switch can understand. This is the transcoding part of its name, where code in one format is converted to another. The TRAU is not required but apparently it saves quite a bit of money to install one. Here's how Nortel Networks sells their unit:

www.final-yearproject.com | www.finalyearthesis.com

"Reduce transmission resources and realize up to 75% transmission cost savings with the TCU." "The TransCoding Unit (TCU), inserted between the BSC and MSC, enables speech compression and data rate adaptation within the radio cellular network. The TCU is designed to reduce transmission costs by minimizing transmission resources between the BSC and MSC. This is achieved by reducing the number of PCM links going to the BSC, since four traffic channels (data or speech) can be handled by one PCM time slot. Additionally, the modular architecture of the TCU supports all three GSM vocoders (Full Rate, Enhanced Full Rate, and Half Rate) in the same cabinet, providing you with a complete range of deployment options." Voice coders or vocoders are built into the handsets a cellular carrier distributes. They're the circuitry that turns speech into digital. The carrier specifies which rate they want traffic compressed, either a great deal or just a little. The cellular system is designed this way, with handset vocoders working in league with the equipment of the base station subsystem.

4.6 Network Subsystem


The Mobile Switch The central component of the Network Subsystem is the Mobile services Switching Center (MSC). It acts like a normal switching node of the PSTN or ISDN, and additionally 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 form the Network Subsystem. The MSC provides the connection to the fixed networks (such as the PSTN or ISDN). Signalling between functional entities in the Network Subsystem uses Signalling System Number 7 (SS7), used for trunk signalling in ISDN and widely used in current public networks. Mobile switches go by many names: mobile switch (MS), mobile switching center (MSC), or mobile telecommunications switching office (MTSO). They all do the same thing, however, and that is to process mobile telephone calls. This switch can be

www.final-yearproject.com | www.finalyearthesis.com

a normal landline switch like a 5ESS, a Nokia, an Alcatel, or an Ericsson AXE (Automatic Exchange Electric) or a dedicated switch, built just to handle mobile calls. Each mobile switch manages dozens to scores of cell sites. In GSM the mobile switch handles cell sites by first directing the base station controllers. Large systems may have two or more MSCs. It's easy understand what a switch does. What is harder to understand is the role the switch has to do with other network resources. Home Location Register and the Visitor/ed Location Register 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 signalling address of the VLR associated with the mobile station. The actual routing procedure will be described later. There is logically one HLR per GSM 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 signalling required. Note that the MSC contains no information about particular mobile stations --- this information is stored in the location registers. The Home Location Register and the Visitor or Visited Location Register work together -- they permit both local operation and roaming outside the local service area. You couldn't use your mobile in San Francisco and then Los Angeles without these two electronic directories sharing information. Most often these these two directories are located in the same place, often on the same computer.

www.final-yearproject.com | www.finalyearthesis.com

The HLR and VLR are big databases maintained on computers called servers, often UNIX workstations. Companies like Tandem, now part of Compaq, make the servers, which they call HLRs when used for cellular. These servers maintain more than the home location register, but that's what they call the machine. Many mobile switches use the same HLR. So, you'll have many Home Location Registers. To operate its nationwide cellular system, iDEN, Motorola uses over 60 HLRs nationwide. The HLR stores complete local customer information. It's the main database. Signed up for cellular service in Topeka? Your carrier puts your information on its nearest HRL, or the one assigned to your area. That info includes your international mobile equipment identity number or IMEI, your directory number, and the class of service you have. It also includes your current city and your last known "location area," the place you last used your mobile. The VLR or visitor location registry contains roamer information. Passing through another carrier's system? Once the visited system detects your mobile, its VLR queries your assigned home location register. The VLR makes sure you are a valid subscriber, then retrieves just enough information from the now distant HLR to manage your call. It temporarily stores your last known location area, the power your mobile uses, special services you subscribe to and so on. Though traveling, the cellular network now knows where you are and can direct calls to you. The equipment Identity Register and the Authentication Center 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 Center (AuC) is a protected database that stores a copy of the secret key stored in each subscriber's SIM card, which is used for authentication and encryption over the radio channel.

www.final-yearproject.com | www.finalyearthesis.com

"The Equipment Identity Register (EIR) is a standard GSM network element that allows a mobile network to check the type and serial number of a mobile device and determine whether or not to offer any service." The EIR or equipment identity register is yet another database. It's first purpose is to deny stolen or defective mobiles service. Good mobiles are allowed on the network, of course, as is faulty but still serviceable equipment. In the latter case such mobiles are flagged for the cellular carrier to monitor. The AC or AuC is the Authentication Center, a secured database handling authentication and encryption keys. Authentication verifies a mobile customer with a complex challenge and reply routine. The network sends a randomly generated number to the mobile. The mobile then performs a calculation against it with a number it has stored in its SIM and sends the result back. Only if the switch gets the number it expects does the call proceed. The AC stores all data needed to authenticate a call and to then encrypt both voice traffic and signaling messages. The Interfaces Cellular radio's most cryptic terms belong to these names: A, Um, Abis, and Ater. A telecom interface means many things. It can be a mechanical or electrical link connecting equipment together. Or a boundary between systems, such as between the base station system and the network subsystem. GSM calls that one Interface "A", remember? To be more specific, Smith says "A" is the signaling link between the two subsystems. Which brings us to the point I want to make. Interfaces are standardized methods for passing information back and forth. The transmission media isn't important. Whether copper or fiber optic cable or microwave radio, an interface insists that signals go back and forth in the same way, in the same format. With this approach different equipment from any manufacturer will work together. See my page on standards. Let's consider the the A-bis interface as an example. Tektronix says the A-bis "is a French term meaning 'the second A Interface.' " Good grief! In most cases the actual span or physical connection is made on a T1 line or in Europe its equivalent, the

www.final-yearproject.com | www.finalyearthesis.com

E1.But regardless of the material used, the transmission media, it is the signaling protocol that is most important. Although the interface is unlabeled, the mobile switch communicates with the telephone network using Signaling System Seven, an internationally agreed upon standard. More specifically, it uses ISUP over SS7. As the Performance Technologies people tersely put in in their tutorial on SS7, "ISUP defines the protocol and procedures used to set-up, manage, and release trunk circuits that carry voice and data calls over the public switched telephone network (PSTN). ISUP is used for both ISDN and non-ISDN calls." Using SS7 throughout is a big difference between conventional cellular and GSM. IS136 and IS-95 also uses SS7 but to communicate between the HLR and VLR it uses a standard called IS-41. What about the mysterious UM? That's the radio link between a mobile and a base station. Um are the actual radio frequencies that calls are put on. Possibly the letters stand for User Mobile. R.C. Levine clears up this matter nicely, "Interface names (A, Abis, B, C, etc.) were arbitrarily assigned in alphabetical order. The Um label is taken from the customer-network U interface label used in ISDN. Although mnemonics have been proposed for these letters, they are after-the-fact."

Figure 1. General architecture of a GSM network

www.final-yearproject.com | www.finalyearthesis.com

CHAPTER 5 RELAY
5.1 Introduction to relay
A relay is an electrically operated switch. Many relays use an electromagnet to operate a switching mechanism, but other operating principles are also used. Relays find applications where it is necessary to control a circuit by a low-power signal, or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits, repeating the signal coming in from one circuit and re-transmitting it to another. Relays found extensive use in telephone exchanges and early computers to perform logical operations. A type of relay that can handle the high power required to directly drive an electric motor is called a contactor. Solidstate relays control power circuits with no moving parts, instead using a semiconductor device triggered by light to perform switching. Relays with calibrated operating characteristics and sometimes multiple operating coils are used to protect electrical circuits from overload or faults; in modern electric power systems these functions are performed by digital instruments still called "protection relays". Basic design and operation:

Simple electromechanical relay

www.final-yearproject.com | www.finalyearthesis.com

Small relay as used in electronics A simple electromagnetic relay, such as the one taken from a car in the first picture, is an adaptation of an electromagnet. It consists of a coil of wire surrounding a soft iron core, an iron yoke, which provides a low reluctance path for magnetic flux, a movable iron armature, and a set, or sets, of contacts; two in the relay pictured. The armature is hinged to the yoke and mechanically linked to a moving contact or contacts. It is held in place by a spring so that when the relay is de-energized there is an air gap in the magnetic circuit. In this condition, one of the two sets of contacts in the relay pictured is closed, and the other set is open. Other relays may have more or fewer sets of contacts depending on their function. The relay in the picture also has a wire connecting the armature to the yoke. This ensures continuity of the circuit between the moving contacts on the armature, and the circuit track on the printed circuit board (PCB) via the yoke, which is soldered to the PCB. When an electric current is passed through the coil, the resulting magnetic field attracts the armature and the consequent movement of the movable contact or contacts either makes or breaks a connection with a fixed contact. If the set of contacts was closed when the relay was De-energized, then the movement opens the contacts and breaks the connection, and vice versa if the contacts were open. When the current to the coil is switched off, the armature is returned by a force, approximately half as strong as the magnetic force, to its relaxed position. Usually this force is provided by a spring, but gravity is also used commonly in industrial motor starters. Most relays are manufactured to operate quickly. In a low voltage application, this is to reduce noise. In a high voltage or high current application, this is to reduce arcing. If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise generate a voltage spike dangerous to circuit components. Some automotive relays already include a diode inside the relay case. Alternatively a contact protection network, consisting of a capacitor and resistor in series, may absorb the surge. If the coil is designed to be energized with AC, a small copper ring can be crimped to the end of the solenoid. This "shading ring" creates a small out-of-phase current, which increases the minimum pull on the armature during the AC cycle.

www.final-yearproject.com | www.finalyearthesis.com

By analogy with the functions of the original electromagnetic device, a solid-state relay is made with a thyristor or other solid-state switching device. To achieve electrical isolation an opt coupler can be used which is a light-emitting diode (LED) coupled with a photo transistor.

5.2 Types
Latching relay

Latching relay, dust cover removed, showing pawl and ratchet mechanism. The ratchet operates a cam, which raises and lowers the moving contact arm, seen edge-on just below it. The moving and fixed contacts are visible at the left side of the image. A latching relay has two relaxed states (bistable). These are also called "impulse", "keep", or "stay" relays. When the current is switched off, the relay remains in its last state. This is achieved with a solenoid operating a ratchet and cam mechanism, or by having two opposing coils with an over-center spring or permanent magnet to hold the armature and contacts in position while the coil is relaxed, or with a remanent core. In the ratchet and cam example, the first pulse to the coil turns the relay on and the second pulse turns it off. In the two coil example, a pulse to one coil turns the relay on and a pulse to the opposite coil turns the relay off. This type of relay has the advantage that it consumes power only for an instant, while it is being switched, and it retains its last setting across a power outage. A remanent core latching relay requires a current pulse of opposite polarity to make it change state. Reed relay A reed relay has a set of contacts inside a vacuum or inert gas filled glass tube, which protects the contacts against atmospheric corrosion. The contacts are closed by a

www.final-yearproject.com | www.finalyearthesis.com

magnetic field generated when current passes through a coil around the glass tube. Reed relays are capable of faster switching speeds than larger types of relays, but have low switch current and voltage ratings.

Mercury-wetted relay A mercury-wetted reed relay is a form of reed relay in which the contacts are wetted with mercury. Such relays are used to switch low-voltage signals (one volt or less) because of their low contact resistance, or for high-speed counting and timing applications where the mercury eliminates contact bounce. Mercury wetted relays are position-sensitive and must be mounted vertically to work properly. Because of the toxicity and expense of liquid mercury, these relays are rarely specified for new equipment. See also mercury switch. Polarized relay A polarized relay placed the armature between the poles of a permanent magnet to increase sensitivity. Polarized relays were used in middle 20th Century telephone exchanges to detect faint pulses and correct telegraphic distortion. The poles were on screws, so a technician could first adjust them for maximum sensitivity and then apply a bias spring to set the critical current that would operate the relay. Machine tool relay A machine tool relay is a type standardized for industrial control of machine tools, transfer machines, and other sequential control. They are characterized by a large number of contacts (sometimes extendable in the field) which are easily converted from normally-open to normally-closed status, easily replaceable coils, and a form factor that allows compactly installing many relays in a control panel. Although such

www.final-yearproject.com | www.finalyearthesis.com

relays once were the backbone of automation in such industries as automobile assembly, the programmable logic controller (PLC) mostly displaced the machine tool relay from sequential control applications. Contactor relay A contactor is a very heavy-duty relay used for switching electric motors and lighting loads. Continuous current ratings for common contactors range from 10 amps to several hundred amps. High-current contacts are made with alloys containing silver. The unavoidable arcing causes the contacts to oxidize; however, silver oxide is still a good conductor. Such devices are often used for motor starters. A motor starter is a contactor with overload protection devices attached. The overload sensing devices are a form of heat operated relay where a coil heats a bi-metal strip, or where a solder pot melts, releasing a spring to operate auxiliary contacts. These auxiliary contacts are in series with the coil. If the overload senses excess current in the load, the coil is deenergized. Contactor relays can be extremely loud to operate, making them unfit for use where noise is a chief concern. Solid-state relay

Solid state relay, which has no moving parts

25 A or 40 A solid state contactors

www.final-yearproject.com | www.finalyearthesis.com

A solid state relay (SSR) is a solid state electronic component that provides a similar function to an electromechanical relay but does not have any moving components, increasing long-term reliability. With early SSR's, the tradeoff came from the fact that every transistor has a small voltage drop across it. This voltage drop limited the amount of current a given SSR could handle. As transistors improved, higher current SSR's, able to handle 100 to 1,200 Amperes, have become commercially available. Compared to electromagnetic relays, they may be falsely triggered by transients. Solid state contactor relay A solid state contactor is a very heavy-duty solid state relay, including the necessary heat sink, used for switching electric heaters, small electric motors and lighting loads; where frequent on/off cycles are required. There are no moving parts to wear out and there is no contact bounce due to vibration. They are activated by AC control signals or DC control signals from Programmable logic controller (PLCs), PCs, Transistortransistor logic (TTL) sources, or other microprocessor and microcontroller controls. Buchholz relay A Buchholz relay is a safety device sensing the accumulation of gas in large oil-filled transformers, which will alarm on slow accumulation of gas or shut down the transformer if gas is produced rapidly in the transformer oil. Forced-guided contacts relay A forced-guided contacts relay has relay contacts that are mechanically linked together, so that when the relay coil is energized or de-energized, all of the linked contacts move together. If one set of contacts in the relay becomes immobilized, no other contact of the same relay will be able to move. The function of forced-guided contacts is to enable the safety circuit to check the status of the relay. Forced-guided contacts are also known as "positive-guided contacts", "captive contacts", "locked contacts", or "safety relays".

www.final-yearproject.com | www.finalyearthesis.com

Overload protection relay Electric motors need over current protection to prevent damage from over-loading the motor, or to protect against short circuits in connecting cables or internal faults in the motor windings. One type of electric motor overload protection relay is operated by a heating element in series with the electric motor. The heat generated by the motor current heats a bimetallic strip or melts solder, releasing a spring to operate contacts. Where the overload relay is exposed to the same environment as the motor, a useful though crude compensation for motor ambient temperature is provided. Pole and throw:

Circuit symbols of relays. "C" denotes the common terminal in SPDT and DPDT types.

The diagram on the package of a DPDT AC coil relay Since relays are switches, the terminology applied to switches is also applied to relays. A relay will switch one or more poles, each of whose contacts can be thrown by energizing the coil in one of three ways:

www.final-yearproject.com | www.finalyearthesis.com

Normally-open (NO) contacts connect the circuit when the relay is activated; the circuit is disconnected when the relay is inactive. It is also called a Form A contact or "make" contact.

Normally-closed (NC) contacts disconnect the circuit when the relay is activated; the circuit is connected when the relay is inactive. It is also called a Form B contact or "break" contact.

Change-over (CO), or double-throw (DT), contacts control two circuits: one normally-open contact and one normally-closed contact with a common terminal. It is also called a Form C contact or "transfer" contact ("break before make"). If this type of contact utilizesmake before break" functionality, then it is called a Form D contact.

The following designations are commonly encountered:

SPST Single Pole Single Throw. These have two terminals which can be connected or disconnected. Including two for the coil, such a relay has four terminals in total. It is ambiguous whether the pole is normally open or normally closed. The terminology "SPNO" and "SPNC" is sometimes used to resolve the ambiguity.

SPDT Single Pole Double Throw. A common terminal connects to either of two others. Including two for the coil, such a relay has five terminals in total. DPST Double Pole Single Throw. These have two pairs of terminals. Equivalent to two SPST switches or relays actuated by a single coil. Including two for the coil, such a relay has six terminals in total. The poles may be Form A or Form B (or one of each).

DPDT Double Pole Double Throw. These have two rows of change-over terminals. Equivalent to two SPDT switches or relays actuated by a single coil. Such a relay has eight terminals, including the coil.

The "S" or "D" may be replaced with a number, indicating multiple switches connected to a single actuator. For example 4PDT indicates a four pole double throw relay (with 14 terminals).

www.final-yearproject.com | www.finalyearthesis.com

5.3 Applications: Relays are used to and for:

Control a high-voltage circuit with a low-voltage signal, as in some types of modems or audio amplifiers, Control a high-current circuit with a low-current signal, as in the starter solenoid of an automobile, Detect and isolate faults on transmission and distribution lines by opening and closing circuit breakers (protection relays),

A DPDT AC coil relay with "ice cube" packaging

Isolate the controlling circuit from the controlled circuit when the two are at different potentials, for example when controlling a mains-powered device from a low-voltage switch. The latter is often applied to control office lighting as the low voltage wires are easily installed in partitions, which may be often moved as needs change. They may also be controlled by room occupancy detectors in an effort to conserve energy,

Logic functions. For example, the boolean AND function is realised by connecting normally open relay contacts in series, the OR function by connecting normally open contacts in parallel. The change-over or Form C contacts perform the XOR (exclusive or) function. Similar functions for NAND and NOR are accomplished using normally closed contacts. The Ladder programming language is often used for designing relay logic networks.

www.final-yearproject.com | www.finalyearthesis.com

Early computing. Before vacuum tubes and transistors, relays were used as logical elements in digital computers. See ARRA (computer), Harvard Mark II, Zuse Z2, and Zuse Z3. Safety-critical logic. Because relays are much more resistant than semiconductors to nuclear radiation, they are widely used in safetycritical logic, such as the control panels of radioactive waste-handling machinery.

Time delay functions. Relays can be modified to delay opening or delay closing a set of contacts. A very short (a fraction of a second) delay would use a copper disk between the armature and moving blade assembly. Current flowing in the disk maintains magnetic field for a short time, lengthening release time. For a slightly longer (up to a minute) delay, a dashpot is used. A dashpot is a piston filled with fluid that is allowed to escape slowly. The time period can be varied by increasing or decreasing the flow rate. For longer time periods, a mechanical clockwork timer is installed.

Relay application considerations:

A large relay with two coils and many sets of contacts, used in an old telephone switching system.

www.final-yearproject.com | www.finalyearthesis.com

Several 30-contact relays in "Connector" circuits in mid 20th century 1XB switch and 5XB switch telephone exchanges; cover removed on one Selection of an appropriate relay for a particular application requires evaluation of many different factors:

Number and type of contacts normally open, normally closed, (doublethrow) Contact sequence "Make before Break" or "Break before Make". For example, the old style telephone exchanges required Make-before-break so that the connection didn't get dropped while dialing the number.

Rating of contacts small relays switch a few amperes, large contactors are rated for up to 3000 amperes, alternating or direct current Voltage rating of contacts typical control relays rated 300 VAC or 600 VAC, automotive types to 50 VDC, special high-voltage relays to about 15 000 V Coil voltage machine-tool relays usually 24 VAC, 120 or 250 VAC, relays for switchgear may have 125 V or 250 VDC coils, "sensitive" relays operate on a few mill amperes

Coil current Package/enclosure open, touch-safe, double-voltage for isolation between circuits, explosion proof, outdoor, oil and splash resistant, washable for printed circuit board assembly

Assembly Some relays feature a sticker that keeps the enclosure sealed to allow PCB post soldering cleaning, which is removed once assembly is complete.

Mounting sockets, plug board, rail mount, panel mount, through-panel mount, enclosure for mounting on walls or equipment Switching time where high speed is required "Dry" contacts when switching very low level signals, special contact materials may be needed such as gold-plated contacts Contact protection suppress arcing in very inductive circuits Coil protection suppress the surge voltage produced when switching the coil current Isolation between coil circuit and contacts

www.final-yearproject.com | www.finalyearthesis.com

Aerospace or radiation-resistant testing, special quality assurance Expected mechanical loads due to acceleration some relays used in aerospace applications are designed to function in shock loads of 50 g or more Accessories such as timers, auxiliary contacts, pilot lamps, test buttons Regulatory approvals Stray magnetic linkage between coils of adjacent relays on a printed circuit board.

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

5.5 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 ICs can provide, so a low power transistor may be needed to switch the current for the relay's coil.

www.final-yearproject.com | www.finalyearthesis.com

CHAPTER 6 LM324 SOIL MOISTURE SENSOR

www.final-yearproject.com | www.finalyearthesis.com

CHAPTER 7 RESULT

1. Picture of project and working

www.final-yearproject.com | www.finalyearthesis.com

2. WORKING
User sends the message through phone to the gsm module. That message is captured by gsm module and sends the message to the microcontroller directly. Microcontroller understands that message and executes the program. Here we are Writing the program using the string command that accepts the strings as commands directly. If the command is help then gsm understands that user is ready to use the gsm. It stores the number and ready to communicate with that number. Then it sends a message that irrigation project is ready to use Later if the user wants to on the pump. He sends the command on then that message Is sent to the microcontroller. Microcontroller checks the output of soil moisture Sensor. If the water level is low then microcontroller will on the relay that will switch on the Water pump. Then gsm sends the message irrigation water pump is switched on then when the water level is high it will switch off the pump. If the user sends off command then it will switch off the water pump leaving the message irrigation water pump is switched off.

www.final-yearproject.com | www.finalyearthesis.com

3. SIM 300 GSM MODULE

www.final-yearproject.com | www.finalyearthesis.com

CHAPTER 8 CONCLUSION
As the technology is running with time, it completely occupied the life style of human beings. Even though there is such an importance for technology in our routine life there are even people whose life styles are very far to this well known term technology. So it is our responsibility to design few reliable systems which can be even efficiently used by them. This basic idea gave birth to the project GSM controlled soil moisture sensor. Here the automation process is done through the micro controller based technology.

www.final-yearproject.com | www.finalyearthesis.com

APPENDIX A
1 . Source code
#include <16F877A.h> #include <string.h> #include <gsm.h> #use #use delay (clock=20000000) rs232 (baud = 9600, xmit=PIN_B0,rcv=PIN_B1,stream=GSM)

byte ch = 0; int count = 0; byte data[150]; //For SMS storage byte on[] = {"on"}; byte off[] = {"off"}; byte about[] = {"about"}; byte help[] = {"help"}; byte num[12]; void init_gsm() { fprintf(GSM,"AT\r\n"); delay_ms(1500); fprintf(GSM,"AT+CMGF=1\r\n"); delay_ms(1500); } void WRITE_TO_EEPROM(int tdata, int location) //write data to eprom at location { write_eeprom(location,tdata); } int READ_FROM_EEPROM(int location) //read eeprom data strored location { int tdata; tdata = read_eeprom(location); return(tdata);

www.final-yearproject.com | www.finalyearthesis.com

} void main() { int i = 0; int j = 0; int system_on_flag = 0; int pump_on_flag = 0; output_high(PIN_D2); output_high(PIN_D3); delay_ms(1000); output_low(PIN_D2); output_low(PIN_D3); delay_ms(1000); output_high(PIN_D2); output_high(PIN_D3); delay_ms(1000); output_low(PIN_D2); output_low(PIN_D3); init_gsm(); while(1) { output_toggle(PIN_D2); delay_ms(1000); system_on_flag = READ_FROM_EEPROM(0); if(system_on_flag == 1) { output_high(PIN_D3); if((pump_on_flag == 0) && (input(PIN_B6))) //PIN_B6 is from soil sensor output {

www.final-yearproject.com | www.finalyearthesis.com

pump_on_flag = 1; output_high(PIN_D7); //Relay ON fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num); delay_ms(1000); fprintf(GSM,"*** ALERT ***Irrigation Water Pump got Switched ON\r\n"); delay_ms(1000); fputc(0x1A,GSM); delay_ms(2000); } if((pump_on_flag == 1) && (!input(PIN_B6))) //PIN_B6 is from soil sensor output { pump_on_flag = 0; output_low(PIN_D7); //Relay OFF fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num); delay_ms(1000); fprintf(GSM,"*** ALERT ***Irrigation Water Pump got Switched OFF\r\n"); delay_ms(1000); fputc(0x1A,GSM); delay_ms(2000); } }

count = 0; fprintf(GSM,"AT+CMGR=1\r\n"); num = get_gsm_sms_number(); //get the phone number from sms data = get_gsm_sms_text(); //get sms message content fprintf(GSM,"AT+CMGD=1\r\n"); //delete message delay_ms(2000);

www.final-yearproject.com | www.finalyearthesis.com

if(strstr(data,on)) //check if the message got on { WRITE_TO_EEPROM(1,0); //data, location (address) output_high(PIN_D3); fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num); delay_ms(1000); fprintf(GSM,"Irrigation Water Sensing System got switched ON\r\n"); delay_ms(1000); fputc(0x1A,GSM); fgetc(GSM); delay_ms(2000); } else if(strstr(data,off)) { WRITE_TO_EEPROM(0,0); //data, location (address) output_low(PIN_D3); output_low(PIN_D7); fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num); delay_ms(1000); fprintf(GSM,"Irrigation Water Sensing System got switched OFF\r\n"); delay_ms(1000); fputc(0x1A,GSM); fgetc(GSM); delay_ms(2000); } else if(strstr(data,about)) { fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num); delay_ms(1000); output_high(PIN_D2); fprintf(GSM,"B.Tech Final Year(2009-2010) Project.\r\n"); delay_ms(1000); fputc(0x1A,GSM);

www.final-yearproject.com | www.finalyearthesis.com

fgetc(GSM); delay_ms(2000); } else if(strstr(data,help)) //check for help message { fprintf(GSM,"AT+CMGS=\"%s\"\r\n",num); output_high(PIN_D2); delay_ms(1000); fprintf(GSM,"Send \"on\" to on OR \"off\" to off the Automatic Irrigation Water System.\r\n"); fprintf(GSM,"Send \"about\" to know about me \r\n"); delay_ms(1000); fputc(0x1A,GSM); fgetc(GSM); delay_ms(2000); } } }

www.final-yearproject.com | www.finalyearthesis.com

REFERENCES
1. GSM and UMTS: the creation of global mobile communication by Friedhelm Ilebrand 2.GSM: Cellular Network, Subscriber Identity Module by Frederic P. Miller, Agnes F. Vandome 3. The PIC microcontroller by John Morton 4. PIC microcontroller: an introduction to software and hardware interfacing by Han-Way Huang 5.www.rentron.com/pic.htm 6.en.wikibooks.org/wiki/Embedded.../PIC_Microcontroller 7.ww1.microchip.com/downloads/en/DeviceDoc/39630C.pdf 8.www.best-microcontroller-projects.com/12F675.html 9.www.piclist.com/techref/piclist/begin.htm