design and development of microcontroller based sms ... · 5.1.3 interfacing of microcontroller...

143
Design and Development of Microcontroller Based SMS Controlled Home Automation System Tahmina Begum DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING DHAKA UNIVERSITY OF ENGINEERING AND TECHNOLOGY, GAZIPUR July 2010 i

Upload: others

Post on 11-Jun-2020

14 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Design and Development of Microcontroller Based SMS Controlled Home Automation System

Tahmina Begum

DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING DHAKA UNIVERSITY OF ENGINEERING AND TECHNOLOGY, GAZIPUR

July 2010

i

Page 2: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Design and Development of Microcontroller Based

SMS Controlled Home Automation System

A thesis

submitted to the Department of Electrical and Electronic Engineering, DUET, Gazipur in partial fulfillment of the requirements for the degree of

MASTER OF SCIENCE IN ELECTRICAL AND ELECTRONIC ENGINEERING

by

Tahmina Begum

DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING DHAKA UNIVERSITY OF ENGINEERING AND TECHNOLOGY, GAZIPUR

July 2010

ii

Page 3: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

iii

Page 4: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

DECLARATION

I hereby declare that this thesis or any part of the thesis has not been submitted elsewhere for the award of any degree or diploma. Signature of the candidate

(Tahmina Begum)

iv

Page 5: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

ACKNOWLEDGEMENTS

First of all, I would like to thank Almighty Allah for providing me the health, courage

and strength necessary to start and complete this work. Alhamdulillah.

I feel privileged and proud to acknowledge my profound gratitude to Professor Dr. M.

Bashir Uddin, Dean of the faculty of EEE, DUET, Gazipur, for his kind consent to select

this topic, constant guidance, supervision and invaluable suggestions, inspiration,

support, patience, and especially his encouragement to this thesis work.

I am deeply indebted and grateful to Professor Mohammad Abdul Mannan, Head,

Department of EEE, DUET, Gazipur, for his encouragement and valuable advice during

this work.

I would like to show my gratitude to my Co-Supervisor, Md. Shazzat Hossain, Assistant

Professor, Department of EEE, DUET, Gazipur, for his guidance.

I am highly grateful to Professor Dr. Md. Shaheen Choudhury, Department of EEE,

DUET, Gazipur, for his constant guidance, encouragement and valuable advice during

this work.

I also would like to thank all my fellow friends for their contribution in giving me a

moral support throughout this thesis work.

I am also thankful to the librarian and the laboratory staffs of Dhaka University of

Engineering and Technology (DUET) for their assistance in this thesis work.

Last but not least, to all my beloved family members, especially my mother, elder

brother Engineer Mr. Faizullah and my husband Dr. Mohammad Salman who were

always, stand by my side to encourage, advice, comfort, cherish, and support me during

this entire thesis work.

Lastly, I really appreciate to have this responsibility to finish this work. This task has

taught a lot of lesson and knowledge which is much valuable for me in the future.

July, 2010 Tahmina Begum

v

Page 6: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

ABSTRACT

This thesis mainly focuses on the controlling of home appliances remotely and providing

security when the user is away from the place. The system is SMS based and uses

wireless technology to revolutionize the standards of living. This system provides ideal

solution to the problems faced by home owners in daily life. The system is wireless

therefore more adaptable and cost-effective.

The home appliances control system provides control on automation of various home

appliances using SMS. The system is capable enough to receive the instruction from user

via SMS by a cell phone to change the condition of the home appliance according to the

user’s needs and requirements. The system uses GSM technology thus providing

ubiquitous access to the system for automated appliance control. The whole system is

comprised of two components; one is hardware includes, PIC Microcontroller, GSM

Module, Cell phone, power supply, sensors and relays. Other part is to develop master

software based on PICBasic Pro and EPIC WIN software which is capable of remote

controlling and monitoring appliances and devices via the SMS. The Prototype developed

in the premises of Dhaka University of Engineering and Technology (DUET) shows the

ability to receive and transmit back the SMS to communicate with the user and automate

the home appliances. Results proved that home appliances control is possible by this

system with less human dependence.

Keywords: Short Message Service (SMS), Global System for Mobile communication

(GSM), ubiquitous access and Automation.

vi

Page 7: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

CONTENTS

PagesBoard of Examiners Declaration Acknowledgement Abstract List of Figures List of Tables List of Abbreviations

iii iv v vi

xiii xv

xvi

CHAPTER-1 INTRODUCTION

1.0 Introduction 1

1.1 Review 2

1.2 Some Important Terms Related to Home Automation 3

1.2.1 GSM Network 3

1.2.2 GSM Module 3

1.2.3 Subscriber Identity Module (SIM) 3

1.2.4 Short Message Service (SMS) 4

1.2.5 Microcontroller 4

1.2.6 Software 5

1.2.6.1 PicBasic Pro Software 5

1.2.6.2 EPIC Win 5

1.3 Aims and Objectives 6

1.4 Organization of the Thesis 6

CHAPTER-2 HOME APPLIANCES CONTROL SYSTEM

2.0 An Intelligent Home 8

2.1 Types of Home Automation Controls 10

2.1.1 Individual Control Devices 10

2.1.2 Distributed Control Systems 11

2.1.3 Centrally Controlled Systems 11

2.2 Appliances usually controlled 11

vii

Page 8: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

2.2.1 Lighting, fan, air conditioner and other electrical devices 11

2.2.2 Security Systems and Access Control 11

2.2.3 Home Theater and Entertainment 11

2.2.4 Phone System 12

2.2.5 Thermostat 12

2.2.6 Irrigation 12

CHAPTER-3 HARDWARE COMPONENTS

3.0 Microcontroller 14

3.1 Components of Microcontroller 15

3.1.1 Microprocessor/CPU 16

3.1.2 Memory in a Microcontroller 16

3.1.2.1 Read Only Memory (RAM) 16

3.1.2.2 Random Access Memory 17

3.1.3 The I/O (Input/Output) Ports 18

3.1.4 Embedded Design 19

3.1.4.1 Interrupts 20

3.1.4.2 Programs 20

3.1.4.3 Other Microcontroller features 20

3.1.5 List of common Microcontrollers 21

3.1.6 PIC Microcontroller 25

3.1.7 Architecture of PIC Microcontroller 25

3.1.7.1 Data space (RAM) 25

3.1.7.2 Code space 26

3.1.7.3 Word size 26

3.1.7.4 Stacks 26

3.1.7.5 Instruction set 27

3.1.7.6 Performance 27

3.1.7.7 Limitations 28

3.1.8 8/16/24-bit PIC Microcontroller product families 29

3.1.9 Selection of PIC Microcontroller (PIC 16F877A) for this study

29

viii

Page 9: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.1.10 Memory organization 37

3.1.10.1 Program memory organization 37

3.1.10.2 Data memory organization 37

3.2 GSM Module 38

3.2.1 Features of GSM Module SIM 300 39

3.2.2 Functional diagram of GSM Module SIM 300 42

3.2.3 Operating modes of GSM Module SIM 300 44

3.2.4 SIM Card interface 44

3.3 SIM Card holder 46

3.4 Subscriber Identity Module (SIM) 47

3.4.1 Smart Card Technology 48

3.4.2 Issuer Identification Number 48

3.4.3 Usage in mobile phone standard 49

3.4.4 Operating systems 49

3.4.5 Data storage 50

3.4.6 Integrated Circuit Card ID (ICCID) 50

3.4.7 IMSI 50

3.4.8 Authentication Key (Ki) 50

3.4.9 Authentication Process 51

3.4.10 Location Area Identity 51

3.4.11 SMS Messages and Contacts 52

3.4.12 SIM Serial Number (SSN) Digits 52

3.5 Power Supply 52 3.5.1 Electrical Power Supply 53 3.5.2 Power Supply Types 53 3.5.2.1 Battery Power Supply 54 3.5.2.2 Linear Power Supply 55 3.5.2.3 AC/DC Power Supply 55 3.5.2.4 Switched Mode Power Supply 56 3.5.2.5 Programmable Power Supply 57

ix

Page 10: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.5.2.6 Uninterruptible Power Supply 57 3.5.2.7 High Voltage Power Supply 58

3.6 Liquid Crystal Display 58 3.6.1 Overview 59 3.6.2 Specifications 60 3.6.3 Colour Displays 61 3.6.4 Passive Matrix and Active Matrix addressed LCDs 62 3.6.5 Drawbacks of LCD Technology 64

CHAPTER-4 SOFTWARE COMPONENTS 4.0 PICBasic Pro and PICBasic Pro Compiler 68

4.0.1 Additional commands available only in PICBASIC PRO 70

4.0.2 PICBASIC PRO advantages 70

4.0.3 PICBASIC PRO Compiler Instruction Set 72

4.0.4 Functions / Operators 74

4.0.5 PICBASIC Compiler Features 75

4.0.6 Structure of a Compiled Program 75

4.0.7 Target Specific Headers 75

4.0.8 The Library Files 76

4.0.9 PBP Generated Code 76

4.0.10 .ASM File Structure 77

4.1 EPIC programmer 78

4.1.1 EPIC Programmer for PICmicro controllers 78

4.1.2 EPICWIN and EPIC Programmer 79

4.1.2.1 Software Installation 79

4.1.2.2 Hardware Installation 79

4.1.3 General Operation 80

4.1.4 EPIC for Windows 95/98/ME/NT/2000/XP 80

4.1.5 EPICWin Controls 81

4.1.6 EPICWin Menus 83

4.1.6.1 File Menu 83

x

Page 11: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

4.1.6.2 View Menu 83

4.1.6.3 Run Menu 84

4.1.6.4 Configuration Menu 84

4.1.6.5 Options Menu 84

4.1.6.6 Help Menu 85

4.1.7 EPICWin Command Line Parameters 86

CHAPTER-5 METHODOLOGY 5.0 Design Overview 87

5.1 Hardware implementations 92

5.1.1 The PIC16F877A Microcontroller 92

5.1.1.1 Features of PIC16F877A Microcontroller 93

5.1.2 GSM Module SIM300CZ 94

5.1.3 Interfacing of Microcontroller with GSM Module 95

5.1.4 Liquid Crystal Display (LCD) 96

5.1.5 Interfacing of Microcontroller with LCD 97

5.1.6 Interfacing Circuit (Microcontroller to Load Devices) 98

5.1.7 Short Message Service (SMS) 99

5.1.8 Interfacing Circuit (GSM Module to SIM Card) 99

5.1.9 Power Supply to the System 100

5.2 Software Implementations 101

5.2.1 Steps of writing program in PICBasic Pro 101

5.2.2 Steps of loading program in to microcontroller by using

EPIC WIN soft ware 104

5.3 Sending SMS and display 107

5.4 Functioning of the Device 109

5.4.1 Steps of the functioning of the Device 109

CHAPTER-6 RESULTS

6.0 Hardware part testing 111

6.1 Software part testing 111

xi

Page 12: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

CHAPTER-7 DISCUSSION Discussion 113

CHAPTER-8 CONCLUSION AND FUTURE WORK

Conclusion and future work 117

REFERENCES

References 118

APPENDICES

Program used in the device 1-4

xii

Page 13: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

LIST OF FIGURES

Figures Pages

Fig. 3.1 Main components of a microcontroller 15

Fig .3.2 Microcontroller ROM/RAM 18

Fig .3.3 Microcontroller I/O ports 19

Fig.3.4 PIC16F877A Block Diagram 31

Fig. 3.5 Pin diagram of PIC16F877A 32

Fig. 3.6 PIC16F877A Program Memory Map and Stack 37

Fig. 3.7 Functional Diagram of GSM Module SIM 300CZ 42

Fig. 3.8 Top view of GSM Module SIM300CZ 43

Fig.3.9 Pin diagram of GSM Module SIM300 CZ 43

Fig. 3.10 Reference Circuit of the 6 Pins SIM Card 45

Fig. 3.11 Diagram of the SIM Card Holder 46

Fig.3.12 Diagram of the 6 pin SIM Card 46

Fig. 3.13 A General Purpose Alphanumeric LCD 63

Fig. 4.1 EPICWin Controls 81

Fig.5.1 Project development flow chart 88

Fig.5.2 Block diagram of the project 89

Fig 5.3 Flowchart of functioning of Device 90

Fig.5.4 PCB Layout 91

Fig.5.5 Schematic diagram of the project 92

Fig.5.6 Interfacing of Microcontroller with GSM Module 95

Fig.5.7 Reflective twisted nematic liquid crystal display 96

Fig.5.8 Interfacing of Microcontroller with LCD 97

Fig.5.9 Interfacing of Microcontroller with load Devices 98

Fig.5.10 Interfacing of GSM Module to SIM Card 99

xiii

Page 14: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Fig.5.11 Power Supply Unit 100

Fig.5.12 Camera picture of SMS display 107

Fig.5.13 Front Photograph of the Device 108

Fig.5.14 Front Photograph of the Device in functional state 108

Fig.5.15 Bottom view of the Device 109

Fig.6.1 Sequence of loading the program to PIC 112

xiv

Page 15: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

LIST OF TABLESTables Pages

Table 2.1 Comparison of different technology used for home automation

13

Table 3.1 Features of PIC16F877A Device 30

Table 3.2(a) PIC16F874A/877A Pinout Description 33

Table 3.2(b) PIC16F874A/877A Pinout Description 34

Table 3.2(c) PIC16F874A/877A Pinout Description 35

Table 3.2(d): PIC16F874A/877A Pinout Description 36

Table3.3(a) Key Features of GSM Module SIM 300CZ 40

Table 3.3(b) Key Features of GSM Module SIM 300CZ 41

Table 3.4 Overview of operating modes of GSM Module SIM 300CZ

44

Table 3.5 Pin define of the SIM interface 45

Table 3.6 Pin description of the SIM Interface 47

Table 4.1 Comparison between PICBasic and PICBasic Pro Compilers

69

xv

Page 16: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

LIST OF ABBREVIATIONS

A/D Analog-to-Digital

ADC Analogue to Digital Converter

AFFS Advanced Fringe Field Switching

ASM file Assembler Source Language file

AT Attention

AuC Authentication Center LAI

BAS BASIC language source code file

BGAN Broadband Global Area Network

CDMA Code Division Multiple Access

CISC Complex instruction set computer or computing

CPU Central Processing Unit

CSTN Color-STN

D/A Digital-to-Analog

DAC Digital to Analogue Converters

DCS Digital Cellular System

DSTN Double-Layer

DTMF Dual-Tone Multi-Frequency

EDGE Enhanced Data Rates for Global Evaluation

EEPROM Electrically Erasable Programmable Read-Only Memory

E-GSM Enhanced-Global System for Mobile Communication

EGSM Extended GSM

EPIC Explicitly Parallel Instruction Computing

EPROM Erasable Programmable Read-Only Memory

xvi

Page 17: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

FSR File Select Register

GPR General Purpose Registers

GPRS General Packet Radio System

GSM Global System for Mobile Communications

HACS Home Appliance Control System

I/O Input/Output

ICCID Integrated Circuit Card ID

IMSI International Mobile Subscriber Identity

INDF Indirect Register

IPS In-plane switching

ISR Interrupt Service Routine

ITO Indium Tin Oxide

ITU International Telecommunication Union

Ki Authentication Key

LAI Local Area Identity SMSC (Short Message Service Center)

LAN Local Area Network

LCD Liquid Crystal Display

LED Light Emitting Diode

MCC Mobile Country Code

MII Major Industry Identifier

MNC Mobile Network Code

MVNO Mobile Virtual Network Operator

PBP PICBasic Pro Compiler

PC Program Counter

xvii

Page 18: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

PCS Personal Communication Service

PDA Personal Digital Assistant

PIC Peripheral Interface Controller

PIN Personal Identity Number

PIT Programmable Interval Timer

PSU Power Supply Unit

PUK Personal Unblocking Key

PWM Pulse Width Modulation

RAM Random Access Memory

RAND Random Number

RF Radio frequency

RISC Reduced Instruction Set Computer

ROM Read-Only Memory

R-UIM Removable User Identity Module

RX Receive

SC Stack Pointer

SDN Service Dialing Numbers

SFR Special Function Registers

SIM Subscriber Identity Module

SMPS Switched-mode Power Supply

SMS Short Message Services

SMSC Short Message Service Center

SPN Service Provider Name

SRAM Static Random Access Memory

xviii

Page 19: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

SRES Signed Response

SSN SIM Serial Number

STN Super-Twisted Nematic

TCP/IP Transmission Control Protocol/Internet Protocol

TFTs Thin-Film Transistors

TN Twisted nematic

TPU Time Processing Unit

TTL Transistor-Transistor Logic

TX Transmit

UART Universal Asynchronous Receiver/Transmitter

UICC Universal Integrated Circuit Card

UMTS Universal Mobile Telephony System

UPS Uninterruptible Power Supply

USIM Universal Subscriber Identity Module

VAS Value Added Service

VTS Vessel Traffic Services

xix

Page 20: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

CHAPTER-1 INTRODUCTION

1.0 Introduction Modern man is basically sleepwalking if he is not multitasking. His lifestyle has evolved in such a way that optimizing time is the most important thing. The newest innovations show that we can -and therefore must- be online while watching TV, be e-mail—ready while driving the car, be taking calls while ascending Mount Everest, be watching television while shaving in front of the mirror. Most evenings most first world's kids do their homework on the computer while instant messaging friends and talking on the phone. There may be something wrong with this picture, but the kids are definitely not sleepwalking. The pressure to be wired -everywhere, always, fast- is hard to ignore [1]. Home Automation is the integration and control of lighting, security, multimedia, climate control and other electronic systems within a household. It is a subset of building automation with particular focus on living spaces in a scale of an apartment or a family house. The main purpose is to make everyday life more comfortable, safe and energy efficient. Devices in a Smart home are interconnected into a network and controlled by specialized software called Control system. It connects to the devices, monitors their state and reacts to events. The control system performs many tasks associated with the household instead of the residents, enabling them to spend more time on matters that are really important. The control system not only enables comfortable light scenes, daily programs or remote access. It also takes care of optimal heating and ventilation to keep the air fresh and temperature comfortable, but to safe power when nobody is present.[1] Research of home automation thus gains significant importance. But until recently, it has been neglected in the shadow of industrial automation and building automation focusing on office spaces. By now, the smart homes have grown big enough to have specialized solutions. However, offered systems are often expensive, complicated and inflexible. On the other hand, really easy and affordable solutions such as X10 still have very limited functionality. That’s why home automation market falls far behind the expectations and possibilities. All the technology and hardware to build commercially successful Smart homes that today people only dream of are available. It is all just the matter of good software.

Introduction 1

Page 21: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

This thesis discusses general considerations and technologies involved in a home automation system. This thesis covers the range of the development of this project including: the concept of the system, the technology involved in implementation, and the prototype product developed. 1.1 Review Delgado, Picking, and Grout (2006) consider the problems with the implementation of home automation systems. Furthermore the possible solutions are devised through various network technologies. Several issues affecting home automation systems such as lack of robustness, compatibility issue and acceptability among the old and disabled people are discussed [2]. Ciubotaru-Petrescu, Chiciudean, Cioarga, and Stanescu (2006) present a design and implementation of SMS based control for monitoring systems. The paper has three modules involving sensing unit for monitoring the complex applications. A processing unit that is microcontroller and a communication module that uses GPRS modem or cell phone via serial port RS-232. The SMS is used for status reporting such as power failure [3]. In their paper, Conte and Scaradozzi (2003) view home automation systems as multiple agent systems (MAS). In the paper home automation system has been proposed that includes home appliances and devices that are controlled and maintained for home management. The major task is to improve performance [4]. In their paper, Alkar and Buhur (2005) propose an Internet Based Wireless Home Automation System for Multifunctional Devices. This paper proposes a low cost and flexible web-based solution but this system has some limitations such as the range and power failure [5]. Jawarkar, Ahmed, Ladhake, and Thakare (2008) propose remote monitoring through mobile phone involving the use of spoken commands. The spoken commands are generated and sent in the form of text SMS to the control system and then the microcontroller on the basis of SMS takes a decision of a particular task [6]. Potamitis, Georgila, Fakotakis, and Kokkinakis, G. (2003) suggest the use of speech to interact remotely with the home appliances to perform a particular action on behalf of the user. The approach is inclined for people with disability to perform real-life operations at home by directing appliances through speech. Voice separation strategy is selected to take appropriate decision by speech recognition [7].

Introduction 2

Page 22: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

1.2 Some Important Terms Related to Home Automation The terms related to home automation such as GSM Network, GSM Module, SIM, SMS

and Microcontroller are outlined below.

1.2.1 GSM Network

GSM, which stands for Global System for Mobile Communications, is a digital cellular radio network operating in over 200 countries world-wide. It provides almost complete coverage in Western Europe, and growing coverage in the Americas, Asia and elsewhere. [8] Of special interest is the capability of the GSM network to be used for data computing. Most people think of voice calls when they think of cellular phones. But because GSM is digital, you can connect your GSM-enabled phone to your laptop computer and send or receive e-mail, faxes, browse the Internet, securely access your company's Local Area Network (LAN)/intranet, and use other digital data features including Short Messaging Service. The unique roaming features of GSM allow cellular subscribers to use their services in any GSM service area in the world in which their provider has a roaming agreement. That means the phone you use in France could work in Germany, Australia, Finland and even China, depending on your provider's roaming agreements. GSM-enabled phones have a "smart card" inside called the Subscriber Identity Module (SIM). The SIM card is personalized to you and you alone. It identifies your account to the network and provides authentication, which allows appropriate billing.

