Sei sulla pagina 1di 55

GSM BASED AC APPLICATION CONTROL

A PROJECT REPORT Submitted by

PATEL ROCKY S. (090280111004) PATEL JIMIT V. (090280111008)

PATEL VISHAL S. (090280111011)

Guided by: Prof. SHILPA RANA


In fulfillment for the award of the degree Of

BACHELOR OF ENGINEERING
In ELECTRONICS & COMMUNICATION

L.D. College of Engineering, Ahmedabad-15.

Gujarat Technological University, Ahmedabad.


November, 2012

ACKNOWLEDGEMENT

We have taken efforts in this project. However, it would not have been possible without the kind support and help of many individuals and organizations. We would like to extend our sincere thanks to all of them.

We are thankful to Prof. Shilpa Rana for their guidance and constant supervision as well as for providing necessary information regarding the project & also for their support in completing the project.

We would like to express our gratitude towards Prof. K.R.Parmar for their kind cooperation and encouragement which help us in completion of this project.

We would like to express special gratitude and thanks to department persons for giving us such attention and time.

Patel Rocky S.

Patel Jimit V.

Patel Vishal S.

ABSTRACT

Now a day's every system is automated in order to face new challenges in the present day situation. Automated systems have less manual operations, so that the flexibility, reliabilities are high and accurate. Hence every field prefers automated control systems. Especially in the field of electronics automated systems are doing better performance .Probably the most useful thing to know about the global system for mobile communication is that it is an international standard. If you travel in parts of world, GSM is only type of cellular service available. Instead of analog services,

The goal of the project is to develop a system, which uses Mobile technology that keeps control of the various units of the home appliances, which executes with respect to the signal sent by the mobile. For utilization of appliances the new concept has been thought to manage them remotely by using GSM, which enables the user to remotely control switching of domestic appliances. Just by dialing keypad of remote telephone, from where we are calling we can perform ON / OFF operation of the appliances.

The ranges of appliances that can be controlled through tele remote systems are many in numbers. Some of them are as follows and this depends upon the usage priority of the appliances i.e. Lights, Motors or other electrical / electronic appliances.

L. D. COLLEGE OF ENGINEERING AHMEDABAD 380 015 ELECTRONICS AND COMMUNICATION DEPARTMENT


____________________________________________________________

CERTIFICATE
Date: This is to certify that the project entitled GSM BASED AC

APPLICATION CONTROL has been carried out by PATEL ROCKY SHANKARBHAI(090280111004), PATEL JIMIT VINODBHAI (090280111008) and PATEL VISHAL SURESHBHAI (090280111011) under my guidance in fulfillment of the degree of Bachelor
of Engineering in ELECTRONICS AND COMMUNICATION ENGINEERING (7th semester) of Gujarat Technological University, Ahmedabad during the academic year 2012-13.

Project guide:-

Head of department:-

Prof. S.K.RANA
Asst. Prof. (E.C. Engg.) L.D.College Of Engineering,Ahmedabad

Prof. K.R.PARMAR
Prof.(E.C. Engg.) L.D.College Of Engineering,Ahmedabad

TABLE OF CONTENTS

Chapter : 1 INTRODUCTION 1.1 Introduction of Project 1.2 Background 1.3 Problem Statement 1.4 GSM Technology 1.5 Microcontroller Chapter: 2 SYSTEM SPECIFICATION AND BLOCK DIAGRAM 2.1 System Specification 2.1.1 Scopes and Purpose of System Specification 2.1.2 Goals and Objectives 2.1.3 Operating environment 2.1.4 Intended Users and Uses 2.1.5 Assumptions 2.2 Block Diagram 2.2.1 Block Diagram 2.2.2 System Operation Flow Diagram Chapter: 3 HARDWARE DESCRIPTION 3.1 Power Supply 3.2 Microcontroller(PIC18F4520) 3.2.2 8-bit Microcontroller with 32K Bytes Flash PIC18F4520 3.2.3 Pin Configurations 3.2.4 Pin Descriptions 3.2.5 Block Diagram Of Microcontroller 9 11 12 14 15 18 5 5 5 6 6 6 7 7 8 1 1 2 3 4

3.2.6 Crystal Oscillator 3.3 GSM Module 3.3.1 GSM Unit 3.4 AT Commands 3.5 LCD 3.6 Relays 3.6.1 Choosing A Relay 3.6.2 Advantages of Relays 3.6.3 Disadvantages of relays 3.7 Contactor Chapter: 4 FLOWCHART AND SCHEMATIC DIAGRAM 4.1 Flowchart Chapter: 5 SOFTWARE AND TOOLS 5.1 Introduction to MPLAB 5.2 Advantages 5.2.1 Steps to create new project Chapter: 6 CONCLUSION AND FUTURE ENHANCEMENT

19 21 22 24 25 28 31 32 32 33

34

38 40 42 46

REFERENCES

47

LIST OF FIGURES

Figure No.

Figure Description

Page No.

Figure 2.2.1 Figure 2.2.2 Figure 3.1.1 Figure 3.2.2 Figure 3.2.3 Figure 3.2.5 Figure 3.2.6

Block Diagram System operation flow diagram Regulated D.C. power supply PIC18F4520 IC Pin diagram of PIC18F4520 Architecture of PIC18F4520 External crystal connection

