7.4.1.1 Transmission Process of Intra-operator SMS Messages. 7.4.2 ...... notification service a decade ago, the bulk of SMS usage today is for interpersonal .... center are interconnected through an SMS gateway or with a communication.
Microcontroller based SCADA System Using GSM (Final Year Project Report)
Supervised by MR. ABDUL RAHEEM Submitted by
Hafeez Ur Rehman S.M. Jawad Haider Faizan Zafar
2319 2314 2225
Department of Electronic Engineering University College of Engineering & Technology\
The Islamia University of Bahawalpur
Microcontroller based SCADA System Using GSM Supervised By
MR. ABDUL RAHEEM Submitted by
Roll No.
Hafeez Ur Rehman S.M. Jawad Haider Faizan Zafar
2319 2314 2225
DEPARTMENT OF ELECTRONIC ENGINEERING UNIVERSITY COLLEGE OF ENGINEERING & TECHNOLOGY
The Islamia University of Bahawalpur
CERTIFICATE
This thesis submitted by Mr. HAFEEZ UR REHMAN , Mr. S.M. JAWAD HAIDER and Mr. FAIZAN ZAFAR in direction of their supervisor MR. ABDUL RAHEEM approved by all members of the Thesis Committee, has been presented to and accepted by the PRINCIPAL, University College Of Engineering & Technology, in partial fulfillment of the requirement of the Degree of BSc Electronic Engineering
Committee Members:
MR. ABDUL RAHEEM Supervisor
_____________________ MHHAMMAD AMJAD Incharge
__________________ External Examiner
__________________ Prof J. M. KEERIO Principal
DEDICATION
HUMBLY DEDICATED TO , THE UNRESTRAINED LOVE & AFFECTION OF OUR PARENTS & BROTHERS, SISTERS AFFLUENT ENCOURAGEMENT & INTENTION OF OUR TEACHERS, FORTIFYING COOPERATION OF OUR FELLOWS & JUNIORS, WHICH GAVE US MOTIVATION , INSPIRATION AND COURAGE US TO GET INVLOVED AND COMPLETE THIS PROJECT.
ACKNOWLEDGEMENT
Up and above everything, all prays go to ALLAH, we find no words to express our deepest sense to gratitude to the almighty ALLAH. The most gracious compassionate and beneficent and his prophet MUHAMMAD (S.A.W.),who is the true torch of guidance for whole humanity forever. We say heartiest thanks to our project advisor MR. FAREED A. JOKHIO for his encouragement, kind guidance, valuable suggestions, keen supervision and exactitude needed throughout the course of the project. We are very grateful to our loving and caring parents for providing us all sort of moral, social and financial support during our life, especially to our loving mothers whose prayers were incessant and enabled us to reach this stage & or fathers who always provoked a power in our selves to lead us to success .We heartily express our love to all our brothers and sisters for their love and care. We are very thankful to our principal Prof. J.M. KEERIO to give us all the facilities and much moral support especially in the last two months when the construction work of labs and our project hardware were at the same importance. We can’t forget to express thanks to all our faculty teachers who helped us a lot by all means and also lab technicians especially to Mr. BILAL, Mr. KHALIQ AND Mr. IMTIAZ.
Also we would like to thanks all my fellows and all juniors to encourage us all the way. Here we also wish to express our feelings for our late. Fellow M. Touseef Younis who helped us to move toward this project, may his soul rest in peace.
Hafeez Ur Rehman S.M. jawad Haider Faizan Zafar
ABSTRACT
Microcontroller based SCADA System Using GSM is capable of monitoring and controlling the industrial processes & switching of the electronic devices. This project is a wonderful & most reliable solution for the widely scattered SCADA (Supervisory Control & Data Acquisition Systems).Here Two microcontrollers are used .One at input section other at output section. The microcontroller at the input side is serving as a transmitting station. It is designed to take several inputs from several systems (i.e.) temperature for the time being , in a real-time from the external environment and sends it to a mobile through GSM service. The microcontroller on the other hand takes the input from the Mobile device & then monitor the connected device (i.e.) heater as instructed by the user through an SMS. This microcontroller has a dedicated port to drive the physical outputs in a real-time for controlling the processes. First microcontroller is serially connected with the personal computer via max232. For technical purpose we used the Hyper Terminal to get the systems real time information i.e. Temperature on the Personal computer. The graphical user interface is created with the help of VISUAL BASIC 6.0 software. Using graphical user interface we can observe the present temperature conditions of our system. We can monitor the systems or devices on the bases of almost all kind of parameters VENTILATION, PRESSURE, TEMPERATURE, HUMIDITY MOTION using relative sensing equipment we take the values of these process variables via microcontroller and then we can control relevant device or process. An indication is also the part of this project for security & personalization of the system. This will
indicate that some unauthorized person from some unauthorized number is trying to access the system control. This project is unique in its feature that it is highly personal & is global in its nature. This system provides you the facility to control your system from anywhere in the world where any GSM service is available. Other excellent features included are Self Diagnostic Behavior, its built in facility of acquisition of data & then making decision on its bases, High Security Level, User Friendly and Incremental Capacity. This project fully facilitates the laymen to control there devices just by using there handset and needs not to carry extra equipment with them or needs no special knowledge. This system just needs one time installation expensive and after that it costs very low to send SMS from any cellular service.
PROJECT BRIEF
PROJECT NAME
Microcontroller based SCADA System Using GSM
OBJECTIVE
acquiring and transmitting data by microcontroller through GSM and controlling of system devices.
UNDERTAKEN BY
Hafeez Ur Rehman S.M. jawad Haider Faizan Zafar
SUPERVISED BY
MR. ABDUL RAHEEM
System USED
Pentium M 1400MHZ
SOURCE LANGUAGE
Assembly Microsoft Visual Basic 6.0
PACKAGE USED
Microsoft Office 2003 Adobe Acrobat reader 7.0
OPERATION SYSTEM
Microsoft Windows XP 2007
TECHNICAL TOOLS
Pinnacle 52 Professional Development System Keil µVision 3 Multisim 9.0 Pro (EWB)
GRAPHICAL REPRESENTATION
Microsoft Visio 2003 Pro Adobe PhotoShop Cs
THESIS DEPICTION To make this report more knowledgeable and effective, it is divided into several sections and these sections are presented in the form of chapters. Each chapter heading covers the specific area of knowledge which has been used during the process of construction of this project through the incubation of its idea to its working hardware form. This thesis is organized in the 5 chapters which are organized in the proper and gradual order for the best explanation and understanding of this project. Here are the highlights of all chapter for quick access to the report.
Chapter 1:
Project Introduction
A brief introduction of whole project is given. T inspirations, project description in terms of hardware & software section and in the end block diagrams of the project. Chapter 2
Introduction to Microcontroller
This chapter explains Atmel’s microcontroller AT89C52 in detail in terms of its features, memory organization, pins configuration and description and logical internal diagrams. Chapter 3
Serial Port Operation
This Chapter provides the important information about serial port standards, signals and pin assignments, serial data formats and types of connections.
Chapter 4
Project Layout
This chapter provides a system design flow of the transmitter & receiver. Project Interface circuitry for the inputs, sensors and serial connection with com port and mobile phone. It provides the
interface circuitry for the receiver module mobile phone,
microcontroller & external system to be controlled. In the end the G.U.I layout is given.. Chapter 5
Hardware Specifications
This chapter provides the specification and data sheets for all the IC’s and components used in this projects. Theses specs include important features, pins configurations, absolute maximum rating, operation requirements and AC & DC Characteristics. Chapter 6
GSM Technology
This chapter gives an overview of the GSM (Global System for Mobile Communication) technology , SMS (Short Messaging Service), GSM service providers, AT commands. Chapter 7
SMS & AT Commands
This chapter gives an overview of the one of the valuable services of GSM (Global System for Mobile Communication) SMS (Short Messaging Service), SMS history, Types and AT commands , their history, background , AT command sets and usage. Chapter 8
Conclusions
This chapter is the extractant of the thesis and presents a conclusion of the whole work. It gives the applications, advantages, salient features, precautions and worst expected situations as well. This section also provides the future enhancement and up gradation options available for this project. Index This section contains the list of figures , tables and reference materials
TABLE OF CONTENTS
1
PROJECT INTRODUCTION 1.1 Introduction 1.2 Project Inspiration 1.3 Project Description 1.3.1 Hardware Construction 1.3.1.1 Transmitter Module 1.3.1.2 Receiver Module 1.3.2 Software Overview 1.3.2.1 Assembly Language Introduction 1.3.2.2 Overview To The Project Software a. Transmitter Module Program b. Receiver Module Program 1.4 Project Block Diagram 1.4.1 Transmitter Module Block Diagram 1.4.2 Receiver Module Block Diagram
2
MICROCONTROLLER 2.1 2.2 2.3 2.4 2.5
3
Introduction To Microcontroller Important Features Memory Organization Pins Configuration And Description Logical Internal Diagram
SERIAL PORT 3.1 3.2 3.3 3.4
Introduction Serial Port Interface Standards Connection Two Devices With Serial Port Signals And Pin Assignment 3.4.1 SCON (Serial Control) 3.4.2 PCON (Power Control) 3.4.3 SBUF (Serial Buffer)
18 18 19 20
3.5 Serial Data Format 3.6 Synchronous & Asynchronous Connections 3.7 How Are The Bits Transmitted 3.7.1 Start And Stop Bits 3.7.2 Data Bits 3.7.3 The Parity Bits 3.8 Creating a Serial Port Objective
4
26
SYSTEM DESIGN FLOW 4.1 4.2 4.3 4.4 4.5
5
22 23 24
Microcontroller Interfacing Transmitter Module Schematic Diagram Receiver Module Using Hyper Terminal
29 32
33
INTERFACED HARDWARE SPECIFICATIONS 5.1 AT89C52 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.2 MAX232 5.2.1 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.3
36 General Description Important Features Pins Configuration Logical Internal Diagram Absolute Maximum Rating DC Characteristics AC Characteristics
36 36 37 38 38 39 40 41
General Description Important Features Applications Pins Configuration Pins Description Logical Internal Diagram Absolute Maximum Rating Operating Conditions
Demultiplexer SN74LS138 5.3.1 General Description 5.3.2 Important Features 5.3.3 Pins Configuration 5.3.4 Truth Table 5.3.5 Absolute Maximum Rating 5.3.6 Switch Circuit Schematic 5.3.7 Electrical characteristics
41 41 42 42 43 44 11
46 46 47 48 48
5.4 ADC0832 5.4.1 General Description 5.4.2 Important Features 5.4.3 Key Specs 5.4.4 Pins Configuration 5.4.5 Absolute Maximum Rating 5.4.6 AC Characteristics 5.5 7805/7810 Voltage Sensor 5.5.1 General Description 5.5.2 Important Features 5.5.3 Connection Diagram 5.5.4 Absolute Maximum Rating 5.5.5 Electrical Characteristics 5.6 LM35 Temperature Sensor 5.6.1 General Description 5.6.2 Important Features 5.6.3 Connection Diagram 5.6.4 Absolute Maximum Rating 5.6.5 Self Heating 5.6.6 Electrical Characteristics 5.7 Relay 5.7.1 General Description 5.7.2 Relay Specifications 5.7.3 Pick up Voltage 5.7.4 Holding Current 5.7.5 Drop out Voltage 5.7.6 Contact Voltage Ratings 5.7.7 Contact Current Ratings 5.7.8 Insulation Resistance 6
GSM Technology 6.1 6.2 6.3
6.4
6.5 6.6 6.7 6.8
History of GSM Services provided by GSM Architecture of the GSM network 6.3.1 Mobile Station 6.3.2 Base Station Subsystem 6.3.3 Network Subsystem Multiple access and channel structure 6.4.1 Traffic Channels 6.4.2 Control Channels 6.4.3 Burst Structure Speech Coding Channel Coding and Modulation Frequency Hopping Power Control
65
69 69 70 70 71 73 73 74 75 75 76 77
6.9
7
SMS and AT Commands 7.1 7.2 7.3 7.4
7.5
7.6 7.7 7.8 7.9 7.10 7.11
8
Network Aspects 6.9.1 Radio Resources Management 6.9.1.1 Handover 6.9.2 Mobility Management 6.9.2.1 Location Updating 6.9.2.2 Authentication and Security 6.9.3 Communication Management 6.9.3.1 Call Routing
Introduction To SMS History Of SMS SMS Applications Types Of SMS Messages 7.4.1 Intra-operator SMS Messages 7.4.1.1 Transmission Process of Intra-operator SMS Messages 7.4.2 Inter-operator SMS Messages 7.4.2.1 Transmission Process of Intra-operator SMS Messages 7.4.3 International SMS Messages SMS Services 7.5.1 Validity Period of an SMS Message 7.5.2 Message Status Reports 7.5.3 Message Submission Reports 7.5.4 Message Delivery Reports AT Commands History Of AT Commands Hayes AT Command Set Navtalk GSM AT Command Set AT COMMANDS FOR SMS Using AT- Commands
CONCLUSION
Conclusion Future Upgrading Features
85
APPENDIX A LIST OF FIGURES Fig 1.1 Basic Controller Block Diagram………………………………………… 7 Fig 1.2 Project Block Diagram……………………………………………………8 Fig 2.1 Pins Configuration………………………………………………………..15
LIST OF TABLES Table 1.1 Basic Controller Block Diagram………………………………………… 7 Table 1.2 Project Block Diagram……………………………………………………8 Table 1.3 Pins Configuration
References
Chapter 1
PROJECT INTRODUCTION
PROJECT INTRODUCTION
Microcontroller based SCADA System Using GSM
1
Chapter 1
PROJECT INTRODUCTION
1.1 INTRODUCTION
The purpose of a final study project is to awake the practical skills in ourselves as well as to implement the knowledge and subjects which are studies during the all course of studies. Thus this idea of Microcontroller based SCADA System Using GSM came to mind due to largely expanded GSM networks and because of the importance of the SCADA ( Supervisory Control And Data Acquisition ) Systems which are almost the kernel of any control industry. Also its of great importance to take the control of your system along with you without large expenses and to keep in touch with your system and devices all the time ,no matter wherever you are . Surely the Control Rooms are called the brains of industry. We can control and Set parameters of any process located in any area of field through its control room. The Monitoring and Controlling of different device is the main feature of Control Rooms. The systems that are installed in the Control Rooms demands the men power to be there all the time to look after and control the system devices. But this project was developed to provide a freehand for controlling the systems and device by self examining whether the system needs any attention , decided on the bases of the parameters set for the system just through an SMS. Microcontroller based SCADA System Using GSM
2
Chapter 1
PROJECT INTRODUCTION
1.2 PROJECT INSPIRATION
Our great inspiration in this project was due to widely spreading field of GSM Global System for Mobiles and its influence in the today’s modern life. This field is rapidly growing and the SMS short messaging service which is a very cheap & efficient service and is affordable by ordinary people, these things meant us a lot to deal with such a kind of project which can add up more to human services as already we are using SMS for Provision of Information, Downloading, Alerts and Notifications, Email, Fax , Voice Message Notifications, E-commerce and Credit Card Transaction Alerts, Stock Market Alerts and , SMS Marketing. These services also inspired us a lot and brought us to construct this supervisory system which is able to put the control of an industry or home appliances just using your cell phone and using the too much cheap SMS service. We thought to use this cheap and global technology to use it for the industrial control as well as to facilitate the laymen. So the work on the idea to utilize the cheap SMS service and to put the control of systems and devices on our hands all the time in our cell phone lead us to this project.
1.3
PROJECT DESCRIPTION
Microcontroller based SCADA System Using GSM
3
Chapter 1
PROJECT INTRODUCTION
This Project is an effort to construct an remote
control which can use the
available service from any GSM network provider to control devices whether industry control or home appliances. This GSM controller has an ability to keep a check on the parameters mentioned and then to control the system by self diagnostic if any change occurs in the system. The operator has its display panel to view the current status and control manually desired process variable. The computer operator in the control room can also view the current status on its computer and can also control desired process variable with available options. The parameters of this device can also be changed at any time when installing this device. Every input module and output module is functionally independent of each other. This controller responds in real time.
1.3.1 HARDWARE CONSTRUCTION The two Microcontrollers 8052 are separately used for Input module and Output module for this application.
1.3.1.1 TRANSMITTER MODULE On the transmitter side microcontrollers is serially interfaced with the personal computer and mobile phone , which acquires the real time value of temperature of a system and performs the signal conditioning and then compare the temperature and generates an SMS and sends it to the specified SIM (subscriber’s Identification Module).It also connects to the serial port of PC and the real time temperature value is also displayed on the computer using the Hyper terminal.
Microcontroller based SCADA System Using GSM
4
Chapter 1
PROJECT INTRODUCTION
The microcontroller gets the input from an ADC0831 on the Input side , receives whose pin 2 is connected to the analog output of temperature sensor LM35DZ and then to microcontroller on pins 2.0, 2.1, 2.2 (21,22,23), here we use EA (pin 31)which is low enable ,this is tied to the Vcc so that the 8051 executes the program from the internal memory as our program is stored in the microcontroller as we r not using an external Rom. And finally pin P3.1 i.e. TXD & Pin 3.7 i.e. RD low enable is connected to the De-Multiplexer SN74HC138N at pins 5 i.e. G2A and 1A (enable) . De-Multiplexer SN74HC138N then is connected to MAX 232 at pins 10 i.e. T2in and pin 11 T1in for transferring serial data to the personal computer by using DB9 pins 2 and 3 to MAX 232 pins 7 i.e. T2out and GND. To send data to Mobile DB9 Male Pins 2 and 3 ares connected to MAX232 at pins 14 i.e. T1out and ground. 1.3.1.2 RECEIVER MODULE Receiver Module acquire the data through the mobile inbox through DB9 pins 2 and pin3 connected to Max 232 pin 8 i.e. R2 in and Pin 13 R1in. Then data is sent to the microcontroller at Pin 10 i.e. RDX which is connected to MAX 232 at Pin 9 i.e. R2Outand Pin 11 i.e. TXD connected to MAX232 Pin 10 i.e. T2in. Data is serially transferred from the Mobile into the SBUF using AT commands, then the SIM number is compared Authenticate the user . Then Microcontroller is programmed to compare the Message sent through SMS as ON or OFF by comparing its ASCII value.
Microcontroller based SCADA System Using GSM
5
Chapter 1
PROJECT INTRODUCTION
If the SMS is ON then microcontroller set the Pin 24 . P2.3 of microcontroller and if the SMS is OFF then it clears this pin. Pin 2.3 is derived to Control the respective devices.
1.3.2
SOFTWARE OVERVIEW The Project software is written in the Assembly Language.The Software is
comprised of the following sections.
1.3.2.1 ASSEMBLY LANGUAGE INTRODUCTION INTRODUCTION Assembly language is computer language lying between the extreme of machine language and high-level language. typical high-level language like Pascal or C use words and statement that are easily understood by humans, although still a long way from” natural” language. Machine language is the binary language of computers. A machine language program is a series of binary bytes representing instructions the computer can execute. Assembly language replaces the binary codes of machine language with easy to remember “mnemonics” that facilitates programming. For example, An addition instruction in machine language might be represented by the e code “10110011”. It be represented in an assembly language by the mnemonics”ADD”. Programming with mnemonics is obviously preferable to programming binary codes. Of course, this is not the whole story. instruction operates on data, and the location of the data is specified by various” addressing modes” embedded in binary code of the machine language instruction. So. There may be several variations of ADD Microcontroller based SCADA System Using GSM
6
Chapter 1
PROJECT INTRODUCTION
instructions, depending on what is added. The rules for specifying these variations to the theme of assembly language programming. An assembly language program is not executable by a computer. Once written the program must undergo translation to machine language. In the example above, the mnemonic ADD must be translated to binary code “100110011”. Depending on the complexity of the programming environment, this translation may involves one or more steps before an executable machine language program results. As a minimum, a program called an “assembler” is required to translate the instruction mnemonics to machine language binary codes. An further step may require a “linker” to combine portions of programs from separate files and to set the address in memory at which program may execute.
1.3.2.2 OVERVIEW OF PROJECT SOFTWARE 1.3.2.2.A
TRANSMITTER MODULE PROGRAM
This test the working of serial port , gets data from LM35 sensor, compares it with the specified temperature and then sends SMS through mobile device . it can be divided in the following sections.
1.3.2.2.B
•
EQUATES & VARIABLE DEFINITIONS
•
READING DATA FROM 0831 DATA
•
SENDING DATA TO PC THROUGH SBUFF
•
COMPARING TEMPRATURE
•
SENDING AT COMMANDS TO MOBILE
•
SENDING SMS
RECEIVER MODULE PROGRAM
Microcontroller based SCADA System Using GSM
7
Chapter 1
PROJECT INTRODUCTION
THIS PROGRAMM GETS THE SMS DATA FROM THE MOBILE PHONE , AUTHENTICATES THE SENDER’S NUMBER AND THEN SWITCH ON OR OFF THE CONNECTED DEVICE. THIS PROGRAMM CAN BE DIVIDED INTO FOLLOWING PORTIONS.
1.4
•
ACCESSING MOBILE THOUGH AT COMMANDS
•
ACCESSING SMS FROM MOBILE INBOX
•
AUTHENTICATING SENDER
•
COMPARING SMS INSTRUCTION
•
SWITCHING CONNECTED DEVICE
PROJECT BLOCK DIAGRAM
The block diagrams for the both modules of project , illustrating the whole functionality of project. 1.4.1
TRANSMITTER MODULE BLOCK DIAGRAM
Microcontroller based SCADA System Using GSM
8
Chapter 1
PROJECT INTRODUCTION
GSM Network
SET POINT
Micocontroller
Compare
Condition True
Input data
Generate SMS
PC
Fig 1.1 Transmitter module Controller Block Diagram
1.4.2
Mobile Phone
RECEIVER MODULE BLOCK DIAGRAM
Microcontroller based SCADA System Using GSM
9
Chapter 1
PROJECT INTRODUCTION
GSM Network
Caution
Validating SMS ON/ OFF
User Verified
Mobile Phone
Check Sender
Valid SMS
Switching Device
Fig 1.2 Receiver module Controller Block Diagram
Microcontroller based SCADA System Using GSM
10
Micocontroller
Chapter 2
MICROCONTROLLER AT80C51
MICROCONTROLLER AT80C51/52
9 Microcontroller based SCADA System Using GSM
Chapter 2
2.1
MICROCONTROLLER AT80C51
INTODUCTION TO MICROCONTROLLER
The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.
2.2
IMPORTANT FEATURES
Compatible with MCS-51™ Products 8K Bytes of In-System Reprogrammable Flash Memory – Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-level Program Memory Lock 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Programmable Serial Channel Low-power Idle and Power-down Modes 10 Microcontroller based SCADA System Using GSM
Chapter 2
2.3
MICROCONTROLLER AT80C51
MEMORY ORGANIZATION
Most microprocessors implement a shared space for data and programs. This is why programs are usually stored in disk and loaded into RAM for execution: thus both data and program lies in the system RAM. Microcontrollers, on the other hand, are rarely used as the CPU in “computers system”. Instead, they are employed as the central component in control-oriented designs. There is limited memory and there is no disk drive or disk operating system. The control program must reside in ROM. For this reason, the 8052 implement a separate memory space for programs (code) and data. Both the code and data may be internal: however both can be extended to using external components to maximum of 64K code memory and 64K data memory. The internal memory consists of on-chip ROM and on-chip data RAM. The onchip RAM contains a rich arrangement of general-purpose storage, bit addressable storage, register banks, and special function registers.
Two important features are: (a) The registers and input/output ports are memory mapped and accessible like any other memory location. (b) The stack resides within the internal RAM, rather than in external RAM as typical for microprocessors. The 8052 have 8Kbytes of In-system reprogrammable memory and 256 x 8 bit internal RAM. 11 Microcontroller based SCADA System Using GSM
Chapter 2
2.4
MICROCONTROLLER AT80C51
PINS CONFIGURATION AND DESCRIPTION
Fig 2.1 Pins Configuration
A brief description of pins & memory organization is given to make the understanding of microcontroller more easy and quick.
12 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
ACC (Accumulator) SFR Address: E0h (224 decimal) Bit-Addressable: Yes Description: Accumulator working register
Explanation: The Accumulator (ACC) is the 8052's primary working register. It is used to temporarily hold values as they are manipulated or moved between other registers. When used within assembly language instructions, the Accumulator is referred to as simply "A". However, when it is referred to as an SFR (such as in the POP and PUSH instructions), it is referred to as "ACC". B (Auxillary Register) SFR Address: F0h (240 decimal) Bit-Addressable: Yes Description: Auxillary Working Register
Explanation: The 'B' Register (B) is the 8052's auxillary working register. It is used to temporarily hold values as they are manipulated or moved between other registers, and to perform 16-bit division and multiplication along with the Accumulator . "R" Registers SFR Address: 00h - 1Fh (0 through 31 decimal) Bit-Addressable: No Description: Register Banks
Explanation: The "R" registers, or register banks, are the eight registers named R0 through R7. These registers are used in many operations. The "R" registers are really aliases for locations in Internal RAM. When the microcontroller is reset, by default R0-R7 refer to Internal RAM address 00h through 07h. By changing the values of RS0 and RS1 , however, alternate register banks may be selected which cause R0-R7 to refer to either 08h-0Fh, 10h-17h, or 18h-1Fh.
13 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
PSW (Program Status Word) SFR Address: D0h (208 decimal) Bit-Addressable: Yes Description: Power Status Word
Explanation: CY: Carry Flag. This bit is set by a number of instructions, such as mathematical functions such as ADD, ADDC, SUBB, MUL, DIV, and many others such as the RLC and RRC instructions. Review the documentation on each individual instruction to determine the exact conditions under which the Carry bit is set or cleared. However, when used as a mathematical carry, it is set when there is a carry out of bit 7 during an add, or when there was a borrow into the 7th bit during a subtraction. AC: Auxillary Carry. This bit is set when adding two binary coded decimal values (BCD), and there was a carry out of bit 3 to bit 4, or if the lower nibble of the result is in the range of 0Ah to 0Fh (10 through 15 decimal). When adding BCD values, the AC bit means the program must execute a DA instruction to obtain the correct BCD answer. F0: Flag 0. This bit is not used by the microcontroller, and the programmer may use it for his/her own purposes. RS1/RS0: Register Bank Select. The two bits RS1 and RS0 are used to select the active register bank. RS1 0 0 1 1
RS0 0 1 0 1
REG BANK IRAM ADDRESS 0 00h - 07h 1 08h - 0Fh 2 10h - 17h 3 18h - 1Fh
The Active Register Bank determines which group of Internal RAM addresses are used for the 'R' Registers (R0 through R7). The default is Register Bank 0, which means that R0 is Internal RAM address 00h, R1 is Internal RAM address 01h, etc. If Register Bank 2 is selected, R0 is Internal RAM address 10h, R1 is Internal RAM address 11h, etc. OV: Overflow Flag. This bit is set by a number of instructions, but is particularly valuable with the ADD and SUBB instructions, which set this bit when a mathematical 14 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
operation resulted in an overflow, treating both bytes in the operation as signed integers. For example, adding the values 90 and 90 result in 180, which is a negative number when the result is treated as a signed integer. This will cause the Overflow flag to be set. P: Parity Bit. The parity bit is set or cleared whenever the Accumulator (ACC) is modified, such that this bit establishes even parity with the Accumulator. The number of bits set in the Accumulator plus the value of the Parity bit is always even. For example, if the accumulator contains the value 15h (binary 00010101), the number of bits set in the Accumulator is odd (3). Thus the Parity bit will be set so that the total number of bits set is even. Input/Output SFRs P0 P1 P2 P3
- Port 0 - Port 1 - Port 2 - Port 3
P0 (Port 0) SFR Address: 80h (128 decimal) Bit-Addressable: Yes Description: I/O Port 0
Explanation: ADx: Address/Data Line. All lines of P0 may be used by the developer for I/O lines if the project does not require external RAM or ROM. However, if the project uses external RAM or RAM, P0 is used to communicate with such external memory. P0 is used in conjunction with P2 and an external latch to send the 16-bit address of external RAM or ROM that is to be accessed, and to send or receive the data itself. P0 holds the low 8 bits of the 16-bit address, and sends/receives the data. A full explanation of how the address and data bytes are latched is beyond the scope of this help file. P1 (Port 1) SFR Address: 90h (144 decimal) Bit-Addressable: Yes Description: I/O Port 1
Explanation: 15 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
Port 1 is completely available, in its entirety, for the developer's own use as I/O lines.
P2 (Port 2) SFR Address: A0h (160 decimal) Bit-Addressable: Yes Description: I/O Port 2
Explanation: Ax: Address Line. All lines of P2 may be used by the developer for I/O lines if the project does not require external RAM or ROM. However, if the project uses external RAM or RAM, P2 is used to communicate with such external memory. P2 is used in conjunction with P0 and an external latch to send the 16-bit address of external RAM or ROM that is to be accessed, and to send or receive the data itself. P2 holds the high 8 bits of the 16-bit address. A full explanation of how the address and data bytes are latched is beyond the scope of this help file. P3 (Port 3) SFR Address: B0h (176 decimal) Bit-Addressable: Yes Description: I/O Port 3
Explanation: RD: External RAM Read. The RD line is used in order to instruct attached Extenal RAM to read the address specified on lines AD0-AD15 (P0). When RD pulses low, the data stored in the External RAM address held on AD0-AD15 will be read. When External RAM is present, this line is controlled automatically by the microcontroller when the MOVX instruction is used. If External RAM is not present, the developer may use this line for his/her own use. WR:External RAM Write. WR functions as RD, but WR instructs the attached External RAM to write the data held on AD0-AD7 to the address specified on lines AD0-AD15. When WR pulses low, the data stored on the AD0-AD7 lines is written to the External RAM address held on AD0-AD15. When External RAM is present, this line is controlled automatically by the microcontroller when the MOVX instruction is used. If External RAM is not present, the developer may use this line for his/her own use. 16 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
T1: Timer 1 External Input. When Timer 1 is in Event Counting mode (TMOD.6 = 1), a 1-0 transition on this line will cause Timer 1 to be incremented. If Timer 1 is not in event counting mode, the developer may use this line for his/her own use. T0: Timer 0 External Input. When Timer 0 is in Event Counting mode (TMOD.2 = 1), a 1-0 transition on this line will cause Timer 0 to be incremented. If Timer 0 is not in event counting mode, the developer may use this line for his/her own use. INT1: External Interrupt 1. When Timer 1 is in gated mode (TMOD.7 = 1), Timer 1 may only run when INT1 is high. If External Interrupts are enabled and IT1 is set, a 1-0 transition on INT1 will cause an External 1 Interrupt. If External Interrupts are enabled and IT1 is cleared, a low level on this line will cause an External 1 Interrupt. If none of these functions are used, the developer may use this line for his/her own use. INT0: External Interrupt 0. When Timer 0 is in gated mode (TMOD.3 = 1), Timer 0 may only run when INT0 is high. If External Interrupts are enabled and IT0 is set, a 1-0 transition on INT0 will cause an External 0 Interrupt. If External Interrupts are enabled and IT0 is cleared, a low level on this line will cause an External 0 Interrupt. If none of these functions are used, the developer may use this line for his/her own use. TXD: UART Transmit Data. When the program uses the on-board serial port, data transmitted is sent via TXD. When the serial port is not used, the developer may use this line for his/her own use. RXD: UART Receive Data. When the program uses the on-board serial port, data is received via this line. When the serial port is not used, the developer may use this line for his/her own use.
TCON (Timer Control) SFR Address: 88h (136 decimal) Bit-Addressable: Yes Description: Timer Control
Explanation: TF1: Timer 1 Overflow. This bit is automatically set by the microcontroller when Timer 1 overflows. When enabled, this bit also triggers Timer 1 Interrupt. The bit is automatically cleared when the interrupt is triggered, or it may be cleared by the program if the interrupt is not enabled. TR1: Timer 1 Run. 17 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
This bit controls whether or not Timer 1 is currently running. Set this bit to run Timer 1. TF0: Timer 0 Overflow. This bit is automatically set by the microcontroller when Timer 0 overflows. When enabled, this bit also triggers Timer 0 Interrupt. The bit is automatically cleared when the interrupt is triggered, or it may be cleared by the program if the interrupt is not enabled. TR0: Timer 0 Run. This bit controls whether or not Timer 9 is currently running. Set this bit to run Timer 0. IE1: External Interrupt 1. This bit is set by the microcontroller to indicate an External Interrupt 1 condition. This is either triggered on a 1-0 transition of INT1 (P3.3), or whenever INT1 is low, depending on the configuration of IT1. When enabled, setting this bit will trigger an External 1 Interrupt. This bit is cleared automatically when an interrupt is triggered, or it may be cleared by the program if the interrupt is not enabled. IT1: External Interrupt 1 Type. This bit is used to configure whether External 1 Interrupt will be triggered on a 1-0 transition or low-level condition on INT1. If set, an External 1 Interrupt will be triggered on a 1-0 transition on INT1. If clear, an External 1 Interrupt will be triggered continuously as long as INT1 is low. IE0: External Interrupt 0. This bit is set by the microcontroller to indicate an External Interrupt 0 condition. This is either triggered on a 1-0 transition of INT0 (P3.2), or whenever INT0 is low, depending on the configuration of IT0. When enabled, setting this bit will trigger an External 0 Interrupt. This bit is cleared automatically when an interrupt is triggered, or it may be cleared by the program if the interrupt is not enabled. IT0: External Interrupt 0 Type. This bit is used to configure whether External 0 Interrupt will be triggered on a 1-0 transition or low-level condition on INT0. If set, an External 0 Interrupt will be triggered on a 1-0 transition on INT0. If clear, an External 0 Interrupt will be triggered continuously as long as INT0 is low. T2CON (Timer 2 Control) (On 8052 models only) SFR Address: C8h (200 decimal) Bit-Addressable: Yes Description: Timer 2 Control Explanation:
18 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
TF2: Timer 2 Overflow. This bit is automatically set by the microcontroller when Timer 2 overflows, unless TCLK or RCLK is set. If enabled, setting this bit will trigger a Timer 2 Interrupt. This bit must be cleared by software. This bit is not cleared automatically when a Timer 2 Interrupt is triggered. EXF2: Timer 2 External Flag. Set when a capture or reload is caused by a 1-0 transition on T2EX and EXEN2 is set. If enabled, setting this bit will trigger a Timer 2 Interrupt. This bit must be cleared by software. This bit is not cleared automatically when a Timer 2 Interrupt is triggered. RCLK: Receive Clock. When this bit is set, the overflow rate of Timer 2 is used to calculate the serial port receive baud rate in serial modes which use a timer for baud rate calculation; otherwise, Timer 1 is used. TCLK: Transmit Clock. When this bit is set, the overflow rate of Timer 2 is used to calculate the serial port transmit baud rate in serial modes which use a timer for baud rate calculation; otherwise, Timer 1 is used. EXEN2: Timer 2 External Enable. When this bit is set, Timer 2 capture or reload occurs automatically on a 1-0 transition of T2EX . When this occurs, the bit EXF2 will be set, which will provoke a Timer 2 Interrupt if interrupts are enabled. TR2: Timer 2 Run. When this bit is set, Timer 2 will run. When clear, Timer 2 is suspended. C/T2: Timer 2 Counter/Timer Mode. When this bit is clear, Timer 2 operates as an interval timer, incrementing by 1 every machine cycle that it is enabled. When this bit is set, Timer 2 will be incremented every time a 1-0 transition is detected on the T2 line (assuming Timer 2 is enabled). CP/RL2C: Timer 2 Capture/Reload. When this bit is clear, Timer 2 will automatically be reloaded with the value contained in RCAP2H/RCAP2L whenever it overflows. When this bit is set, if EXEN2 is also set, a 1-0 transition on T2EX will capture the current value of TH2/TL2 into RCAP2H/RCAP2L.
TMOD (Timer Mode) SFR Address: 89h (137 decimal) Bit-Addressable: No Description: Timer Mode 19 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
Explanation: GATEx: Timer X Gate Bit. When this bit is set, the corresponding timer will only run if INTX is high. That is to say, if Timer 1's GATE bit is set, Timer 1 will only run when INT1 is high. If Timer 0's GATE bit is set, Timer 0 will only run when INT0 is high. C/Tx: Counter/Timer. When this bit is clear, the corresponding timer will run whenever the corresponding TRx bit is set, incrementing once per machine cycle. When this bit is set, the corresponding timer will be incremented on each 1-0 transition on Tx, but only when the TRx bit is set. M1/M0: Timer mode. Bits M1 and M0 determine the operating mode of the corresponding timer, according to the following table: M1 0 0 1 1
M0 0 1 0 1
MODE DESCRIPTION 0 13-bit Timer 1 16-bit Timer 2 8-bit Auto-Reload 3 Split Timer
13-bit Timer (Mode 0): This mode exists primarily for backwards compatability with the 8051's predecessor, the 8048, and is generally not used in new project. In this mode, the timer will increment using only 13-bits of THx and TLx. TLx is incremented each machine cycle, but when TLx is incremented to the value 20h, it is reset to 00h and THx is incremented. Thus only 13 bits of precision are used. 16-bit Timer (Mode 1): This mode is the same as Mode 0, but the full 16 bits of THx and TLx are used. TLx is incremented once every machine cycle, and when it overflows from FFh to 00h, THx is incremented by one. The timer is considered to have "overflowed" when THx is incremented from FFh back to 00h.
8-bit Auto-Reload (Mode 2): In this mode, TLx operates as an 8-bit timer. When the 8-bit value in TLx overflows (is incremented from FFh), instead of resetting to 00h it is reloaded with the value contained in THx. This is useful since the reload is automatic and requires no software intervention once it is initialized. This is often 20 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
used to generate baud rates since, once initialized, the overflow occurs at a constant rate without any additional overhead. Split Timer (Mode 3): In this mode, Timer 0 is split into two 8-bit timers. Effectively, TL0 becomes Timer 0 and TH0 becomes Timer 1. Thus when TH0 overflows, TF1 will be set and corresponding Timer 1 interrupts will be triggered. However, placing Timer 1 into Split Timer mode will cause the real timer 1 (TH1/TL1) to stop. However, Timer 1 may be used for baud rate generation (in auto-reload mode) or any other purpose that does not require interrupts. TH0 (Timer 0 High) SFR Address: 8Ch (140 decimal) Bit-Addressable: No Description: Timer 0 High Byte Explanation: This SFR is used in conjunction with TL0 to form Timer 0. Timer 0, as a whole, may contain a 13-bit value, a 16-bit value, an 8-bit timer and 8-bit reload value, or two independent 8-bit timers, depending on the configuration of TMOD . TL0 (Timer 0 Low) SFR Address: 8Ah (138 decimal) Bit-Addressable: No Description: Timer 0 Low Byte Explanation: This SFR is used in conjunction with TH0 to form Timer 0. Timer 0, as a whole, may contain a 13-bit value, a 16-bit value, an 8-bit timer and 8-bit reload value, or two independent 8-bit timers, depending on the configuration of TMOD . TH1 (Timer 1 High) SFR Address: 8Dh (141 decimal) Bit-Addressable: No Description: Timer 1 High Byte Explanation: This SFR is used in conjunction with TL1 to form Timer 1. Timer 1, as a whole, may contain a 13-bit value, a 16-bit value, an 8-bit timer and 8-bit reload value, or two independent 8-bit timers, depending on the configuration of TMOD . TL1 (Timer 1 Low) SFR Address: 8Bh (139 decimal) Bit-Addressable: No Description: Timer 1 Low Byte Explanation: This SFR is used in conjunction with TH1 to form Timer 1. Timer 1, as a whole, may contain a 13-bit value, a 16-bit value, an 8-bit timer and 8-bit reload value, or two independent 8-bit timers, depending on the configuration of TMOD . 21 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
TH2 (Timer 2 High) SFR Address: CDh (205 decimal) Bit-Addressable: No Description: Timer 2 High Byte Explanation: This SFR is used in conjunction with TL2 to form Timer 2. The operation of Timer 2 depends on the configuration of RCAP2L, RCAP2H, and T2CON . TL2 (Timer 2 Low) SFR Address: CCh (204 decimal) Bit-Addressable: No Description: Timer 2 Low Byte Explanation: This SFR is used in conjunction with TH2 to form Timer 2. The operation of Timer 2 depends on the configuration of RCAP2L, RCAP2H, and T2CON .
RCAP2H (Timer 2 Reload/Capture) SFR Address: CBh (203 decimal) Bit-Addressable: No Description: Timer 2 Reload/Capture High Explanation: This SFR is used in conjunction with RCAP2L to form the Reload/Capture register for Timer 2. The operation of Timer 2 depends on the configuration of T2CON . RCAP2L (Timer 2 Reload/Capture) SFR Address: CAh (202 decimal) Bit-Addressable: No Description: Timer 2 Reload/Capture Low Explanation: This SFR is used in conjunction with RCAP2H to form the Reload/Capture register for Timer 2. The operation of Timer 2 depends on the configuration of T2CON . RCAP2H (Timer 2 Reload/Capture) SFR Address: CBh (203 decimal) Bit-Addressable: No Description: Timer 2 Reload/Capture High Explanation: This SFR is used in conjunction with RCAP2L to form the Reload/Capture register for Timer 2. The operation of Timer 2 depends on the configuration of T2CON .
IE (Interrupt Enable) SFR Address: A8h (168 decimal) Bit-Addressable: Yes Description: Interrupt Enable 22 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
Explanation: EA: Global Enable (Enable All). This bit must be set in order for any interrupt to be enabled. This is a "master switch" for all interrupts. For example, to enable Timer 0 interrupt, the ET0 bit must be set as well as EA. If you have a number of interrupts enabled, this is a convenient way to temporarily turn all of them off and later back on.
IP (Interrupt Priority) SFR Address: B8h (184 decimal) Bit-Addressable: Yes Description: Interrupt Priority
Explanation:
PT2: Timer 2 Interrupt Priority.
0=Low Priority, 1=High Priority.
PS: Serial Interrupt Priority.
0=Low Priority, 1=High Priority.
PT1: Timer 1 Interrupt Priority.
0=Low Priority, 1=High Priority.
PX1: External 1 Interrupt Priority. 0=Low Priority, 1=High Priority. PT0: Timer 0 Interrupt Priority.
0=Low Priority, 1=High Priority.
PX0: External 0 Interrupt Priority. 0=Low Priority, 1=High Priority.
Ground: 0V reference. Power Supply: This is the power supply voltage for normal, idle, and power-down operation.
23 Microcontroller based SCADA System Using GSM
Chapter 2
2.5
MICROCONTROLLER AT80C51
LOGICAL INTERNAL DIAGRAM
Fig 2.2 Logical Internal Diagram
24 Microcontroller based SCADA System Using GSM
Chapter 2
MICROCONTROLLER AT80C51
25 Microcontroller based SCADA System Using GSM
Chapter 3
SERIAL PORT
SERIAL PORT
Microcontroller based SCADA System Using GSM
26
Chapter 3
SERIAL PORT
3.1 INTRODUCTION
Serial communication is the most common low-level protocol for communicating between two or more devices. Normally, one device is a computer, while the other device can be a modem, a printer, another computer, or a scientific instrument such as an oscilloscope or a function generator or a motor. As the name suggests, the serial port sends and receives bytes of information in a serial fashion -- one bit at a time. These bytes are transmitted using either a binary format or a text (ASCII) format.
3.2 SERIAL PORT INTERFACE STANDARDS
Over the years, several serial port interface standards for connecting computers to peripheral devices have been developed. These standards include RS-232, RS-422, and RS-485 -- all of which are supported by the serial port object. Of these, the most widely used standard is RS-232, which stands for Recommended Standard number 232. The current version of this standard is designated as TIA/EIA-232C, which is published by the Telecommunications Industry Association. However, the term "RS-232" is still in popular use, and is used in this report when referring to a serial communication port that follows the TIA/EIA-232 standard.
Microcontroller based SCADA System Using GSM
27
Chapter 3
SERIAL PORT
RS-232 defines these serial port characteristics: •
The maximum bit transfer rate and cable length
•
The names, electrical characteristics, and functions of signals
•
The mechanical connections and pin assignments.
Primary communication is accomplished using three pins: 1.
Transmit Data pin,
2.
Receive Data pin,
3.
Ground pin.
Other pins are available for data flow control, but are not required.
3.3
CONNECTING TWO DEVICES WITH SERIAL PORT
The RS-232 standard defines the two devices connected with a serial cable as the Data Terminal Equipment (DTE) and Data Circuit-Terminating Equipment (DCE). This terminology reflects the RS-232 origin as a standard for communication between a computer terminal and a modem. Throughout this guide, our computer is considered a DTE, while peripheral devices such as modems and printers are considered DCEs. Note that many scientific instruments function as DTEs. Because RS-232 mainly involves connecting a DTE to a DCE, the pin assignments are defined such that straight-through cabling is used, where pin 1 is connected to pin 1, pin 2 is connected to pin 2, and so on. A DTE to DCE serial
Microcontroller based SCADA System Using GSM
28
Chapter 3
SERIAL PORT
connection using the transmit data (TD) pin and the receive data (RD) pin is shown below.
Fig 3.1 DTE & DCE
3.4 SIGNALS AND PIN ASSIGNMENTS
Serial ports consist of two signal types: data signals and control signals. To support these signal types, as well as the signal ground, the RS-232 standard defines a 25pin connection. However, most PC's and UNIX platforms use a 9-pin connection. In fact, only three pins are required for serial port communications:
1.
One for receiving data,
2.
One for transmitting data, and
3.
One for the signal ground.
The pin assignment scheme for a 9-pin male connector on a DTE is given below.
Microcontroller based SCADA System Using GSM
29
Chapter 3
SERIAL PORT
Fig 3.2 Pins Assignment Scheme The pins and signals associated with the 9-pin connector are described below. Refer to the RS-232 standard for a description of the signals and pin assignments used for a 25-pin connector.
Pin
Label
Signal Name
Signal Type
1
CD
Carrier Detect
Control
2
RD
Received Data
Data
3
TD
Transmitted Data
Data
4
DTR
Data Terminal Ready Control
5
GND
Signal Ground
Ground
6
DSR
Data Set Ready
Control
7
RTS
Request to Send
Control
8
CTS
Clear to Send
Control
9
RI
Ring Indicator
Control
Table 3.1 Pins & Signal Assignment
Microcontroller based SCADA System Using GSM
30
Chapter 3
SERIAL PORT
The term "data set" is synonymous with "modem" or "device," while the term "data terminal" is synonymous with "computer."
3.4.1 SCON (Serial Control) SFR Address: 98h (152 decimal) Bit-Addressable: Description:
Yes
Serial Port Control
SM0/SM1: Serial Port Mode. The two bits SM0 and SM1 define the serial port mode in which the serial port will operate. SM0
SM1
SER. MODE DESCRIPTION
BAUD
0
0
0
Shift Register Oscillator / 12
0
1
1
8-bit UART
Set by timer
1
0
2
9-bit UART
Oscillator / 32 or /64
1
1
3
9-bit UART
Set by timer
Mode 0: Shift Register (Oscillator / 12). Serial send/receive occurs on RXD (P3.0), while TXD (P3.1) is the clock line. The TXD line alternates between high and low
Microcontroller based SCADA System Using GSM
31
Chapter 3
SERIAL PORT
for each bit output on RXD. On reception, the microcontroller expects one bit of input on RXD for each TXD line pulse.
Mode 1: 8-bit UART (Timer-Based). Serial output is transmitted on TXD (P3.1) and received on RXD (P3.0). Data consists of 10-bit words, a start bit which is always 0, the 8 data bits starting with the least-significant-bit, and a stop bit which is always 1. The baud rate is based on the overflow rate of Timer 1 (on an 8052, it may be based on either Timer 1 or Timer 2).
Mode 2: 9-bit UART (Oscillator / 32 or /64). Serial output is transmitted on TXD (P3.1) and received on RXD (P3.0). Data consists of 11-bit words, a start bit which is always 0, the 8 data bits starting with the least-significant-bit, a programmable ninth bit, and a stop bit which is always 1. When transmitting, the ninth bit is whatever TB8 contains. On reception, the ninth bit received is placed in RB8. The baud rate is 1/32nd of the oscillator frequence (1/64th if the SMOD bit is set).
Mode 3: 9-bit UART (Timer-Based). Same as mode 2, but the baud rate is based on the overflow rate of Timer 1 (or, optionally, Timer 2 on an 8052).
SM2: Multiprocessor Communications. When set, the serial port operates in multiprocessor mode when in Serial Mode 2 or 3. In this mode, data will only be received in SBUF if the ninth data bit received is set. If the ninth bit is not set, the data will be disregarded and the RI bit will not be set.
Microcontroller based SCADA System Using GSM
32
Chapter 3
SERIAL PORT
REN: Receive Enable. This bit must be set to receive data via the serial port. If this bit is not set, data will not be received in SBUF, nor will the RI bit be set.
TB8: Transmit Bit 8. When in Serial Modes 2 and 3, this bit will become the ninth bit whenever a byte is transmitted via the serial port.
RB8: Receive Bit 8. When in Serial Modes 2 and 3, this bit will hold the ninth bit that was received (i.e., the bit immediately following the 8 bits of the data byte).
TI: Transmit Interrupt. This bit is set when a character has been completely sent by the UART. Sending a character via the UART is not immediate. At 1200 baud, it takes .0083 seconds to transmite a character. The TI bit is set after this time period has transpired, indicating that the program may send the next serial character. This bit should be cleared by the program before sending a byte to the serial port. If so configured, a Serial Interrupt will be trigerred when this bit is set.
RI: Receive Interrupt. This bit is set when a character has been completely received by the UART. When this bit is set, the program may read the value of SBUF to obtain the value of the byte received. If in modes 2 or 3, the RB8 bit will hold the value of the ninth bit received. This bit should be cleared by the program as soon as it
Microcontroller based SCADA System Using GSM
33
Chapter 3
SERIAL PORT
has read the value of SBUF. If so configured, a Serial Interrupt will be trigerred when this bit is set.
Most serial port devices support full-duplex communication meaning that they can send and receive data at the same time. Therefore, separate pins are used for transmitting and receiving data. For these devices, the TD, RD, and GND pins are used. However, some types of serial port devices support only one-way or half-duplex communications. For these devices, only the TD and GND pins are used. In this guide, it is assumed that a full-duplex serial port is connected to your device. The TD pin carries data transmitted by a DTE to a DCE. The RD pin carries data that is received by a DTE from a DCE.
3.4.2 PCON (Power Control) SFR Address: 87h (135 decimal) Bit-Addressable: Description:
No
Power Control Register
SMOD:Double Baud Rate. SMOD, when set, will cause the serial port baud rate to be doubled when timer 1 is being used to determine the port's baud rate (i.e., serial port modes 1, 2, and 3).
Microcontroller based SCADA System Using GSM
34
Chapter 3
SERIAL PORT
GF1: General Purpose Flag bit 1. This bit is not used by the microcontroller, and the programmer may use it for his/her own purposes.
GF0: General Purpose Flag bit 0. This bit is not used by the microcontroller, and the programmer may use it for his/her own purposes.
PD: Power Down bit. This bit, when set, activates the microcontroller's power-down mode. In power-down mode, the microcontroller stops executing code immediately. Port output latches will remain as they were. The microcontroller must be reset to exit power-down mode.
IDL: Idle Bit. This bit, when set, activates the microcontroller's idle mode. When activated, the microcontroller immediately suspends the program. The only operations that continue during idle mode are serial port input/output, interrupts, and the timers. Idle mode may be exited by an active interrupt being triggered or a reset of the microcontroller, both of which clear the IDL bit.
3.4.3 SBUF (Serial Buffer) SFR Address: 99h (153 decimal) Bit-Addressable: Description:
No
Serial Input/Output Buffer
Microcontroller based SCADA System Using GSM
35
Chapter 3
SERIAL PORT
The SBUF SFR is used to obtain data that has been received from the serial port, or to transmit data to the serial port. To transmit or receive data using this SFR, the serial port must first be correctly configured using the SCON SFR as well as the necessary timers (if the serial mode requires timers to set the baud rate).
The SBUF register The SBUF register is used both to transmit data via the serial port as well as to read data that has been received from it. Essentially, when an instruction reads the value from SBUF, it is reading the last data byte received from the serial port. When an instruction writes a value to SBUF, it is transmitting a data byte out the serial port.
Transmission Data may be transmitted via the serial port by simply moving the value into the SBUF register. The microcontroller will automatically send the data out the serial port, and set the TI Serial bit once the transmission process has been complete. The program should not move a second character to SBUF until the TI bit has been set--doing so will result in garbled data being sent on TXD, or no data at all. When using instructions such as INC or DEC with the SBUF SFR, the original value will be based on the last byte transmitted. That is to say, if you move the value 10h into SBUF, then receive the value 30h, then INCrement the value of SBUF, the value that will be transmitted is 11h--not 31h.
Microcontroller based SCADA System Using GSM
36
Chapter 3
SERIAL PORT
When in serial modes 2 or 3 (see information regarding serial modes in SCON), the byte moved to SBUF will be transmitted, followed by the bit held in TB8.
Reception The data that is received by the serial port is automatically placed in SBUF. Once an entire data byte has been received and stored in SBUF, the microcontroller will set the RI bit. Reading the SBUF register before the RI bit has been set will normally result in invalid data. Note that for reception to occur via the serial port, the REN bit must be set. If the REN bit is not set, no data will be received in SBUF nor will the RI bit be set. Setting the REN bit is normally done at the beginning of a program as part of the serial port configuration.
3.5
SERIAL DATA FORMAT
The serial data format includes one start bit, between five and eight data bits, and one stop bit. A parity bit and an additional stop bit might be included in the format as well. The diagram below illustrates the serial data format.
Fig 3.3 Serial Data Format
Microcontroller based SCADA System Using GSM
37
Chapter 3
SERIAL PORT
The format for serial port data is often expressed using the following notation: Number of data bits - parity type - number of stop bits
For example, 8-N-1 is interpreted as eight data bits, no parity bit, and one stop bit, while 7-E-2 is interpreted as seven data bits, even parity, and two stop bits. The data bits are often referred to as a character because these bits usually represent an ASCII character. The remaining bits are called framing bits because they frame the data bits.
3.6
SYNCHRONOUS & ASYNCHRONOUS CONNECTIONS
The RS-232 standard supports two types of communication protocols: synchronous and asynchronous. Using the synchronous protocol, all transmitted bits are synchronized to a common clock signal. The two devices initially synchronize themselves to each other, and then continually send characters to stay synchronized. Even when actual data is not really being sent, a constant flow of bits allows each device to know where the other is at any given time. That is, each bit that is sent is either actual data or an idle character. Synchronous communications allows faster data transfer rates than asynchronous methods, because additional bits to mark the beginning and end of each data byte are not required.
Microcontroller based SCADA System Using GSM
38
Chapter 3
SERIAL PORT
Using the asynchronous protocol, each device uses its own internal clock resulting in bytes that are transferred at arbitrary times. So, instead of using time as a way to synchronize the bits, the data format is used. In particular, the data transmission is synchronized using the start bit of the word, while one or more stop bits indicate the end of the word. The requirement to send these additional bits causes asynchronous communications to be slightly slower than synchronous. However, it has the advantage that the processor does not have to deal with the additional idle characters. Most serial ports operate asynchronously.
3.7
HOW ARE THE BITS TRANSMITTD?
By definition, serial data is transmitted one bit at a time. The order in which the bits are transmitted follows these steps: 1.
The start bit is transmitted with a value of 0.
2.
The data bits are transmitted. The first data bit corresponds to the least significant bit (LSB), while the last data bit corresponds to the most significant bit (MSB).
3.
The parity bit (if defined) is transmitted.
4.
One or two stop bits are transmitted, each with a value of 1.
The number of bits transferred per second is given by the baud rate. The transferred bits include the start bit, the data bits, the parity bit (if defined), and the stop bits.
Microcontroller based SCADA System Using GSM
39
Chapter 3
SERIAL PORT
3.7.1 START AND STOP BITS
As described in Synchronous and Asynchronous Communication, most serial ports operate asynchronously. This means that the transmitted byte must be identified by start and stop bits. The start bit indicates when the data byte is about to begin and the stop bit(s) indicates when the data byte has been transferred. The process of identifying bytes with the serial data format follows these steps: 1.
When a serial port pin is idle (not transmitting data), then it is in an "on" state.
2.
When data is about to be transmitted, the serial port pin switches to an "off" state due to the start bit.
3.
The serial port pin switches back to an "on" state due to the stop bit(s). This indicates the end of the byte.
3.7.2 DATA BITS
The data bits transferred through a serial port might represent device commands, sensor readings, error messages, and so on. The data can be transferred as either binary data or as text (ASCII) data.
3.7.3 THE PARITY BIT
Microcontroller based SCADA System Using GSM
40
Chapter 3
SERIAL PORT
The parity bit provides simple error (parity) checking for the transmitted data. The types of parity checking are given below. Parity is important to detect any kind of encryption in data sent by the transceiver end and from communication medium. The table shows the detail about parity bit:
Parity Type
Description
Even
The data bits plus the parity bit produce an even number of 1's.
Mark
The parity bit is always 1.
Odd
The data bits plus the parity bit produce an odd number of 1's.
Space
The parity bit is always 0.
Table 3.2 Parity Bits Mark and space parity checking are seldom used because they offer minimal error detection. We might choose not to use parity checking at all.
3.8
CREATING A SERIAL PORT OBJECT
You create a serial port object with the serial function. Serial requires the name of the serial port connected to your device as an input argument. As described in Configuring Property Values, we can also configure property values during object creation. Each serial port object is associated with one serial port. For example, to create a serial port object associated with the COM1 port: s = serial ('com1');
Microcontroller based SCADA System Using GSM
41
Chapter 3
SERIAL PORT
The important thing which should be considered is the baud rate. In our project we have adjusted baud rate to the standard used internationally by serial port programmers and is used as a default setting to internationally recognized computer boards manufacturing companies. Baud rate is set to 9600 bps. We can manually assign any baud rate to the serial port.
Microcontroller based SCADA System Using GSM
42
Chapter 4
System Design Flow
SYSTEM DESIGN FLOW
Microcontroller based SCADA System Using GSM
43
Chapter 4
4.1
System Design Flow
MICROCONTROLLER INTERFACING
Some of the basics about Microcontroller based SCADA System Using GSM and the main theme had been made clear in the first chapter “INTRODUCTION” with some of Project Description and with Project block diagram. The detailed hardware interfacing and process data flow structure will be discuss here. Both microcontrollers 8052 are interfaced serially with the controlling computer via MAX232. The input sensor is connected to the I/O port 2 for our transmitter module and with input side microcontroller and the driven output to mobile is connected in serial with microcontroller. We have discussed Input side circuitry, Output side circuitry, Serial port circuitry in detail below; All the digital inputs being used here are provided to the microcontroller port 0 & 2 via Optical Couplers. This is done because we want to provide electric isolation to the circuit from any external high voltage that might accidentally enter. The interfacing circuitry of Sensors and Physical Control Panel is given as under
Microcontroller based SCADA System Using GSM
44
Chapter 4
4.2
System Design Flow
TRANSMITTER MODULE
On the transmitter side microcontrollers is serially interfaced with the personal computer and mobile phone , which acquires the real time value of temperature of a system and performs the signal conditioning and then compare the temperature and generates an SMS and sends it to the specified SIM (subscriber’s Identification Module).It also connects to the serial port of PC and the real time temperature value is also displayed on the computer using the Hyper terminal. The microcontroller gets the input from an ADC0831 on the Input side , receives whose pin 2 is connected to the analog output of temperature sensor LM35DZ and then to microcontroller on pins 2.0, 2.1, 2.2 (21,22,23), here we use EA (pin 31)which is low enable ,this is tied to the Vcc so that the 8051 executes the program from the internal memory as our program is stored in the microcontroller as we r not using an external Rom. And finally pin P3.1 i.e. TXD & Pin 3.7 i.e. RD low enable is connected to the De-Multiplexer SN74HC138N at pins 5 i.e. G2A and 1A (enable) . De-Multiplexer SN74HC138N then is connected to MAX 232 at pins 10 i.e. T2in and pin 11 T1in for transferring serial data to the personal computer by using DB9 pins 2 and 3 to MAX 232 pins 7 i.e. T2out and GND. To send data to Mobile DB9 Male Pins 2 and 3 are connected to MAX232 at pins 14 i.e. T1out and ground.
Microcontroller based SCADA System Using GSM
45
Chapter 4
4.3
System Design Flow
SCHEMATIC DIAGRAM
Fig 4.1 Schematic Diagram
4.4
RECEIVER MODULE
Receiver Module acquire the data through the mobile inbox through DB9 pins 2 and pin3 connected to Max 232 pin 8 i.e. R2 in and Pin 13 R1in. Then data is sent to the microcontroller at Pin 10 i.e. RDX which is connected to MAX 232 at Pin 9 i.e. R2Outand Pin 11 i.e. TXD connected to MAX232 Pin 10 i.e. T2in. Data is serially transferred from the Mobile into the SBUF using AT commands, then the SIM number is compared Authenticate the user . Microcontroller based SCADA System Using GSM
46
Chapter 4
System Design Flow
Then Microcontroller is programmed to compare the Message sent through SMS as ON or OFF by comparing its ASCII value. If the SMS is ON then microcontroller set the Pin 24 . P2.3 of microcontroller and if the SMS is OFF then it clears this pin.Pin 2.3 is derived to Control the respective devices.
4.5 USING HYPERTTERMINAL The RS-232 Com (Setup) port to a computer using a one to one pinned DB9 serial cable. This cable has a DB9 male on one end and a DB9 female on the other end. Do not try to use a null modem cable with gender changers to get the “correct” pin configuration. A null modem cable reverses transmit and receive lines and therefore will not work in this application. To allow communication the computer must be running a terminal emulation program such as HyperTerminal. HyperTerminal is included with Windows 95/98/NT/ME/2000/XP computers.
To start a HyperTerminal session left click on the START button and follow the path of Programs\Accessories\Communications\ HyperTerminal as shown in Figure 4.2
Microcontroller based SCADA System Using GSM
47
Chapter 4
System Design Flow
Fig 4.2 Selecting Hyper Terminal
Microcontroller based SCADA System Using GSM
48
Chapter 4
System Design Flow
Double click on HyperTerminal. We will then be prompted to name the HyperTerminal session and
Fig 4.3 Naming Hyper Terminal Session
Microcontroller based SCADA System Using GSM
49
Chapter 4
System Design Flow
On the Connect To screen skip past the Country/region, Area code and Phone number configuration selections. In the Connect using box select the desired RS-232 port, COM 1 or COM 2 as shown in Figure 4.4 Click on the OK box to continue.
Fig 4.4 Naming Hyper Terminal Session
Microcontroller based SCADA System Using GSM
50
Chapter 4
System Design Flow
Next we will be prompted to enter the port properties. Select restore defaults as shown in Figure 4.5. Click on the OK box to continue.
Fig 4.5 Settings for Hyper Terminal
Microcontroller based SCADA System Using GSM
51
Chapter 4
System Design Flow
The HyperTerminal Session is now ready for use.
Fig 4.7 Hyper Terminal Ready
Microcontroller based SCADA System Using GSM
52
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
INTERFACED HARDWARE SPECIFICATIONS
Microcontroller based SCADA System Using GSM
53
Chapter 5
5.1
INTERFACED HARDWARE SPECIFICATIONS
AT89C52 (MICROCONTROLLER)
5.1.1 GENERAL DESCRIPTION The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89C52 provides the following standard features: 8K bytes of flash, 256 bytes of RAM, 32 I/O lines, Three 16-bit Timer/counters, a six vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition, the AT89C52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power-down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.
Microcontroller based SCADA System Using GSM
54
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.1.2 IMPORTANT FEATURES •
Compatible with MCS-51™ Products
•
8K Bytes of In-System Reprogrammable Flash Memory – Endurance: 1,000 Write/Erase Cycles
•
Fully Static Operation: 0 Hz to 24 MHz
•
Three-level Program Memory Lock
•
256 x 8-bit Internal RAM
•
32 Programmable I/O Lines
•
Three 16-bit Timer/Counters
•
Eight Interrupt Sources
•
Programmable Serial Channel
•
Low-power Idle and Power-down Modes
Microcontroller based SCADA System Using GSM
55
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.1.3 PINS CONFIGURATION
Fig 5.1 Pins Configuration 8052
Microcontroller based SCADA System Using GSM
56
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.1.4 LOGICAL INTERNAL DIAGRAM
Fig 5.2 Logical Internal Diagram 8052
Microcontroller based SCADA System Using GSM
57
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.1.5 ABSOLUTE MAXIMUM RATING
•
Operating Temperature.................................. -55°C to +125°
•
Storage Temperature ..................................... -65°C to +150°C
•
Voltage on Any Pin with Respect to Ground .....................................-1.0V to +7.0V
•
Maximum Operating Voltage............................................ 6.6V
•
DC Output Current...................................................... 15.0 mA
5.1.6
DC CHARACTRISTICS
Table 5.1 DC Characteristics 8052
Microcontroller based SCADA System Using GSM
58
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.1.7 AC CHARACTERISTICS
Table 5.2 AC Characteristics 8052 Microcontroller based SCADA System Using GSM
59
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.2 MAX 232 (Serial Interfacing )
5.2.1 GENERAL DESCRIPTION
The MAX 232 family of RS-232 transmitters/receivers interface circuits meets all ElA RS-232E and V.28 specifications, and is particularly suited for those applications where ±12V is not available. They require a single +5V power supply and feature onboard charge pump voltage converters which generate +10V and -10V supplies from the 5V supply. The drivers feature true TTL/CMOS input compatibility, slew rate-limited output, and 300Ω power-off source impedance. The receivers can handle up to ±30V, and have 3kΩ to7kΩ input impedance. The receivers also feature hysteresis to greatly improve noise rejection. The MAX 232 is characterized for operation from 0°C to 70°C.
5.2.2 IMPORTANT FEATURES
•
Meets All RS-232E and V.28 Specifications
•
Requires Only Single +5V Power Supply - (+5V and +12V - HIN239)
•
High Data Rate 120kbps
•
Onboard Voltage Doubler/Inverter
•
Low Power Consumption
•
Low Power Shutdown Function
•
Three-State TTL/CMOS Receiver Outputs
Microcontroller based SCADA System Using GSM
60
Chapter 5
•
INTERFACED HARDWARE SPECIFICATIONS
Multiple Drivers - ±10V Output Swing for 5V input - 300Ω Power-Off Source Impedance - Output Current Limiting - TTL/CMOS Compatible - 30V/μs Maximum Slew Rate
•
Multiple Receivers - ±30V Input Voltage Range - 3kΩ to 7kΩ Input Impedance - 0.5V Hysteresis to Improve Noise Rejection
5.2.3 Applications
•
Any System Requiring RS-232 Communication Ports - Computer - Portable, Mainframe, Laptop - Peripheral - Printers and Terminals - Instrumentation - Modems
Microcontroller based SCADA System Using GSM
61
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.2.4 PINS CONFIGURATION
Fig 5.3 Pins Configuration MAX 232
5.2.5 Pins Description
Table 5.3 Pins Description MAX 232 Microcontroller based SCADA System Using GSM
62
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.2.6 LOGICAL INTERNAL DIAGRAM
Fig 5.4 Logical Internal Diagram MAX 232
5.2.7 ABSOLUTE MAXIMUM RATING •
VCC to Ground. . . . . . . . . . . . . . . . . . . . . . (GND -0.3V) < VCC < 6V V+ to Ground (Note 2) . . . . . . . . . . . . . . . (VCC -0.3V) < V+ < 13.2V V- to Ground . . . . . . . . . . . . . . . . . . . . . . .-12V < V- < (GND +0.3V) V+ to V- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24V
Microcontroller based SCADA System Using GSM
63
Chapter 5
•
INTERFACED HARDWARE SPECIFICATIONS
Input Voltages TIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -0.3V < VIN < (V+ +0.3V) RIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ±30V
•
Output Voltages TOUT . . . . . . . . . . . . . . . . . . . .(V- -0.3V) < VTXOUT < (V+ +0.3V) ROUT . . . . . . . . . . . . . . . . . (GND -0.3V) < VRXOUT < (V+ +0.3V)
•
Short Circuit Duration TOUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Continuous ROUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Continuous
5.2.8 OPERATING CONDITIONS
•
Temperature Range MAX232CX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0oC to 70oC MAX232IX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -40oC to 85oC
Microcontroller based SCADA System Using GSM
64
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5. 3 SN74LS138 1-Of – 8 Decoder / Demultiplexer
5.3.1 GENERAL DESCRIPTION The LSTTL/MSI SN74LS138 is a high speed 1-of-8 Decoder/ Demultiplexer. This device is ideally suited for high speed bipolar memory chip select address decoding. The multiple input enables allow parallel expansion to a 1-of-24 decoder using just three LS138 devices or to a 1-of-32 decoder using four LS138s and one inverter. The LS138 is fabricated with the Schottky barrier diode process for high speed and is completely compatible with all ON Semiconductor TTL families.
5.3.2 IMPORTANT FEATURES Demultiplexing Capability Multiple Input Enable for Easy Expansion Typical Power Dissipation of 32 mW Active Low Mutually Exclusive Outputs Input Clamp Diodes Limit High Speed Termination Effects
Microcontroller based SCADA System Using GSM
65
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.3.3 PINS CONFIGURATION
Fig 5.5 Pins Configuration SN74LS138
Microcontroller based SCADA System Using GSM
66
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.3.4 TRUTH TABLE
Table 5.4 Truth Table SN74LS138
Microcontroller based SCADA System Using GSM
67
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.3.5 ABSOLUTE MAXIMUM RATING
Table 5.5 Absolute Maximum Rating SN74LS138
Microcontroller based SCADA System Using GSM
68
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.3.6 SWITCH CIRCUIT SCHEMATIC
Fig 5.6 Switch Circuit Schematic SN74LS138
Microcontroller based SCADA System Using GSM
69
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.3.7 ELECTRICAL CHARACTERISTICS
Table 5.6 Electrical Characteristics SN74LS138
Microcontroller based SCADA System Using GSM
70
Chapter 5
5.4
INTERFACED HARDWARE SPECIFICATIONS
ADC 0831 (ANALOG TO DIGITAL CONVERTOR)
5.4.1 GENERAL DESCRIPTION The ADC0831 series are 8-bit successive approximation A/D converters with a serial I/O and configurable input multiplexers with up to 8 channels. The serial I/O is configured to comply with the NSC MICROWIRE™ serial data exchange standard for easy interface to the COPS™ family of processors, and can interface with standard shift registers or µPs. The 2-, 4- or 8-channel multiplexers are software configured for single-ended or differential inputs as well as channel assignment. The differential analog voltage input allows increasing the common-mode rejection and offsetting the analog zero input voltage value. In addition, the voltage reference input can be adjusted to allow encoding any smaller analog voltage span to the full 8 bits of resolution.
5.4.2 IMPORTANT FEATURES
•
NSC MICROWIRE compatible—direct interface to COPS family processors
•
Easy interface to all microprocessors, or operates” stand-alone”
•
Operates ratio metrically or with 5 VDC voltage reference
•
No zero or full-scale adjust required
•
2-, 4- or 8-channel multiplexer options with address logic
•
Shunt regulator allows operation with high voltage supplies
•
0V to 5V input range with single 5V power supply
Microcontroller based SCADA System Using GSM
71
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
•
Remote operation with serial digital data link
•
TTL/MOS input/output compatible
•
0.3" standard width, 8-, 14- or 20-pin DIP package
•
20 Pin Molded Chip Carrier Package (ADC0838 only)
•
Surface-Mount Package
5.4.3 KEY SPECIFICATIONS •
Resolution
•
Total Unadjusted Error
±1/2 LSB and ±1 LSB
•
Single Supply
5 VDC
•
Low Power
15 mW
•
Conversion Time
32 µs
8 Bits
5.4.4 PINS CONFIGURATION
Fig 5.7 Pins Configuration ADC0832 Microcontroller based SCADA System Using GSM
72
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.4.5 ABSOLUTE MAXIMUM RATING
•
Current into V+ (Note 3) 15 mA
•
Supply Voltage, VCC (Note 3) 6.5V
•
Voltage
•
Logic Inputs −0.3V to VCC +0.3V
•
Analog Inputs −0.3V to VCC +0.3V
•
Input Current per Pin (Note 4) ±5 mA Package ±20 mA
•
Storage Temperature −65°C to +150°C
•
Package Dissipation at TA=25°C (Board Mount) 0.8W
•
Lead Temperature (Soldering 10 sec.)
•
Dual-In-Line Package (Plastic) 260°C
•
Molded Chip Carrier Package
•
Vapor Phase (60 sec.) 215°C
•
Infrared (15 sec.) 220°C
•
ESD Susceptibility (Note 5) 2000V
Microcontroller based SCADA System Using GSM
73
Chapter 5
5.4.6
INTERFACED HARDWARE SPECIFICATIONS
AC CHARACTERISTICS
Table 5.7 AC Characteristics ADC0832
Microcontroller based SCADA System Using GSM
74
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.5 7805/7810 (Voltage Regulator)
5.5.1
GENERAL DESCRIPTION
The LM78XX series of three terminal regulators is available with several fixed output voltages making them useful in a wide range of applications. One of these is local on card regulation, eliminating the distribution problems associated with single point regulation. The voltages available allow these regulators to be used in logic systems, instrumentation, HiFi, and other solid state electronic equipment. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and currents. The LM78XX series is available in an aluminum TO-3 package which will allow over 1.0A load current if adequate heat sinking is provided. Current limiting is included to limit the peak output current to a safe value. Safe area protection for the output transistor is provided to limit internal power dissipation. If internal power dissipation becomes too high for the heat sinking provided, the thermal shutdown circuit takes over preventing the IC from overheating. Considerable effort was expanded to make the LM78XX series of regulators easy to use and minimize the number of external components. It is not necessary to bypass the output, although this does improve transient response. Input by passing is needed only if the regulator is located far from the filter capacitor of the power supply. For output voltage other than 5V, 12V and 15V the LM117 series provides an output voltage range from 1.2V to 57V.
Microcontroller based SCADA System Using GSM
75
Chapter 5
5.5.2
INTERFACED HARDWARE SPECIFICATIONS
IMPORTANT FEATURES
•
Output current in excess of 1.5A
•
Internal thermal overload protection
•
No external components required
•
Output transistor safe area protection
•
Internal short circuit current limit
•
Available in the aluminum TO-3 package
•
Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V
5.5.3
CONNECTION DIAGRAM
Fig 5.8 Connection Diagram 78ҳҳ
Microcontroller based SCADA System Using GSM
76
Chapter 5
5.5.4
INTERFACED HARDWARE SPECIFICATIONS
ABSOLUTE MAXIMUM RATING
Table 5.8 Absolute Maximum Rating 78ҳҳ
Microcontroller based SCADA System Using GSM
77
Chapter 5
5.5.5
INTERFACED HARDWARE SPECIFICATIONS
ELECTRICAL CHARACTERISTICS
Table 5.9 Electrical Characteristics 78ҳҳ
Microcontroller based SCADA System Using GSM
78
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.6 LM35 (TEMPERATURE SENSOR)
5.6.1 GENERAL DESCRIPTION
The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of ±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to +150°C temperature range. Low cost is assured by trimming and calibration at the wafer level. The LM35’s low output impedance, linear output, and precise inherent calibration make interfacing to readout or control circuitry especially easy. It can be used with single power supplies, or with plus and minus supplies. As it draws only 60 μA from its supply, it has very low self-heating, less than 0.1°C in still air. The LM35 is rated to operate over a −55° to +150°C temperature range, while the LM35C is rated for a −40° to +110°C range (−10° with improved accuracy). The LM35 series is available packaged in hermetic TO-46 transistor packages, while the LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package. The LM35D is also available in an 8-lead surface mount small outline package and a plastic TO-220 package.
Microcontroller based SCADA System Using GSM
79
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.6.2 IMPORTANT FEATURES •
Calibrated directly in ° Celsius (Centigrade)
•
Linear + 10.0 mV/°C scale factor
•
0.5°C accuracy guaranteeable (at +25°C)
•
Rated for full −55° to +150°C range
•
Suitable for remote applications
•
Low cost due to wafer-level trimming
•
Operates from 4 to 30 volts
•
Less than 60 μA current drain
•
Low self-heating, 0.08°C in still air
•
Nonlinearity only ±1⁄4°C typical
•
Low impedance output, 0.1 W for 1 mA load
5.6.3
CONNECTION DIAGRAM
Fig 5.9 Connection Diagram LM35DZ Microcontroller based SCADA System Using GSM
80
Chapter 5
5.6.4
INTERFACED HARDWARE SPECIFICATIONS
ABSOLUTE MAXIMUM RATING
•
Supply Voltage +35V to −0.2V
•
Output Voltage +6V to −1.0V
•
Output Current 10 mA
•
Storage Temp.; TO-92 Package, −60°C to +150°C
•
Lead Temp.: TO-92 and TO-220 Package, (Soldering, 10 seconds) 260°C
•
Specified Operating Temperature Range: TMIN to T MAX (Note 2) LM35, LM35A −55°C to +150°C
5.6.5
SELF-HEATING (Thermal Resistance,өJA)
Table 5.10 Thermal Resistance (өJA)
Microcontroller based SCADA System Using GSM
81
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.6.6 ELECTRICAL CHARACTERISTICS
Table 5.11 Electrical Characteristics LM35
Microcontroller based SCADA System Using GSM
82
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.7 RELAYS
5.7.1 GENERAL DESCRIPTION
A relay is electromechanical device, which operates on the basis of electromagnetic induction. It uses either an AC or DC actuated electromagnetic to open or close one or more sets of contacts. Relay contacts, which are open when the relay is not energized, are called Normally Open contacts. Conversely, Relay contacts which are closed when the relay is not energized are called Normally Closed contacts. Relay contacts are held in their resting or normal position either by a spring or by some type of gravity-actuated mechanism. In most cases, an adjustment of the spring tension is provided to set the restraining force on the normally open and normally closed contacts to some desired level based on the pre-determined circuit conditions.
Fig 5.10 Schematic Symbol Relay Figure shows the schematic symbol that is commonly used to represent relay contacts. When the normally open close, they are said to make, whereas when the normally closed contacts open they are said to break. Like mechanical switches, the switching contacts of the relay can have any number of poles and throws.
Microcontroller based SCADA System Using GSM
83
Chapter 5
INTERFACED HARDWARE SPECIFICATIONS
5.7.2 RELAY SPECIFICATIONS The specification of the relays contains voltage and current ratings for both the relay coil and its switching contacts. The specification sheet also includes information regarding the location of the relay coil and the switching contact terminals, and also whether the relay can be energized from AC source or DC source.The following is an explanation of the relays’ most important ratings: 5.7.3 PICKUP VOLTAGE The minimum amount of the relay coil voltage necessary to energize or operate the relay. 5.7.4 HOLDING CURRENT The minimum amount of current required to keep a relay energized or operating. 5.7.5 DROP OUT VOLTAGE The maximum relay coil voltage at which the relay is no longer energized. 5.7.6 CONTACT VOLTAGE RATING The maximum voltage the relay contacts are capable of switching safely. 5.7.7 CONTACT CURRENT RATING The maximum current the relay contacts are capable of switching safely. 5.7.8 INSULATION RESISTANCE The resistance measured across the relay constants in the open position. Microcontroller based SCADA System Using GSM
84
Chapter 5
Microcontroller based SCADA System Using GSM
INTERFACED HARDWARE SPECIFICATIONS
85
Chapter 6
GSM TECHNOLOGY
GSM TECHNOLOGY
Microcontroller based SCADA System Using GSM
86
Chapter 6
6.1
GSM TECHNOLOGY
History of GSM
During the early 1980s, analog cellular telephone systems were experiencing rapid growth in Europe, particularly in Scandinavia and the United Kingdom, but also in France and Germany. Each country developed its own system, which was incompatible with everyone else's in equipment and operation. This was an undesirable situation, because not only was the mobile equipment limited to operation within national boundaries, which in a unified Europe were increasingly unimportant. The Europeans realized this early on, and in 1982 the Conference of European Posts and Telegraphs (CEPT) formed a study group called the Groupe Spécial Mobile (GSM) to study and develop a pan-European public land mobile system. The proposed system had to meet certain criteria: •
Good subjective speech quality
•
Low terminal and service cost
•
Support for international roaming
•
Ability to support handheld terminals
•
Support for range of new services and facilities
•
Spectral efficiency
•
ISDN compatibility
In 1989, GSM responsibility was transferred to the European Telecommunication Standards Institute (ETSI), and phase I of the GSM specifications were published in 1990. Commercial service was started in mid-1991, and by 1993 there were 36 GSM networks in 22 countries [6]. Although standardized in Europe, GSM is not only a European standard. Over 200 GSM networks (including DCS1800 and PCS1900) are
Microcontroller based SCADA System Using GSM
87
Chapter 6
GSM TECHNOLOGY
operational in 110 countries around the world. In the beginning of 1994, there were 1.3 million subscribers worldwide [18], which had grown to more than 55 million by October 1997. With North America making a delayed entry into the GSM field with a derivative of GSM called PCS1900, GSM systems exist on every continent, and the acronym GSM now aptly stands for Global System for Mobile communications.
6.2
Services provided by GSM
From the beginning, the planners of GSM wanted ISDN compatibility in terms of the services offered and the control signalling used. However, radio transmission limitations, in terms of bandwidth and cost, do not allow the standard ISDN Bchannel bit rate of 64 kbps to be practically achieved. A variety of data services is offered. GSM users can send and receive data, at rates up to 9600 bps, to users on POTS (Plain Old Telephone Service), ISDN, Packet Switched Public Data Networks, and Circuit Switched Public Data Networks using a variety of access methods and protocols, such as X.25 or X.32. Since GSM is a digital network, a modem is not required between the user and GSM network, although an audio modem is required inside the GSM network to interwork with POTS. A unique feature of GSM, not found in older analog systems, is the Short Message Service (SMS). SMS is a bidirectional service for short alphanumeric (up to 160 bytes) messages. Messages are transported in a store-and-forward fashion. For pointto-point SMS, a message can be sent to another subscriber to the service, and an acknowledgement of receipt is provided to the sender. SMS can also be used in a cellbroadcast mode, for sending messages such as traffic updates or news updates. Messages can also be stored in the SIM card for later retrieval [2]. Microcontroller based SCADA System Using GSM
88
Chapter 6
GSM TECHNOLOGY
6.3
Architecture of the GSM network
A GSM network is composed of several functional entities, whose functions and interfaces are specified. Figure 1 shows the layout of a generic GSM network. The GSM network can be divided into three broad parts. The Mobile Station is carried by the subscriber. The Base Station Subsystem controls the radio link with the Mobile Station. The Network Subsystem, the main part of which is the Mobile services Switching Center (MSC), performs the switching of calls between the mobile users, and between mobile and fixed network users. The MSC also handles the mobility management operations. Not shown is the Operations and Maintenance Center, which oversees the proper operation and setup of the network. The Mobile Station and the Base Station Subsystem communicate across the Um interface, also known as the air interface or radio link. The Base Station Subsystem communicates with the Mobile services Switching Center across the A interface.
Fig 6.1 A GSM Network
Microcontroller based SCADA System Using GSM
89
Chapter 6
GSM TECHNOLOGY
6.3.1 Mobile Station
The mobile station (MS) consists of the mobile equipment (the terminal) and a smart card called the Subscriber Identity Module (SIM). The SIM provides personal mobility, so that the user can have access to subscribed services irrespective of a specific terminal. By inserting the SIM card into another GSM terminal, the user is able to receive calls at that terminal, make calls from that terminal, and receive other subscribed services.
6.3.2 Base Station Subsystem The Base Station Subsystem is composed of two parts, the Base Transceiver Station (BTS) and the Base Station Controller (BSC). These communicate across the standardized Abis interface, allowing (as in the rest of the system) operation between components made by different suppliers.
6.3.3 Network Subsystem The central component of the Network Subsystem is the Mobile services Switching Center (MSC). It acts like a normal switching node of the PSTN or ISDN, and additionally provides all the functionality needed to handle a mobile subscriber. The Home Location Register (HLR) and Visitor Location Register (VLR), together with the MSC, provide the call-routing and roaming capabilities of GSM. The Visitor Location Register (VLR) contains selected administrative information from the HLR, necessary for call control and provision of the subscribed services, for each mobile currently located in the geographical area controlled by the VLR. Microcontroller based SCADA System Using GSM
90
Chapter 6
GSM TECHNOLOGY
The other two registers are used for authentication and security purposes. The Equipment Identity Register (EIR) is a database that contains a list of all valid mobile equipment on the network. The Authentication Center (AuC) is a protected database that stores a copy of the secret key stored in each subscriber's SIM card, which is used for authentication and encryption over the radio channel.
6.4
Multiple access and channel structure
Since radio spectrum is a limited resource shared by all users, a method must be devised to divide up the bandwidth among as many users as possible. The method chosen by GSM is a combination of Time- and Frequency-Division Multiple Access (TDMA/FDMA). The FDMA part involves the division by frequency of the (maximum) 25 MHz bandwidth into 124 carrier frequencies spaced 200 kHz apart. One or more carrier frequencies are assigned to each base station. The fundamental unit of time in this TDMA scheme is called a burst period and it lasts 15/26 ms (or approx. 0.577 ms). Eight burst periods are grouped into a TDMA frame (120/26 ms, or approx. 4.615 ms).
6.4.1 Traffic Channels Traffic channel (TCH) is used to carry speech and data traffic. Traffic channels are defined using a 26-frame multiframe, or group of 26 TDMA frames. The length of a 26-frame multiframe is 120 ms, which is how the length of a burst period is defined (120 ms divided by 26 frames divided by 8 burst periods per frame).
Microcontroller based SCADA System Using GSM
91
Chapter 6
GSM TECHNOLOGY
6.4.2 Control Channels Common channels can be accessed both by idle mode and dedicated mode mobiles. The common channels are used by idle mode mobiles to exchange the signalling information required to change to dedicated mode. The common channels include: Broadcast Control Channel (BCCH) Continually broadcasts, on the downlink, information including base station identity, frequency allocations, and frequencyhopping sequences. Frequency Correction Channel (FCCH) and Synchronisation Channel (SCH) Used to synchronise the mobile to the time slot structure of a cell by defining the boundaries of burst periods, and the time slot numbering. Every cell in a GSM network broadcasts exactly one FCCH and one SCH, which are by definition on time slot number 0 (within a TDMA frame). Random Access Channel (RACH) Slotted Aloha channel used by the mobile to request access to the network. Paging Channel (PCH) Used to alert the mobile station of an incoming call. Access Grant Channel (AGCH) Used to allocate an SDCCH to a mobile for signalling (in order to obtain a dedicated channel), following a request on the RACH.
6.4.3 Burst Structure There are four different types of bursts used for transmission in GSM [16]. The normal burst is used to carry data and most signalling. It has a total length of 156.25 bits,
Microcontroller based SCADA System Using GSM
92
Chapter 6
GSM TECHNOLOGY
6.5
Speech Coding
GSM is a digital system, so speech which is inherently analog, has to be digitized. The method employed by ISDN, and by current telephone systems for multiplexing voice lines over high speed trunks and optical fiber lines, is Pulse Coded Modulation (PCM).
6.6
Channel Coding and Modulation
Because of natural and man-made electromagnetic interference, the encoded speech or data signal transmitted over the radio interface must be protected from errors. GSM uses convolutional encoding and block interleaving to achieve this protection.
6.7
Frequency Hopping
The mobile station already has to be frequency agile, meaning it can move between a transmit, receive, and monitor time slot within one TDMA frame, which normally are on different frequencies. GSM makes use of this inherent frequency agility to implement slow frequency hopping, where the mobile and BTS transmit each TDMA frame on a different carrier frequency. The frequency hopping algorithm is broadcast on the Broadcast Control Channel. Since multipath fading is dependent on carrier frequency, slow frequency hopping helps alleviate the problem. In addition, co-channel interference is in effect randomized.
6.8
Power Control
There are five classes of mobile stations defined, according to their peak transmitter power, rated at 20, 8, 5, 2, and 0.8 watts. To minimize co-channel interference and to conserve power, both the mobiles and the Base Transceiver Microcontroller based SCADA System Using GSM
93
Chapter 6
GSM TECHNOLOGY
Stations operate at the lowest power level that will maintain an acceptable signal quality. Power levels can be stepped up or down in steps of 2 dB from the peak power for the class down to a minimum of 13 dBm (20 milliwatts). The mobile station measures the signal strength or signal quality (based on the Bit Error Ratio), and passes the information to the Base Station Controller, which ultimately decides if and when the power level should be changed. Power control should be handled carefully, since there is the possibility of instability. This arises from having mobiles in co-channel cells alternatingly increase their power in response to increased co-channel interference caused by the other mobile increasing its power. This in unlikely to occur in practice but it is (or was as of 1991) under study.
6.9
Network Aspects
Ensuring the transmission of voice or data of a given quality over the radio link is only part of the function of a cellular mobile network. A GSM mobile can seamlessly roam nationally and internationally, which requires that registration, authentication, call routing and location updating functions exist and are standardized in GSM networks.
6.9.1 Radio Resources Management The radio resources management (RR) layer oversees the establishment of a link, both radio and fixed, between the mobile station and the MSC. The main functional components involved are the mobile station, and the Base Station Subsystem, as well as the MSC.
Microcontroller based SCADA System Using GSM
94
Chapter 6
GSM TECHNOLOGY
6.9.1.1
Handover
In a cellular network, the radio and fixed links required are not permanently allocated for the duration of a call. Handover, or handoff as it is called in North America, is the switching of an on-going call to a different channel or cell. The execution and measurements required for handover form one of basic functions of the RR layer. There are four different types of handover in the GSM system, which involve transferring a call between: •
Channels (time slots) in the same cell
•
Cells (Base Transceiver Stations) under the control of the same Base Station Controller (BSC),
•
Cells under the control of different BSCs, but belonging to the same Mobile services Switching Center (MSC), and
•
Cells under the control of different MSCs.
6.9.2
Mobility Management
The Mobility Management layer (MM) is built on top of the RR layer, and handles the functions that arise from the mobility of the subscriber, as well as the authentication and security aspects. Location management is concerned with the procedures that enable the system to know the current location of a powered-on mobile station so that incoming call routing can be completed.
Microcontroller based SCADA System Using GSM
95
Chapter 6
GSM TECHNOLOGY
6.9.2.1
Location Updating
A powered-on mobile is informed of an incoming call by a paging message sent over the PAGCH channel of a cell. One extreme would be to page every cell in the network for each call, which is obviously a waste of radio bandwidth. The other extreme would be for the mobile to notify the system, via location updating messages, of its current location at the individual cell level. This would require paging messages to be sent to exactly one cell, but would be very wasteful due to the large number of location updating messages. A compromise solution used in GSM is to group cells into location areas. Updating messages are required when moving between location areas, and mobile stations are paged in the cells of their current location area. The location updating procedures, and subsequent call routing, use the MSC and two location registers: the Home Location Register (HLR) and the Visitor Location Register (VLR).
6.9.2.2
Authentication and Security
Since the radio medium can be accessed by anyone, authentication of users to prove that they are who they claim to be, is a very important element of a mobile network. Authentication involves two functional entities, the SIM card in the mobile, and the Authentication Center (AuC). Each subscriber is given a secret key, one copy of which is stored in the SIM card and the other in the AuC. During authentication, the AuC generates a random number that it sends to the mobile. Both the mobile and the AuC then use the random number, in conjuction with the subscriber's secret key and a ciphering algorithm called A3, to generate a signed
Microcontroller based SCADA System Using GSM
96
Chapter 6
GSM TECHNOLOGY
response (SRES) that is sent back to the AuC. If the number sent by the mobile is the same as the one calculated by the AuC, the subscriber is authenticated. Another level of security is performed on the mobile equipment itself, as opposed to the mobile subscriber. White-listed The terminal is allowed to connect to the network. Grey-listed The terminal is under observation from the network for possible problems. Black-listed The terminal has either been reported stolen, or is not type approved (the correct type of terminal for a GSM network). The terminal is not allowed to connect to the network.
6.9.3
Communication Management
The Communication Management layer (CM) is responsible for Call Control (CC), supplementary service management, and short message service management. Each of these may be considered as a separate sublayer within the CM layer.
6.9.3.1
Call Routing
Unlike routing in the fixed network, where a terminal is semi-permanently wired to a central office, a GSM user can roam nationally and even internationally. The directory number dialed to reach a mobile subscriber is called the Mobile Subscriber ISDN (MSISDN), which is defined by the E.164 numbering plan. This number includes a country code and a National Destination Code which identifies Microcontroller based SCADA System Using GSM
97
Chapter 6
GSM TECHNOLOGY
the subscriber's operator. The first few digits of the remaining subscriber number may identify the subscriber's HLR within the home PLMN.
An incoming mobile terminating call is directed to the Gateway MSC (GMSC) function. The GMSC is basically a switch which is able to interrogate the subscriber's HLR to obtain routing information, and thus contains a table linking MSISDNs to their corresponding HLR. A simplification is to have a GSMC handle one specific PLMN. It should be noted that the GMSC function is distinct from the MSC function, but is usually implemented in an MSC.
The routing information that is returned to the GMSC is the Mobile Station Roaming Number (MSRN), which is also defined by the E.164 numbering plan. MSRNs are related to the geographical numbering plan, and not assigned to subscribers, nor are they visible to subscribers.
The most general routing procedure begins with the GMSC querying the called subscriber's HLR for an MSRN. The HLR typically stores only the SS7 address of the subscriber's current VLR, and does not have the MSRN (see the location updating section). The HLR must therefore query the subscriber's current VLR, which will temporarily allocate an MSRN from its pool for the call. This MSRN is returned to the HLR and back to the GMSC, which can then route the call to the new MSC. At the new MSC, the IMSI corresponding to the MSRN is looked up, and the mobile is paged in its current location area.
Microcontroller based SCADA System Using GSM
98
Chapter 6
GSM TECHNOLOGY
Fig 6.2 Call Routing for Gsm Network
Microcontroller based SCADA System Using GSM
99
Chapter 7
SMS & AT COMMANDS
SMS & AT COMMANDS
Microcontroller based SCADA System Using GSM
100
Chapter 7
7.1
SMS & AT COMMANDS
Introduction To SMS
The Short Message Service (SMS) provides a means for sending a message of a limited size (160 characters) to and from terminal equipment.SMS is a wireless, radio based service conceived for the bidirectional transfer of short alphanumeric messages among mobile terminals on GSM cellular telecommunication networks. Since its inception as a notification service a decade ago, the bulk of SMS usage today is for interpersonal communication. Its continued popularity has driven pricing steadily down. Beyond affordability, SMS messaging has other technical merits that lend the technology to corporate adoption.
7.2
History Of SMS
SMS was an accidental success that took nearly everyone in the mobile industry by surprise. Few people predicted that this hard of use service would take off. There was hardly any promotion for or mention of SMS by network operators until after SMS started to be a success. SMS advertising went from showing business people in suits entering text messages to bright pink and yellow advertisements aimed at the youth markets that adopted SMS. SMS was the triumph of the consumer - every generation needs a technology that it can adopt as its own to communicate with - and the text generation took up SMS. Paradoxically, it was because SMS was so very difficult to use that the young people said that they were going to overcome the man machine interface and other issues and use the service anyway. SMS is one of the few services in consumer history that has grown very fast without corresponding decreases in pricing. Usually, even in the case of voice mobile phones, price reductions in the cost of the phones and phone service have led to increases in usage. Whilst these factors have helped to bring younger people into the mobile market, the price of SMS itself stayed steady because the networks were having trouble handling the volumes of messages being sent and dared not reduce prices. A whole new alphabet emerged because SMS messages took a long time to enter and were quite abrupt as people attempted to say as much as possible with as few keystrokes. Abbreviations such as 'C U L8er' for 'See you later' sprung up for timesaving and coolness. The use of smileys Microcontroller based SCADA System Using GSM
101
Chapter 7
SMS & AT COMMANDS
to reduce the abruptness of the medium and to help indicate the mood of the person in a way that was difficult with just text became popular. The introduction of prepay mobile tariffs in which people could pay for their airtime in advance and thereby control their mobile phone expenditure was the catalyst that accelerated the take up of SMS. The network operators were unable technically to bill prepay customers for the SMS they were using because the links between the prepay platform and the billing system and the SMS Centers were not in place. The network operators responded with silence- the prepay literature did not mention SMS at all even though the prepay phones supported the service. One thing that is certain is that in these days with the Internet revolution to spread information, the young people will identify loopholes like this. And they did. Suddenly, millions more SMS messages were being sent- with some individual mobile phone subscriptions accounting for thousands of SMS per month alone as they set up automated message generators. Network operators worked with their platform suppliers to try and sort this out and implement charging for SMS for prepay customers. Meanwhile SMS incubated and spread and people were using it because it cost nothing whereas carrying out the same transaction using voice clearly did cost. Eventually after a few months the network operators finally got their act together and managed to implement SMS charging for prepay users- such that they could decrement the prepay credit by the cost of an SMS message.
7.3
SMS Applications
There are many different kinds of SMS applications on the market today and many others are being developed. Applications in which SMS messaging can be utilized are virtually unlimited. We will describe some common examples of SMS applications below to give you some ideas of what can be done with SMS messaging.
• • • • • • • • • • 7.4
Person-to-Person Text Messaging Provision of Information Downloading Alerts and Notifications Email, Fax and Voice Message Notifications E-commerce and Credit Card Transaction Alerts Stock Market Alerts Remote System Monitoring Two-way Interactive Text Messaging Applications SMS Marketing
Types Of SMS Messages
There are some major sorts of short messaging service routines given as under
Microcontroller based SCADA System Using GSM
102
Chapter 7
SMS & AT COMMANDS
7.4.1 Intra-operator SMS Messages If both you and your friend are using the mobile phone service of the same wireless network operator, the transmission of an SMS message from you to your friend will involve only one wireless network operator. This SMS message is called an intraoperator SMS message. Typically, the cost for sending an intra-operator SMS message from a mobile phone is lower than that for sending other kinds of SMS messages such as inter-operator SMS messages. Some wireless network operators allow their subscribers to send unlimited intra-operator SMS messages free of charge.
7.4.1.1
Transmission Process of Intra-operator SMS Messages
The transmission of an intra-operator SMS message involves only one SMS center. After leaving the sender, the intra-operator SMS message reaches the SMS center. The SMS center then delivers the SMS message to the recipient mobile phone. If the recipient mobile phone is offline, the SMS center stores the SMS message. It will deliver the SMS message when the recipient mobile phone is online. If the SMS message's validity period expires and the recipient mobile phone is still offline, the SMS center will remove the SMS message. When the SMS center receives the message delivery report from the recipient mobile phone or removes the SMS message (for example, when the validity period expires), it sends a status report to the sender if the sender requested one earlier. The following figure illustrates the transmission process of an intra-operator SMS message
Fig 7.1
Transmission Process of Intra-operator SMS Messages
Microcontroller based SCADA System Using GSM
103
Chapter 7
SMS & AT COMMANDS
7.4.2 Inter-operator SMS Messages Suppose you and your friend are using the mobile phone service of wireless network operator A and wireless network operator B respectively. The transmission of an SMS message from you to your friend involves two wireless networks. This SMS message is called an inter-operator SMS message. Typically, the cost for sending an inter-operator SMS message from a mobile phone is higher than that for sending an intra-operator SMS message.
7.4.2.1 Transmission Process of Intra-operator SMS Messages The transmission of an inter-operator SMS message involves one or more SMS centers. Generally, there are two different ways for the transmission of inter-operator SMS messages. In the first way, signaling interconnections are set up between two wireless networks. When the originator SMS center receives an inter-operator SMS message, it gets the routing information from the recipient wireless network and delivers the SMS message to the recipient mobile phone directly. The following figure illustrates the transmission process:
Fig 7.2
Transmission Process of Inter-operator SMS Messages
The first way can be used if the two wireless networks involved in the transmission of the inter-operator SMS message are based on similar technologies. However, if this is not true, the second way has to be used. For example, when an SMS message is sent from a GSM network to a CDMA network. In the second way, the originator SMS center and the recipient SMS center are interconnected through an SMS gateway or with a communication protocol that is supported by both SMS centers. The SMS message first reaches the originator SMS center, which will then forward the SMS message towards the recipient SMS center. The recipient SMS center will be responsible for sending the SMS message to the recipient mobile phone and storing the SMS message if Microcontroller based SCADA System Using GSM
104
Chapter 7
SMS & AT COMMANDS
the recipient mobile phone is offline. The following figure illustrates the transmission process.
Fig 7.3
7.4.3
Transmission Process of Inter-operator SMS Messages
International SMS Messages
Inter-operator SMS messages can be further divided into two categories -- local interoperator SMS messages and international inter-operator SMS messages (international SMS messages). A local inter-operator SMS message is an SMS message that is sent from one wireless network operator to another wireless network operator in the same country, while an international SMS message is an SMS message that is sent from a wireless network operator in one country to a wireless network operator in another country. Usually the cost for sending an international SMS message from a mobile phone is higher than that for sending a local inter-operator SMS message. Hence, the cost for sending an intra-operator SMS message Originate call to phone number in current memory ATDL Redial last telephone number used ATE Set command echo mode ATH Disconnect existing connection ATI Display product identification information ATL Set monitor speaker loudness ATM Set monitor speaker mode ATO Switch from command mode to data mode ATP Select pulse dialing ATQ Set Result code presentation mode ATS0 Set number of rings before auto answering the call ATS3 Set command line termination character ATS4 Set response formatting character ATS5 Set command line editing character ATS6 Set pause before blind dialling ATS7 Set number of seconds to wait for connection completion
Microcontroller based SCADA System Using GSM
108
Chapter 7
SMS & AT COMMANDS
ATS8 ATS10 ATT ATV ATX ATZ AT&C AT&D AT&F AT&V AT&W AT+DRV AT+DS AT+GCAP AT+GMI AT+GMM AT+GMR AT+GOI AT+GSN AT+ICF AT+IFC AT+ILRR AT+IPR AT+CBST AT+CGMI AT+CGMM AT+CGMR
7.10
Set number of seconds to wait when comma dial modifier used Set disconnect delay after indicating the absence of data carrier Select tone dialling Set result code format mode Set connect result code format and call monitoring Set all current parameters to user defined profile Set DCD function mode Set DTR function mode Set all current parameters to manufacturer defaults Display current configuration Store current parameter to user defined profile 42bis data compression reporting control V.42bis data compression control Request complete TA capabilities list Request manufacturer identification Request TA model identification Request TA revision identification Request global object identification Request TA serial number identification (IMEI) Set TE-TA control character framing Set TE-TA local data flow control Set TE-TA local rate reporting mode Set fixed local rate SELECT BEARER SERVICE TYPE REQUEST MANUFACTURER IDENTIFICATION REQUEST MODEL IDENTIFICATION REQUEST REVISION IDENTIFICATION
AT COMMANDS FOR SMS
The GSM 07.05 commands are for performing SMS and CBS related operations for both Text and PDU modes.
Command Description
AT+CMGD AT+CMGF AT+CMGL AT+CMGR AT+CMGS AT+CMGW AT+CMSS AT+CMGC
DELETE SMS MESSAGE SELECT SMS MESSAGE FORMAT LIST SMS MESSAGES FROM PREFERRED STORE READ SMS MESSAGE SEND SMS MESSAGE WRITE SMS MESSAGE TO MEMORY SEND SMS MESSAGE FROM STORAGE SEND SMS COMMAND
Microcontroller based SCADA System Using GSM
109
Chapter 7
SMS & AT COMMANDS
AT+CNMI AT+CPMS AT+CRES AT+CSAS AT+CSCA AT+CSCB AT+CSDH AT+CSMP AT+CSMS
NEW SMS MESSAGE INDICATIONS PREFERRED SMS MESSAGE STORAGE RESTORE SMS SETTINGS SAVE SMS SETTINGS SMS SERVICE CENTER ADDRESS SELECT CELL BROADCAST SMS MESSAGES SHOW SMS TEXT MODE PARAMETERS SET SMS TEXT MODE PARAMETERS SELECT MESSAGE SERVICE
7.11 Using AT- Commands MODE SELECTION AT+ CMGF
Description: The message formats supported are text mode and PDU mode. In PDU mode, a complete SMS Message including all header information is given as a binary string (in hexadecimal format). Therefore, only the following set of characters is allowed: {‘0’,’1’,’2’,’3’,’4’,’5’,’6’,’7’,’8’,’9’, ‘A’, ‘B’,’C’,’D’,’E’,’F’}.
Figure 1
Microcontroller based SCADA System Using GSM
110
Chapter 7
SMS & AT COMMANDS
Send Message +CMGS
Description: The field is the address of the terminal to which the message is sent. To send the message, simply type, character (ASCII 26). The text can contain all existing characters except and (ASCII 27). This command can be aborted using the character when entering text. In PDU mode, only hexadecimal characters are used (‘0’…’9’,’A’…’F’). Values: type this to send the message text is entered AT+CMGS= PDU is entered
Service Center Address +CSCA Description This command indicates the service center to which the message must be sent. The product has no default value for this address. If the application tries to send a message without having indicated the service center address, an error will be generated. Therefore, the application must indicate the SC address when initializing the SMS. This address is then permanently valid. The application may change it if necessary.
Values: service center address Syntax: AT+CSCA
Microcontroller based SCADA System Using GSM
111
Chapter 7
Microcontroller based SCADA System Using GSM
SMS & AT COMMANDS
112
Chapter 8
CONCLUSION
CONCLUSION
Microcontroller based SCADA System Using GSM
113
Chapter 8
8.1
CONCLUSION
CONCLUSION This project “Microcontroller based SCADA System Using GSM ” is a very efficient, less costly, reliable, easy to amend, User friendly to use and
Ideal for automating industrial equipments of a relatively small industry. We have designed this project by keeping this thing in mind to provide advance controlling facilities when automating equipments and machineries in small industries at a very reasonable cost. We had made available flexible options for controlling the running processes, changing the set points in the running conditions instead of terminating the process and emergency stopping both from the controlling computer or physical panel in the field.
8.2 FUTURE UPGRADING All inventions give rise to another miracle expanding the previous idea at a more advance level. Future upgrading will give upcoming students some ideas to extend our project “Microcontroller based SCADA System Using GSM” at a very high level. We have suggested some future enhancement for this project; •
With small amendments this project can be used for very complex applications in heavy industries with available extreme conditions.
•
The GSM technology can be used for in many beneficial ways with the theme of this project.
•
More process variable can be added for monitoring and controlling purposes.
•
The No of available inputs and outputs can be increased in the hardware designing.
Microcontroller based SCADA System Using GSM
114
Chapter 8
•
CONCLUSION
The communication Technique between controlling computer and the Project hardware can be switched to parallel ports or USB or IR.
•
Some vast programming can be done at the GUI level to give user more facilities and implement secret codes for important data control and irrelevant access.
8.3 Features •
It’s the most cheapest way because SMS services costs very less , even international SMS services are as low as Rs. 5 per SMS. And GSM companies have too much low SMS rates that can be thought approx. free.
•
It gives the dynamic mobility for controlling your devices in the industry and control all processes just through one SMS.
•
This system provides a lot of facility to the laymen to live their life with lot of freedom , while fulfilling all there duties. You can install this device and then can go anywhere and its on just one SMS to warm up
•
Its easy to control several devices by using only one SMS and programming the module as a single short message can be up to 160 characters of text in length. Those 160 characters can comprise of words or numbers or an alphanumeric combination. Non-text based short messages (for example, in binary format) are also supported. These are used for ringtones and logos services for instance.
•
The Short Message Service is a store and forward service, in other words, short messages are not sent directly from sender to recipient, but always via an SMS Center instead also many handsets allow to manage the timing of sms sending. So by setting the timings for SMS we can set the timer control for devices.Each mobile telephone network that supports SMS has one or more messaging centers to handle and manage the short messages.
•
We can be confirmed about the device controls by the Short Message Service features confirmation of message delivery. This means that unlike paging, users do not simply send a short message and trust and hope that it gets
Microcontroller based SCADA System Using GSM
115
Chapter 8
CONCLUSION
delivered. Instead the sender of the short message can receive a return message back notifying them whether the short message has been delivered or not.
• This service is also very fast and efficient as compared to wireless control as Short messages can be sent and received simultaneously with GSM voice, Data and Fax calls. This is possible because whereas voice, Data and Fax calls take over a dedicated radio channel for the duration of the call, short
messages travel over and above the radio channel using the signaling path. As such, users of SMS rarely if ever get a busy or engaged signal as they can do during peak network usage times.
• It provides the simultaneous control of different devices through one subscriber by Ways of sending multiple short messages are available. SMS concatenation (stringing several short messages together) and SMS compression (getting more than 160 characters of information within a single short message) have been defined and incorporated in the GSM SMS standards.
Microcontroller based SCADA System Using GSM
116
Chapter 8
CONCLUSION
8.2 REFERENCES 8.2.1
•
THE 8051 MICROCONTROLLER By SCOTT MACKENZIE
•
ELECTRONIC DEVICES AND CIRCUITS 2By THEODORE F BOGARD, JR
•
MASTERING VISUAL BASIC 6 By EVANGELOS PETROUTSOS
8.2. WEB LINKS
•
www.datasheetarchive.com
•
www.digchip.com
•
www.homeauto.com
•
www.8052.com
•
www.datasheetcatalog.com
Microcontroller based SCADA System Using GSM
117