1.2.2 GSM Modules

GSM modules are similar to modems, but there's one difference: A GSM modem is an external equipment, whereas the GSM module is a module that can be integrated within an equipment. It is an embedded piece of hardware. A GSM module is a wireless module that works with GSM networks. A wireless module behaves like a Hayes compatible dial-up modules. The main difference between a standard Hayes module and a GSM module is that a Hayes module sends and receives data through a fixed telephone line while a GSM Module sends and receives data through radio waves.[9]

1.2.3 Subscriber Identity Module (SIM)

One of the key features of GSM is the Subscriber Identity Module, commonly known as a

SIM card. The SIM is a detachable smart card containing the user's subscription

Introduction 3

Page 23: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

information and phone book. This allows the user to retain his or her information after

switching handsets. Alternatively, the user can also change operators while retaining the

handset simply by changing the SIM. A Subscriber Identity Module (SIM) on a

removable SIM Card securely stores the service-subscriber key known as International

Mobile Subscriber Identity (IMSI) used to identify a subscriber on mobile telephony

devices (such as computers and mobile phones). SIM card contains its unique serial

number, international unique number of the mobile user (IMSI), security authentication

and ciphering information, temporary information related to the local network (also

temporary local id that has been issued to the user), list of the services the user has access

to and two passwords (regular PIN and unblocking PUK). SIM cards are available in two

standard sizes. The first is the size of a credit card (85.60 mm × 53.98 mm x 0.76 mm).

The newer, more popular miniature version has a width of 25 mm, a length of 15 mm,

and a thickness of 0.76 mm. However, most SIM cards are still supplied as a full-sized

card with the smaller card held in place by a few plastic links and can be easily broken

off to be used in a phone that uses the smaller SIM.[10]

1.2.4 Short Message Service (SMS)

Short Message Service (SMS) is an integrated paging service that lets GSM cellular subscribers send and receive data right on their cellular phone's LED display, up to a maximum of 160 characters. Combine this with your laptop, and you can receive urgent email, fax notifications, news and stock quotes -- all without even dialing the phone. You can receive messages even when you are making a call. The structure of an SMS message includes the mobile number the message is originating from, time, date, country code, length and the actual message.[11]

1.2.5 Microcontroller

Microcontroller is the embedded chip form of Random Access Memory (RAM) and I/O that are basic parts of a computer. Today, microcontroller is used in cameras, automobiles, TV’s, cellular phones, toys, radios and many similar areas. Microcontroller is preferred because of speed, small size, reduced instruction set and serial port control over 2 pins, interrupt control, internal timer, and re-programmable flash memory properties. PIC’s (Peripheral Interface Controller) are the most popular and common used

Introduction 4

Page 24: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

microcontrollers produced by Microchip firm. PIC has easy understandable and small sized instruction set because it’s produced with RISC (Reduced Instruction Set Computer) architecture.[12]

1.2.6 Software

The following softwares were used for uploading the machine codes in to microcontroller.

1.2.6.1 PICBasic Pro Software

The PICBasic Pro Compiler makes it quick and easy for you to program Microchip

Technology’s powerful PICmicro microcontrollers (MCUs). The English-like BASIC

language is much easier to read and write than the quirky Microchip assembly language.

The PICBasic and PICBasic Pro compilers both function in the same way. The program

code, saved as a text file, is run through either the PICBasic or PICBasic Pro compilers.

The compiler reads through the text file and creates (or compiles) an equivalent machine

code instruction listing (the hex file) of the program. The machine code is a list of

hexadecimal numbers that represents the PICBasic Pro program. The hex file is uploaded

(or programmed) in to the microcontroller. When the microcontroller started its CPU will

run through the programmed list of hexadecimal numbers that run the PICBasic Pro

program.[13]

1.2.6.2 EPIC win

EPIC (Explicitly Parallel Instruction Computing) is a 64-bit microprocessor instruction

set, jointly defined and designed by Hewlett Packard and Intel, that provides up to 128

general and floating point unit registers and uses speculative loading, predication, and

explicit parallelism to accomplish its computing tasks. By comparison, current 32-bit

CISC and RISC microprocessor architectures depend on 32-bit registers, branch

prediction, memory latency, and implicit parallelism, which are considered a less

efficient approach in micro-architecture design.[14]

Introduction 5

Page 25: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

1.3 Aims and Objectives The objective of this thesis is to design a microcontroller based home automation system

that controls home appliances remotely by SMS. Besides, this work concern is to

optimize the use of power by regulating the shutting off and on of the electrical

components of the systems.

1. To develop a cost-effective method for controlling and activating home

appliances remotely.

2. This system should work easily in most places where a house may exist.

3. There would have to be two-way communication to ensure that the messages had

been received.

4. The system would also have to be affordable and easy to use.

5. Explain possible actual benefits for Home Automation Systems.

6. Demonstrate the possibility of a ubiquitous access to the home network using

actual technologies.

7. Propose a standardized remote-controlled Home Automation architecture.

8. Encourage user- friendly interfaces development.

1.4 Organization of thesis

This thesis analyzes the home automation system domain and conceives ideas for a home

appliances control by SMS through Microcontroller in easy to use and secured manner.

Following is the structure of the report:

Chapter 1

Chapter 1 describes on the introduction and brief information of the thesis subject. It

includes the review of previous works and short definitions of the components used in the

thesis project. This chapter briefly describes on the thesis objectives.

Chapter 2

Chapter 2 gives an overview on the brief definition of Home Automation System and

different types of automation, different appliances controlled by the system. It also gives

the comparison among different technologies used in home automation.

Introduction 6

Page 26: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Chapter 3

Chapter 3 gives the detailed description of the hardware components used in this thesis

projects e.g. Microcontroller, GSM Module, SIM holder, LCD Display and power

supply.

Chapter 4

Chapter 4 gives description of software components of this thesis project. It gives the

detailed description of PICBasic Pro, PICBasic Pro compiler, EPIC Programmer, EPIC

WIN and advantages of these programs.

Chapter 5

Chapter 5 deals with the methodology used in this thesis project. It also gives the detail

about the prototype developed. It includes the flow chart of the research method, block

diagram of the project, assembling of the hardware and development of the software.

Chapter 6

Chapter briefly discuss the results which includes the testing of hardware and software

part of the prototype and its functioning.

Chapter 7

Chapter 7 deals with discussion on achievement of the main objectives as mentioned in

the chapter 1. The Home automation System is met the objectives which are to develop

master software that capable of integrated remote control and monitoring of appliances

and devices via the SMS.

Chapter 8

Chapter 8 offers conclusions from the performed study and provides proposals for future work.

Introduction 7

Page 27: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

CHAPTER 2

HOME APPLIANCES CONTROL SYSTEM

2.0 An intelligent home

The area of intelligent homes, also called home automation, building automation or

domotics, is broad, but at the core quite simple. It is the idea to interconnect all (or some)

of the technical equipment in a house in order to combine their functions and control

them in new and easier ways. It might also include automation of equipment in a house

that was previously not considered technical, such as: lamps, fans, air conditioners, doors

and windows. In some cases the terms intelligent houses, home automation, domotics and

building automation are used to describe same things.

Here follows some definitions

"Home automation is the use of one or more computers/microcontrollers to control basic

home functions and features automatically and sometimes remotely. An automated home

is sometimes called a smart home." [15]

"Intelligent Building: A building that integrates technology and process to create a

facility that is safer, more comfortable and productive for its occupants, and more

operationally efficient for its owners. Advanced technology combined with improved

processes for design, construction and operations provide a superior indoor environment

that improves occupant comfort and productivity while reducing energy consumption and

operations staffing." [15]

"For some it may be something as simple as remote or automatic control of a few lights.

For others, security may be the central application. Still others may choose to install

advanced controllers or use voice recognition. As a very basic definition, we tend to refer

to home automation as anything that gives you remote or automatic control of things

around the home." [15]

As can be seen, the definitions are quite different, but there still is some kind of

consensus about the basic purposes, goals and motivation for intelligent houses.

Home Appliances Control System 8

Page 28: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

A home automation system automates the whole house, triggering events and routines

involving light fixtures, security components and the heating/cooling system based on the

time of day, temperature or any other condition. For example, when a sensor detects a

person to enter a room, the home automation system could open the door.

In automation system, there are collections of "subsystems." A subsystem is a system that

(even when operating by itself) provides benefits to a homeowner. Common subsystems

include home appliances (lighting, fan, freezer, and washing machine), security and

heating/cooling systems. A home automation system puts two or more subsystems under

the control of one central controller, so that the press of one button can issue several

commands to a variety of different electronic products.[2]

Meanwhile, most whole-house systems consist of two important components: a

microcontroller and user interface. The microcontroller serves as the brains of a home

automation system. Homeowners use interfaces such as SMS to interact when necessary

with the various systems linked to the automation microcontroller. Subsystems, like

cooling system controls, communicate with the automation system via the

microcontroller. Each automation system has a different in its degree of intelligence, ease

of programming, level of flexibility, intuitiveness of operation, communications media

employed, price and other features.

Automated home is a home equipped with special facilities to enable occupants to control

or program an array of automated home electronic devices. For example, a homeowner

on vacation can arm a home security system, control temperature gauges, switch

appliances on or off, control lighting, program a home theater or entertainment system,

and perform many other tasks. Smart home became smarter if the controlling can be done

from any remote place. Our main focus is to control the home appliances from remote

place. The motivations behind the goal to remote control of home appliances are simple.

It’s not always feasible to be physically near to the home still sometimes it’s very

important to control the appliances for many purposes. So the remote controlling takes

the control of the home beyond the home and to the hands of the people. If a simple

mobile phone takes the added responsibility to control the smart home then the control is

reachable from almost everywhere people travels and lives on earth. This sort of high end

Home Appliances Control System 9

Page 29: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

technology is supposed to facilitate the different life easing utilities to a new age and

bringing things out of the box to as near as one’s palm.[2]

There exists a number of available media for remote communication. Internet is a good

example of this type of remote communication. Internet places virtually no bounds on

geographical placement and is thus considered “enough” remote by our definition. But

the Internet is a place crowded with various types of traffics, often hostile to each other.

Security vulnerability is the most striking alert point of the Internet. Whenever a web

based application goes live, a lot of efforts have to take place before it can be said to be

secured, if at all. When we say remote control, we want to make sure no malicious party

ever gains control and abolishes everything. Also to use web, it requires resources like

flawless internet connections and hosting servers, which may not always fit to the

concept of remote controlling.[16]

Another candidate solution to this remote communication problem is the use of mobile

telephony. Mobile telephony offers a wide range of communication services like voice

and data transfer through SMS and other enhanced data transfer protocols like GPRS,

EDGE at a relatively low price and at a wide variety of places on the earth. On the other

hand, the security is better achieved by the use of strict traffic control. We adhered to this

method of remote controlling of home appliances because of its unparallel availability

and modest security at the affordable price.[16]

2.1 Types of Home Automation Controls

The new stream, automation home information system has developed into a vast one and

the current market is flooded with a flurry of home automation system. Here are some of

the types of home automation system.

2.1.1 Individual Control Devices

This type is perhaps the first one to hit the market in the early years. Here each device

like the heater or AC will have an independent control dedicated for it unlike the central

control system. These are very handy and are user friendly.

Home Appliances Control System 10

Page 30: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

2.1.2 Distributed Control Systems

The main feature of this type of systems is emergency shut-down. Rest of the features

includes hardware and software components developed under special software for better

automated control that reduce human interaction. With this you can preset or change the

control parameters, for example, the thermostat of several ACs and ON/OFF timings.

2.1.3 Centrally Controlled Systems

These are computerized systems programmed to handle all functions of multiple utilities

like ACs, heaters, home entertainments, doors, windows, refrigerators and cooking

systems etc regardless of whether you are home or out. You can connect to your control

system from office through telephone or internet. The best part of this is, with

computerized control, you can afford to forget things and still be safe and timely on

controls.

2.2 Appliances usually controlled

2.2.1 Lighting, fan, air-conditioner and other electrical devices

Probably the most popular control category and a great way to get involved with home

automation. Lighting, fan, air-conditioner and other electrical devices can be controlled

from anywhere in the house or world (via SMS or the Internet).

2.2.2 Security Systems & Access Control

Have your home call you and/or loved ones if there is an alert situation. Money can be

saved on security monitoring services or even monitor for non-traditional security events

like water in the laundry room or basement. Additionally, VTS products include devices

that will allow unlocking the front door to let friends in or close the garage door from the

office via the web.

2.2.3 Home Theater & Entertainment

The pile of remotes can be replaced with just one controller. Now, imagine not having to

know all 10 steps to starting up the home theater - just press the HBO icon and the home

Home Appliances Control System 11

Page 31: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

automation products/system will do the rest. In-wall and in-ceiling speakers are

especially popular with homeowners as they provide beautiful sound throughout the

house while adding no clutter whatsoever.

2.2.4 Phone Systems

Phone systems that are usually used for small business applications are surprisingly

convenient in the home. With caller ID and a home automation controller you can even

screen your calls for only those you wish to cause your phone to ring. Voice control

software turns every phone in the home into a remote controller.

2.2.5 Thermostats

Remote-control thermostats allow us to adjust the temperature from bed at night or even

from a cell phone while on our way home. They can even trigger a notice to us if the

temperature gets too low (to prevent pipes from freezing) or too high (to protect your

pets, plants, etc.).

2.2.6 Irrigation

sprinklers can be turned on only when it's not raining. Some of automation even turn the

sprinklers on when there is motion in the yard at unwanted times - imagine an intruder

trying to explain the wet clothes to the police!

Home Appliances Control System 12

Page 32: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Table 2.1: Comparison of different technology used for home automation Technology Transmission medium Transmission speed Maximum distance to the device

Unshielded twisted pair 10 Mbit/s – 1 Gbit/s 100 m Ethernet

Optical Fiber 1 Gbit/s – 10 Gbit/s 2 km – 15 km

HomePlug Electrical wiring 14 Mbit/s - 200 Mbit/s 200 m

Wi-Fi Radio frequency 11 Mbit/s – 248 Mbit/s 30 m – 100 m

Bluetooth Radio frequency 1 Mbit/s – 10 Mbit/s 10 m – 100 m

INSTEON Electrical wiring + Wireless 1.2 kbit/s 1,000 m+ (Electrical wiring), 50

m+ (Wireless)

X10 Electrical wiring 50 bit/s – 60 bit/s ----- Zigbee Radio frequency 20 kbit/s – 250 kbit/s 10 m – 75 m

Zwave Radio frequency 9.6 kbit/s – 40 kbit/s 1 m – 75 m

USB Twisted pair 12 Mbit/s – 480 Mbit/s 5 m

SMS Radio frequency above 144 Kbit/s Unlimited

The three areas were meant to represent different reasons why intelligent houses might be

attractive to consumers. They are:

1. Saving cost, environment and energy.

2. Making everyday life easier.

3. Making the house seem luxurious and high tech.

This thesis represents a simple, practical and very low cast method which applies the

SMS technique that already available in all types of mobile phone devices and provided

with all modern mobile telecommunication networks. [17]

Home Appliances Control System 13

Page 33: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

CHAPTER 3

HARDWARE COMPONENTS

3.0 Microcontroller A microcontroller (also microcontroller unit, MCU or µC) is an inexpensive single-chip

computer. Single chip means that the entire computer system lies within the confines of the

integrated circuit. The microcontroller existing on the encapsulated silver of silicon has

features and similarities to our standard personal computers. Primarily, the microcontroller is

capable of storing and running a program. [18]

The microcontroller contains a central processing unit (CPU: ALU, PC, SP and registers),

random access memory (RAM), read-only memory (ROM), electrically erasable

programmable read-only memory (EEPROM), input/output (I/O) lines, serial and parallel

ports, timers, clock circuit and other built-in peripherals, such as analog-to-digital (A/D) and

digital-to-analog (D/A) converters.

The microcontroller’s ability to store and run unique programs makes it extremely versatile.

For instance, a microcontroller can be programmed to make decisions and selections. Its

ability to perform math and logic functions allows it to mimic sophisticated logic and

electronic circuits.

Other programs can make the microcontroller behave like a neural circuit or a fuzzy logic

controller. Microcontrollers are responsible for the intelligence in most smart devices on the

consumer market. In any hobbyist electronics magazine articles that features the use of

microcontrollers either directly or embedded inside a circuit’s design. Because of their

versatility, they add a lot of power, control and options for a small cost. It therefore becomes

essential that the electronics engineer or hobbyist learns to program these microcontrollers in

order to maintain a competence and to gain the advantages that microcontrollers can provide

in their own circuit designs. The microcontrollers embedded in just about every-things.[18]

The microcontroller is a very common component in modern electronic systems. Its use is so

widespread that it is almost impossible to work in electronics without coming across it.

Microcontrollers are used in a wide number of electronic systems such as:

• Engine management systems in automobiles.

Hardware Components 14

Page 34: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• Keyboard of a PC.

• Electronic measurement instruments (such as digital multimeters, frequency

synthesizers and oscilloscopes)

• Printers.

• Mobile phones.

• Televisions, radios, CD players and tape recording equipment.

• Hearing aids.

• Security alarm systems, fire alarm systems and building services systems.

• Remote controls, office machines, appliances, power tools and toys.

In fact the list is endless. [18]

3.1 Components of Microcontroller

Basically, a microcontroller is a device which integrates a number of the components of a

microprocessor system onto a single chip (IC), with the following common features: [19]

• The CPU core - ranging from simple 4-bit processors to sophisticated 32/64-bit

processors

• Memory (both ROM and RAM)

• Some parallel digital I/O

Fig 3.1 Main components of a microcontroller

Most microcontrollers will also combine other devices such as:

Hardware Components 15

Page 35: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• A Timer module to allow the microcontroller to perform tasks for certain time

periods.

• A serial I/O port to allow data to flow between the microcontroller and other devices

such as a PC or another microcontroller.

• An ADC to allow the microcontroller to accept analogue input data for processing.

3.1.1 Microprocessor/CPU

A microprocessor is a programmable digital electronic component that incorporates the

functions of a central processing unit (CPU) into a single IC package. It consists of

Arithmetic Logic Unit (ALU), Program Counter (PC), Stack Pointer (SP) and registers. The

main functions of CPU are:

• The ability to execute a stored set of instructions to carry out user defined tasks.

• The ability to be able to access external memory chips to both read and write data

from and to the memory.

3.1.2 Memory in a Microcontroller

3.1.2.1 Read Only Memory (ROM)

ROM memory can be ROM (as in One Time Programmable memory), EPROM, or

EEPROM. [19]

• This is memory that can only be read, the data being stored in the memory device

during its manufacture. Once data has been written onto ROM memory, it cannot

be easily removed and is designed for 'read only' use. ROM is referred to as being

non-volatile as it retains its contents even when the power is turned off.

• Erasable Programmable Read Only Memory (EPROM). This is similar to ROM

type memory but the user can program it. The contents of the memory can be

erased from the memory by exposing the memory chip to ultraviolet radiation for

a short period of time. It can therefore be used many times over.

• Electrically Erasable Programmable Read Only Memory (EEPROM). Similar to

EPROM but has part or all of the memory contents erased by the microprocessor.

Hardware Components 16

Page 36: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.1.2.2 Random Access Memory (RAM)

All microprocessor systems need memory that can be both read from and written to -

such memory is RAM. RAM got its name because early read-write memories were

sequential, and did not allow random access. RAM memory is used to store dynamic data

(that will change during the operation of the program). RAM takes the form of integrated

circuits that allow the stored data to be accessed in ANY order — that is, at random and

without the physical movement of the storage medium or a physical reading head. The

word "random" infers that any piece of data can be returned quickly, and in a constant

time, regardless of its actual physical location, in relation to the previous data storage

location. The key benefit of RAM is that retrieval times are short and consistent. The

disadvantages of RAM are cost and the loss of data when power is turned off (volatile).

[19]

Both ROM and EPROM memory are used to hold the program code of a microprocessor

used in an embedded system, i.e. a microprocessor used in an application where the program

code is always the same and is designed to execute every time the system is switched on.

Most development work is done using EPROM or EEPROM type memory, ROM memory

being used in the final production version (when all the program code has been fully tested).

So a typical microprocessor system will contain both ROM (could be EPROM, EEPROM, or

ROM) to store the program code, and RAM to store dynamic data.

Figure 3.2 shows the ROM of a microcontroller which is used to store the application

program and RAM is used for data storage and stack management tasks. It is also used for

register stacks (as in the microchip PIC range of microcontrollers). Typically, the amount of

ROM type memory will vary between around 512 bytes and 4096 bytes, although some 16

bit microcontrollers such as the Hitachi H8/3048 can have as much as 128 Kbytes of ROM

type memory. The amount of RAM memory is usually somewhat smaller, typically ranging

between 1 Kbytes to 64 Kbytes.

Hardware Components 17

Page 37: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Fig 3.2 Microcontroller ROM/RAM