7 8 10 12 14 18 19 22 23 27 28 28 29 33 36 39 40 41 42 43

Figure 3.3.1(a) GSM Unit(SIM 300) Figure 3.3.1(b) SIM card interface with GSM modem Figure 3.5 Figure 3.6.1 Figure 3.6.2 Figure 3.6.3 Figure 3.7.1 Figure 5.1 16x2 LCD Symbol of relay Relays Relay circuit Telemecanique AC2-D202 contactor MPLAB IDE

Figure 5.2.1(a) Confirming Device Figure 5.2.1(b) Setting up language tools Figure 5.2.1(c) Naming the project Figure 5.2.1(d) Select template tool Figure 5.2.1 (e) Final Screen Shot

LIST OF TABLES

Table No.

Table Description

Page No.

Table 3.3.1 Network status indication Table 3.4 Table 3.5 AT commands used in Project LCD pin function

24 25 26

CHAPTER 1 INTRODUCTION
1.1 Introduction to Project
GSM based AC application Control System implements the emerging applications of the GSM technology. Using GSM networks, a control system has been proposed that will act as an embedded system which can monitor and control appliances and other devices locally using built-in input and output peripherals. Remotely the system allows the user to effectively monitor and control the house/office appliances and equipments via the mobile phone set by sending commands in the form of SMS messages and receiving the appliances status. The main concept behind the project is receiving the sent SMS and processing it further as required to perform several operations. The type of the operation to be performed depends on the nature of the SMS sent. The principle in which the project is based is fairly simple. First, the sent SMS is stored and polled from the receiver mobile station and then the required control signal is generated and sent to the intermediate hardware that we will design according to the command received in form of the sent message. The messages are sent from the mobile set that contain commands in written form which are then processed accordingly to perform the required task. A microcontroller based system has been proposed for our project. There are several terminologies that are used extensively throughout this project report. GSM (Global System for Mobile Communications): It is a cellular communication standard widely used. SMS (Short Message Service): It is a service available on most digital mobile phones that Permit the sending of short messages (also known as text messaging service).

1.2 Background
The new age of technology has redefined communication. Most people nowadays have access to mobile phones and thus the world indeed has become a global village. At any given moment, any particular individual can be contacted with the mobile phone. But the application of mobile phone cant just be restricted to sending SMS or starting conversations. New innovations and ideas can be generated from it that can further enhance its capabilities. Technologies such as Infra-red, Bluetooth, etc which has developed in recent years goes to show the very fact that
1

improvements are in fact possible and these improvements have eased our life and the way we live. Remote management of several home and office appliances is a subject of growing interest and in recent years we have seen many systems providing such controls. These days, apart from supporting voice calls a mobile phone can be used to send text messages as well as multimedia messages (that may contain pictures, graphics, animations, etc). Sending written text messages is very popular among mobile phone users. Instant messaging, as it is also known, allows quick transmission of short messages that allow an individual to share ideas, opinions and other relevant information. We have used the very concept to design a system that acts a platform to receive messages which in fact are commands sent to control different appliances and devices connected to the platform. We have designed a control system which is based on the GSM technology that effectively allows control from a remote area to the desired location. The application of our suggested system is immense in the ever changing technological world. It allows a greater degree of freedom to an individual whether it is controlling the household appliances or office equipments. The need to be physically present in order to control appliances of a certain location is eliminated with the use of our system.

1.3 Problem Statement


Technology has advanced so much in the last decade or two that it has made life more efficient and comfortable. The comfort of being able to take control of devices from one particular location has become imperative as it saves a lot of time and effort. Therefore there arises a need to do so in a systematic manner which we have tried to implement with our system. The system we have proposed is an extended approach to automating a control system. With the advancement and breakthroughs in technology over the years, the lives of people have become more complicated and thus they have become busier than before. With the adoption of our system, we can gain control over certain things that required constant attention. The application of our system comes in handy when people who forget to do simple things such as turn ON or OFF devices at their home or in their office, they can now do so without their presence by the transmission of a simple text message from their mobile phone. This development, we believe, will ultimately save a lot of time especially when people dont have to come back for simple things such as to turn ON/OFF switches at their home or at their office once they set out for their respective work. The objective of this project is to develop a device that allows for a user to remotely control and monitor multiple home/office appliances using a cellular phone. This system will be a powerful and flexible tool that will offer this service at any time, and from anywhere with the constraints

of the technologies being applied. Possible target appliances include (but are not limited to) climate control system, security systems, lights; anything with an electrical interface. The proposed approach for designing this system is to implement a microcontroller-based control module that receives its instructions and command from a cellular phone over the GSM network. The microcontroller then will carry out the issued commands and then communicate the status of a given appliance or device back to the cellular phone.

1.4 GSM Technology

Global System For Mobile Communication (GSM) is a set of ETSI (Europian Telecommunication Standards Institute) standards specifying the infrastructure for a digital cellular service. GSM (Global System for Mobile communication) is a digital mobile telephone service that is widely used in many parts of the world. GSM uses a variation of Time Division Multiple Access (TDMA) and is the most widely used of the three digital wireless telephone technologies (TDMA,GSM and CDMA). GSM digitizes and compresses data, then sends it down a channel with two other streams of user data, each in its own time slot. GSM operates in the 900 MHz, 1800 MHz, or 1900 MHz frequency bands.