3.1.3 The I/O (Input/Output) Ports

I/O (input/output) is the collection of interfaces that different functional devices, of any

information processing system, use to communicate with each other. Every information

transfer is an output from one device and an input into another. For instance, on a computer,

a keyboard and mouse are considered input devices while monitors and printers are

considered output devices. Typical devices for communication between computers, such as

modems and network cards, operate as both input and output devices. [19]

I/O can be:

• A number of digital bits formed into a number of digital inputs or outputs called a

port. These are usually eight bits wide and thus referred to as a BYTE wide port. i.e.

byte wide input port, byte wide output port.

• A serial line from the microprocessor (Transmit or TX) and a serial line to the

microprocessor (Receive or RX) allowing serial data in the form of a bit stream to be

transmitted or received via a two wire interface.

• Other I/O devices such as Analogue to Digital Converters (ADC) and Digital to

Analogue Converters (DAC), Timer modules, Interrupt controllers etc. (which will be

discussed later in the context of microcontrollers).

Hardware Components 18

Page 38: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Figure 3.3 shows microcontroller ports which are used to access the outside world.

Fig 3.3 Microcontroller I/O ports

The digital I/O ports are the means by which the microcontroller interfaces to the

environment.

Digital I/O tends to be grouped into byte wide ports (8 digital bits) that can be configured as

either input bits or output bits. There are some exceptions, such as the microchip PIC 16C54

with one 6-bit RA port and a byte wide RB port.

The number of I/O port bits varies, depending upon the size of the microcontroller. Some

very simple 8 bit microcontroller have as few as 4 bits of I/O, whilst those at the high end

range can have as many as 33 bits of I/O (some 16 bit microcontrollers could have around 78

bits of I/O).

3.1.4 Embedded design

The majority of computer systems in use today are embedded in other machinery, such as

automobiles, telephones, appliances, and peripherals for computer systems. These are called

embedded systems. While some embedded systems are very sophisticated, many have

minimal requirements for memory and program length, with no operating system, and low

software complexity. Typical input and output devices include switches, relays, solenoids,

LEDs, small or custom LCD displays, radio frequency devices, and sensors for data such as

temperature, humidity, light level etc. Embedded systems usually have no keyboard, screen,

disks, printers, or other recognizable I/O devices of a personal computer, and may lack

human interaction devices of any kind. [18]

Hardware Components 19

Page 39: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.1.4.1 Interrupts

It is mandatory that microcontrollers provide real time response to events in the embedded

system they are controlling. When certain events occur, an interrupt system can signal the

processor to suspend processing the current instruction sequence and to begin an interrupt

service routine (ISR). The ISR will perform any processing required based on the source of

the interrupt before returning to the original instruction sequence. Possible interrupt sources

are device dependent, and often include events such as an internal timer overflow,

completing an analog to digital conversion, a logic level change on an input such as from a

button being pressed, and data received on a communication link. Where power consumption

is important as in battery operated devices, interrupts may also wake a microcontroller from a

low power sleep state where the processor is halted until required to do something by a

peripheral event. [18]

3.1.4.2 Programs

Microcontroller programs must fit in the available on-chip program memory, since it would

be costly to provide a system with external, expandable, memory. Compilers and assembly

language are used to turn high-level language programs into a compact machine code for

storage in the microcontroller's memory. Depending on the device, the program memory may

be permanent, read-only memory that can only be programmed at the factory, or program

memory may be field-alterable flash or erasable read-only memory.

3.1.4.3 Other microcontroller features

Since embedded processors are usually used to control devices, they sometimes need to

accept input from the device they are controlling. This is the purpose of the analog to digital

converter. Since processors are built to interpret and process digital data, i.e. 1s and 0s, they

won't be able to do anything with the analog signals that may be being sent to it by a device.

So the analog to digital converter is used to convert the incoming data into a form that the

processor can recognize. There is also a digital to analog converter that allows the processor

to send data to the device it is controlling.

Hardware Components 20

Page 40: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

In addition to the converters, many embedded microprocessors include a variety of timers as

well. One of the most common types of timers is the Programmable Interval Timer, or PIT

for short. A PIT just counts down from some value to zero. Once it reaches zero, it sends an

interrupt to the processor indicating that it has finished counting. This is useful for devices

such as thermostats, which periodically test the temperature around them to see if they need

to turn the air conditioner on, the heater on, etc.

Time Processing Unit or TPU for short is a sophisticated timer. In addition to counting down,

the TPU can detect input events, generate output events, and perform other useful operations.

Dedicated Pulse Width Modulation (PWM) block makes it possible for the CPU to control

power converters, resistive loads, motors, etc., without using lots of CPU resources in tight

timer loops.

Universal Asynchronous Receiver/Transmitter (UART) block makes it possible to receive

and transmit data over a serial line with very little load on the CPU.

For those wanting Ethernet one can use an external chip like Crystal Semiconductor

CS8900A, Realtek RTL8019, or Microchip ENC 28J60. All of them allow easy interfacing

with low pin count.[18]

3.1.5 List of common Microcontrollers

This is a list of common microcontrollers listed by brand. [18]

AMCC

Until May 2004, these µCs were developed and marketed by IBM, whose 4xx family was sold to Applied Micro Circuits Corporation.

• PowerPC 403 o PPC 403GCX

• PowerPC 405 o PPC 405EP o PPC 405GP/CR o PPC 405GPr

Hardware Components 21

Page 41: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

o PPC NPe405H/L

• PowerPC 440 o PPC 440GP o PPC 440GX o PPC 440EP/EPx/GRx o PPC 440SP/SPe

Atmel

• AT89 series (Intel 8051 architecture) • AT90, ATtiny, ATmega, ATxmega series (AVR architecture) (Atmel Norway design) • AT91SAM (ARM architecture) • AVR32 (32-bit AVR architecture) (Atmel Norway design) • MARC4

Dallas Semiconductor

• 8051 Family • MAXQ RISC Family • Secure Micros Family

EPSON Semiconductor

• 4-bit Microcomputers S1C60/62/63 family • 8-bit Microcomputers S1C88 family • 16-bit Microcomputers S1C17 family • 32-bit Microcomputers S1C33 family

Freescale Semiconductor

Until 2004, these µCs were developed and marketed by Motorola, whose semiconductor division was spun-off to establish Freescale.

• 8-bit o 68HC05 (CPU05) o 68HC08 (CPU08) o 68HC11 (CPU11)

• 16-bit o 68HC12 (CPU12) o 68HC16 (CPU16) o Freescale DSP56800 (DSPcontroller)

• 32-bit o Freescale 683XX o M·CORE o MPC500 o MPC 860 (PowerQUICC) o MPC 8240/8250 (PowerQUICC II)

Hardware Components 22

Page 42: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

o MPC 8540/8555/8560 (PowerQUICC III)

Fujitsu

• F²MC Family (8/16 bit) • FR Family (32 bit) • FR-V Family (32 bit RISC)

Infineon

• 8-bit o XC800 family o C500/C800 family

• 16-bit o C166 family o C167 family o XC167 family

• 32-bit o TRICORE family

Intel

• 8-bit o MCS-48 (8048 family – also incl. 8035, 8038, 8039, 8040, 8X42, 8X49, 8050;

X=0 or 7) o MCS-51 (8051 family – also incl. 8X31, 8X32, 8X52; X=0, 3, or 7) o 8xC251

• 16-bit o MCS-96 (8096 family – also incl. 8061) o Intel MCS 296

Microchip Technology

Microchip produces microcontrollers with 3 very different architectures:

8-bit (8 bit data bus) PICmicro, with a single accumulator (8 bits):

• PIC10 and PIC12: 12-bit instruction words • PIC16 series: 14-bit instruction words, one address pointer ("indirect register pair")

o PIC16F84 o PICAXE

• PIC18 series: 16-bit instruction words, three address pointers ("indirect register pairs")

16-bit (16-bit data bus) microcontrollers, with 16 general-purpose registers (each 16-bit)

• PIC24: 24-bit instruction words

Hardware Components 23

Page 43: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• dsPIC: based on PIC24, plus DSP functions, such as a single-cycle MAC (multiply-accumulate) into two 40-bit accumulators.

32-bit (32 bit data bus) microcontrollers:

• PIC32MX series: 32 bit instructions, uses the MIPS architecture

NXP(Philips Semiconductors)

• 8-bit o 80C51

• 16-bit o XA

• 32-bit o ARM7

LPC2000

Toshiba

• TLCS-47 (4-bit) • TLCS-870 (8-bit CISC) • TLCS-900 (16 and 32-bit CISC) • TX19A (32-bit RISC)

ZiLOG

Zilog's (primary) microcontroller families, in chronological order:

• Older: o Zilog Z8 - 8-bit Harvard architecture ROM / EPROM / OTP microcontroller

with on-chip SRAM. o Zilog Z180 - Z80 based microcontroller; on-chip peripherals; external

memory; 1 MB address space. • Newer:

o Zilog eZ8 - Better pipelined Z8 (2-3 times as clock cycle efficient as original Z8) with on-chip flash memory and SRAM.

o Zilog eZ80 - Fast 8/16/24-bit Z80 (3-4 times as cycle efficient as original Z80) with flash, SRAM, peripherals; linear addressing of 16 MB.

o Zilog Z16 - Fast 8/16/32-bit CPU with compact object code; 16 MB (4GB possible) addressing range; flash, SRAM, peripherals, on chip.

Hardware Components 24

Page 44: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.1.6 PIC Microcontroller

PIC is a family of Harvard architecture microcontrollers made by Microchip Technology.

[20] Originally developed by General Instrument's Microelectronics Division. The name PIC

initially referred to "Peripheral Interface Controller". [20]

3.1.7 Architecture of PIC Microcontroller

The PIC architecture characterized by the following features: [20]

• Separate code and data spaces (Harvard architecture)

• A small number of fixed length instructions

• Most instructions are single cycle execution (4 clock cycles), with single delay cycles

upon branches and skips

• A single accumulator (W), the use of which (as source operand) is implied (i.e. is not

encoded in the opcode)

• All RAM locations function as registers as both source and/or destination of math and

other functions.

• A hardware stack for storing return addresses

• A fairly small amount of addressable data space (typically 256 bytes), extended

through banking

• Data space mapped CPU, port, and peripheral registers

• The program counter is also mapped into the data space and writable (this is used to

implement indirect jumps).

Unlike most other CPUs, there is no distinction between memory space and register space

because the RAM serves the job of both memory and registers, and the RAM is usually just

referred to as the register file or simply as the registers.[4]

3.1.7.1 Data space (RAM)

PICs have a set of registers that function as general purpose RAM. Special purpose control

registers for on-chip hardware resources are also mapped into the data space. The

addressability of memory varies depending on device series, and all PIC devices have some

banking mechanism to extend the addressing to additional memory. Later series of devices

Hardware Components 25

Page 45: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

feature move instructions which can cover the whole addressable space, independent of the

selected bank. In earlier devices (i.e., the baseline and mid-range cores), any register move

had to be achieved via the accumulator. [20]

To implement indirect addressing, a "file select register" (FSR) and "indirect register"

(INDF) are used: A register number is written to the FSR, after which reads from or writes to

INDF will actually be to or from the register pointed to by FSR. Later devices extended this

concept with post- and pre- increment/decrement for greater efficiency in accessing

sequentially stored data. This also allows FSR to be treated almost like a stack pointer.

3.1.7.2 Code space

All PICs feature Harvard architecture, so the code space and the data space are separate. PIC

code space is generally implemented as EPROM, ROM, or flash ROM. In general, external

code memory is not directly addressable due to the lack of an external memory interface. The

exceptions are PIC17 and select high pin count PIC18 devices. [20]

3.1.7.3 Word size

The word size of PICs can be a source of confusion. All PICs handle (and address) data in 8-

bit chunks, so they should be called 8-bit microcontrollers. However, the unit of

addressability of the code space is not generally the same as the data space. For example,

PICs in the baseline and mid-range families have program memory addressable in the same

wordsize as the instruction width, ie. 12 or 14 bits respectively. In contrast, in the PIC18

series, the program memory is addressed in 8-bit increments (bytes), which differs from the

instruction width of 16 bits. In order to be clear, the program memory capacity is usually

stated in number of (single word) instructions, rather than in bytes. [20]

3.1.7.4 Stacks

PICs have a hardware call stack, which is used to save return addresses. The hardware stack

is not software accessible on earlier devices, but this changed with the 18 series devices.

Hardware support for a general purpose parameter stack was lacking in early series, but this

greatly improved in the 18 series, making the 18 series architecture friendlier to high level

language compilers. [20]

Hardware Components 26

Page 46: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.1.7.5 Instruction set

A PIC's instructions vary from about 35 instructions for the low-end PICs to over 80

instructions for the high-end PICs. The instruction set includes instructions to perform a

variety of operations on registers directly, the accumulator and a literal constant or the

accumulator and a register, as well as for conditional execution, and program branching.

Some operations, such as bit setting and testing, can be performed on any numbered register,

but bi-operand arithmetic operations always involve W; writing the result back to either W or

the other operand register. To load a constant, it is necessary to load it into W before it can be

moved into another register. On the older cores, all register moves needed to pass through W,

but this changed on the "high end" cores.

PIC cores have skip instructions which are used for conditional execution and branching. The

skip instructions are: 'skip if bit set', and, 'skip if bit not set'. Because cores before PIC18 had

only unconditional branch instructions, conditional jumps are implemented by a conditional

skip (with the opposite condition) followed by an unconditional branch. Skips are also of

utility for conditional execution of any immediate single following instruction.

The PIC architecture has no (or very meager) hardware support for automatically saving

processor state when servicing interrupts. The 18 series improved this situation by

implementing shadow registers which save several important registers during an interrupt.

[20]

3.1.7.6 Performance

Many of these architectural decisions are directed at the maximization of top-end speed, or

more precisely of speed-to-cost ratio. The PIC architecture was among the first scalar CPU

designs, and is still among the simplest and cheapest. The Harvard architecture - in which

instructions and data come from conveniently separate sources - simplifies timing and

microcircuit design greatly, and this pays benefits in areas like clock speed, price, and power

consumption.

The PIC is particularly suited to implementation of fast lookup tables in the program space.

Such lookups are O(1) and can complete via a single instruction taking two instruction

Hardware Components 27

Page 47: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

cycles. Basically any function can be modelled in this way. Such optimization is facilitated

by the relatively large program space of the PIC (e.g. 4096 x 14-bit words on the 16F690)

and by the design of the instruction set, which allows for embedded constants.

The simplicity of the PIC, and its scalar nature, also serve to greatly simplify the construction

of real-time code. It is typically possible to multiply the line count of a PIC assembler listing

by the instruction cycle time to determine execution time. (This is true because skip-based

instructions take 2 cycles whether the skip occurs or doesn't.) On other CPUs (even the

Atmel, with its MUL instruction), such quick methods are just not possible. In low-level

development, precise timing is often critical to the success of the application, and the real-

time features of the PIC can save crucial engineering time.

A similarly useful and unique property of PICs is that their interrupt latency is constant (it's

also low: 3 instruction cycles). The delay is constant even though instructions can take one or

two instruction cycles: a dead cycle is optionally inserted into the interrupt response

sequence to make this true. External interrupts have to be synchronized with the four clock

instruction cycle; otherwise there can be a one instruction cycle jitter. Internal interrupts are

already synchronized.

The constant interrupt latency allows PICs to achieve interrupt driven low jitter timing

sequences. An example of this is a video sync pulse generator. Other microcontrollers can do

this in some cases, but it's awkward. The non-interrupt code has to anticipate the interrupt

and enter into a sleep state before it arrives. On PICs, there is no need for this.

The three-cycle latency is increased in practice because the PIC does not store its registers

when entering the interrupt routine. Typically, 4 instructions are needed to store the W-

register, the status register and switch to a specific bank before starting the actual interrupt

processing. [20]

3.1.7.7 Limitations

The PIC architectures have several limitations: [20]

• Only a single accumulator

• A small instruction set

Hardware Components 28

Page 48: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• Operations and registers are not orthogonal; some instructions can address RAM

and/or immediate constants, while others can only use the accumulator

• Memory must be directly referenced in arithmetic and logic operations, although

indirect addressing is available via 2 additional registers

• Register-bank switching is required to access the entire RAM of many devices,

making position-independent code complex and inefficient

• Conditional skip instructions are used instead of conditional branch instructions used

by most other architectures

3.1.8 8/16/32-bit PIC microcontroller product families

8-bit Microcontrollers

• PIC10 • PIC12 • PIC14 • PIC16 • PIC17 • PIC18

16-bit Microcontrollers

• PIC24F • PIC24H

32-bit Microcontrollers

• PIC32

16-bit Digital Signal Controllers

• dsPIC30 • dsPIC33F

3.1.9 Selection of PIC Microcontroller (PIC16F877A) for this study Selecting PIC microcontroller for this study requires taking into account a variety of factors.

These factors include: [12]

• The number of I/O pins • The peripherals needed (i.e. module) • The memory size (program memory, RAM, EEPROM) • Microcontroller speed

Hardware Components 29

Page 49: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• Physical size

An important thing to remember when choosing a PIC microcontroller is there is a balancing

act between cost and all of the factors listed above. Keeping all these factors in mind we

selected PIC16F877A for this study. Key features of PIC16F877A are given below.

Table 3.1 Features of PIC16F877A Device

Key Features PIC16F877A

Operating Frequency DC – 20 MHz

Resets (and Delays) POR, BOR (PWRT, OST)

Flash Program Memory (14-bit words)

8K

Data Memory (bytes) 368

EEPROM Data Memory (bytes) 256

Interrupts 15

I/O Ports Ports A, B, C, D, E

Timers 3

Capture/Compare/PWM modules 2

Serial Communications MSSP, USART

Parallel Communications PSP

10-bit Analog-to-Digital Module 8 input channels

Analog Comparators 2

Instruction Set 35 Instructions

Packages 40-pin PDIP 44-pin PLCC 44-pin TQFP 44-pin QFN

Hardware Components 30

Page 50: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Block and Pin Diagram of PIC16F877A

Figure 3.4 PIC16F877A Block Diagram

Hardware Components 31

Page 51: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Figure 3.5 Pin diagram of PIC16F877A

Hardware Components 32

Page 52: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Table 3.2(a): PIC16F874A/877A Pinout Description

Hardware Components 33

Page 53: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Table 3.2(b): PIC16F874A/877A Pinout Description (Continued)

Hardware Components 34

Page 54: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Table 3.2(c): PIC16F874A/877A Pinout Description (Continued)

Hardware Components 35

Page 55: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Table 3.2(d): PIC16F874A/877A Pinout Description (Continued)

Hardware Components 36

Page 56: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.1.10 Memory Organization 3.1.10.1 Program Memory Organization There are three memory blocks in each of the PIC16F87XA devices. The program memory

and data memory have separate buses so that concurrent access can occur. The PIC16F877A

device has 8K words x 14 bits of Flash program memory. [12]

Figure 3.6: PIC16F877A Program Memory Map and Stack

3.1.10.2 Data Memory Organization

The data memory is partitioned into multiple banks which contain the General Purpose

Registers and the Special Function Registers (SFR). Bits RP1 (Status<6>) and RP0

(Status<5>) are the bank select bits. Each bank extends up to 7Fh (128 bytes). The lower

locations of each bank are reserved for the Special Function Registers. Above the Special

Function Registers are General Purpose Registers, implemented as static RAM. All

Hardware Components 37

Page 57: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

implemented banks contain Special Function Registers. Some frequently used Special

Function Registers from one bank may be mirrored in another bank for code reduction and

quicker access.

PICs are popular with developers and hobbyists alike due to their low cost, wide availability,

large user base, extensive collection of application notes, availability of low cost or free

development tools, and serial programming (and re-programming with flash memory)

capability.[12]

3.2 GSM Module

GSM Modules are similar to modems, but there's one difference: A GSM Modem is external

equipment, whereas the GSM Module is a module that can be integrated within equipment. It

is an embedded piece of hardware.

A GSM module is a wireless module that works with GSM networks. A wireless module

behaves like a Hayes compatible dial-up modem. The main difference between a standard

Hayes modem and a GSM module is that a Hayes modem sends and receives data through a

fixed telephone line while a GSM module sends and receives data through radio waves.

Like a GSM mobile phone, a GSM module requires a SIM card from a wireless carrier in

order to operate.

GSM modules and normal Hayes modems support a common set of AT commands. A GSM

module can be used just like a Hayes compatible modem.

GSM modules support an extended set of AT commands. These extended AT commands are

defined in the GSM standards. With the extended AT commands, you can do things like: [21]

• Read, write and delete SMS messages.

• Send SMS messages.

Hardware Components 38

Page 58: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• Monitor the signal strength.

• Monitor the charging status and charge level of the battery.

• Read, write and search phone book entries.

The number of SMS messages that can be processed by a GSM module is pretty low, approx

six messages per minute. GPRS Modules are similar to modems, but there's one difference:

A GRPS Modem is external equipment, whereas the GPRS Module is a module that can be

integrated within equipment. It is an embedded piece of hardware.

A GPRS module is a GSM module with additional support for GPRS technology for data

transmission. GPRS means: 'General Packet Radio Service'. It is based on a packet-switched

technology, as an extension to GSM (note that GSM is a circuit-switched). An advantage of

GPRS over GSM is that GPRS has a much higher data transmission speed.

GPRS can be used as the bearer of SMS. If SMS over GPRS is used, an SMS transmission

speed of about 30 SMS messages per minute may be achieved. This is much faster than SMS

over GSM. A GPRS modem is required to send and receive SMS via GPRS. Some wireless

carriers do not support the sending and receiving of SMS via GPRS. In this study SIM 300

module is used. [21]

3.2.1 Features of GSM Module SIM300CZ

SIM300 is a Tri-band GSM/GPRS module that works on frequencies EGSM 900 MHz, DCS

1800 MHz and PCS 1900 MHz. SIM300 features GPRS multi-slot class 10/ class 8

(optional) and supports the GPRS coding schemes CS-1, CS-2, CS-3 and CS-4.

With a tiny configuration of 40mm x 33mm x 2.85mm, SIM300 can fit almost all the space

requirements in the applications, such as smart phone, PDA phone and other mobile devices.

The physical interface to the mobile application is made through a 60-pin board-to-board

connector, which provides all hardware interfaces between the module and customers’ boards

except the RF antenna interface.

• The keypad and SPI display interface will give you the flexibility to develop

customized applications.

Hardware Components 39

Page 59: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• Serial port and Debug port can help you easily develop your applications.

• Two audio channels include two microphones inputs and two speaker outputs. This

can be easily configured by AT command.

The SIM300 provides RF antenna interface with two alternatives: antenna connector and

antenna pad. The antenna connector is MURATA MM9329-2700. And customer’s antenna

can be soldered to the antenna pad. The SIM300 is designed with power saving technique;

the current consumption is as low as 2.5mA in SLEEP mode.

The SIM300 is integrated with the TCP/IP protocol; extended TCP/IP AT commands are

developed for customers to use the TCP/IP protocol easily, which is very useful for those

data transfer applications. [21]

Table 3.3(a) Key Features of GSM Module SIM300CZ

Feature Implementation

Power supply Single supply voltage 3.4V – 4.5V

Power saving Typical power consumption in SLEEP mode to 2.5mA ( BS-PA-

MFRMS=5 )

Frequency bands • SIM300 Tri-band: EGSM 900, DCS 1800, PCS 1900. The SIM300 can search the 3 frequency bands automatically. The frequency bands also can be set by AT command.

• Compliant to GSM Phase 2/2+

GSM class Small MS Transmit power • Class 4 (2W) at EGSM 900

• Class 1 (1W) at DCS 1800 and PCS 1900 GPRS connectivity • GPRS multi-slot class 10 (default)

• GPRS multi-slot class 8 (option) • GPRS mobile station class B

Temperature range • Normal operation: -20°C to +55°C

• Restricted operation: -30°C to -20°C and +55°C to +80°C (1)

• Storage temperature -40°C to +85°C

Hardware Components 40

Page 60: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Table 3.3(b) Key Features of GSM Module SIM 300CZ

Feature Implementation

DATA GPRS: CSD:

• GPRS data downlink transfer: max. 85.6 kbps • GPRS data uplink transfer: max. 42.8 kbps • Coding scheme: CS-1, CS-2, CS-3 and CS-4 • SIM300 supports the protocols PAP (Password

Authentication Protocol) usually used for PPP connections. • The SIM300 integrates the TCP/IP protocol. • Support Packet Switched Broadcast Control Channel

(PBCCH) • CSD transmission rates: 2.4, 4.8, 9.6, 14.4 kbps, non-

transparent • Unstructured Supplementary Services Data (USSD) support

SMS • MT, MO, CB, Text and PDU mode

• SMS storage: SIM card

FAX Group 3 Class 1 SIM interface Support SIM card: 1.8V, 3V External antenna Connected via 50 Ohm antenna connector or antenna pad Audio features Speech codec modes:

• Half Rate (ETS 06.20) • Full Rate (ETS 06.10) • Enhanced Full Rate (ETS 06.50 / 06.60 / 06.80) • Echo suppression

Serial port and Debug port

• Serial Port: Seven lines on Serial Port Interface • Serial Port can be used for CSD FAX, GPRS service and

send AT command of controlling module. • Serial Port can use multiplexing function. • Autobauding supports baud rate from 4800 bps to

115200bps. • Debug Port: Two lines on Serial Port Interface /TXD and

/RXD • Debug Port only used for debugging

Phonebook management

Support phonebook types: SM, FD, LD, RC, ON, MC.

SIM Application Toolkit

Support SAT class 3, GSM 11.14 Release 99

Real time clock Implemented Timer function Programmable via AT command Physical characteristics

Size: 40±0.15 x 33±0.15 x 3.3±0.3mm (including application connector)

40±0.15 x 33±0.15 x 2.85±0.3mm (excluding application connector) Weight: 8g

Firmware upgrade Firmware upgrade by serial port.

Hardware Components 41

Page 61: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.2.2 Functional Diagram of GSM Module SIM 300CZ

The following figure shows a functional diagram of the SIM 300CZ and illustrates the

mainly functional part:

• The GSM base band engine

• Flash and SRAM

• The GSM radio frequency part

• The antenna interface

• The board-to-board interface

Figure 3.7: Functional Diagram of GSM Module SIM 300CZ

Hardware Components 42

Page 62: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.2.2 Top view of GSM Module SIM 300CZ

Figure 3.8: Top view of GSM Module SIM300CZ

3.2.2 Pin diagram of GSM Module SIM 300CZ

Figure 3.9: Pin diagram GSM Module SIM300 CZ

Hardware Components 43

Page 63: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.2.3 Operating modes of GSM Module SIM 300CZ The table below briefly summarizes the various operating modes. [21] Table 3.4: Overview of operating modes of GSM Module SIM 300CZ

Mode Function GSM/GPRS SLEEP Module will automatically go into SLEEP mode if

DTR is set to high level and there is no on air and no hardware interrupt (such as GPIO interrupt or data on serial port). In this case, the current consumption of module will reduce to the minimal level. During SLEEP mode, the module can still receive paging message and SMS from the system normally.

GSM IDLE Software is active. Module has registered to the GSM network, and the module is ready to send and receive.

GSM TALK Connection is going on between two subscribers. In this case, the power consumption depends on network settings such as DTX off/on, FR/EFR/HR, hopping sequences, antenna.

GPRS STANDBY Module is ready for GPRS data transfer, but no data is currently sent or received. In this case, power consumption depends on network settings and GPRS configuration.

Normal operation

GPRS DATA There is GPRS data in transfer (PPP or TCP or UDP). In this case, power consumption is related with network settings (e.g. power control level), uplink / downlink data rates and GPRS configuration (e.g. used multi-slot settings).

POWER DOWN Normal shutdown by sending the “AT+CPOWD=1” command or using the PWRKEY. The power management ASIC disconnects the power supply from the base band part of the module, only the power supply for the RTC is

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

The SIM interface is powered from an internal regulator in the module having normal voltage

3V. All pins reset as outputs driving low. [21]

Hardware Components 44

Page 64: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Logic levels are as described in table

Table 3.5: Pin define of the SIM interface

Name

Pin Function

SIM_VDD 25 SIM Card Power output automatic output on SIM mode one is 3.0V±10%, another is 1.8V±10%. Current is about 10mA.

SIM_DATA 29 SIM Card data I/O

SIM_CLK 31 SIM Card Clock

SIM_RST 27 SIM Card Reset

Following is the reference circuit about SIM interface. The 22Ω resistors showed in the

following figure should be added in series on the IO line between the module and the SIM

card for protecting the SIM I/O port. The pull up resistor (about 10KΩ) must be added on the

SIM_DATA line. The SIM peripheral circuit should be closed to the SIM card socket.

The SIM_PRESENCE pin is used for detecting the SIM card removal. The AT commands

can be used “AT+CSDT” to set the SIMCARD configure.

The 6 pins SIM card can be selected. The reference circuit about 6 pins SIM card illustrates

as following figure.

Figure 3.10: Reference Circuit of the 6 Pins SIM Card

Hardware Components 45

Page 65: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.3 SIM Card Holder

For 6 pins SIM card, usually Amphenol C707 10M006 SIM Card holders are used. The

diagram of the SIM Card holder is given below. [22]

Figure 3.11: Diagram of the SIM Card Holder

Figure 3.12: Diagram of the 6 pin SIM Card

Hardware Components 46

Page 66: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Table 3.6: Pin description of the SIM Interface.

Pin Name Description 1 VCC +5V DC power supply input (optional use by the card)

2 RESET Either used itself (reset signal supplied from the interface device) or in combination with an internal reset control circuit (optional use by the card). If internal reset is implemented, the voltage supply on VCC is mandatory

3 CLOCK Clocking or timing signal (optional use by the card) 4 GND Ground (reference voltage)

5 VPP Programming voltage input (optional). This contact may be used to supply the voltage required to program or to erase the internal non-volatile memory.

6 I/O Input or Output for serial data to the integrated circuit inside the card 7,8 N/C not used

The dialogue between the interface device and the card shall be conducted through the

consecutive operations:

• connection and activation of the contacts by the interface device

• reset of the card

• answer to reset by the card

• subsequent information exchange between the card and the interface device

• desactivation of the contacts by the interface device

The adapter electronic gets its power supply from the smartcard reader device VCC line or an

external 5 V supply can be used. The card slot’s RST line is connected using one of the TTL-

>RS-232 drivers in the MAX232 to DCD, so that the software and the reader can easily

resynchronize in case of a protocol error.

3.4 Subscriber Identity Module (SIM) A Subscriber Identity Module (SIM) on a removable SIM Card securely stores the service-

subscriber key (IMSI) used to identify a subscriber on mobile telephony devices (such as

computers and mobile phones). The SIM card allows users to change phones by simply

removing the SIM card from one mobile phone and inserting it into another mobile phone or

broadband telephony device. [10]

Hardware Components 47

Page 67: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

SIM card contains its unique serial number, international unique number of the mobile user

(IMSI), security authentication and ciphering information, temporary information related to

the local network (also temporary local ID that has been issued to the user), list of the

services the user has access to and two passwords (regular PIN and unblocking PUK).

SIM cards are available in two standard sizes. The first is the size of a credit card (85.60 mm

× 53.98 mm x 0.76 mm). The newer, more popular miniature version has a width of 25 mm,

a length of 15 mm, and a thickness of 0.76 mm. However, most SIM cards are still supplied

as a full-sized card with the smaller card held in place by a few plastic links and can be easily

broken off to be used in a phone that uses the smaller SIM.

The first SIM Card was made in 1991, with Munich smart card maker Giesecke & Devrient

selling the first 300 SIM cards to Finnish wireless network operator Elisa Oyj (formerly

Radiolinja). [10]

3.4.1 Smart Card technology

Each SIM Card stores a unique International Mobile Subscriber Identity (IMSI). The format

of this number is as follows:

• The first 3 digits represent the Mobile Country Code (MCC).

• The next 2 digits represent the Mobile Network Code (MNC).

• The next 10 digits represent the mobile station identification number.

Since a SIM card is a smart card, it also has an ICC-ID number based on International

Standard ISO/IEC 7812. The maximum length of the visible card number is 20 characters; 19

digits are preferred, but telecommunication network operators who are already issuing Phase

1 SIM cards with an identification number length of 20 digits may retain this length. The

number is composed of the following subparts: [10]

3.4.2 Issuer Identification number (max. 7 digits)

• Major Industry Identifier (MII), 2 digits, 89 for telecommunication purposes.

• Country code, 1-3 digits, as defined by ITU-T recommendation E.164.

• Issuer identifier, variable.

Hardware Components 48

Page 68: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Individual account identification

• Individual account identification number.

• Parity check digit.

W-SIM is a SIM card which also integrates core cellular technology into the card itself.

A Virtual SIM is a mobile phone number provided by a wireless carrier which does not

require a SIM Card to terminate phone calls on a user's mobile phone. [10]

3.4.3 Usage in mobile phone standards

The use of SIM cards is mandatory in GSM devices. The equivalent of a SIM in UMTS is

called the Universal Integrated Circuit Card (UICC), which runs a USIM application,

whereas the Removable User Identity Module (R-UIM) is more popular in CDMA-based

devices. The UICC card is still colloquially referred to as a SIM card. Many CDMA-based

standards do not include any such card, and the service is bound to a unique identifier

contained in the handset itself.

The satellite phone networks Iridium, Thuraya and Inmarsat's BGAN also use SIM cards.

Sometimes these SIM cards work in regular GSM phones and also allow GSM customers to

roam in satellite networks by using their own SIM card in a satellite phone.

The SIM card introduced a new and significant business opportunity of mobile telecoms

operator/carrier business of the MVNO (Mobile Virtual Network Operator) which does not

own or operate a cellular telecoms network, but which leases capacity from one of the

network operators, and only provides a SIM card to its customers. MVNOs first appeared in

Denmark, Hong Kong, Finland and the UK and today exist in over 50 countries including

most of Europe, USA, Canada, Australia and parts of Asia and account for approximately

10% of all mobile phone subscribers around the world. [10]

3.4.4 Operating systems

SIM operating systems come in two main types: Native and Java Card. Native SIMs are

based on proprietary, vendor specific software whereas the Java Card SIMs are based on

Hardware Components 49

Page 69: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

standards, particularly Java Card which is a subset of the Java programming language

specifically targeted at embedded devices. Java Card allows the SIM to contain programs that

are hardware independent and interoperable. [10]

3.4.5 Data Storage

SIM cards store network specific information used to authenticate and identify subscribers on

the Network, the most important of these are the ICCID, IMSI, Authentication Key (Ki),

Local Area Identity (LAI) and Operator-Specific Emergency Number. The SIM also stores

other carrier specific data such as the SMSC (Short Message Service Center) number,

Service Provider Name (SPN), Service Dialing Numbers (SDN), Advice-Of-Charge

parameters and Value Added Service (VAS) applications.

3.4.6 Integrated Circuit Card ID ICCID

Each SIM is internationally identified by its ICC-ID (Integrated Circuit Card ID). ICCIDs are

stored in the SIM cards and are also engraved or printed on the SIM card body during a

process called personalization. The ICCID is defined by the ITU-T recommendation E.118.

The number is up to 18 or 19 digits long and in addition is often associated with a single

check digit calculated using the Luhn algorithm.

3.4.7 IMSI

SIM cards are identified on their individual operator networks by holding a unique

International Mobile Subscriber Identity. Mobile operators connect mobile phone calls and

communicate with their market SIM cards using their IMSI.

3.4.8 Authentication key (Ki)

The Ki is a 128-bit value used in authenticating the SIMs on the mobile network. Each SIM

holds a unique Ki assigned to it by the operator during the personalization process. The Ki is

also stored on a database (known as Authentication Center or AuC) on the carrier’s network.

The SIM card is designed not to allow the Ki to be obtained using the smart-card interface.

Instead, the SIM card provides a function, "RUN GSM ALGORITHM", that allows the

phone to pass data to the SIM card to be signed with the Ki. This, by design, makes usage of

Hardware Components 50

Page 70: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

the SIM card mandatory unless the Ki can be extracted from the SIM card, or the carrier is

willing to reveal the Ki. In practice, the GSM "crypto" algorithm for computing SRES_2 (see

step 4, below) from the Ki has certain vulnerabilities which can allow the extraction of the Ki

from a SIM card and the making of a duplicate SIM card. [10]

3.4.9 Authentication process

1. When the Mobile Equipment starts up, it obtains the IMSI (International Mobile

Subscriber Identity) from the SIM card, and passes this to the mobile operator

requesting access and authentication. The Mobile Equipment may have to pass a PIN

to the SIM card before the SIM card will reveal this information.

2. The operator network searches its database for the incoming IMSI and its associated

Ki.

3. The operator network then generates a Random Number (RAND) and signs it with

the Ki associated with the IMSI (and stored on the SIM card), computing another

number known as Signed Response (SRES_1).

4. The operator network then sends the RAND to the Mobile Equipment, which passes it

to the SIM card. The SIM card signs it with its Ki, producing SRES_2 which it gives

to the Mobile Equipment along with encryption key Kc. The Mobile Equipment

passes SRES_2 on to the operator network.

5. The operator network then compares its computed SRES_1 with the computed

SRES_2 that the Mobile Equipment returned. If the two numbers match the SIM is

authenticated and the Mobile Equipment is granted access to the operator's network.

Kc is used to encrypt all further communications between the Mobile Equipment and

the network.

3.4.10 Location area identity

The SIM stores network state information, which is received from the Location Area Identity

(LAI). Operator networks are divided into Location Areas, each having a unique LAI

number. When the device changes locations, it stores the new LAI to the SIM and sends it

back to the operator network with its new location. If the device is power cycled, it will take

data off the SIM, and search for the previous LAI. This saves time by avoiding having to

search the whole list of frequencies that the telephone normally would. [10]

Hardware Components 51

Page 71: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.4.11 SMS messages and contacts

Most SIM cards will orthogonally store a number of SMS messages and phone book

contacts. The contacts are stored in simple 'Name and number' pairs - entries containing

multiple phone numbers and additional phone numbers will usually not be stored on the SIM

card. When a user tries to copy such entries to SIM the handset's software will break them up

into multiple entries, discarding any information that isn't a phone number. The number of

contacts and messages stored depends on the SIM; early models would store as little as 5

messages and 20 contacts while modern SIM cards can usually store over 250 contacts. [10]

3.4.12 SIM Serial Number (SSN) Digits

A typical SSN (19 digits) example 89 91 10 1200 00 320451 0, provides several details as

follows: [23]

• The first two digits (89 in the example) refer to the Telecom Id.

• The next two digits (91 in the example) refer to the country code (88-Bangladesh).

• The next two digits (10 in the example) refer to the network code.

• The next four digits (1200 in the example) refer to the month and year of

manufacturing; December, 2000 in this case.

• The next two digits (00 in the example) refer to the switch configuration code.

• The next six digits (320451 in the example) refer to the SIM number.

• The last digit which is separated from the rest is called the check digit.

3.5 Power Supply Unit

Power supply is a reference to a source of electrical power. A device or system that supplies

electrical or other types of energy to an output load or group of loads is called a power supply

unit or PSU. The term is most commonly applied to electrical energy supplies, less often to

mechanical ones, and rarely to others. [23]

Hardware Components 52

Page 72: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.5.1 Electrical power supplies

This term covers the power distribution system together with any other primary or secondary

sources of energy such as:

• Conversion of one form of electrical power to another desired form and voltage. This

typically involves converting 120 or 240 volt AC supplied by a utility company (see

electricity generation) to a well-regulated lower voltage DC for electronic devices.

Low voltage, low power DC power supply units are commonly integrated with the

devices they supply, such as computers and household electronics. For other

examples, see switched-mode power supply, linear regulator, rectifier and inverter

(electrical).

• Batteries

• Chemical fuel cells and other forms of energy storage systems

• Solar power

• Generators or alternators (particularly useful in vehicles of all shapes and sizes, where

the engine has torque to spare or in semi-portable units containing an internal

combustion engine and a generator).

Constraints that commonly affect power supplies are the amount of power they can supply,

how long they can supply it without needing some kind of refueling or recharging, how

stable their output voltage or current is under varying load conditions, and whether they

provide continuous power or pulses.

The regulation of power supplies is done by incorporating circuitry to tightly control the

output voltage and/or current of the power supply to a specific value. The specific value is

closely maintained despite variations in the load presented to the power supply's output, or

any reasonable voltage variation at the power supply's input. This kind of regulation is

commonly categorized as a Stabilized power supply. [24]

3.5.2 Power supply types

Power supplies for electronic devices can be broadly divided into linear and switching power

supplies. The linear supply is a relatively simple design that becomes increasingly bulky and

Hardware Components 53

Page 73: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

heavy for high current devices; voltage regulation in a linear supply can result in low

efficiency. A switched-mode supply of the same rating as a linear supply will be smaller, is

usually more efficient, but will be more complex. [23,24]

3.5.2.1 Battery power supply

A battery is a type of linear power supply that offers benefits that traditional line-operated

power supplies lack: mobility, portability, and reliability. A battery consists of multiple

electrochemical cells connected to provide the voltage desired.

The most commonly used dry-cell battery is the carbon-zinc dry cell battery. Dry-cell

batteries are made by stacking a carbon plate, a layer of electrolyte paste, and a zinc plate

alternately until the desired total voltage is achieved. The most common dry-cell batteries

have one of the following voltages: 1.5, 3, 6, 9, 22.5, 45, and 90. During the discharge of a

carbon-zinc battery, the zinc metal is converted to a zinc salt in the electrolyte, and

magnesium dioxide is reduced at the carbon electrode. These actions establish a voltage of

approximately 1.5 V.

The lead-acid storage battery may be used. This battery is rechargeable; it consists of lead

and lead/dioxide electrodes which are immersed in sulfuric acid. When fully charged, this

type of battery has a 2.06-2.14 V potential. During discharge, the lead is converted to lead

sulfate and the sulfuric acid is converted to water. When the battery is charging, the lead

sulfate is converted back to lead and lead dioxide.

A nickel-cadmium battery has become more popular in recent years. This battery cell is

completely sealed and rechargeable. The electrolyte is not involved in the electrode reaction,