GSM (Global System for Mobile communication) is the technology that underpins most of the worlds mobile phone networks. The GSM platform is a hugely successful wireless technology and an unprecedented story of global achievement and cooperation. GSM has become the worlds fastest growing communications technology of all time and leading global mobile standard, spanning 218 countries. GSM is an open, digital cellular technology used for transmitting mobile voice and data services. GSM operates in the 900MHz and 1.8GHz supports data transfer speeds of up to 9.6 kbps, allowing the transmissions of basic data services such as SMS.

Everyday, millions of people are making phone calls by pressing a few buttons. Little is known about how one persons voice reaches the other persons phone that is thousands of miles away. Even less is known about the security measures and protection behind the system. The complexity of the cell phone is increasing as people begin sending text messages and digital pictures to their friends and family. The cell phone is slowly turning into a handheld computer. All the features and advantages in cell phone technology require a backbone to support it.

When a mobile subscriber roams into a new location area (new VLR), the VLR automatically determines that it must update the HLR with the new location information, which it does using an SS7 Location Update Request Message. The Location Update Message is routed to the HLR through the SS7 network, based on the global title translation of the IMSI that is stored within the SCCP Called Party Address portion of the message. The HLR responds with a message that informs the VLR whether the subscriber should be provided service in the new location.

1.5 Micro controller

Microcontrollers as the name suggests are small controllers. They are like single chip computers that are often embedded into other systems to function as processing/controlling unit. Microcontroller A single chip used to control other devices. Any microcomputer system requires memory to store a sequence of instruction making up a program, parallel port or serial port for communicating with an external system, timer / counter for control purposes like generating time delays, Baud rate for the serial port, apart from the controlling unit called the Central Processing Unit.

CHAPTER 2 SYSTEM SPECIFICATION AND BLOCK DIAGRAM

2.1 System Specification 2.1.1 Scopes and Purpose of System Specification

The system specification shows the description of the function and the performance of system and the user. The scope of our project GSM Based control system is immense. The future implications of the project are very great considering the amount of time and resources it saves. The project we have undertaken can be used as a reference or as a base for realizing a scheme to be implemented in other projects of greater level such as weather forecasting, temperature updates, device synchronization, etc. The project itself can be modified to achieve a complete Home Automation system which will then create a platform for the user to interface between himself and the household .

2.1.2 Goals and Objectives

The project GSM based Control System at the title suggests is aimed to construct a control system that enables the complete control of the interface on which it is based. General objectives of the project are defined as; a. To co-ordinate appliances and other devices through Short Message Service (SMS). b. To effectively receive and transmit data via SMS c. To eliminate the need of being physically present in any location for tasks involving the operation of appliances within a household/office. d. Minimize power and time wastage

2.1.3 Operating Environment

The control system will include two separate units: the cellular phone, and the control unit. There will therefore be two operating environments. The cellular phone will operate indoors and outdoors whereas the control unit will operate indoors within the temperature and humidity limits for proper operation of the hardware.

2.1.4 Intended Users and Uses

This system is aimed toward all the average users who wish to control their household/office appliances remotely from their cell phones provided that the appliances are electrically controllable. Example of feasible appliances and applications under consideration include; enable/disable security systems, fans, lights, kitchen appliances, and adjusting the temperatures settings of a heating/ventilation/air conditioning system.

2.1.5 Assumptions
Certain assumptions have to be made in order to implement our project. The list of assumptions for our project is; a. The user and control unit will establish communication via GSM b. The cell phone and service provider chosen will support text messaging service. c. The user is familiar with the text messaging program on their cell phone. d. All service charges (standard messaging rates) from the service provider apply. e. The controlled appliances can and will have to have an electrical interface in order to be controlled by the microcontroller.

2.2 Block Diagram 2.2.1 Block Diagram

Keybo ard

16*2 LCD TRIAC circuit Relay & its driver circuit

GSM Module SIM Card

I/O Ports

PIC18F4520 Power Supply


Figure 2.2.1 Block Diagram

The figure shown above is the simple block diagram of our project. It is a simple illustration of how we have implemented our project and the various parts involved in it. From the above representation, the first Mobile station is used as a transmitting section from which the subscriber sends text messages that contain commands and instructions to the second mobile station which is based on a specific area where our control system is located. Any mobile phone as indicated in the block diagram. The received SMS message is stored in the SIM memory of the phone and then extracted by the microcontroller and processed accordingly to carry out specific operations. The relay driver is used to drive the relay circuits which switches the different appliances connected to the interface.
7

The LCD is used to indicate the status of the operation performed by the microcontroller and also its inclusion makes the overall system user-friendly. The system will also acknowledge the user in case of failure of device. The input from different sensors are feed to micro-controller and processed to operate respective task semi autonomously and autonomously.

2.2.2System Operation Flow Diagram

Figure 2.2.2 System Operation Flow Diagram

Assuming that the control unit is powered and operating properly, the process of controlling a device connected to the interface will proceed through the following steps; The remote user sends text messages including commands to the receiver. GSM receiver receives messages sent from the user cell phone. GSM receiver decodes the sent message and sends the commands to the microcontroller. Microcontroller issues commands to the appliances and the devices connected will switch ON/OFF.
8