making the voltage constant over the span of the batteries long service life. During the

charging process, nickel oxide is oxidized to its higher oxidation state and cadmium oxide is

reduced. The nickel-cadmium batteries have many benefits. They can be stored both charged

and uncharged. They have a long service life, high current availabilities, constant voltage,

and the ability to be recharged.

Hardware Components 54

Page 74: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.5.2.2 Linear power supply

A home-made linear power supply (used here to power amateur radio equipment). An AC

powered linear power supply usually uses a transformer to convert the voltage from the wall

outlet (mains) to a different, usually a lower voltage. If it is used to produce DC, a rectifier is

used. A capacitor is used to smooth the pulsating current from the rectifier. Some small

periodic deviations from smooth direct current will remain, which is known as ripple. These

pulsations occur at a frequency related to the AC power frequency (for example, a multiple

of 50 or 60 Hz).

The voltage produced by an unregulated power supply will vary depending on the load and

on variations in the AC supply voltage. For critical electronics applications a linear regulator

will be used to stabilize and adjust the voltage. This regulator will also greatly reduce the

ripple and noise in the output direct current. Linear regulators often provide current limiting,

protecting the power supply and attached circuit from over-current.

Adjustable linear power supplies are common laboratory and service shop test equipment,

allowing the output voltage to be set over a wide range. For example, a bench power supply

used by circuit designers may be adjustable up to 30 volts and up to 5 amperes output. Some

can be driven by an external signal, for example, for applications requiring a pulsed output.

The simplest DC power supply circuit consists of a single diode and resistor in series with the

AC supply. This circuit is common in rechargeable flashlights.

3.5.2.3 AC/ DC supply

In the past, mains electricity was supplied as DC in some regions, AC in others. A simple,

cheap linear power supply would run directly from either AC or DC mains, often without

using a transformer. The power supply consisted of a rectifier and a capacitor filter. The

rectifier was essentially a conductor, having no sudden effect when operating from DC. [23]

Hardware Components 55

Page 75: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.5.2.4 Switched-mode power supply

A switched-mode power supply (SMPS) works on a different principle. AC mains input is

directly rectified without the use of a transformer, to obtain a DC voltage. This voltage is

then sliced into small pieces by a high-speed electronic switch. The size of these slices grows

larger as power output requirements increase.

The input power slicing occurs at a very high speed (typically 10 kHz — 1 MHz). High

frequency and high voltages in this first stage permit much smaller step down transformers

than are in a linear power supply. After the transformer secondary, the AC is again rectified

to DC. To keep output voltage constant, the power supply needs a sophisticated feedback

controller to monitor current draw by the load.

Modern switched-mode power supplies often include additional safety features such as the

crowbar circuit to help protect the device and the user from harm. In the event that an

abnormal high current power draw is detected, the switched-mode supply can assume this is

a direct short and will shut itself down before damage is done. For decades PC computer

power supplies have also provided a power good signal to the motherboard which prevents

operation when abnormal supply voltages are present.

Switched mode power supplies have an absolute limit on their minimum current output.

They are only able to output above a certain power level and cannot function below that

point. In a no-load condition the frequency of the power slicing circuit increases to great

speed, causing the isolation transformer to act as a tesla coil, causing damage due to the

resulting very high voltage power spikes. Switched-mode supplies with protection circuits

may briefly turn on but then shut down when no load has been detected. A very small low-

power dummy load such as a ceramic power resistor or 10 watt light bulb can be attached to

the supply to allow it to run with no primary load attached.

Power factor has become a recent issue of concern for computer manufacturers. Switched

mode power supplies have traditionally been a source of power line harmonics and have a

very poor power factor. Many computer power supplies built in the last few years now

include power factor correction built right into the switched-mode supply, and may advertise

the fact that they offer 1.0 power factor.

Hardware Components 56

Page 76: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

By slicing up the sinusoidal AC wave into very small discrete pieces, the portion of the

alternating current not used stays in the power line as very small spikes of power that cannot

be utilized by AC motors and results in waste heating of power line transformers. Hundreds

of switched mode power supplies in a building can result in poor power quality for other

customers surrounding that building, and high electric bills for the company if they are billed

according to their power factor in addition to the actual power used. Filtering capacitor banks

may be needed on the building power mains to suppress and absorb these negative power

factor effects. [23]

3.5.2.5 Programmable power supply

Programmable power supplies are those in which the output voltage can be varied remotely.

One possible option is digital control by a computer interface. Variable properties include

voltage, current, and frequency. This type of supply is composed of a processor,

voltage/current programming circuits, current shunt, and voltage/current read-back circuits.

Programmable power supplies can furnish DC, AC, or both types of output. The AC output

can be either single-phase or three-phase. Single-phase is generally used for low-voltage,

while three-phase is more common for high-voltage power supplies.

When choosing a programmable power supply, several specifications should be considered.

For AC supplies, output voltage, voltage accuracy, output frequency, and output current are

important attributes. For DC supplies, output voltage, voltage accuracy, current, and power

are important characteristics. Many special features are also available, including computer

interface, overcurrent protection, overvoltage protection, short circuit protection, and

temperature compensation. Programmable power supplies also come in a variety of forms.

Some of those are modular, board-mounted, wall-mounted, and floor-mounted or bench top.

Programmable power supplies are now used in many applications. Some examples include

automated equipment testing, crystal growth monitoring, and differential thermal analysis.

3.5.2.6 Uninterruptible power supply

An Uninterruptible Power Supply (UPS) takes its power from two or more sources

simultaneously. It is usually powered directly from the AC mains, while simultaneously

Hardware Components 57

Page 77: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

charging a storage battery. Should there be a dropout or failure of the mains, the battery

instantly takes over so that the load never experiences an interruption. Such a scheme can

supply power as long as the battery charge suffices, e.g., in a computer installation, giving

the operator sufficient time to effect an orderly system shutdown without loss of data. Other

UPS schemes may use an internal combustion engine or turbine to continuously supply

power to a system in parallel with power coming from the AC mains. The engine-driven

generators would normally be idling, but could come to full power in a matter of a few

seconds in order to keep vital equipment running without interruption. Such a scheme might

be found in hospitals or telephone central offices.

3.5.2.7 High-voltage power supply

High voltage refers to an output on the order of hundreds or thousands of volts. High-voltage

power supplies use a linear setup to produce an output voltage in this range.

When choosing a high-voltage power supply, there are several options to consider. Some of

these are maximum current, maximum power, maximum voltage, output polarity, user

interface, and style. The first four of these characteristics of course depend upon the supply's

intended application. There are many available types of user interfaces. For example, the

interface may be local in the form of a digital meter, or analog meter. Also, the interface can

be remote, as in a computer connection. Numerous styles of high-voltage power supplies are

also manufactured. Available models come in printed circuit board mount, open frame (as

designed to be incorporated into an instrument), and rack mount. Models with multiple

outputs can also be found. [23]

3.6 Liquid crystal display A liquid crystal display (LCD) is an electronically-modulated optical device shaped into a

thin, flat panel made up of any number of color or monochrome pixels filled with liquid

crystals and arrayed in front of a light source (backlight) or reflector. It is often utilized in

battery-powered electronic devices because it uses very small amounts of electric power. [25]

Hardware Components 58

Page 78: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3.6.1 Overview

Each pixel of an LCD typically consists of a layer of molecules aligned between two

transparent electrodes, and two polarizing filters, the axes of transmission of which are (in

most of the cases) perpendicular to each other. With no actual liquid crystal between the

polarizing filters, light passing through the first filter would be blocked by the second

(crossed) polarizer.

The surfaces of the electrodes that are in contact with the liquid crystal material are treated so

as to align the liquid crystal molecules in a particular direction. This treatment typically

consists of a thin polymer layer that is unidirectionally rubbed using, for example, a cloth.

The direction of the liquid crystal alignment is then defined by the direction of rubbing.

Electrodes are made of a transparent conductor called Indium Tin Oxide (ITO).

Before applying an electric field, the orientation of the liquid crystal molecules is determined

by the alignment at the surfaces. In a twisted nematic device (still the most common liquid

crystal device), the surface alignment directions at the two electrodes are perpendicular to

each other, and so the molecules arrange themselves in a helical structure, or twist. This

reduces the rotation of the polarization of the incident light, and the device appears grey. If

the applied voltage is large enough, the liquid crystal molecules in the center of the layer are

almost completely untwisted and the polarization of the incident light is not rotated as it

passes through the liquid crystal layer. This light will then be mainly polarized perpendicular

to the second filter, and thus be blocked and the pixel will appear black. By controlling the

voltage applied across the liquid crystal layer in each pixel, light can be allowed to pass

through in varying amounts thus constituting different levels of gray.

The optical effect of a twisted nematic device in the voltage-on state is far less dependent on

variations in the device thickness than that in the voltage-off state. Because of this, these

devices are usually operated between crossed polarizers such that they appear bright with no

voltage (the eye is much more sensitive to variations in the dark state than the bright state).

These devices can also be operated between parallel polarizers, in which case the bright and

dark states are reversed. The voltage-off dark state in this configuration appears blotchy,

however, because of small variations of thickness across the device.

Hardware Components 59

Page 79: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Both the liquid crystal material and the alignment layer material contain ionic compounds. If

an electric field of one particular polarity is applied for a long period of time, this ionic

material is attracted to the surfaces and degrades the device performance. This is avoided

either by applying an alternating current or by reversing the polarity of the electric field as

the device is addressed (the response of the liquid crystal layer is identical, regardless of the

polarity of the applied field). [26]

When a large number of pixels are needed in a display, it is not technically possible to drive

each directly since then each pixel would require independent electrodes. Instead, the display

is multiplexed. In a multiplexed display, electrodes on one side of the display are grouped

and wired together (typically in columns), and each group gets its own voltage source. On the

other side, the electrodes are also grouped (typically in rows), with each group getting a

voltage sink. The groups are designed so each pixel has a unique, unshared combination of

source and sink. The electronics or the software driving the electronics then turns on sinks in

sequence, and drives sources for the pixels of each sink.

3.6.2 Specifications

Important factors to consider when evaluating an LCD monitor: [25]

• Resolution: The horizontal and vertical size expressed in pixels (e.g., 1024x768).

Unlike CRT monitors, LCD monitors have a native-supported resolution for best

display effect.

• Dot pitch: The distance between the centers of two adjacent pixels. The smaller the

dot pitch size, the less granularity is present, resulting in a sharper image. Dot pitch

may be the same both vertically and horizontally, or different (less common).

• Viewable size: The size of an LCD panel measured on the diagonal (more specifically

known as active display area).

• Response time: The minimum time necessary to change a pixel's color or brightness.

Response time is also divided into rise and fall time. For LCD Monitors, this is

measured in btb (black to black) or gtg (gray to gray). These different types of

measurements make comparison difficult. A response time of <16ms is sufficient for

video-gaming, and the difference between response times below 10ms becomes

imperceptible due to limitations of the human eye.

Hardware Components 60

Page 80: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• Refresh rate: The number of times per second in which the monitor draws the data it

is being given. Since activated LCD pixels do not flash on/off between frames, LCD

monitors exhibit no refresh-induced flicker, no matter how low the refresh rate. Many

high-end LCD televisions now have a 120 or 240 Hz (current and former NTSC

countries) or 100 or 200 Hz (PAL/SECAM countries) refresh rate. The rate of 120

was chosen as the least common multiple of 24 frame/s (cinema) and 30 frame/s

(NTSC TV), and allows for less distortion when movies are viewed due to the

elimination of telecine (3:2 pulldown). For PAL at 25 frame/s, 100 or 200 Hz is used

as a fractional compromise of the least common multiple of 600 (24 x 25). Until a

600 Hz refresh rate becomes available, PAL video will speed up cinema by a small

percentage (currently 1 to 4 percent). These higher refresh rates are most effective

from a 24p-source video output (e.g. Blu-ray Disc), and/or scenes of fast motion.

• Matrix type: Active TFT or Passive.

• Viewing angle: (coll., more specifically known as viewing direction).

• Color support: How many types of colors are supported (coll., more specifically

known as color gamut).

• Brightness: The amount of light emitted from the display (coll., more specifically

known as luminance).

• Contrast ratio: The ratio of the intensity of the brightest bright to the darkest dark.

• Aspect ratio: The ratio of the width to the height (for example, 4:3, 5:4, 16:9 or

16:10).

• Input ports (e.g., DVI, VGA, LVDS, DisplayPort, or even S-Video and HDMI).

• Gamma correction

3.6.3 Color displays

In color LCDs each individual pixel is divided into three cells, or subpixels, which are

colored red, green, and blue, respectively, by additional filters (pigment filters, dye filters and

metal oxide filters). Each subpixel can be controlled independently to yield thousands or

millions of possible colors for each pixel. CRT monitors employ a similar 'subpixel'

structures via phosphors, although the electron beam employed in CRTs do not hit exact

'subpixels'.

Hardware Components 61

Page 81: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Color components may be arrayed in various pixel geometries, depending on the monitor's

usage. If the software knows which type of geometry is being used in a given LCD, this can

be used to increase the apparent resolution of the monitor through subpixel rendering. This

technique is especially useful for text anti-aliasing. [25]

3.6.4 Passive-matrix and active-matrix addressed LCDs

LCDs with a small number of segments, such as those used in digital watches and pocket

calculators, have individual electrical contacts for each segment. An external dedicated

circuit supplies an electric charge to control each segment. This display structure is unwieldy

for more than a few display elements.

Small monochrome displays such as those found in personal organizers, or older laptop

screens have a passive-matrix structure employing super-twisted nematic (STN) or double-

layer STN (DSTN) technology—the latter of which addresses a color-shifting problem with

the former—and color-STN (CSTN)—wherein color is added by using an internal filter.

Each row or column of the display has a single electrical circuit. The pixels are addressed

one at a time by row and column addresses. This type of display is called passive-matrix

addressed because the pixel must retain its state between refreshes without the benefit of a

steady electrical charge. As the number of pixels (and, correspondingly, columns and rows)

increases, this type of display becomes less feasible. Very slow response times and poor

contrast are typical of passive-matrix addressed LCDs.

High-resolution color displays such as modern LCD computer monitors and televisions use

an active matrix structure. A matrix of thin-film transistors (TFTs) is added to the polarizing

and color filters. Each pixel has its own dedicated transistor, allowing each column line to

access one pixel. When a row line is activated, all of the column lines are connected to a row

of pixels and the correct voltage is driven onto all of the column lines. The row line is then

deactivated and the next row line is activated. All of the row lines are activated in sequence

during a refresh operation. Active-matrix addressed displays look "brighter" and "sharper"

than passive-matrix addressed displays of the same size, and generally have quicker response

times, producing much better images

Hardware Components 62

Page 82: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Figure 3.13 A General Purpose Alphanumeric LCD,

Active matrix technologies

Twisted nematic (TN)

Twisted nematic displays contain liquid crystal elements which twist and untwist at varying

degrees to allow light to pass through. When no voltage is applied to a TN liquid crystal cell,

the light is polarized to pass through the cell. In proportion to the voltage applied, the LC

cells twist up to 90 degrees changing the polarization and blocking the light's path. By

properly adjusting the level of the voltage almost any grey level or transmission can be

achieved. [26]

In-plane switching (IPS)

In-plane switching is an LCD technology which aligns the liquid crystal cells in a horizontal

direction. In this method, the electrical field is applied through each end of the crystal, but

this requires two transistors for each pixel instead of the single transistor needed for a

standard thin-film transistor (TFT) display. This results in blocking more transmission area,

thus requiring a brighter backlight, which will consume more power, making this type of

display less desirable for notebook computers. [26]

Advanced Fringe Field Switching (AFFS)

Advanced Fringe Field Switching is a similar technology to IPS or S-IPS offering superior

performance and color gamut besides high luminosity. AFFS is developed by Boe Hydis

Displays, Korea.

AFFS-applied notebook applications minimize color distortion while maintaining its superior

wide viewing angle for a professional display. Color shift and deviation caused by light

Hardware Components 63

Page 83: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

leakage is corrected by optimizing the white gamut which also enhances white/grey

reproduction.

In premium IBM ThinkPad series notebooks, Boe Hydis AFFS displays are used to provide

higher resolutions up to 1600x1200, UXGA (in some versions QXGA) in a relatively small

15 inch display setting. IBM also advertised these high end panels under their FlexViewTM

label. AFFS panels are mostly classified under the VIEWIZTM name by Boe Hydis

resembling premium performance.

As of 2008, Hitachi acquired AFFS license to manufacture high end panels in their product

line. Boe Hydis suspended their production of high quality displays however the company

still advertises the benefits of the superior technology. [26]

Vertical alignment (VA)

Vertical alignment displays are a form of LC displays in which the liquid crystal material

naturally exists in a horizontal state removing the need for extra transistors (as in IPS). When

no voltage is applied the liquid crystal cell, it remains perpendicular to the substrate creating

a black display. When voltage is applied, the liquid crystal cells shift to a horizontal position,

parallel to the substrate, allowing light to pass through and create a white display. VA liquid

crystal displays provide some of the same advantages as IPS panels, particularly an improved

viewing angle and improved black level.

Blue Phase mode

Blue phase LCDs do not require an LC top layer. Blue phase LCDs are relatively new to the

market, and very expensive because of the low volume of production. They provide a higher

refresh rate than normal LCDs, but normal LCDs are still cheaper to make and actually

provide better colors and a sharper image

3.6.5 Drawbacks of LCD Technology

LCD technology still has a few drawbacks in comparison to some other display technologies:

[26]

Hardware Components 64

Page 84: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• While CRTs are capable of displaying multiple video resolutions without introducing

artifacts, LCDs produce crisp images only in their native resolution and, sometimes,

fractions of that native resolution. Attempting to run LCD panels at non-native

resolutions usually results in the panel scaling the image, which introduces blurriness

or "blockiness" and is susceptible in general to multiple kinds of HDTV blur. Many

LCDs are incapable of displaying very low resolution screen modes (such as

320x200) due to these scaling limitations.

• Smaller color gamut compared to CRT and Plasma displays.

• Some types of LCD displays have a more limited color resolution than advertised,

and must use spatial and/or temporal dithering to increase the apparent color depth.

This can cause a shimmering effect with some types of displays which can be

distracting for some users.

• Although LCDs typically have more vibrant images and better "real-world" contrast

ratios (the ability to maintain contrast and variation of color in bright environments)

than CRTs, they do have lower contrast ratios than CRTs in terms of how deep their

blacks are. A contrast ratio is the difference between a completely on (white) and off

(black) pixel, and LCDs can have "backlight bleed" where light (usually seen around

corners of the screen) leaks out and turns black into gray or even a bluish / purple tint

with TN-film based displays. However, as of 2009, the very best LCD TVs that do

not use LED backlighting can achieve a dynamic contrast ratio of 150,000:1.

• LCDs typically have longer response times than their plasma and CRT counterparts,

especially older displays, creating visible ghosting when images rapidly change. For

example, when moving the mouse quickly on an LCD, multiple cursors can

sometimes be seen.

• LCDs appear to exhibit motion blur as the human eye follows moving objects, where

some CRT screens do not. This is because an individual LCD pixel is constantly

visible for the entire duration of a frame (typically 16.7ms), whereas a CRT pixel is

lit for only a fraction of a microsecond once per frame as the electron beam scans past

it. The means that even on a hypothetical LCD panel with a response time of zero, a

Hardware Components 65

Page 85: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

panning image will appear to have motion blur whereas a panning image on a CRT

monitor will not. This is caused by the movement of our eyes during the time the

frame is visible. Blur can be reduced by increasing the refresh rate to a multiple of the

frame rate (e.g. 120 or 240 Hz) and employing various image processing techniques.

Blur or ghosting can be partially "corrected" using software techniques that present a

negative image of the blur to compensate by canceling-out the predicted blur. For

example, if a ghost image is caused by a left-over spot that is 5% brighter than

normal, the software will draw a negative of the ghost image that is minus-5 percent,

and the result will add up to the expected value (n + 5 - 5 = n). However, this

technique requires a processing delay, which can be problematic for fast-action video-

game usage. Some monitors even come with a "gaming mode" to turn off anti-

ghosting when needed.

• LCD panels using TN tend to have a limited viewing angle relative to CRT and

plasma displays. This reduces the number of people able to conveniently view the

same image – laptop screens are a prime example. Usually when looking below the

screen, it gets much darker; looking from above makes it looks lighter. This distorts

the colors and makes consumer grade LCD monitors unsuitable for work where color

is important (photography, fashion, etc) as the colors change when one moves one's

eyes slightly up or down, or when looks at the top of the screen or at the bottom from

a fixed position. Many displays based on thin film transistor variants such as IPS,

MVA, or PVA, have much improved viewing angles; typically the color only gets a

little brighter when viewing at extreme angles, though much of the improvements on

viewing angles has been done on lateral angles, not on vertical ones.

• Consumer LCD monitors tends to be more fragile than their CRT counterparts. The

screen may be especially vulnerable due to the lack of a thick glass shield as in CRT

monitors.

• Dead pixels can occur when the screen is damaged or pressure is put upon the screen;

few manufacturers replace screens with dead pixels under warranty.

• Horizontal and/or vertical banding is a problem in some LCD screens. This flaw

occurs as part of the manufacturing process, and cannot be repaired (short of total

Hardware Components 66

Page 86: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

replacement of the screen). Banding can vary substantially even among LCD screens

of the same make and model. The degree is determined by the manufacturer's quality

control procedures.

• The cold cathode fluorescent lamps typically used for back-lights in LCD screens

contain mercury, a toxic substance, though LED-backlit LCD screens are mercury-

free.

• Pattern based flicker, caused by imperfect voltage balance. LCD Flicker tests - one or

more of the tests will usually demonstrate objectionable flicker, which can also show

up if the problem pattern occurs as a hatching pattern over a significant area.

Hardware Components 67

Page 87: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

CHAPTER 4 SOFT WARE COMPONENTS

4.0 PICBasic and PICBasic Pro Compilers PICBASIC is a micro-controller developed by COMFILE Technology and is

programmed in a form of the BASIC language. The PICBasic Pro Compiler (or PBP)

makes it even quicker and easier to program Microchip Technology’s powerful PICmicro

microcontrollers (MCUs). The English-like BASIC language is much easier to read and

write than the quirky Microchip assembly language.[27,13]

The PICBasic and PICBasic Pro Compilers both functions in the same way. The program

code, saved as a text file is run through either the PICBasic or PICBasic Pro Compiler.

The compiler reads through the text file and creates (or compiles) an equivalent machine

code instruction listing (the hex file) of the program. The machine code is a list of

hexadecimal numbers that represents the PICBasic Pro program. The hex file is uploaded

(or programmed) in to the microcontroller. When the microcontroller started its CPU will

run through the programmed list of hexadecimal numbers that run the PICBasic Pro

program. Uploading the machine code into the microcontroller is the job of the EPIC

programmer board and software. The PICBasic Pro (Professional) compiler is

considerably more expensive than the standard PICBasic compiler. The Pro version

offers a richer, more enhanced Basic command syntax than is available in the PICBasic

compiler packages. A few of the additional commands that can be found in the Pro

version allow the use of Interrupts, direct control of Liquid crystal display (LCD)

modules, dual-tone multi-frequency (DTMF) out, and X-10 commands, to name a few.

PICBasic Pro (PBP) is compatible with Windows 98/Me/NT/2000/XP/Vista. It supports

over 300 of Microchip's PIC microcontrollers, including the very latest releases. From the

tiny, inexpensive 6-pin parts to the immensely powerful 100-pin parts, PBP allows you to

choose the microcontroller that best fits your application.

Software Components 68

Page 88: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Used by thousands of engineers, students, and hobbyists for more than a decade, the

PICBASIC PRO Compiler is one of the most popular development tools ever created for

the PIC microcontroller. [27,13]

A new 32-bit version of PBP (PBPL) is included that offers BIT, BYTE, WORD, and

LONG (32-bit, signed)* variable types. This LONG version is intended for use with the

PIC18 family devices. When working with LONGs, the mathematical operators return

signed results in 32-bit, twos-complement format. This allows storage, calculation, and

display of values from -2,147,483,648 to 2,147,483,647

Table 4.1: Comparison between PICBasic and PICBasic Pro Compilers

PICBASIC™ Compiler PICBASIC PRO™ Compiler

Limited to first 2K code space. Uses all available code space.

Interrupt handlers must be Assembly

language.

Interrupt handler routines may be either

PICBASIC PRO or Assembly.

Uses Peek and Poke commands to access

internal registers and move contents to and

from pre-defined variables.

Internal register names may be used

directly, even in calculations and

conditional statements.

Some built-in commands can only be used

on PortB, PortC or GPIO. While all ports

may be accessed with Peek and Poke, some

aren't available for commands like Serout,

Pulsin, etc.

Software-based commands may be used on

any available port/pin. (Commands that utilize

a hardware module are limited to the pins dedicated

to that module. Some pins have special

characteristics that might cause compatibility

issues.)

Clock speed pre-defined at 4MHz. Clock speeds from 3.5975 to 48MHz,

depending upon device capabilities.

Most 14-bit core PICmicro® MCUs

supported.

ALL PICmicro® MCUs are supported,

including 12-bit core, 17CXXX, 18CXXX,

and 18FXXX.

BASIC Stamp I compatible variable names

pre-defined.

Define your own custom variables,

including arrays of bits, bytes or words.

Software Components 69

Page 89: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

4.0.1 Additional commands available only in PICBASIC PRO

• LCDOut / LCDIn - for controlling parallel interfaced LCD modules. • HSerin / HSerout - for controlling the hardware USART available on many

PICmicro MCUs. • HPWM - for controlling the hardware PWM modules available on many

PICmicro MCUs. • Serin2 / Serout2 - RS-232 serial commands capable of sending and receiving

ASCII formatted numeric data. Serin2 can be invoked with a timeout parameter to avoid lockup caused by missed serial data.

• Select Case - Visual BASIC style case statement. • ReadCode / WriteCode - read and write locations in the code space of self-

programming microcontrollers. • OWin / OWout - communicate with One Wire devices. • USBin / USBout - access the USB module on specially equipped

microcontrollers. • Xin / Xout - send and receive X-10 commands for household remote control. • ADCin - perform analog-to-digital conversion on devices so equipped.

4.0.2 PICBASIC PRO advantages:

• Uses 5-10% less code space than standard compiler.

• Syntax is less demanding, making Pro easier to learn.

• Debug information can be generated for Microchip development tools.

The PICBASIC PRO Compiler gives you direct access to all of the PIC MCU registers -

I/O ports, A/D converters, hardware serial ports, etc. - easily and in BASIC. It

automatically takes care of the page boundaries and RAM banks. It even includes built-in

commands to control intelligent LCD modules. Floating-Point calculations are possible

with downloaded routines. [13]

The PICBASIC PRO Compiler instruction set is compatible with the BASIC Stamp II

and Pro uses BS2 syntax. Programs can be compiled and programmed directly into a

PIC MCU, eliminating the need for a BASIC Stamp module. These programs execute

Software Components 70

Page 90: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

much faster and may be longer than their Stamp equivalents. They may also be protected

so no one can copy your code.

The PICBASIC PRO Compiler can create programs for most of Microchip's PIC

microcontrollers and works with most PIC MCU programmers, including the melabs

USB Programmer.

The PICBASIC PRO Compiler can also be used inside Microchip's MPLAB® IDE. This

allows using Microchip tools for source-level debugging. [13]

PICBASIC PRO Compiler has limited support for the 12-bit core microcontrollers.

Windows 98/Me/NT/2000/XP/Vista and DOS compatible

• Supports Microchip PIC10, PIC12, PIC14, PIC16, PIC17, and PIC18

microcontrollers

• True compiler provides faster program execution and longer programs than

BASIC interpreters

• Direct access to any pin or internal register on a PIC MCU

• Automatic code-page and RAM-bank handling

• BIT, BYTE, WORD, and LONG* individual variables or arrays

• 32-bit signed math for PIC18*, 16-bit unsigned for other PIC microcontroller

families

• Real If..Then..Else..Endif and Select Case conditionals

• Hierarchal expression handling with grouping by parentheses

• Interrupts in BASIC and Assembly Language

• BASIC Stamp I and II libraries

• System clock oscillator support from 3.58MHz to 64MHz

• In-line Assembly Language insertion and Call supportMPLAB® / MPASM /

ICD2 / ICE compatible with source-level debuggig

Software Components 71

Page 91: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

4.0.3 PICBASIC PRO Compiler Instruction Set

• @ Insert one line of assembly language code. • ADCIN Read on-chip analog to digital converter. • ASM..ENDASM Insert assembly language code section. • BRANCH Computed GOTO (equiv. to ON..GOTO). • BRANCHL Branch out of page (long BRANCH). • BUTTON Debounce and auto-repeat input on specified pin. • CALL Call assembly language subroutine. • CLEAR Zero all variables. • CLEARWDT Clear (tickle) Watchdog Timer. • COUNT Count number of pulses on a pin. • DATA Define initial contents of on-chip EEPROM. • DEBUG Asynchronous serial output to fixed pin and baud. • DEBUGIN Asynchronous serial input from fixed pin and baud. • DISABLE Disable ON DEBUG and ON INTERRUPT processing. • DISABLE DEBUG Disable ON DEBUG processing. • DISABLE INTERRUPT Disable ON INTERRUPT processing. • DTMFOUT Produce touch-tones on a pin. • EEPROM Define initial contents of on-chip EEPROM. • ENABLE Enable ON DEBUG and ON INTERRUPT processing. • ENABLE DEBUG Enable ON DEBUG processing. • ENABLE INTERRUPT Enable ON INTERRUPT processing. • END Stop execution and enter low power mode. • ERASECODE Erase block of code memory • FOR..NEXT Repeatedly execute statements. • FREQOUT Produce up to 2 frequencies on a pin. • GOSUB Call BASIC subroutine at specified label. • GOTO Continue execution at specified label. • HIGH Make pin output high. • HPWM Output hardware pulse width modulated pulse train. • HSERIN Hardware asynchronous serial input. • HSERIN2 Hardware asynchronous serial input, second port. • HSEROUT Hardware asynchronous serial output. • HSEROUT2 Hardware asynchronous serial output, second port. • I2CREAD Read from I2C device. • I2CWRITE Write to I2C device. • IF..THEN..ELSE..ENDIF Conditionally execute statements. • INPUT Make pin an input. • LCDIN Read from LCD RAM. • LCDOUT Display characters on LCD. • LET Assign result of an expression to a variable. • LOOKDOWN Search constant table for value. • LOOKDOWN2 Search constant / variable table for value. • LOOKUP Fetch constant value from table. • LOOKUP2 Fetch constant / variable value from table.

Software Components 72

Page 92: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• LOW Make pin output low. • NAP Power down processor for short period of time. • ON DEBUG Execute BASIC debug monitor. • ON INTERRUPT Execute BASIC subroutine on an interrupt. • OWIN One-wire input. • OWOUT One-wire output. • OUTPUT Make pin an output. • PAUSE Delay (1mSec resolution). • PAUSEUS Delay (1uSec resolution). • PEEK Read byte from register. • PEEKCODE Read byte from code space • POKE Write byte to register. • POKECODE Write byte to code space at device programming time • POT Read potentiometer on specified pin. • PULSIN Measure pulse width on a pin. • PULSOUT Generate pulse to a pin. • PWM Output pulse width modulated pulse train to pin. • RANDOM Generate pseudo-random number. • RCTIME Measure pulse width on a pin. • READ Read byte from on-chip EEPROM. • READCODE Read word from code memory. • REPEAT..UNTIL Execute statements until condition is true. • RESUME Continue execution after interrupt handling. • RETURN Continue at statement following last GOSUB. • REVERSE Make output pin an input or an input pin an output. • SELECT CASE Compare a variable with different values. • SERIN Asynchronous serial input (BS1 style). • SERIN2 Asynchronous serial input (BS2 style). • SEROUT Asynchronous serial output (BS1 style). • SEROUT2 Asynchronous serial output (BS2 style). • SHIFTIN Synchronous serial input. • SHIFTOUT Synchronous serial output. • SLEEP Power down processor for a period of time. • SOUND Generate tone or white-noise on specified pin. • STOP Stop program execution. • SWAP Exchange the values of two variables. • TOGGLE Make pin output and toggle state. • USBIN USB input. • USBINIT Initialize USB. • USBOUT USB output. • WHILE..WEND Execute statements while condition is true. • WRITE Write byte to on-chip EEPROM. • WRITECODE Write word to code memory. • XIN X-10 input. • XOUT X-10 output.

Software Components 73

Page 93: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

4.0.4 Functions / Operators:

All math operations are unsigned and performed with 16-bit precision. [13]

Math Operators Description

+ Addition

- Subtraction

* Multiplication

** Top 16 Bits of Multiplication

*/ Middle 16 Bits of Multiplication

/ Division

// Remainder (Modulus)

<< Shift Left

>> Shift Right

ABS Absolute Value*

COS Cosine

DCD 2n Decode

DIG Digit

DIV32 31-bit x 15-bit Divide

MAX Maximum*

MIN Minimum*

NCD Encode

REV Reverse Bits

SIN Sine

SQR Square Root

& Bitwise AND

| Bitwise OR

^ Bitwise Exclusive OR

~ Bitwise NOT

&/ Bitwise NOT AND

|/ Bitwise NOT OR

^/ Bitwise NOT Exclusive OR

Software Components 74

Page 94: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

4.0.5 PICBASIC Compiler Features

• Quicker and easier than "C" or assembler • Expanded BASIC Stamp I compatible instruction set • True compiler provides faster program execution and longer programs than

BASIC interpreters • I2CIN and I2COUT instructions to access external serial EEPROMs • More user variables • Peek and Poke instructions to access any PICmicro MCU register from BASIC • Serial speeds to 9600 baud • In-line assembler and Call support • Supports most 14-bit core PICmicro microcontrollers • Use in DOS or Windows • Compatible with most PICmicro MCU programmers (see melabs USB

Programmer)

4.0.6 Structure of a Compiled Program

PBP is designed to be easy to use. Programs can be compiled and run with little thought

to PBP's internal workings. Some people, however, only have confidence in a product

when they understand its internal workings. Others are just plain curious.

This section is for them. It describes the files used and output generated by PBP and

gives some idea of exactly what is going on. [13]

4.0.7 Target Specific Headers

Three target specific header files are used when a program is compiled. One is used by

PBP, the other two are included for use by the assembler.

A file with the name of the microcontroller followed by the extension .BAS contains chip

specific information needed by PBP. This includes the memory profile of the chip, which

library it uses, and includes for the definition of the variables it needs. For the PIC16F84,

the default microcontroller, the file is named 16F84.BAS.

A file with the name of the microcontroller followed by the extension .INC is included in

the generated .ASM file to give the assembler information about the chip, including the

Software Components 75

Page 95: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

default configuration parameters (oscillator mode, Watchdog Timer setting, etc.). For the

PIC16F84, the file is named 16F84.INC.

Finally, the assembler has its own include file that defines the addresses of the

microcontroller registers. This file is usually named something on the order of

M16F84.INC. and is in the INC directory. [13]

4.0.8 The Library Files

PBP includes a set of library files that contain all of the code and definition files for a

particular group of microcontrollers. In the case of 14-bit core PICmicros, these files start

with the name PBPPIC14.

PBPPIC14.LIB contains all of the assembly language subroutines used by the compiler.

PBPPIC14.MAC contains all of the macros that call these subroutines. Most PICBASIC

PRO™ commands consist of a macro and an associated library subroutine.

PBPPIC14.RAM contains the VAR statements that allocate the memory needed by the

library. [13]

PIC14EXT.BAS contains the external definitions that tell PBP all of the 14-bit core

PICmicro register names.

4.0.9 PBP Generated Code

A PICBASIC PRO™ compiled program is built in several stages. First PBP creates the

.ASM file. It then builds a custom .MAC file that contains only the macros from the

macro library that are used in the .ASM file. If everything is error free up to this point, it

spawns the assembler.

The assembler generates its own set of files. These include the .HEX final output file and

possibly listing and debugging files.

Software Components 76

Page 96: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

4.0.10 .ASM File Structure

The .ASM file has a very specific structure. Things must be done in a particular order for

everything to work out properly.

The first item placed in the file is an equate defining which assembler is to be used,

followed by an INCLUDE to tell the assembler which microprocessor is the target and

give it some basic information, such as the configuration data.

Next, all of the variable allocations and aliasing is listed. EEPROM initialization is next,

if called for.

An INCLUDE for the macro file is then placed in the file, followed by an INCLUDE for

the library subroutines.

Finally, the actual program code is incorporated. This program code is simply a list of

macros that were generated from the PICBASIC PRO™ lines. [13]

Software Components 77

Page 97: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

4.1 EPIC programmer

EPIC (Explicitly Parallel Instruction Computing) is a 64-bit microprocessor instruction

set, jointly defined and designed by Hewlett Packard and Intel, that provides up to 128

general and floating point unit registers and uses speculative loading, predication, and

explicit parallelism to accomplish its computing tasks. By comparison, current 32-bit

CISC and RISC microprocessor architectures depend on 32-bit registers, branch

prediction, memory latency, and implicit parallelism, which are considered a less

efficient approach in micro architecture design. [14]

IA-64 (Intel Architecture-64), Intel's first 64-bit CPU micro architecture, is based on

EPIC. Intel's first implementation, long expected and well-known as Merced (its code

name), was christened with the Itanium brand name in October, 1999. It is expected that

Itanium-based systems will be compatible with versions of existing and future operating

systems including HP-UX, 64-bit Windows, IA-64 Linux, Project Monterey, and Nov

The EPIC programmer consists of software (EPIC Program) and a programming carrier

board (hardware). The EPIC software package has two executable files one for DOS and

another version for Windows. It is the EPIC hardware and software that take the

compiled hex file generated by the compiler and upload it into the microcontroller where

it may be run. The EPIC programmer is compatible with both the PICBasic and PICBasic

Pro compilers. [13,14]

4.1.1 EPIC Programmer for PICmicro controllers Features

• Low cost programmer for most PICmicro microcontrollers

• Connects to PC parallel printer port

• ICSP programming

• The programmer has a built-on 18-pin socket for programming 8-, 14- and 18-pin

DIP packaged PICmicro MCUs and must be powered with a power adapter within

the range of 15 - 18 Volt. (Before using the programmer be sure to adjust the

Software Components 78

Page 98: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

programming voltage of 13.5 Volt using the mounted Potentiometer and a

Voltmeter) [14]

4.1.2 EPICWIN and EPIC Programmer

The EPIC Programmer is an inexpensive microcontroller programmer that will program

most PICmicro microcontrollers (MCUs). Most 8-, 14- and 18-pin PICmicro MCUs may

be programmed in the socket on the EPIC Programmer. Optional adapters are available to

program 20-, 28- and 40-pin DIP PICmicro MCUs, as well as PICmicro MCUs in

surface-mount and PLCC packages.

4.1.2.1 Software Installation

The EPIC Programmer files are compressed into a self-extracting file on the disk. They

must be uncompressed before use. To uncompress the files, first a directory should be

created on hard drive called EPIC, or any other name. [14]

4.1.2.2 Hardware Installation

There should be no PICmicro MCUs installed in the EPIC programming socket or any

connected adapter's socket until the programming software is executed and the LED is

off. The EPIC Programmer should be placed on an insulated surface to prevent the

shorting out of traces on the bottom.

The EPIC Programmer is connected to a PC compatible parallel printer port using a 25-

pin male to 25-pin female printer extension cable. The EPIC Programmer uses pins 2-6,

10, and 19-25. A serial cable may not have all of the necessary connections so it should

be assured to use a printer extension cable.

If the EPIC Programmer is powered with the optional AC adapter, it should be plugged it

into the power connector on the programmer and then into a wall outlet. The AC adapter

should provide approximately 16V DC at 500ma.

Software Components 79

Page 99: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

If the EPIC Programmer is powered with two 9-volt batteries, then batteries should be

snapped onto the battery snaps. 2-pin shorting jumper should be connected to the 2-pin

"Batt ON" posts. It is a good idea to check the battery voltage from time to time or if

there seems to be difficulty programming parts. [14]

The EPIC Plus Programmer should now be powered up and ready to program PICmicro

MCUs.

4.1.3 General Operation

The next task is to write the program using any text editor, such as DOS EDIT or

Windows NOTEPAD, and assemble it using the assembler, PM, included on the disk, or

MPASM (or MPLAB), available from Microchip. Instructions for the use of PM are on

the included disk.

Once the program assembles properly, the generated .HEX file may be programmed into

a PICmicro MCU using the EPIC programming software. Three versions of the EPIC

software are included: two versions for DOS (one command line and one graphical) and

one for Windows 95/98/ME/NT/2000/XP.

The Windows 95/98/ME/NT/2000/XP version should, of course, be run under Windows

95, 98, ME, NT, 2000 or XP. The Windows and command line DOS versions are more

up-to-date than the graphical DOS version and are able to program more types of

PICmicro MCUs. [14]

4.1.4 EPIC for Windows 95/98/ME/NT/2000/XP

First the Windows 95/98/ME/NT/2000/XP version of the EPIC software should be

started by navigating using Explorer to the EPIC directory and double-clicking on

EPICWin. Alternatively, a shortcut can be created to EPIC on desktop. The EPIC

software will take a look around to find where the EPIC Plus Programmer is attached and

get it ready to program a PICmicro MCU. If the EPIC Programmer is not found, all of the

Software Components 80

Page 100: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

above connections should be checked and verified if there is any PICmicro MCU

installed in the programmer or any connected adapter.

Once the programming bar is displayed, the device type should be selected by using the

drop-down device selector box to the right of the buttons.

The assembled object (.HEX) file should be opened. Double-click on the appropriate file

to load it. Once the file has been loaded, the proper device characteristics are selected

under the Options menu. The Code Protect is set to OFF before programming a

windowed (JW) PICmicro MCU. Code protected windowed part may not be erased. A

PICmicro MCU sould be inserted into the EPIC Programmer or connected adapter

socket. The end of the PICmicro MCU with the notch should be all the way at the Pin 1

end of the socket, away from the battery connectors. the Program button should be

clicked or Run|Program with the mouse to program the PICmicro MCU.

Before programming, the EPIC software optionally does a blank check to ensure that the