CHAPTER 3 HARDWARE DESCRIPTION

Main blocks of the project are listed and explained below:

1. 2. 3. 4. 5. 6. 7.

POWER SUPPLY MICROCONTRLLER((PIC184520) GSM MODULE LCD KEYBOARD RELAYS TRIAC

3.1 Power supply

The power supplies are designed to convert high voltage AC mains electrically to a suitable low voltage supply for electronics circuits and other devices. A power supply can be broken down into a series of blocks, each of which performs a particular function. A d.c. power supply which maintains the output voltage constant irrespective of a a.c. mains fluctuations or load variations is known as Regulated D.C. Power Supply.

Figure 3.1.1 Regulated D.C. Power Supply

By changing the value of RPOT1 as shown in figure 3(g) one can adjust output voltage of LM317.

Here R2 = 240, Vo = 4.1V, so we need to adjust RPOT1 at 550

3.2 MICROCONTROLLER(PIC18F4520)

An embedded microcontroller is a chip, which has a computer processor with all its support function (clocking and reset), memory (both program storage and RAM), and I/O (including bus interfaces) built into the device. These built in function minimize the need for external circuits and devices to the designed in the final applications. The improvements in micro-controller technology has meant that it is often more cost effective, faster and more efficient to develop an application using a micro-controller rather than discrete logic. Creating applications for microcontrollers is completely different than any other development job in computing and electronics.

10

In most other applications, number of subsystems and interfaces are available but this is not the case for the micro-controller where the following responsibilities have to be taken. Power distribution System clocking Interface design and wiring System Programming Application programming Device programming There are two types of micro-controller commonly in use. Embedded micro-controller is the micro-controller, which has the entire hardware requirement to run the application, provided on the chip. External memory micro-controller is the micro-controller that allows the connection of external memory when the program memory is insufficient for an application or during the work a separate ROM (or even RAM) will make the work easier. In this project work we are using PIC18F4520 micro-controller. This micro-controller plays a major role. Micro-controllers were originally used as components in complicated processcontrolled systems. However, because of their small size and low price, Micro-controllers are now also being used in regulators for individual control loops. In several areas micro-controllers are now outperforming their analog counterparts and are cheaper as well. A micro-controller consists of a powerful CPU tightly coupled with memory RAM , ROM or EPROM, various I/O features such as Serial ports, Parallel ports, Timer/counters, Interrupt Controller, Data Acquisition interfaces-Analog to Digital Convertor(ADC), Digital to Analog Convertor(DAC), everything integrated on a single Silicon chip. It does not mean that any microcontroller should have all the above said features on the chip, Depending on the need and area of the application for which it is designed. The ON CHIP features present in it may or may not include all the individual section said above. Any microcomputer system requires memory to store a sequence of instructions making up a program, parallel port or serial port for communicating with an external system, timer/counter for control purposes like generating time delays, Baud rate for the serial port, apart from the controlling unit called the Central processing Unit.

11

3.2.1 CRITERIA FOR CHOOSING A MICRO-CONTROLLER


The first and foremost criterion for choosing a microcontroller is that it must meet the task at hand efficiently and cost effectively .In analyzing the needs of a microcontrollerbased project, it is seen whether an 8-bit, 16-bit or 32-bit -controller can best handle the computing needs of the task most effectively. Among the other considerations in this category are: Speed What is the highest speed that the microcontroller supports? (b) Packaging Does it come in 40-pin DIP (dual inline package) or a QFP (quad flat package), or some other packaging format? This is important in terms of space, assembling, and prototyping the end product. (c) Power consumption This is especially critical for battery-powered products. (d) The number of I/O pins and other peripherals on chip. (f) How easy it is to upgrade to higher performance or lower consumption versions. (g) Cost per unit this is important in terms of the final cost of the product in which a microcontroller is used. The second criterion in choosing a microcontroller is how easy it is to develop products around it. Key considerations include the availability of an assembler, debugger, a code efficient compiler and technical support. The third criterion in choosing a microcontroller is its ready availability in needed quantities both now and in the future. Currently of the leading 8-bit microcontrollers, the PIC18F4520 family has the largest number of diversified suppliers.

3.2.2 8-bit Microcontroller with 32K Bytes Flash PIC18F4520

Figure 3.2.2 PIC18F4520 IC

12

FEATURES

High-performance, Low-power PIC 8-bit Microcontroller

One 8-bit Timer/Counters with Separate Prescalers and Compare Modes Three 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode Real Time Counter with Separate Oscillator Four PWM Channels 13-channel, 10-bit ADC Master/Slave SPI Serial Interface On-chip Analog Comparator Speed Grades DC - 40 MHz Operating Voltages 4.5 - 5.5V for PIC18F4520 2.0 5.5V for PIC18LF4520

13

3.2.3 PIN CONFIGURATIONS

Figure . 3.2.3 pin diagram of PIC18F4520

14

3.2.4 PIN DESCRIPTIONS

VDD:Supply voltage. VSS:Ground. MCLR:Reset Input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running. The minimum pulse length is 1.5 sec Shorter pulses are not guaranteed to generate a reset. Port A (PA7..PA0) : Port A serves as the analog inputs to the A/D Converter. Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. The Port A output buffers have symmetrical drive characteristics with both high sink and source capability of 25mA. The Port A pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port B (PB7..PB0) : Port B is an 8-bit bi-directional I/O port with internal pull-up resistors. The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running. The Port B pins are also multiplexed with Interrupt logic circuits.

15

Port C (PC7..PC0) : Port C is an 8-bit bi-directional I/O port. The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port C pins are multiplexed with communication modules like SPI, I2C and USART. Port D (PD7..PD0) : Port D is an 8-bit bi-directional I/O. The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not running. OCS1:Input to the inverting Oscillator amplifier and input to the internal clock operating circuit. OCS2 :Output from the inverting Oscillator amplifier. Vref+ & Vref-:These are the analog reference pins for the A/D Converter.

Timers On-chip timing/counting facility has proved the capabilities of microcontroller for implementing the real time applications. These includes pulse counting, frequency measurement, pulse width measurement, baud rate generation , etc. Having sufficient number of timer or counter may be a need in a certain design application. The PIC controller has one 8-bit timer and three 16-bit timers. They can be used either as timers to generate a time delay or as counters to count events happening outside the micro-controller.

Polling In polling, the micro-controller continuously moniters the status of a given device; when the status condition is met, it performs the service. After that, it moves on to monitor the next device
16

until each one is serviced. Although polling can monitor the status of several devices and serve each of them as certain condition are met.

Interrupts The PIC controller has multiple interrupt sources and an interrupt priority feature that allows most interrupt sources to be assigned high priority or low priority level. The high priority interrupt vector is at location 0008H. the low priority interrupt vector is at location 0018H. The high priority interrupt events can interrupt any low priority event that may be in the progress. There are ten registers which controls the interrupt operation which are as follows: RCON INTCON1, INTCON2, INTCON3 PIR1, PIR2 PIE1, PIE2 IPR1, IPR2

In general interrupt sources have three bits to control their operation. They are as follows: 1. flag bit to indicate that an interrupt event occurred. 2. Enable bit that allows program execution to branch to the interrupt vector address when the flag bit is set. 3. Priority bit to select high priority or low priority. The interrupt priority feature is enabled by setting the IPEN bit of RCON register. When interrupt priority is enabled, there are two bits which enable interrupts globally. When an interrupt is responded to global interrupt enable bit is cleared to disable further interrupts. Low priority interrupts are not processed when high priority interrupts are in progress.

17

3.2.5 Block diagram of Microcontroller

Figure 3.2.5 Architecture of PIC18F4520

18

3.2.6 CRYSTAL OSCILLATOR

PIC18F2420/2520/4420/4520 devices can be operated in ten different oscillator modes. The user can program the Configuration bits, FOSC<3:0>, in Configuration Register 1H to select one of these ten modes: 1. LP Low-Power Crystal 2. XT Crystal/Resonator 3. HS High-Speed Crystal/Resonator 4. HSPLL High-Speed Crystal/Resonator with PLL Enabled 5. RC External Resistor/Capacitor with FOSC/4 Output on RA6 6. RCIO External Resistor/Capacitor with I/O on RA6 7. INTIO1 Internal Oscillator with FOSC/4 Output on RA6 and I/O on RA7 8. INTIO2 Internal Oscillator with I/O on RA6and RA7 9. EC External Clock with FOSC/4 Output 10. ECIO External Clock with I/O on RA6

Figure 3.2.6 External Crystal Connection

19

3.2.7 Special Function Registers


ADCON0: A/D CONTROL REGISTER 0

ADCON1: A/D CONTROL REGISTER 1

ADCON1: A/D CONTROL REGISTER 2

INTCON: INTERRUPT CONTROL REGISTER

PIR1: PERIPHERAL INTERRUPT REQUEST (FLAG) REGISTER 1

PIE1: PERIPHERAL INTERRUPT ENABLE REGISTER 1

T2CON: TIMER2 CONTROL REGISTER

20

TXSTA: TRANSMIT STATUS AND CONTROL REGISTER

RCSTA: RECEIVE STATUS AND CONTROL REGISTER

3.3 GSM Module:-

GSM (Global System for Mobile Communications) is world's most famous Mobile platform. Mobile phones with SIM cards use GSM technology to help you communicate with your family, friends and business associates. GSM systems have following advantages over basic land line telephony systems: 1. Mobility 2. Easy availability 3. High uptime We use communication feature of Telephone landlines for internet, e-mail, data connectivity, remote monitoring, computer to computer communication, security systems. In the same way we can use GSM technology and benefit from its advantages. We use GSM technology for following applications: 1. Access control devices: Access control devices can communicate with servers and security staff through SMS messaging. Complete log of transaction is available at the head-office Server instantly without any wiring involved and device can instantly alert security personnel on their mobile phone in case of any problem. 2. Transaction terminals: EDC (Electronic Data Capturing) machines can use SMS messaging to confirm transactions from central servers. The main benefit is that central server can be anywhere in the world.

21

3. Supply Chain Management: With a central server in your head office with GSM capability, you can receive instant transaction data from all your branch offices, warehouses and business associates with nil downtime and low cost.

3.3.1 GSM unit:

Figure 3.3.1(a) GSM Unit(SIM300)

The GSM Modem supports popular "AT" command set so that users can develop applications quickly. The product has SIM card holder to which activated SIM card is inserted for normal use. The power to this unit can be given from UPS to provide uninterrupted operation. This product provides great feasibility for devices in remote location to stay connected which otherwise would not have been possible where telephone line do not exist.

22

SIM card interface:The SIM interface supports the functionality of the GSM Phase 1 specification and also supports the functionality of the new GSM Phase 2+ specification for FAST 64 kbps SIM (intended for use with a SIM application Tool-kit). Both 1.8V and 3.0V SIM Cards are supported. The SIM interface is powered from an internal regulator in the module having nominal voltage 2.8V. All pins reset as outputs driving low. SIM card interface with GSM modem is shown in fig.

Figure 3.3.1(b) SIM card interface with GSM modem

Power on module using the PWRKEY pin

Customers application can turn on the module by driving the pin PWRKEY to a low level voltage and after STATUS pin outputs a high level, PWRKEY pin can be released. Customer may monitor the level of the STATUS pin to judge whether the module is power-on or not. An open collector driver circuit is suggested to control the PWRKEY.

23

Status Indication LED


The STATUS pin is set as an output pin and can be used to judge whether module is power-on

Network status indication

Table 3.3.1 Network status indication

3.4 AT COMMANDS
AT commands, also called Hayes AT commands, are based on the Hayes Modem de facto standard, ATTENTION Commands for modems. They are used to communicate with your modem. These commands modify your modem's behavior or instruct the modem to do something specific, such as dialing a telephone number. The "AT" refers to getting the Attention of your modem. To send a command to modem, we need to start a terminal program such as Windows Hyper Terminal .No matter which terminal program you use, it should be configured to communicate with the COM port that your modem is attached to. You then type commands in the Terminal window. The modem executes the command and responds appropriately. One set of AT commands will identify your modem and version information. Eg: -ATD 1<dial string>M] Dials the phone number specified by the <dial string> parameter.

24

AT Command AT AT+CMGF=1 AT+CPMS="ME","ME","ME" AT+CNMI=2,2,0,0,0 AT+CMGR=1 AT+CMGL="ALL" AT+CMGD=1,4

Response OK OK Details of Storage Memory OK

Description

SMS in TEXT Mode NOT in PDU Format Set SMS storage memory Set to receive +CMTI: "ME",26 on arrival of SMS

1st SMS Read 1st SMS All SMS.OK Read ALL SMS OK Delete ALL SMS Table 3.4 AT Commands used in project

3.5 LCD
A liquid crystal display (LCD) is a thin, flat display device made up of any number of color or monochrome pixels arrayed in front of a light source or reflector. Each pixel consists of a column of liquid crystal molecules suspended between two transparent electrodes, and two polarizing filters, the axes of polarity of which are perpendicular to each other. Without the liquid crystals between them, light passing through one would be blocked by the other. The liquid crystal twists the polarization of light entering one filter to allow it to pass through the other. Many microcontroller devices use smart LCD' displays to output visual information. LCD displays designed around Hitachi's LCD HD44780 module, are inexpensive, easy to use, and it is even possible to produce a readout using the 8x80 pixels of the display. They have a standard ASCII set of characters and mathematical symbols. For an 8-bit data bus, the display requires a +5V supply plus 11 I/O lines. For a 4-bit data bus it only requires the supply lines plus seven extra lines. When the LCD display is not enabled, data lines are tri-state and they do not interfere with the operation of the microcontroller. Data can be placed at any location on the LCD.

25

PIN SIGNAL LEVEL DIRECTION 1 2 3 VSS VDD VO +0v +5.0v variable

DESCRIPTION Ground Supply voltage for logic Supply voltage for driving LCD VO = +1v typical at VDD = +5v which gives a VLCD = (VDD VO) = +4v Register selection input H: data register (for read and write) L: instruction code Read/write selection input H: read (MPU module) L: write (MPU module) Read/write enable signal H: write data is latched on the falling edge: read data is enabled by a high level Data bit 0 Data bit 1 Data bit 2 Data bit 3 Data bit 4 Data bit 5 Data bit 6 Data bit 7 Supply voltage for LED A or anode or + of LED backlight Supply voltage for LED K or cathode or - of LED backlight

RS

H/L

R/W

H/L

H/L

7 8 9 10 11 12 13 14 15

DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 LED+ (A) LED(K)

H/L H/L H/L H/L H/L H/L H/L H/L

I/O I/O I/O I/O I/O I/O I/O I/O

16

Table 3.5 LCD Pin Function

26

Figure 3.5 16x2 LCD

For162LCD,theaddresslocationsare: First line Second line 80 81 82 83 C3 84 C4 85 C5 86 C6 through 8F through CF

C0 C1 C2

The LCD also requires 3 control lines from the microcontroller: 1) Enable(E) ThislineallowsaccesstothedisplaythroughR/WandRSlines.Whenthisline is low, the LCD is disabled and ignores signals from R/W and RS. When (E) line is high, the LCD checks the state of the two control lines and responds accordingly. 2) Read/Write(R/W) This line determines the direction of data between the LCD and microcontroller when it is low, data is written to the LCD and when it is high, data is read from the LCD. 3) Register select(RS) With the help of this line, the LCD interprets the type of data on data lines. When it is low,an instruction is being written to the LCD. When it is high, a character is being written to the LCD.
27