part is erased. If the PICmicro MCU is a 16F84 or another EEPROM or flash part, it is

usually not necessary to erase it before programming. PIC16F7x and PIC18Fxxx devices

do require erasing each time before the MCU may be reprogrammed. [14]

Figure 4.1: EPICWin Controls

4.1.5 EPICWin Controls

The Open speed button opens a .HEX file for programming. The name of an open file

appears in the EPICWin title bar. Previous configuration information will not be altered if

Options|Update Configuration is not checked.

Software Components 81

Page 101: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

The Save speed button will save the current code, data, ID and configuration

information to the currently open file. If no file has been previously selected, it will

prompt for a filename.

The Program speed button will program the current code, data, ID and configuration

into the selected device. It will optionally load the latest version of the .HEX file before

programming. The device will be checked to ensure it is blank before programming,

unless Options|Skip Blank Check is checked.

The Verify speed button will compare the current code, data, ID and configuration to

the programmed device. If the information does not match, an error message is displayed.

A verifies is also done as the device is being programmed. A code protected device

cannot be verified.

The Read speed button will read the current code, data, ID and configuration from the

selected device. The configuration information will not be read if Options|Update

Configuration is not checked.

The Blank Check speed button will read the code space to ensure a device is blank. It

will not check the data space, ID, configuration or the oscillator calibration word

programmed by the factory into some devices.

The Erase speed button will erase EEPROM or flash electrically erasable devices. It

is grayed out for devices that cannot be electrically erased.

The Device box allows selection of the device to be programmed.

Click the down arrow to the right of the box to drop down a list of supported devices, and

then click on the device. This device information, including the default device that is

selected on start-up, is contained in the file EPIC.INI. This file must be in the same

directory as EPICWIN.EXE. The device should be selected before a .HEX file is opened

Software Components 82

Page 102: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

to ensure the configuration information is properly interpreted. Devices with parenthesis

after them indicate that they will program either the base version of the part, or the

version contained within the parenthesis. For example, selecting the device listed as

PIC16F84 (A) means that either the PIC16F84 or the PIC16F84A may be programmed.

4.1.6 EPICWin Menus

4.1.6.1 File Menu

File|New clears the EPICWin code, data and ID information. If Options|Update Configuration is checked, the configuration information will also be cleared.

File|Open opens a .HEX file for programming. The name of an open file appears in the EPICWin title bar. Previous configuration information will not be altered if Options|Update Configuration is not checked.

File|Save saves the current code, data, ID and configuration information to the currently open file. If no file has been previously selected, it will prompt for a filename.

File|EPIC Port will display the parallel printer port the EPIC Programmer was found on, if Auto is checked. If Auto is not checked, the printer port can be selected manually.

File|Exit exits the program.

4.1.6.2 View Menu

View|Code displays the code window. This will show the open .HEX file or recently read code information in hexadecimal or ASCII.

View|Configuration displays the device configuration fuse window. Additional configuration fuses for the PIC17C7xx and PIC18Xxxx devices must be set from the drop-down Configuration menu.

View|Data EEPROM displays the data EEPROM window. This will show the open .HEX file or recently read data information in hexadecimal or ASCII. Only devices with on-chip EEPROM data space will read and program this data.

View|ID displays the ID window. This will show the open .HEX file or recently read code information in hexadecimal or ASCII.

View|Serial Number displays a window that allows the serial number to be set and programmed into the device. The serial number is stored in the code space at the specified location, overwriting any code that may already be there, and will be incremented by the Increment By value after each successful programming.

Software Components 83

Page 103: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

View|Count displays a window showing the number of programming attempts and successes. The count is reset when the software is started, a file is opened, a device is read or the device type is changed.

View|Close All Windows closes any open configuration, code, data, ID or count window.

View|Stay On Top causes the EPICWin bar to float on top of any other windows when checked.

4.1.6.3 Run Menu

Run|Program will program the current code, data, ID and configuration into the selected device. It will optionally load the latest version of the .HEX file before programming. The device will be checked to ensure it is blank before programming, unless Options|Skip Blank Check is checked.

Run|Verify will compare the current code, data, ID and configuration to the programmed device. If the information does not match, an error message is displayed. A verify is also done as the device is being programmed. A code protected device cannot be verified.

Run|Read will read the current code, data, ID and configuration from the selected device. The configuration information will not be read if Options|Update Configuration is not checked.

Run|Blank Check will read the code space to ensure a device is blank. It will not check the data space, ID, configuration or the oscillator calibration word programmed by the factory into some devices.

Run|Erase will erase EEPROM or flash electrically erasable devices. It is grayed out for devices that cannot be electrically erased.

4.1.6.4 Configuration Menu

The configuration fuses are unique to each particular PICmicro MCU.

4.1.6.5 Options Menu

Options|Program/Verify Code allows the device's code space to be programmed and verified when checked. If it is not checked, the device's code space will not be programmed or verified. It will always be read and blank checked, regardless.

Options|Program/Verify Configuration allows the device's configuration fuses to be programmed and verified when checked. If it is not checked, the device's configuration fuses will not be programmed or verified.

Software Components 84

Page 104: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Options|Program/Verify Data allows the device's data space, if any, to be programmed and verified when checked. If it is not checked, the device's data space will not be programmed or verified. It will always be read, regardless.

Options|Program/Verify ID allows the device's ID to be programmed and verified when checked. If it is not checked, the device's ID will not be programmed or verified. It will always be read, regardless.

Options|Program/Verify Oscillator Calibration allows the device's oscillator calibration factor location to be programmed and verified when checked. If it is not checked, the device's oscillator calibration factor location will not be programmed or verified. It will always be read, regardless.

Options|Program Serial Number allows a serial number to be programmed into the device when checked. If it is not checked, the serial number will not be programmed. As the serial number is programmed into the code space, Program Code must also be checked to program the serial number.

Options|Update Configuration, when checked, will cause the configuration fuse settings to be updated when opening a file or reading a device. If it is not checked, the configuration fuse settings will not be changed.

Options|Reread File Before Programming, when checked, will cause the latest version of the .HEX file to be loaded before the device is programmed. The configuration fuse settings will also be updated, if Options|Update Configuration is checked. This will override the current settings.

Options|Erase before Programming, when checked, will cause the device to be erased before it is programmed.

Options|Verify after Programming, when checked, will cause the device to be verified as a separate step after programming.

Options|18Fxxx File Data Address * 2, when checked, will multiply the Data EEPROM addresses in the .HEX file times 2 for compatibility with files generated by PBP after version 2.43.

Options|Disable Completion Messages will prevent the displaying of operation complete messages at the end of programming, verifying and erasing a device.

Options|Skip Blank Check will prevent blank checking a device before it is programmed when checked.

4.1.6.6 Help Menu

Help|Help opens the default browser and displays the HTML help file.

Software Components 85

Page 105: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Help|Readme opens the default text editor and displays the README file.

Help|About... displays the program version number and copyright.

4.1.7 EPICWin Command Line Parameters

Several optional parameters may be passed to the EPICWin program via the command line:

EPICWin switch, filename

The available command line switches are:

• /D Select PICmicro MCU device • /P Program device and exit • /X Exit EPICWin after successful programming

For example:

EPICWin /DPIC16F877 BLINK

would tell EPICWin to select the PIC16F877 as the device and open the file BLINK.HEX.

Software Components 86

Page 106: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

CHAPTER 5 METHODOLOGY

In previous chapters the theoretical concepts behind the home automation system were

discussed. The goal of this chapter is to present a final system specification for the

proposed home automation system of this research work. In this chapter the planning of

the project, hardware and software development including the hardware design and

software programming are discussed.

5.0 Design Overview

This section briefly discusses the overall project design including the workflow of

activities, device design and program development. Initial construction of circuit is done

on a test board for easier testing and modification. It is then transferred to a main board

after the circuit is found to be working. Software development includes the programming

of the PIC16F877A, which interfaces to all the hardware part. A set of instruction code is

written to indicate the microcontroller performs the function required. In the interfacing

stage, hardware and software work together as a complete system. Figure 5.1 shows the

project development flow chart of this project which includes the back ground study and

the planning of the project. Hardware e.g. Microcontroller, GSM module and LCD

display were assembled and software components e.g. development of software and

writing on PIC microcontroller was done. Subsequently hardware and software were

tested and project was finalized. Figure 5.2 shows the overall block diagram of the

project. Basically it is divided in to two parts; one is the mobile phone which transmits

the desired SMS and other is the receiving unit comprising the GSM Module, PIC

Microcontroller that process and sends the desired actions to the load devices and sends a

back to back SMS to user about the present status of all load devices. Figure 5.3 shows

the flow chart of the project functioning. This diagram shows the complete functioning of

the project in flow chart. In figure 5.4 shows the PCB layout which depicts the positions

of different components on the PCB. In the later part the interfacing of individual

components are described

Methodology 87

Page 107: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Planning

Write program for PIC Microcontroller using

PICBasic Pro

Assemble hardware: GSM Module, PIC16F877A, LCD-Display &

Devices controlled.

Test Modify programming and

Hardware/troubleshoot

OK

Finalize & Complete

Research & Study

Figure 5.1: Project development flow chart

Methodology 88

Page 108: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Figure 5.2: Block diagram of the project.

RECEIVER UNIT

TRANSMITTER UNIT

SIM

GSM

Module PIC16F877A

Microcontroller

DC Power Supply

AC Power Supply

Unit

Mobile

LCD Display

Fan Tube Bulb AC

Methodology 89

Page 109: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Delete SMS

Read EEPROM

Y

Is New SMS?

10 Sec Delay N

Check Password

Y

Is password correct?

Read SMS Y

Is SMS format correct?

Send proper signals to relay through port

N

Y

N

Store Program output in EEPROM

Read Caller ID Prepare Reply SMS

Send SMS to Caller

Is connection ok? N

Error Message

Define: LCD Pin RS 232 Pin &

Input Output Port

Start

Fig 5.3: Flowchart of functioning of device.

Methodology 90

Page 110: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Figure 5.4: PCB Layout

Methodology 91

Page 111: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

5.1 Hardware implementations The complete schematic diagram of the project is shown in the Figure 5.5 where all the

hardware part such as GSM Module, PIC16F877A microcontroller, LCD display and

Sensors are combined together. The hardware implementation part will be discussed in

the following section.

Figure 5.5: Schematic diagram of the project

5.1.1 The PIC16F877A Microcontroller

PIC is a family of Harvard architecture microcontrollers made by Microchip Technology,

derived from the PIC1650 originally developed by General Instrument's Microelectronics

Division. The name PIC was originally an acronym for "Programmable Intelligent

Computer"

Methodology 92

Page 112: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

5.1.1.1 Features of PIC16F877A Microcontroller

PIC16F877A is a low power, high speed FLASH/EEPROM using CMOS technology. It

also has 100,000 erase or write cycle enhanced FLASH program memory and has

1,000,000 erase or write cycle data EEPROM memory typical.

The PIC16F877A provides the following features: [12]

• The core features of PIC16F877A are:

♦ High performance RISC CPU

♦ Only 35 single word instructions to learn

♦ All single cycle instructions except for program branches which are two cycle

♦ Operating speed: DC - 20 MHz clock input

DC - 200 ns instruction cycle

♦ Up to 8K x 14 words of FLASH Program Memory,

♦ Up to 368 x 8 bytes of Data Memory (RAM)

♦ Up to 256 x 8 bytes of EEPROM Data Memory

♦ Pin-out compatible to the PIC16C73B/74B/76/77

♦ Interrupt capability (up to 14 sources)

♦ Eight level deep hardware stack

♦ Direct, indirect and relative addressing modes

♦ Power-on Reset (POR)

♦ Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)

♦ Programmable code protection

♦ Power saving SLEEP mode

♦ Low power, high speed CMOS FLASH/EEPROM technology

♦ In-Circuit Serial Programming. (ICSP) via two pins

♦ Single 5V In-Circuit Serial Programming capability

♦ In-Circuit Debugging via two pin

♦ Processor read/write access to program memory

♦ Wide operating voltage range: 2.0V to 5.5V

♦ High Sink/Source Current: 25 mA

Methodology 93

Page 113: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• The peripheral features of the PIC16F877 are:

♦ 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;

- Capture is 16-bit, max. resolution is 12.5 ns

- Compare is 16-bit, max. resolution is 200 ns

- PWM max. resolution is 10-bit

♦ 10-bit multi-channel Analog-to-Digital converter

♦ Synchronous Serial Port (SSP) with SPI. (Master mode) and I2C. (Master/Slave)

♦ Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with

9-bit address detection

♦ Parallel Slave Port (PSP) 8-bits wide, with external RD, WR and CS controls

(40/44-pin only)

5.1.2 GSM Module SIM 300CZ

A GSM module is a wireless module that works with a GSM wireless network. A

wireless module sends and receives data through radio waves. Like a GSM mobile phone,

a GSM module requires a SIM card from a wireless carrier in order to operate [21].

• Reading and writing SMS messages.

• Sending SMS messages.

• Monitoring the signal strength.

• Reading, writing and searching phone book entries.

Methodology 94

Page 114: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

5.1.3 Interfacing of Microcontroller with GSM Module

Figure 5.6: Interfacing of Microcontroller with GSM Module

Interfacing of Microcontroller with GSM Module

This interfacing circuit is used to match the voltage level between GSM Module and

Microcontroller. Microcontroller operates on +5 volts whereas GSM Module on 3.93

volts. Microcontroller is connected to GSM Module through pin 6 (Rx) and 7 (Tx) of

Microcontroller and pin 43 (Tx) and 41 (Rx) of GSM Module respectively. Pin 43 of

GSM Module transmit the 3.9 volts that is phase shifted by 3600 by two transistors Q1

and Q2 (2N2222A). R1 (4.7K), R2 (1K) are transistor base biasing and R3 (1K), R4 (1K)

are the collector biasing resistor whereas R5 (10K) is a load resistor. Pin 7 of

Methodology 95

Page 115: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Microcontroller transmit the 5 volts which is dropped to 3.93 volts by resistors R6 (22R)

and R7 (220R). Zener diode stabilizes voltage across GSM module to 3.93 volts.

Function

send by cell phone is received by the GSM module which uses the GSM SIM

.1.4 Liquid Crystal Display (LCD)

iquid Crystal Display (LCD) is an electronically-modulated optical device shaped into a

Figure 5.7: Reflective twisted nematic liquid crystal display

A SMS is

card. This SMS is send to Microcontroller which receives, compile and compare it with

its stored program. If the message is correct according to microcontroller’s programming

the microcontroller sends the instructions to relays. If the massage is wrong then

microcontroller will not take any action and delete the message. These instructions are

stored in the EEPROM. Microcontroller sends back instructions to module to send an

acknowledgement to the cell phone of sender about the last status.

5

L

thin, flat panel made up of any number of color or monochrome pixels filled with liquid

crystals and arrayed in front of a light source (backlight) or reflector. It is often utilized in

battery-powered electronic devices because it uses very small amounts of electric power.

The nematic phase is characterized by the orientational order of the constituent

molecules. The molecular orientation (and hence the material's optical properties) can be

controlled with applied electric fields. Nematics are (still) the most commonly used phase

in liquid crystal displays (LCDs), with many such devices using the twisted nematic

geometry.

Methodology 96

Page 116: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Reflective tw

1. Polarizing filter film with a vertical axis to polarize light as it enters.

ll determine

3. ystal.

ectrode film (ITO) with horizontal ridges to line

5. rizontal axis to block/pass light.

CD, this layer is

5.1.5 Interfacing of Microcontroller with LCD

Figure 5.8: Interfacing of Microcontroller with LCD

isted nematic liquid crystal display. [26]

2. Glass substrate with ITO electrodes. The shapes of these electrodes wi

the shapes that will appear when the LCD is turned ON. Vertical ridges etched on

the surface are smooth.

Twisted nematic liquid cr

4. Glass substrate with common el

up with the horizontal filter.

Polarizing filter film with a ho

6. Reflective surface to send light back to viewer. (In a backlit L

replaced with a light source.)

Methodology 97

Page 117: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Interfacing of LCD Display to Microcontroller PIC16F877A

in 11, 12, 13, 14, (D4, D5, D6, D7), 4 (RS) and 6 (E) of LCD Display are connected Pin

.1.6 Interfacing Circuit (Microcontroller to Load Devices)

Interfacing of Microcontroller with load Relays

pins 27, 28, 29 and 30 through relays.

P

33, 34, 35, 36, 37& 38 (RBD/NT, RB1, RB2, RB3/PGM, RB4 &RB5) of Microcontroller

PIC16F877A.

5

Figure 5.9: Interfacing of Microcontroller with load Devices

Four load devices are connected to microcontroller

After receiving the signal from GSM Module, Microcontroller takes the decision to send

the signal (+5V) to Transistor to turn on it (VCE approx. 0). Then there will be +12 V

supply in relay coil that in turn switch on/off the load device

Methodology 98

Page 118: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

5.1.7 Short Message Service (SMS)

ce. It is a technology that enables the sending and

ceiving of messages between mobile phones. SMS first appeared in Europe in 1992.

es

SMS stands for Short Message Servi

re

It was included in the GSM (Global System for Mobile Communications) standards right

at the beginning. Later it was ported to wireless technologies like CDMA and TDMA.

SMS text messaging supports languages internationally. It works fine with all languages

supported by Unicode, including Bangla, Arabic, Chinese, Japanese, and Korean. Besid

text, SMS messages can also carry binary data. It is possible to send ring tones, pictures,

operator logos, wallpapers, animations, business cards (e.g. V-Cards) and WAP

configurations to a mobile phone with SMS messages. One major advantage of SMS is

that it is supported by 100% GSM mobile phones. Almost all subscription plans provided

by wireless carriers include inexpensive SMS messaging service. [28]

5.1.8 Interfacing Circuit (GSM Module to SIM Card)

Figure 5.10: Interfacing of GSM Module to SIM Card

Methodology 99

Page 119: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Interfacing of G

0) pins. Pin 1, 3, 5, 7 and 9 are connected to

ve) pole and gets the power supply of 3.93 volts for module. Pin 2, 4, 6, 8 and 10

The system is powered b f 220 volts AC which is

converted to 18 volts AC by a step down transformer. This is again converted to 18 volts

pplied to

SM Module to SIM Card