Writing and reading the data from the LCD 1) Set R/W bit to low 2) Set RS bit to logic 0or1 (instruction or character) 3) Set data to data lines (if it is writing) 4) Set E line to high 5) Set E line to low

3.6 RELAYS:

A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches.

Figure 3.6.1 symbol of relay

Figure 3.6.2 relays

28

Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits, the link is magnetic and mechanical. The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) cannot provide this current and a transistor is usually used to amplify the small IC current to the larger value required for the relay coil. The maximum output current for the popular 555 timer IC is 200mA so these devices can supply relay coils directly without amplification.

Relays are usually SPDT or DPDT but they can have many more sets of switch contacts, for example relays with 4 sets of changeover contacts are readily available. For further information about switch contacts and the terms used to describe them please see the page on switches. Most relays are designed for PCB mounting but you can solder wires directly to the pins providing you take care to avoid melting the plastic case of the relay. The supplier's catalogue should show you the relay's connections. The coil will be obvious and it may be connected either way round. Relay coils produce brief high voltage 'spikes' when they are switched off and this can destroy transistors and ICs in the circuit. To prevent damage you must connect a protection diode across the relay coil. The animated picture shows a working relay with its coil and switch contacts. You can see a lever on the left being attracted by magnetism when the coil is switched on. This lever moves the switch contacts. There is one set of contacts (SPDT) in the foreground and another behind them, making the relay DPDT.

29

Figure 3.6.3 relay circuit

The relay's switch connections are usually labelled COM, NC and NO: Connect to COM and NO if you want the switched circuit to be on when the relay coil is on. Connect to COM and NC if you want the switched circuit to be on when the relay coil is off. COM = Common, always connect to this, it is the moving part of the switch. NC = Normally Closed, COM is connected to this when the relay coil is off. NO = Normally Open, COM is connected to this when the relay coil is on.

3.6.1 Choosing a relay


You need to consider several features when choosing a relay: 1. Physical size and pin arrangement If you are choosing a relay for an existing PCB you will need to ensure that its dimensions and pin arrangement are suitable. You should find this information in the supplier's catalogue.

30

2. Coil voltage The relay's coil voltage rating and resistance must suit the circuit powering the relay coil. Many relays have a coil rated for a 12V supply but 5V and 24V relays are also readily available. Some relays operate perfectly well with a supply voltage which is a little lower than their rated value. 3. Coil resistance The circuit must be able to supply the current required by the relay coil. You can use Ohm's law to calculate the current: Relay coil current = supply voltage/coil resistance For example: A 12V supply relay with a coil resistance of 400 passes a current of 30mA. This is OK for a 555 timer IC (maximum output current 200mA), but it is too much for most ICs and they will require a transistor to amplify the current. 4. Switch ratings (voltage and current) The relay's switch contacts must be suitable for the circuit they are to control. You will need to check the voltage and current ratings. Note that the voltage rating is usually higher for AC, for example: "5A at 24V DC or 125V AC". 5. Switch contact arrangement (SPDT, DPDT etc) Most relays are SPDT or DPDT which are often described as "single pole change over" (SPCO) or "double pole changeover" (DPCO).