GSM Module SIM300CZ consists of sixty (6

(+

remain grounded. Pin 16 connected to network status LED and pin 19 connected to

module status LED. Pin 23 is connected to buzzer. Pin 25, 27, 29 and 31 are connected

to SIM card as follows; pin 25 to VDD, pin 27 to SIM RST, pin 29 to SIM Data and pin

31 to SIM Clock (3 MHz.). Pin 43 (TX) and pin 41 (RX) of GSM Module are connected

to Pin 6 (RA4/TK01/C1OUT) and pin 7 (RA5/AN4/SS/C2OUT) of Microcontroller.

5.1.9 Power Supply to the System

Figure 5.11: Power Supply Unit.

y ordinary house power supply o

DC power by filtering capacitor and bridging rectifier. 18 volts DC power supply is

regulated by different regulators and supplied to different devices accordingly.

18 volts DC is converted to 3.93 volts by regulator IC (LM 317) and supplied to GSM

Module. 18 volts DC regulated to 5 volts DC by regulator IC (LM 7805) and su

Microcontroller. Relays receive 12 volts DC regulated by regulator IC (LM 7812).

This is bolted to a heat sink to conduct the heat away from the device to prevent it from

overheating. Figure 5.11 shows the diagram of power supply.

Methodology 100

Page 120: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

5.2 Software Implementations

5.2.1 Steps of writing program in PICBasic Pro

• Double click on exe. file and install the PICBasic Pro

Step 2. Cre n

asic Pro menu bar

n menu bar →New page

standard menu bar

Step 1. Open the PICBasic Pro window

• Open PICBasic Pro

ati g a new page

• Double click on PICB

• Select →File o

or directly clicking on new page icon on

Methodology 101

Page 121: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

S

102

tep 3. Selection of chip select

• Click on pop down menu

F877A

Write the program

• Under the star marked line write the program code.

e name” →Save

• Select chip 16

Step 4.

Step 5. Save the program

• Select the file on menu bar →Click on “Save as”

→Give “Fil

or click on “Save” icon on standard menu bar

Methodology

Page 122: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Step 6. Compile the program • Select the project on menu bar

The program successfully compiled.

• Click on “Compile”

Methodology 103

Page 123: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

5.2.2 Steps of loading program in to microcontroller by using EPIC WIN soft ware

tep 1. Copy the EPIC WIN to the computer

Select “view” on menu bar

iguration (a window will be

S

• Double click on EPIC WIN →

→Code (a window will be popped up)

• Again select view on menu bar → Conf

popped up)

Methodology 104

Page 124: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Step 2. Select file → open → double click on “Save program file”

ow

• Select the code protection from Configuration Wind

• Disable other options

tep 3. Saved program will go to the right popped up window.

S

Methodology 105

Page 125: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Step 4. Click on pop down menu

• Select chip PIC16F877A

• Successful compilation of Hex code in to microcontroller.

The PIC microcontroller (PIC16F877A TM, Microchip Technology Inc., USA), which is

programmed using PICBASIC Pro is controlled by mobile phone. The SMS is send by

the mobile phone will be received by GSM module connected to SIM holder containing

the SIM. The SMS read and send to the microcontroller by GSM module. The

microcontroller will match the message according to its program and send the

instructions to sensors and relays to switch ON/OFF the devices (Lights, Fan, and Air-

conditioner). The PIC microcontroller subsequently send message GSM module that will

generate a message to the mobile phone owner.

Methodology 106

Page 126: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Sending SMS and display

re of SMS display

.3 Sending SMS and display

Figure 5.12 Camera pictu

5

For the protection of unauthorized access we used a code (1401) which is stored in

microcontroller. These photographs show the status of the load devices.

Methodology 107

Page 127: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Figure 5.13: Front Photograph of the Device

Figure 5.14: Front Photograph of the Device in functional state

Methodology 108

Page 128: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

Methodology 109

• If the massage is wrong then microcontroller will not take any action and delete

the message.

Figure 5.15: Bottom view of the Device 5.4 Functioning of the Device 5.4.1 Steps of functioning of the Device

• The device is switched on by power switch.

• The network status is indicated by blinking of LED. At the beginning LED blinks

fast. When network is searched it blinks slowly.

• A SMS is send by cell phone is received by the GSM module which uses the

GSM SIM card.

• This SMS is send to micro controller which receives, interpret and compare it

with its stored program.

• If the message is correct according to microcontroller’s programming the

microcontroller sends the instructions to relays.

Page 129: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

• Relays switch on uctions given by

microcontroller serially.

tions to module to send an acknowledgement to

the cell phone of sender about the last status.

/off the load devices according to the instr

• These instructions are stored in the EEPROM.

• Microcontroller sends back instruc

Methodology 110

Page 130: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

CHAPTER 6 RESULTS

This chapter comprises the performance of the final product with respect to the

specification conditions. The beauty of this system is the fully flexible system which can

be installed in both new and existing homes and offices. Plus, it is an SMS based system

which is well developed and supported nowadays everywhere. It is always easy to plan,

expand or change and installed. Status of given function can be controlled from anywhere

on the GSM network. It is easy to add new components to a function.

6.0 Hardware Part testing

When power supply is connected to the circuit, the circuit operates successfully. These

include the power indication to Module, PIC Microcontroller and sensors. Usually there is a

delay of about 10 seconds in getting connection of GSM network by GSM Module, but this

much delay is expected. GSM Module receives the designated SMS with security code from

mobile phone and sends it to PIC Microcontroller which matches the SMS with the program

and sends the desired actions to relays. Another delay of average 5 seconds is experienced in

delivery of SMS from mobile phone to GSM Module. GSM Module sends back to back

SMS. During this testing no problem regarding the function of hardware encountered.

6.1 Software Part testing

The programming has been found to be working successfully. Once a source code has been

written, it is compiled to generate the HEX file. The PIC programmer is used to burn the

code into the PIC 16F877A. Figure 4.4 shows the flow of the PIC programming.

Results 111

Page 131: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

PIC PIC ProgrammerProgram Translator Program.hex 16F877A

Figure 6.1: Sequence of loading the program to PIC

• Remote Controlling capability of the system allowed user to switch on/off

through simulating the appliance as directed by the incoming SMS.

• The system automatically performed tests and checked support for available

features and SMS sending and receiving capability and configured system

accordingly.

Overall, the product outcome was on a satisfactory level as the result was functional. Even

though the result is important, the process of researching, implementing, designing and

integrating are even more valuable. The skills and experience gained from this thesis project

surely would be beneficial in the future careers.

Results 112

Page 132: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

CHAPTER 7 DISCUSSION

In this thesis paper a low cost, flexible, wireless solution to the home automation is

introduced. The novel approach in this thesis paper discusses the migration of the initial

control mechanism of devices with simple functionality to more complex devices. The

system is secured for access from outside through SMS with protection code.

In the system at all stages we have used low cost easy to find components. All these

choices of devices were the least possible alternatives making the whole system a low

cost solution to the home automation.

When we are talking about remote communication, there exists a number of available

media for remote communication. Internet is a good example of this type of remote

communication. Internet places virtually no bounds on geographical placement and is

thus considered “enough” remote by our definition. But the Internet is a place crowded

with various types of traffics, often hostile to each other. Security vulnerability is the

most striking alert point of the Internet. Whenever a web based application goes live, a

lot of efforts have to take place before it can be said to be secured, if at all. When we say

remote control, we want to make sure no malicious party ever gains control and abolishes

everything. Also to use web, it requires resources like flawless internet connections and

hosting servers, which may not always fit to the concept of remote controlling.

Another candidate solution to this remote communication problem is the use of mobile

telephone. Mobile telephone offers a wide range of communication services like voice

and data transfer through SMS and other enhanced data transfer protocols like GPRS,

EDGE at a relatively low price and at a wide variety of places on the earth. On the other

hand, the security is better achieved by the use of strict traffic control. In this thesis paper

this method of remote controlling of home appliances is used because of its unparallel

availability and modest security at the affordable price. [16]

AT command and Blue Tooth based solution are the two other media by which the

remote controlling of home appliances is possible. [16]

Discussion 113

Page 133: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

‘AT’ stands for ‘Attention command’. GSM mobile phones are equipped with built in

GSM Modems which responds to the commands issued as an SMS by the connected

computer. AT commands create a logical bidirectional communication between computer

and mobile phone. AT commands provide the computer with the most flexible way to

control and explore the services and resources of a mobile. AT commands enable one to

send and receive SMS from the computer and also it lets the computer to browse the

mobiles resources like memory and phone book and so on.

Pros and Cons

Pros

1. The communication is solely implemented using SMS protocol which is available at

most of the places.

2. It doesn’t rely on the internet and web servers, which cuts down the overhead and the

cost of the communication.

3. From the programming point of view, all the efforts are rendered for the computer and

not the mobile, which makes the total implementation a relatively simple task.

4. There is no binding about the physical connection link that is used between the

computers and mobile, which makes it more versatile and interoperable with data

cables, Bluetooth and infrared.

Cons

1. AT command is somewhat device dependent. So, to permit devices from multiple

vendors and multiple models, it may be necessary to alter the commands accordingly.

2. It is desired for a bidirectional communication that the communication can start from

any of the two ends. But here the communication always starts with the command from

the computer’s end.

Bluetooth wireless technology [29] stands in the way of traditional short-range wired

communications technology connecting portable and/or fixed devices while maintaining

high levels of security. It obsoletes wires between your workstation, mouse, laptop

computer, music head-phones etc. The key features of Bluetooth technology are

robustness, low power yet low cost. The Bluetooth specification sets the standard for a

wide range of devices to connect and communicate with each other. A fundamental

Discussion 114

Page 134: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

strength of Bluetooth wireless technology is the ability to simultaneously handle both

data and voice transmissions, making it most feasible for handheld devices.

Pros and Cons

Pros

1. Bluetooth offers a global standard for connecting a wide range of devices with

different services. So, using a Bluetooth protocol at the bottom makes one application

somewhat versatile in terms of interoperability.

2. Bluetooth is available at most of the handheld devices like cell phones, music players

and cameras all conforming to the defined standard. So, to use the Bluetooth with the

computer, one need not think about overheads like internet and web servers.

3. The technology is very easy to use. The devices generally come with built-in software

support for Bluetooth operations and these are most commonly used applications for

handheld devices.

4. Most desirable property for a communication protocol is the ability to measure the

security support it provides. And Bluetooth restricts the malicious attacks by using the

128-bit long shared keys and once securely started, maintains it until the otherwise

stated.

Cons

1. One of the major limitations of Bluetooth technology is the short range of operations.

So the system is unable to cope with mobility.

2. Bluetooth is not fully developed and integrated into all the products involved. We have

to still wait for it to get fully evolved.

In this thesis work the proposed implementation controls the home appliances of a smart

home using mobile phones from anywhere. It is well devised and precisely implemented

so that a mobile phone can communicate with the microcontroller. The advantages of this

solution are described below.

1. Our solution doesn't need internet which is not a secure and reliable media.

2. This is the first solution of its kind that uses mobile devices which are commonly used

by everyone now days.

Discussion 115

Page 135: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

3. Use of mobile devices gives mobility to the solution and home appliance can be

controlled from almost everywhere on earth.

4. Our system is not tightly coupled to a particular vendor for the third-party controllers.

So, we can have any third-party controller and still make use of the mobility and

accessibility.

5. Although this is about home controlling, the underlying core of the technology can be

used for controlling any system using mobile telephone.

6. This is a comparatively low cost, easy to maintain and the most accessible solution.

Discussion 116

Page 136: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

CHAPTER 8 CONCLUSION AND FUTURE WORK

In this thesis paper, a low cost, secure, ubiquitously accessible, remotely controlled

solution for automation of homes has been introduced. The approach discussed in this

thesis paper is novel and has achieved the target to control home appliances remotely

using the SMS-based system satisfying user needs and requirements.

GSM technology capable solution has proved to be controlled remotely, provide home

appliances control and is cost-effective as compared to the previously existing systems.

This thesis presents an overview of the designing and implementation of the system, which

offers relevant theories and information toward the research. The final product has achieved

essential specification and performance of the desired system at the end of the thesis. Hence

development of the system fulfils the objective of the thesis with success.

The basic level of home appliance control and remote monitoring has been implemented.

The system is extensible and more levels can be further developed. In case of remote

monitoring other appliances can also be monitored such that security system or smoke

and fire in case of emergency the system will automatically generate SMS. This is a very

weak step by a fragile human being but definitely it is going to dominate our life style in

future like mobile phone and computer which become indispensable part of us.

Conclusion & Future Work 117

Page 137: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

REFERENCES

[1] Intille SS. Designing a home of the future. IEEE Pervasive Computing, 2002; Vol 1

(2): pp. 80-86.

[2] Delgado AR, Picking R, Grout V. Remote-controlled home automation systems with

different network technologies. In: Proceedings of the 6th International Network

Conference (INC 2006), 11-14 July 2006, University of Plymouth, Plymouth: pp.

357-366.

[3] Ciubotaru-Petrescu B, Chiciudean D, Cioarga R, Stanescu D. Wireless Solutions for

Telemetry in Civil Equipment and Infrastructure Monitoring.In: 3rd Romanian-

Hungarian Joint Symposium on Applied Computational Intelligence (SACI) 25-26

May, 2006. University of Timisoara, Romania: Available from

http://www.bmf.hu/conferences/saci2006/Ciubotaru.pdf/ Accessed on 16th June 2009.

[4] Conte G, Scaradozzi D. Viewing home automation systems as multiple agents

systems. RoboCUP2003, 10-11 July 2003, Padova, Italy. Available from

http://www.robosiri.it/ROBOCUP_2003/ROBOCUPSITOSIRI/

articles/pdf/Conte.pdf/ Accessed on 16th June 2009.

[5] Alkar A Z, Buhur U. An Internet Based Wireless Home Automation System for

Multifunctional Devices. IEEE Consumer Electronics, 2005; 51(4): pp 1169-1174.

[6] Jawarkar N P, Ahmed V, Ladhake S A, Thakare R D. Micro-controller based Remote

Monitoring using Mobile through Spoken Commands. Journal of Networks, 2008;

Vol 3 (2): pp. 58-63.

[7] Potamitis I, Georgila K, Fakotakis N, Kokkinakis G. An integrated system for smart-

home control of appliances based on remote speech interaction., 8th European

Conference on Speech Communication and Technology, EUROSPEECH 2003, 1-4

Sept., 2003, Geneva, Switzerland: pp. 2197-2200, Available from

http://www.wcl.ee.upatras.gr/ai/papers/potamit is14.pdf/[Accessed on 16th June

2009].

[8] GSM world. Global Mobile Communication is 20 years old.[Online]. Available from.

http:// www.gsmtwenty.com/ [Accessed on 16th June 2009].

References 118

Page 138: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

[9] GSM Module. GSM Notification Module.[Online]. Available from. http://www.

g-e.ee/files/manuals/gsm-n2_eng.pdf/ [Accessed on 16th June 2009].

[10] Wikipedia. Subscriber Identity Module (SIM). [Online] Available from.

http://www.en.wikipedia.org/wiki/Subscriber_Identity_Module/ [Accessed on 16th

June 2009].

[11] Trosby F. SMS, the strange duckling of GSM. Telektronikk.2004; 3: pp. 187-194

[12] Microchip Technology Inc. PIC16F7X: Data Sheet 28/40-pin, 8-bit CMOS FLASH

Microcontrollers.[Online]. Available from: http://www.microchip.com/ [Accessed

on 16th June 2009].

[13] MicroEngineering Labs, Inc. PicBasic Pro Compiler.[Online]. Available from.

http://www.imagesco.com/microcontroller/pbpman.pdf//[Accessed on 17th June

2009].

[14] Ford Equity Research. EPIC for Windows v5.00 – Download and Install Instructions

[Online]. Available from. http://www.fordupdate.com/epic.htm//[Accessed on 17th

June 2009].

[15] Eklund D, Rasmusson D. A Home Automation Prototype. Master thesis. Lund

University, Sweden; 2008.

[16] Shahriyar R, Hoque E, Sohan SM, Naim I, Akbar MM, Khan MK. Remote

Controlling of Home Appliances using Mobile Telephony. International Journal of

Smart Home. 2008; Vol. 2,(3): pp. 37-53.

[17] Wikipedia. Home automation. [Online]. Available from.

http://en.wikipedia.org/wiki/Home_automation/ [Accessed on 17th June 2009].

[18] Wikipedia. Microcontoller. [Online]. Available from.

http://en.wikipedia.org/wiki/Microcontroller/ [Accessed on 18th June 2009].

[19] Karataş P, Aksoy M. Microcontroller based Home Automation. Proceedings of

International Conference on Intelligent Knowledge Systems (IKS-2004), 16-20

August, 2004. [Online]. Available from. http://www Ikss.org/iks-

2004/pdf/E0109.pdf//[Accessed on 17th June 2009].

[20] Wikipedia. PIC Microcontoller. [Online]. Available from.

http://en.wikipedia.org/wiki/PICmicrocontroller/ [Accessed on 18th June 2009]

References 119

Page 139: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

[21] SIM Technology Group Ltd. Wireless Module Solution. [Online]. Available from:

http://www.sim.com/ [Accessed on 22nd June 2009].

[22] Mouser Catalog Download, Mouser Electronics. Amphenol Smart Card Connectors.

[Online]. Available from: http:// www.mouser.com/amphenol-tuchel/ [Accessed on

22nd June 2009].

[23] The Xperts in Power. Power Supply Technical Guide. [Online]. Available from:

http://www.xppower.com/ [Accessed on 26th June 2009].

[24] National Semiconductor Corporation. Introduction to Power Supplies. Application

Note 556. 2002. [Online]. Available from: http:// www.national.com/ [Accessed on

26th June 2009].

[25] Wikipedia. Liquid Crystal Display. [Online]. Available from.

http://en.wikipedia.org/wiki/ Liquid Crystal Display / [Accessed on 27th June 2009]

[26] Gray GW, Kelly SM. Liquid crystals for twisted nematic display devices. Journal of

Material Chemistry. 1999; Vol. 9: pp. 2037-2050.

[27] MicroEngineering Labs, Inc. PicBasic Compiler. [Online]. Available from.

http:// www.melabs.com/ [Accessed on 30th June 2009]

[28] Wikipedia. Short Message Service (SMS). [Online]. Available from.

http://en.wikipedia.org/wiki/Short Message Service/ [Accessed on 19th June 2009]

[29] Bluetooth Technology. Bluetooth SIG. [Online]. Available from.

http://www.bluetooth.com [Accessed on 20th July 2009]

References 120

Page 140: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

'**************************************************************** '* Name : Tahmina.* '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 4/8/2009 * '* Version : 1.0 * '* Notes : 4 output device control : From any mobile with passward * '**************************************************************** @ DEVICE WDT_OFF & PWRT_OFF & PROTECT_ON Define OSC 12 '***** Define LCD registers and bits Define LCD_DREG PORTB Define LCD_DBIT 0 Define LCD_RSREG PORTB Define LCD_RSBIT 4 Define LCD_EREG PORTB Define LCD_EBIT 5 '****** 4 Input/Output define TRISD = %00001111 TRISA = %011111 '*****SERIAL CONNECTION define txd var PortA.5 rxd var PortA.4 Baud con 84 '9600 '****** 4 Output port define lit1 VAR PORTD.4 lit2 VAR PORTD.5 fan VAR PORTD.6 ac VAR PORTD.7 read 30,lit1 : read 31,lit2 : read 32,fan : read 33,ac '******* variabls define sms_no var byte temp var byte slit1 VAR byte[6] ' string "light1" slit2 VAR byte[6] ' string "light2" sfan VAR byte[3] ' string "fan" sac VAR byte[2] ' string "ac" son VAR byte[2] ' string "ON" soff VAR byte[3] ' string "OFF" spa var byte[2] ' string "14" sss var byte[2] ' string "01"

Page 141: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

pass var byte[4] ' string "1401" onof var byte ph_no var byte[11] '******* string define data @0,"1","4" '0-1 "14" DATA @2,"l","i","g","h","t","1" '2-7 "light1" DATA @8,"l","i","g","h","t","2" '8-13 "light2" data @14,"f","a","n" '14-16 "fan" data @17,"a","c" '17-18 "ac" data @19,"o","n" '19-20 "ON" data @21,"o","f","f" '21-23 "OFF" data @24,"0","1" '24-25 "01" LCDOut $fe,1," HOME APPLIANCE",$fe,$c0,"= CONTROLLER =" pause 1500 GOsub netsearch gosub connected gosub delet_sms main: LCDOut $fe,1," HOME APPLIANCE",$fe,$c0,"= CONTROLLER =" SerIn2 rxd,Baud,[wait("+CMTI:"),SKIP 6 ,dec2 sms_no] if sms_no > 9 then gosub read_sms gosub send_sms gosub delet_sms endif goto main netsearch: SerOut2 txd,Baud,["AT",13] SerIn2 rxd,Baud,1500,Conect_Err,[wait("OK")] LCDOut $fe,1," Network ",$fe,$c0," Searching...." PAUSE 1500 IF Network OK THEN goto netsearch endif return connected: SerOut2 txd,Baud,["AT+CFUN?",13] SerIn2 rxd,Baud,1500,conect_err,[wait("+CFUN: 1")] LCDOut $fe,1," connected.... " PAUSE 1500 return delet_sms: SerOut2 txd,Baud,["AT+CMGDA=",34,"DEL ALL",34,13]

Page 142: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

SerIn2 rxd,Baud,2000,Conect_Err,[wait("OK")] goto main read_sms: if pass[0]==1 and pass[1]==4 and pass[2]==0 and pass[3]==1 then goto delet_sms endif SerOut2 txd,Baud,["at+cmgr=",dec2 sms_no,13] SerIn2 rxd,Baud,1500,del_sms,[wait("1401")] SerOut2 txd,Baud,["a/"] SerIn2 rxd,Baud,1500,conect_err,[wait("+88"),str ph_no\11] LCDOut $fe,1," = NEW SMS =" div1: SerOut2 txd,Baud,["a/"] SerIn2 rxd,Baud,1500,lit1_off,[wait("light1 on")] lit1=1 div2: SerOut2 txd,Baud,["a/"] SerIn2 rxd,Baud,1500,lit2_off,[wait("light2 on")] lit2=1 div3: SerOut2 txd,Baud,["a/"] SerIn2 rxd,Baud,1500,fan_off,[wait("fan on")] fan=1 div4: SerOut2 txd,Baud,["a/"] SerIn2 rxd,Baud,1500,ac_off,[wait("ac on")] ac=1 div5: return lit1_off: lit1=0 goto div2 lit2_off: lit2=0 goto div3 fan_off: fan=0 goto div4

Page 143: Design and Development of Microcontroller Based SMS ... · 5.1.3 Interfacing of Microcontroller with GSM Module 95 5.1.4 Liquid Crystal Display (LCD) 96 5.1.5 Interfacing of Microcontroller

ac_off: ac=0 goto div5 send_sms: LCDOut $fe,1," sending sms" SerOut2 txd,Baud,["at+cmgs=",34,str ph_no\11,34,13] SerIn2 rxd,Baud,1500,Conect_Err,[wait(">")] light1: SerOut2 txd,Baud,[str slit1\6," "] if lit1==1 then SerOut2 txd,Baud,[str son\2] else SerOut2 txd,Baud,[str soff\3] endif light2: SerOut2 txd,Baud,[13,str slit2\6," "] if lit2==1 then SerOut2 txd,Baud,[str son\2] else SerOut2 txd,Baud,[str soff\3] endif _fan: SerOut2 txd,Baud,[13,str sfan\3," "] if fan==1 then SerOut2 txd,Baud,[str son\2] else SerOut2 txd,Baud,[str soff\3] endif _ac: SerOut2 txd,Baud,[13,str sac\2," "] if ac==1 then SerOut2 txd,Baud,[str son\2] else SerOut2 txd,Baud,[str soff\3] endif SerOut2 txd,Baud,[13,"---------" ,13," last status",26] 'pause 500 SerIn2 rxd,Baud,2000,conect_err,[wait("OK")] write 30,lit1 : write 31,lit2 : write 32,fan : write 33,ac return End