Protection diodes for relays


Transistors and ICs (chips) must be protected from the brief high voltage 'spike' produced when the relay coil is switched off. The diagram shows how a signal diode (eg 1N4148)is connected across the relay coil to provide this protection. Note that the diode is connected 'backwards' so that it will normally not conduct. Conduction only occurs when the relay coil is switched off, at this moment current tries to continue flowing through the coil and it is harmlessly diverted through the diode. Without the diode no current could flow and the coil would produce a damaging high voltage 'spike' in its attempt to keep the current flowing.

Reed relays
Reed relays consist of a coil surrounding a reed switch. Reed switches are normally operated with a magnet, but in a reed relay current flows through the coil to create a magnetic field and close the reed switch. Reed relays generally have higher coil resistances than standard relays (1000 for example) and a wide range of supply voltages (9-20V for example). They are
31

capable of switching much more rapidly than standard relays, up to several hundred times per second; but they can only switch low currents (500mA maximum for example).The reed relay shown in the photograph will plug into a standard 14-pinDIL socket ('chip holder').

Relays and transistors compared

Like relays, transistors can be used as an electrically operated switch. For switching small DC currents (< 1A) at low voltage they are usually a better choice than a relay. However transistors cannot switch AC or high voltages (such as mains electricity) and they are not usually a good choice for switching large currents (> 5A). In these cases a relay will be needed, but note that a low power transistor may still be needed to switch the current for the relay's coil! The main advantages and disadvantages of relays are listed below:

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

3.6.3 Disadvantages of Relays:


Relays are bulkier than transistors for switching small currents. Relays cannot switch rapidly (except reed relays), transistors can switch many times per second. Relays use more power due to the current flowing through their coil. Relays require more current than many chips can provide, so a low power transistor may be needed to switch the current for the relay's coil.

32

3.7 CONTACTOR

Figure 3.7.1 Telemecanique AC2-D202 contactor

A contactor is an electrically controlled switch used for switching a power circuit, similar to a relay except with higher current ratings. A contactor is controlled by a circuit which has a much lower power level than the switched circuit. Contactors come in many forms with varying capacities and features. Unlike a circuit breaker, a contactor is not intended to interrupt a short circuit current. Contactors range from those having a breaking current of several amperes and 24 V DC to thousands of amperes and many kilovolts. The physical size of contactors ranges from a device small enough to pick up with one hand, to large devices approximately a meter (yard) on a side.

33

CHAPTER 4 FLOWCHART AND SCHEMATIC DIAGRAM


4.1 FLOW CHART

Start

Enable LCD A Read AT Commands From ROM

Send AT commands to GSM Modem

Receive message from GSM Modem

34

No

Check whether new message?

Yes

Not Valid

Check Senders Numbet

A
Valid

Store message in RAM

Perform the Operation

Send Positive Acknowledgement

35

The flowchart of our project is shown above. Its start with LCD initialization. First controller initialize LCD to enable it. Then controller waits for GSM response. The communication between GSM Modem and microcontroller takes place in ASCII format through attention commands. If controller receives any response from GSM modem then controller checks whether the SMS has come from correct number or not. If SMS has come from correct number then it decodes the SMS and ON/OFF devices as per the instruction. After completing the task the microcontroller again checks for the new input from the user.

The schematic diagram of our project is shown below.

36

Figure 4.1 Schematic diagram

37

CHAPTER 5 SOFTWARE AND TOOLS


5.1 INTRODUCTION TO MPLAB

We will use the MPLAB software for programming and simulation of the device. In this we can program in assembly language as well as C programming language.

Figure5.1 (a) MPLAB IDE

38

MPLAB Integrated Development Environment (IDE) is a free, integrated toolset for the development of embedded applications employing Microchip's PIC and PIC microcontrollers.

MPLAB IDE runs as a 32-bit application on MS Windows, is easy to use and includes a host of free software components for fast application development and super-charged debugging. MPLAB IDE also serves as a single, unified graphical user interface for additional Microchip and third party software and hardware development tools.

Moving between tools is a snap, and upgrading from the free software simulator to hardware debug and programming tools is done in a flash because MPLAB IDE has the same user interface for all tools.

5.2 ADVANTAGES:
1. Fully integrated debugging with right mouse click menus for breakpoints, trace and editor functions. 2. Tabbed editor option or separate source windows 3. Recordable macros 4. Context sensitive colour highlighting for assembly, C and BASIC code readability 5. Mouse over variable to instantly evaluate the contents of variables and registers 6. Set breakpoints and trace points directly in editor to instantly make changes and evaluate their effects 7. Graphical project manager 8. Version control support for MS Source Safe, CVS, PVCS, Subversion

39

5.2.1 STEPS TO CREATE A PROJECT:

The first step is to create a project using the project wizard. A project is the way the files are organized to be compiled and assembled. 1. Choose project>project wizard. 2. From the welcome dialog, click on Next>to advance.

3. Create a project creating a project select project menu and select project
wizard.

40

STEP 1: In project wizard first Confirm device.

Figure 5.2.1(a) Confirming Device

41

STEP 2: Setting up language tools


Step two of project wizard sets up the language tools that are used with this project

Figure 5.2.1(b) Setting up language tools

42

STEP 3: Naming the Project.


Step three of the wizard allows you to name the new project and put it into a folder.

Figure 5.2.1 (c) Naming the Project

43

STEP 4: Project wizard-select template file.

Figure 5.2.1(d) Select Tempelate File

44

STEP 5: The final screen of the project wizard is a summary showing the
selected device.

Figure 5.2.1(e) Final Screen Shot

45

CHAPTER 6 CONCLUSION AND FUTURE ENHANCEMENT


We have completed study of PIC18F4520 micro-controller, GSM technology, Relay switching circuit and all other hardware used in our project. We have made the flowchart of the process in our project. We have also made schematic diagram of our project.

The future implications of the project are very great considering the amount of time and resources it saves. The project we have undertaken can be used as a reference or as a base for realizing a scheme to be implemented in other projects of greater level such as weather forecasting, temperature updates, device synchronization, etc. The project itself can be modified to achieve a complete Home Automation System which will then create a platform for the user to interface between himself and his household.

46

References

1. Microchip Technology, LCD PIC Microcontroller Solutions, PIC Microcontrollers Integrated LCD driver Module [http://ww1.microchip.com/downloads/en/devicedoc/39666b.pdf] 2. Microchip Technology, PIC18F4520 Data Sheet, Document Number DS39631E [ww1.microchip.com/downloads/en/devicedoc/39631a.pdf] 3. Microcontroller Board Forun, PIC Serial Communication Tutorial [http://www.microcontrollerboard.com/pic_serial_communication.html] 4. Muhammad Ali Mazidi, Rolin McKinlay and Danny Causey, PIC Microcontroller Embedded Systems, The Islamic Uni of Gaza 5. Quectel Wireless Solutions Co., Ltd. 2010 [http://www.quectel.com/uploadfile/M10_GSM_Module_Specification.pdf] 6. Short Message Service / SMS Tutorial [http://www.developershome.com/sms/]

with

and

47

Potrebbero piacerti anche