Accident Intimation System Using GSM and GPS: D.Raghuram B.Sai Kumar K.P.S.Lakshman
Accident Intimation System Using GSM and GPS: D.Raghuram B.Sai Kumar K.P.S.Lakshman
D.RAGHURAM
B.SAI KUMAR
K.P.S.LAKSHMAN
Department of Electronics and Communication Engineering
MAHATMA GANDHI INSTITUTE OF TECHNOLOGY
(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)
Chaitanya Bharathi P.O., Gandipet, Hyderabad 500 075
2012
ACCIDENT INTIMATION SYSTEM USING GSM AND GPS
PROJECT REPORT
SUBMITTED IN PARTIAL FULFILLMENT
OF THE REQUIREMENTS FOR THE DEGREE OF
BACHELOR OF TECHNOLOGY
IN
ELECTRONICS AND COMMUNICATION ENGINEERING
BY
D.RAGHURAM (08261A0414)
B.SAIKUMAR (08261A0407)
K.P.S.LAKSHMAN(08261A0425)
Department of Electronics and Communication Engineering
MAHATMA GANDHI INSTITUTE OF TECHNOLOGY
(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.) Chaitanya
Bharathi P.O., Gandipet, Hyderabad 500 075
2012
i
MAHATMA GANDHI INSTITUTE OF TECHNOLOGY
(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)
Chaitanya Bharathi P.O., Gandipet, Hyderabad-500 075
Department of Electronics and Communication Engineering
CERTIFICATE
Date:
This is to certify that the project work entitled Accident intimation system using gsm
an gps is a bonafide work carried out by
D.Raghuram (08261A0414)
B.Saikumar (08261A0407)
K.P.S.Lakshman (08261A0425)
in partial fulfillment of the requirements for the degree of BACHELOR OF
TECHNOLOGY in ELECTRONICS & COMMUNICATION ENGINEERING by
the Jawaharlal Nehru Technological University, Hyderabad during the academic year 2011-12.
The results embodied in this report have not been submitted to any other University or
Institution for the award of any degree or diploma
(Signature) (Signature)
------------------ -------------------
Mr. Srinivas Rao, Associate professor Dr S.P.Singh
Faculty Advisor&Liaison Professor & Head of Dept.
ii
ACKNOWLEDGEMENT
.
We are highly indebted to our Faculty Liaison Mr Srinivas Rao, Associate Professor,
Electronics and Communication Engineering Department, who has given us all the necessary
technical guidance in carrying out this Project.
We wish to express our sincere thanks to Dr. S.P.Singh, Head of the Department of
Electronics and Communication Engineering, M.G.I.T., for permitting us to pursue our Project
in NIMSME and encouraging us throughout the Project.
Finally, we thank all the people who have directly or indirectly help us through the
course of our Project.
D.Raghuram
B.Saikumar
K.P.S.Lakshman
iii
ABSTRACT
Now a days heavy traffic is there in main cities due to huge population, there a more chances
to make an accidents frequently. When a person is going on the way, he met an accident at that
time nobody is there for saving. At this time this project is so useful for saving the lives.
In this project we have GPS receiver and GSM module is present in vehicle and vibrating
sensor is also fixed to it for obstacle detection, when the vehicle met to an accident. The GPS
Receiver is interfaced with the micro controller its continuously tracks the position and passes
the information to GSM module through the microcontroller. By this tracking system we can
know the exact location where the accident is occurred to the vehicle. The GPS receiver will
track the information is given to the GSM Modem; it will pass the information to our mobile..
When we will get a mobile alert SMS, then we go to that location and save that person from
injuries by take him/her to hospital. Thus we can save their lives with in the exact time. This can
be implemented in real time
Global Positioning System is an earth-orbiting-satellite based system that provides signals
available anywhere on or above the earth, twenty-four hours a day, which can be used to
determine precise time and the position of a GPS receiver in three dimensions. Its official
name is NAVSTAR-GPS. GPS is increasingly used as an input for Geographic Information
Systems particularly for precise positioning of geospatial data and the collection of data in the
field. Precise positioning is possible using GPS receivers at reference locations providing
corrections and relative positioning data for remote receivers.
iv
Table of contents
CERTIFICATE FROM ECE DEPARTMENT (i)
ACKNOWLEDGEMENTS (ii)
ABSTRACT (iii)
LIST OF FIGURES (vi)
LIST OF TABLES (vii)
CHAPTER 1. OVERVIEW
1.1 Introduction 1
1.2 Aim of the project 1
1.3 Methodology 1
1.4 Significance 2
CHAPTER 2. EMBEDDED INTRODUCTION
2.1 What is embedded system 3
2.2 Embedded System Applications 3
2.3 Which Processor should we use 3
2.4 Which programming language should you use 4
2.5 Summary of C language Features 4
CHAPTER 3. BLOCK DIAGRAM
3.1 Block representation 6
3.2 Tools used in project 7
3.2.1 Software tools 7
3.2.2 Hardware tools 7
CHAPTER 4. HARDWARE DESCRIPTION
4.1 Power Supply 8
4.2 Micro Controller 14
4.3 GPS(Global Positioning System) 25
4.4 GSM 47
4.4.1 Introduction 47
4.4.2 1G 50
v
4.4.3 2G 51
4.4.4 3G 52
4.4.5 Architecture of GSM 54
4.5 MAX232 63
4.6 LCD 70
CHAPTER 5. SOFTWARE DESCRIPTION
5.1 Keil Micro Version 82
5.2 Flash Magic 92
CHAPTER 6.RESULTS AND CONCLUSIONS
6.1 Result 95
6.2 Applications 95
6.3 Conclusion 95
6.4 References 96
vi
LIST OF FIGURES
3.1 Block Diagram.5
4.1 Components of power supply..7
4.2 Electrical transformer..8
4.3 Rectifier...9
4.4 Pin diagram15
4.5 Functional block diagram of MC..16
4.6 Oscillator connection20
4.6a External clock driver20
4.7 Interrupt sources23
4.8 GPS C/A code sample38
4.9 DB9 connector pin out..66
4.10 Interfacing of LCD..75
5.1 Operation of keil mvision...82
vii
LIST OF TABLES
4.1 Port 1 alternate function17
4.2 Port 3 alternate function18
4.3 Interrupt enable register.22
4.4 Characteristics of GPS..27
4.5 GPS C/A code36
4.6 Mobile telephony standards...........49
4.7 LCD commads...73
4.8 Pin description...77
1
CHAPTER 1
INTRODUCTION
Now a days heavy traffic is there in main cities due to huge population, there a more
chances to make an accidents frequently. So the purpose of this project is to identify the
accidents immediately and then we can save the lives.
This project is designed based on the embedded technology, in which 8051 micro
controller is used as main controlling device. In this, we have GPS receiver and GSM module
is present in vehicle and vibrating sensor is also fixed to it for obstacle detection, when the
vehicle met to an accident. The GPS Receiver is interfaced with the micro controller its
continuously tracks the position and passes the information to GSM module through the
microcontroller. By this tracking system we can know the exact location where the accident
is occurred to the vehicle. The GPS receiver will track the information is given to the GSM
Modem; it will pass the information to our mobile.. When we will get a mobile alert SMS,
then we go to that location and save that person from injuries by take him/her to hospital.
Thus we can save their lives within the exact time. This can be implemented in real time.
So the main aim of the project is, when a person is going on the way, he met an
accident at that time nobody is there for saving. At this time this project is so useful for
saving the lives.
AIM OF PROJECT
The aim of the project is to build accident identification using GPS & GSM
METHODOLOGY
Existing System:
Currently there is no system available to intimate accidents occurring in
highways. Due this there are possibilities of threats like loss of life due to a small reason
i.e., no proper medical attention within the golden hour. Hence we are proposing a new
technique to intimate the accidents to the control room of medical center as early as
possible.
2
The Proposed System:
The GSM modem is attached with the MCU via RS232 interface.
Switchs is connected to the microcontroller. Whenever there occurs an accident, the
Switchs which are placed around the car is picks up the signal and transfers it to the
microcontroller. MCU will automatically sends a SMS to the Emergency number and
also its owner number. This will be a much simpler and low cost technique compared to
others, thus saving lots of human life.
SIGNIFICANCE
A strong vehicle oriented culture, a high proportion of older vehicles that have
little or no security features, the ease with which vehicle components can be absorbed by
an extensive black market, gaps in our national exchange of vehicle information and
some major misconceptions concerning the scale and nature of vehicle theft within our
motoring population. In short, vehicles are culturally highly desirable, the normal
inference is that the cause is operator error; the dominant cause of single-vehicle
accidents is excessive speed and alcohol. Some roads are particularly notorious for these
crashes, leading to them being termed "dangerous roads". In the accidental place they
need medical help as soon as possible. To avoid this kind delay in medical service we are
going to implement a system which helps in providing medical assistant for the needy.
3
CHAPTER 2
EMBEDDED INTRODUCTION
In this introductory chapter, we consider some important decisions that must be made
at the start of any embedded project:
- What is an Embedded system?
- The choice of processor.
- The choice of programming language.
2.1 What Is An Embedded System?
An embedded system is an application that contains at least one programmable
computer and which is used by individuals who are, in the main, unaware that the system
is computer-based.
2.2 Embedded System Applications:
Some of the typical examples of embedded applications that are constructed using the
techniques discussed below are:
- Mobile phone system: Including both customer handsets and base stations
- Automotive applications: Including banking systems, traction control, airbag
release systems, engine management units and cruise control applications.
- Domestic appliances: washing machines, television ,microwave ovens, video
recorders, security systems etc
- Medical Equipment: Including anesthesia monitoring systems, ECG monitors,
drug delivery systems and MRI scanners.
2.3 Which Processor should we use?
Overall, the state of the art technology used in desktop processors matches the needs of
the PC user very well: however, their key features-an ability to execute industry standard
4
code at a rate of more than 1000 million instructions per second-come with a heavy price
tag and are simply not required in most embedded systems.
The 8051 device is very different, it is a well tested design, introduced in its
original form by Intel in 1980.The development costs of this device have now been fully
recovered and prices of modern 8051 devices now start at less than US$1.00.At this
price, you get a performance of around 1million instructions per second and 256 bytes of
on- chip RAM and also get a32 port pins, a serial interface. The 8051 s profile match the
needs of many embedded systems very well. As a result, it is now produced in more than
400different forms by a diverse range of companies including Phillips, Infineon, Atmel
and Dallas.
2.4 Which programming language should you use?
Having decided to use an 8051 processor as the basis of your embedded system, the
next key decision that needs to be made is the choice of programming language. In order
to identify a suitable language for embedded systems, we might begin by making the
following observations:
- Computers (such as microcontroller, microprocessor or DSP chips) only accept
instructions in machine code (object codes). Machine code is, by definition, in
the language of the computer, rather than that of the programmer. Interpretation of
the code by the programmer is difficult and error prone.
- All software, whether in assembly, C, C++, Java or Ada must ultimately be
translated into machine code in order to be executed by the computer.
- Embedded processors like the 8051 have limited processor power and very
limited memory available: the language used must be efficient.
- The language chosen should be in common use.
2.5 Summary of C language Features:
It is mid-level, with high-level features (such as support for functions and modules),
and low-level features (such as good access to hardware via pointers).
- It is very efficient.
- It is popular and well understood.
- Even desktop developers who have used only Java or C++ can soon understand C
syntax.
5
- Good, well-proven compilers are available for every embedded processor (8-bit to
32-bit or more).
Basic C program structure:
//Basic blank C program that does nothing
// Includes
#include <reg51.h> // SFR declarations
Void main (void)
{
While (1);
{
Body of the loop // Infinite loop
}
} // match the braces
6
CHAPTER 3
3.1 BLOCK DIAGRAM :
Micro
Controller
GPS
Module
GSM
Modem
Max
232
Nand
Logic
LCD
Switch
7
3.2 TOOLS USED IN PROJECT :
SOFTWARE TOOLS USED:
1) Keil compiler.
2) Express PCB/ORCAD
HARDWARE TOOLS:
1) Micro controller.
2) MAX 232 Serial Communications.
3) Power Supply 5V.
4) GSM Module.
5) GPS Receiver.
6) LCD.
7) Analog switch.
8
CHAPTER 4
HARDWARE DESCRIPTION
4.1 POWER SUPPLY :
The power supplies are designed to convert high voltage AC mains electricity to
a suitable low voltage supply for electronic circuits and other devices. A power supply
can by broken down into a series of blocks, each of which performs a particular function.
A d.c power supply which maintains the output voltage constant irrespective of a.c mains
fluctuations or load variations is known as Regulated D.C Power Supply
Transformer:
A transformer is an electrical device which is used to convert electrical power
from one Electrical circuit to another without change in frequency. Transformers convert
AC electricity from one voltage to another with little loss of power. Transformers work
only with AC and this is one of the reasons why mains electricity is AC. Step-up
transformers increase in output voltage, step-down transformers decrease in output
voltage. Most power supplies use a step-down transformer to reduce the dangerously high
9
mains voltage to a safer low voltage. The input coil is called the primary and the output
coil is called the secondary. There is no electrical connection between the two coils;
instead they are linked by an alternating magnetic field created in the soft-iron core of the
transformer. The two lines in the middle of the circuit symbol represent the core.
Transformers waste very little power so the power out is (almost) equal to the power in.
Note that as voltage is stepped down current is stepped up. The ratio of the number of
turns on each coil, called the turns ratio, determines the ratio of the voltages. A step-
down transformer has a large number of turns on its primary (input) coil which is
connected to the high voltage mains supply, and a small number of turns on its secondary
(output) coil to give a low output voltage.
Fig:4.2 An Electrical Transformer
Rectifier:
A circuit which is used to convert a.c to dc is known as RECTIFIER. The process
of conversion of AC to DC is called rectification
Bridge rectifier:
A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-
wave rectification. This is a widely used configuration, both with individual diodes wired
as shown and with single component bridges where the diode bridge is wired internally.
- A bridge rectifier makes use of four diodes in a bridge arrangement as shown
in fig(a) to achieve full-wave rectification. This is a widely used
configuration, both with individual diodes wired as shown and with single
component bridges where the diode bridge is wired internally.
10
4.3 rectifier
Operation:
- During positive half cycle of secondary, the diodes D2 and D3 are in forward
biased while D1 and D4 are in reverse biased as shown in the fig(b). The current
flow direction is shown in the fig (b) with dotted arrows.
During negative half cycle of secondary voltage, the diodes D1 and D4 are in forward
biased while D2 and D3 are in reverse biased as shown in the fig(c). The current flow
direction is shown in the fig (c) with dotted arrows.
11
Filter:
A Filter is a device which removes the a.c component of rectifier output
but allows the d.c component to reach the load
Capacitor filter:
We have seen that the ripple content in the rectified output of half wave rectifier
is 121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high
percentages of ripples is not acceptable for most of the applications. Ripples can be
removed by one of the following methods of filtering.
(a) A capacitor, in parallel to the load, provides an easier by pass for the ripples voltage
though it due to low impedance. At ripple frequency and leave the d.c.to appears the load.
(b) An inductor, in series with the load, prevents the passage of the ripple current (due to
high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c)
(c) various combinations of capacitor and inductor, such as L-section filter section
filter, multiple section filter etc. which make use of both the properties mentioned in (a)
and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and
another with full wave rectifier
Filtering is performed by a large value electrolytic capacitor connected across the
DC supply to act as a reservoir, supplying current to the output when the varying DC
voltage from the rectifier is falling. The capacitor charges quickly near the peak of the
varying DC, and then discharges as it supplies current to the output. Filtering
significantly increases the average DC voltage to almost the peak value (1.4 RMS
value).
12
To calculate the value of capacitor(C),
C = *3*f*r*Rl
Where,
f = supply frequency,
r = ripple factor,
Rl = load resistance
Note: In our circuit we are using 1000F Hence large value of capacitor is placed to
reduce ripples and to improve the DC component.
Regulator:
Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable
output voltages. The maximum current they can pass also rates them. Negative voltage
regulators are available, mainly for use in dual supplies. Most regulators include some
automatic protection from excessive current ('overload protection') and overheating
('thermal protection'). Many of the fixed voltage regulator ICs have 3 leads and look like
power transistors, such as the 7805 +5V 1A regulator shown on the right. The LM7805 is
simple to use. You simply connect the positive lead of your unregulated DC power
supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to
the Common pin and then when you turn on the power, you get a 5 volt supply from the
output pin.
Fig A Three Terminal Voltage Regulator
78XX:
The Bay Linear LM78XX is integrated linear positive regulator with three
terminals. The LM78XX offer several fixed output voltages making them useful in wide
13
range of applications. When used as a zener diode/resistor combination replacement, the
LM78XX usually results in an effective output impedance improvement of two orders of
magnitude, lower quiescent current. The LM78XX is available in the TO-252, TO-220 &
TO-263packages,
Features:
Output Current of 1.5A
Output Voltage Tolerance of 5%
Internal thermal overload protection
Internal Short-Circuit Limited
No External Component
Output Voltage 5.0V, 6V, 8V, 9V, 10V,12V, 15V, 18V, 24V
Offer in plastic TO-252, TO-220 & TO-263
Direct Replacement for LM78XX
14
4.2 MICROCONTROLLER:
Microprocessors and microcontrollers are widely used in embedded systems
products. Microcontroller is a programmable device. A microcontroller has a CPU in
addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a single
chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in
microcontrollers makes them ideal for many applications in which cost and space are
critical.
The Intel 8051 is Harvard architecture, single chip microcontroller (C) which
was developed by Intel in 1980 for use in embedded systems. It was popular in the 1980s
and early 1990s, but today it has largely been superseded by a vast range of enhanced
devices with 8051-compatible processor cores that are manufactured by more than 20
independent manufacturers including Atmel, Infineon Technologies and Maxim
Integrated Products.
8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data
at a time. Data larger than 8 bits has to be broken into 8-bit pieces to be processed by the
CPU. 8051 is available in different memory types such as UV-EPROM, Flash and NV-
RAM.
The present project is implemented on Keil Uvision. In order to program the
device, Proload tool has been used to burn the program onto the microcontroller.
15
FEATURES OF AT89S52:
8K Bytes of Re-programmable Flash Memory.
RAM is 256 bytes.
4.0V to 5.5V Operating Range.
Fully Static Operation: 0 Hz to 33 MHzs
Three-level Program Memory Lock.
256 x 8-bit Internal RAM.
32 Programmable I/O Lines.
Three 16-bit Timer/Counters.
Eight Interrupt Sources.
Full Duplex UART Serial Channel.
Low-power Idle and Power-down Modes.
Interrupt recovery from power down mode.
Watchdog timer.
Dual data pointer.
Power-off flag.
Fast programming time.
Flexible ISP programming (byte and page mode).
Description:
The AT89s52 is a low-voltage, high-performance CMOS 8-bit microcomputer
with 8K bytes of Flash programmable memory. The device is manufactured using
Atmels high density nonvolatile memory technology and is compatible with the
industry-standard MCS-51 instruction set. The on chip flash allows the program memory
to be reprogrammed in system or by a conventional non volatile memory programmer.
By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89s52
is a powerful microcomputer, which provides a highly flexible and cost-effective solution
to many embedded control applications.
16
In addition, the AT89s52 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes. The Idle Mode
stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system
to continue functioning. The power-down mode saves the RAM contents but freezes the
oscillator disabling all other chip functions until the next hardware reset.
Figure4.4. Pin Diagram
17
Figure 4.5. Functional block diagram of micro controller
18
Pin Description :
Vcc Pin 40 provides supply voltage to the chip. The voltage source is +5V.
GND Pin 20 is the ground.
Port 0
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can
sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high
impedance inputs. Port 0 can also be configured to be the multiplexed low-order
address/data bus during accesses to external program and data memory. In this mode, P0
has internal pull-ups.
Port 0 also receives the code bytes during Flash programming and outputs the
code bytes during Program verification. External pull-ups are required during program
verification.
Port 1
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that
are externally being pulled low will source current (IIL) because of the internal pull-ups.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count
input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown
in the following table. Port 1 also receives the low-order address bytes during Flash
programming and verification.
Table 4.2. Port 1 Alternate Function
19
Port 2
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output
buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that
are externally being pulled low will source current (IIL) because of the internal pull-ups.
Port 2 emits the high-order address byte during fetches from external program
memory and during accesses to external data memory that uses 16-bit addresses (MOVX
@ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s.
During accesses to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2
emits the contents of the P2 Special Function Register. The port also receives the high-
order address bits and some control signals during Flash programming and verification.
Port 3
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that
are externally being pulled low will source current (IIL) because of the pull-ups. Port 3
receives some control signals for Flash programming and verification.
Port 3 also serves the functions of various special features of the AT89S52, as
shown in t he following table.
Table 4.2 Port 3 Alternate Function
20
RST
Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device. This pin drives high for 98 oscillator periods after the
Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to
disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is
enabled.
ALE/PROG
Address Latch Enable (ALE) is an output pulse for latching the low byte of the
address during accesses to external memory. This pin is also the program pulse input
(PROG) during Flash programming.
In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator
frequency and may be used for external timing or clocking purposes. Note, however, that
one ALE pulse is skipped during each access to external data memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH.
With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise,
the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the
microcontroller is in external execution mode.
PSEN
Program Store Enable (PSEN) is the read strobe to external program memory.
When the AT89S52 is executing code from external program memory, PSEN is activated
twice each machine cycle, except that two PSEN activations are skipped during each
access to external data memory.
EA/VPP
External Access Enable. EA must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at 0000H up to
FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on
reset.
21
EA should be strapped to VCC for internal program executions. This pin also
receives the 12-volt programming enable voltage (VPP) during Flash programming.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2
Output from the inverting oscillator amplifier.
Oscillator Connections External Clock Drive Configuration
Figure 4.2.3 .oscillator connections Figure 4.2.4. external clock drive
C1, C2 = 30 pF 10 pF for Crystals
= 40 pF 10 pF for Ceramic Resonators
XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier that can be configured for use as an on-chip oscillator. Either a quartz crystal or
ceramic resonator may be used. To drive the device from an external clock source,
XTAL2 should be left unconnected while XTAL1 is driven. There are no requirements
on the duty cycle of the external clock signal, since the input to the internal clocking
circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high
and low time specifications must be observed.
Memory Organization
MCS-51 devices have a separate address space for Program and Data Memory.
Up to 64K bytes each of external Program and Data Memory can be addressed.
Program memory
22
If the EA pin is connected to GND, all program fetches are directed to external
memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses
0000H through 1FFFH are directed to internal memory and fetches to addresses 2000H
through FFFFH are to external memory.
Data memory:
The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes
occupy a parallel address space to the Special Function Registers. This means that the
upper 128 bytes have the same addresses as the SFR space but are physically separate
from SFR space.
When an instruction accesses an internal location above address 7FH, the address
mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of
RAM or the SFR space. Instructions which use direct addressing access the SFR
space.For example, the following direct addressing instruction accesses the SFR at
location 0A0H (which is P2).
MOV 0A0H, #data
Instructions that use indirect addressing access the upper 128 bytes of RAM. For
example, the following indirect addressing instruction, where R0 contains 0A0H,
accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H).
MOV @R0, #data
Note that stack operations are examples of indirect addressing, so the upper 128
bytes of data RAM are available as stack space.
Interrupts
The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0
and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These
interrupts are all shown in Figure 13-1.Each of these interrupt sources can be individually
23
enabled or disabled by setting or clearing a bit in Special Function Register IE. IE also
contains a global disable bit, EA, which disables all interrupts at once. Note that Table
13-1 shows that bit position IE.6 is unimplemented. User software should not write a 1 to
this bit position, since it may be used in future AT89 products. Timer 2 interrupt is
generated by the logical OR of bits TF2 and EXF2 in register T2CON.
Neither of these flags is cleared by hardware when the service routine is vectored
to. In fact, the service routine may have to determine whether it was TF2 or EXF2 that
generated the interrupt, and that bit will have to be cleared in software. The Timer 0 and
Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow.
The values are then polled by the circuitry in the next cycle. However, the Timer 2 flag,
TF2, is set at S2P2 and is polled in the same cycle in which the timer overflows.
Table 4.3 Interrupt Enable Register
24
4.7 Interrupt sources
25
4.3 GPS (Global positioning system):
The entire GPS system consists of three segments: the control segment, the space
segment and the user segment. The control segment consists of five GPS earth stations.
The master control station is located at Falcon Air Force Base in Colorado Springs, CO.
The main function of the earth stations is to monitor the performance of the GPS
satellites. Each monitor station has two cesium clocks as reference for the GPS system
time. Each of the five earth stations makes continuous pseudo range and delta range
measurements to all satellites in view every 1.5 seconds.
These measurements are used to update the satellites navigation messages. The
data collected from the satellites by the earth stations is transmitted to the master control
station for processing. The master control station is responsible for monitoring GPS
performance, generating and uploading the navigation data to the satellites to sustain
performance standards, as well as promptly detecting and responding to satellite failure to
minimize the impact. Figure is a graphical illustration of the three segments of the GPS
system
26
The Control Segment
The locations of the GPS monitor stations are known with a high degree of
accuracy and each station is equipped with a cesium atomic clock. The control segment
uses the information collected by the monitor stations to predict the behavior of
individual satellites orbiting and clocking status, making sure that they remain in
acceptable limits. The prediction data is up linked to the satellites for transmission back
to the users. A station can perform a track up of up to 11 satellites at a time. The five
unmanned monitor stations are located around the world at Falcon Air Force Base in
Colorado, Hawaii, Ascension Island in the Atlantic Ocean, Diego Garcia Atoll in the
Indian Ocean, and Kwajalein Island in the South Pacific Ocean. The monitor stations
checks the exact altitude, position, speed, and the overall health of the orbiting satellites.
Ground antennas are used to monitor and track the satellites. They also transmit
corrective information back to the individual satellites [2]. The signals from each satellite
are read by four of the five stations excluding the station in Hawaii which does not have a
ground antenna. Since the precise positions of the stations and time coordinates are
known, the pseudorange measurements made by each station for a particular satellite can
27
be used to calculate an inverted navigation solution to correct any error in the location
and time of that satellite. The measurements from the monitor stations are then sent to the
master control station in Colorado. The Master Control Station is called the Consolidated
Space Operations Center (CSOC), which is located at Falcon Air Force Base in Colorado
Springs, Colorado. It controls the overall management of the remote monitoring and
transmission sites. As the main center for support operations, the Master Control Station
calculates any position or clock errors for each individual satellite according on the
information received from the monitor stations. If an error is found, it passes the
instructions to the monitor station with the appropriate ground antenna to relay the
necessary corrective information back to that particular satellite [2]. The ephemeris of
each satellite and the timing errors are uploaded to the satellites once per day via the
ground antennas even without any error occurring
The Space Segment
The space segment consists of the satellites and the Delta rockets that launch the
satellites from Cape Canaveral, in Florida. Each orbit has an inclination angle (the angle
between the earths equator and the actual orbit) of 55 to ensure the coverage of the
polar regions. The radius of the satellite orbit is 26,560 km and each satellite orbits the
earth twice in one sidereal day, which is the time for the earth to complete one 360
rotation. The mean sidereal day is 23 hours, 56 minutes, and 4.09 seconds, which is
slightly shorter than the solar day of 24 hours. Powered by solar cells, the satellites can
orientate themselves to face toward the sun for power and their antennas toward the earth
for transmission. Table lists some of the characteristics of the GPS satellites.
28
Table 4.4
The User Segment
The user segment consists of the passive GPS receivers. The receivers utilize the
signals transmitted from the satellites, together with precise measurement of the signal
transmission delays to determine the user position and velocity, as well as synchronize to
the GPS time. The users can be classified into two groups, military and civilian users.
The military uses the GPS in a wide range of scope, from navigation tools to target
designation, air support to the integration of smart weapons [4]. For the civilian users,
GPS is used in many applications such as point-to-point navigation as well as surveying.
User Position Solution
Though the GPS signal travels to the ground at the speed of light, it still takes a
measurable amount of time to reach the receiver. The receiver then calculates the distance
to he satellite by measuring the difference between the time when the signal is received
and the time when it was sent, and multiply by the speed of light. To calculate its precise
latitude, longitude, and altitude, the receiver measures the distance to four separate GPS
satellites.
Solution of User Position From Pseudorange Measurements
To determine the user position in three-dimensional space, three satellites and
three ranges from different satellites to the receiver are required. The intersection of the
three distances should indicate the users position. However, a fourth satellite is necessary
to calculate the unknown bias between the satellite clock and the receiver clock. The need
29
for the fourth satellite is due to difference in the precise atomic clock that is used in the
satellite and the normal clock used in the receiver. The atomic clock is much more
accurate than the clock used in the GPS receiver. Any slight error in the user clock can
result in a significant offset in the exact user location. However, the atomic clocks are
much more expensive than a regular clock and it is uneconomical for every GPS receiver
to contain an atomic clock. Therefore, the fourth satellite becomes necessary which
allows a receiver to solve for the timing offset and eliminate it in calculating the
navigation solution.
User Position Accuracy Measure
Two factors affect a users overall position accuracy: the errors inherent in the
GPS signals and the geometry of the four GPS satellites whose signals are used to
calculate the navigation solution. The inherent error in the GPS signal is known as the
user equivalent range error (UERE), which is primarily contributed by the clock and
ephemeris errors from the satellites, atmospheric delays, multipath, and receiver noise.
The other source of error depends on the GPS satellite geometry.
Since the receiver determines its position using trilateration, the further apart the
four satellites are, the better the receiver position accuracy is. The effect of satellite
geometry on the accuracy of a navigation solution is measured by the dilution of
precision (DOP).
GPS SINGNAL STRUCTURE:
The GPS signal is a phase-modulated signal using bi-phase shift keying (BPSK).
The phase change rate is often referred as the chip rate. The spectrum of the signal can be
described by a sinc function with spectrum width proportional to the chip rate. If the chip
rate is 1 MHz, the main lobe of the spectrum has a null-to-null width of 2 MHz.
Therefore, this type of signal is referred to as a spread-spectrum signal [1]. A code
division multiple access (CDMA) signal in general is a spread-spectrum system. All the
signals in the system have the same carrier frequency. The signals are modulated by a set
of orthogonal (or nearorthogonal) codes. In order to acquire an individual signal, the code
30
of that signal must be used to correlate with the received signal. A system is referred as a
direct-sequence modulated system when the modulation code is a digital sequence with a
frequency higher than the data rate. The GPS signal is CDMA using direct sequence to
bi-phase modulate the carrier frequency.
Since the CDMA signals of a system use the same carrier frequency, there is a greater
probability of interference among the signals. This effect is especially significant when
strong and weak signals are mixed together. Sometimes during the acquisition process, a
cross-correlation peak of a strong signal may be stronger than the desired peak of a weak
signal. In this case, the receiver may then obtain the wrong information. In order to avoid
the interference, all the signals should have approximately the same power levels at the
receiver.
GPS Signal Structure
There are two types of GPS signals: the coarse/acquisition (C/A) code and
precision (P) code. The actual P code is encrypted by a Y code, so it is often referred as
the P(Y) code. Currently, the C/A code is used for civilian applications while the P(Y)
code is reserved for military use. The focus of this software GPS receiver is to acquire
and track the C/A code. The GPS signals are transmitted on two different frequencies: L1
(1575.42 MHz) and L2 (1227.6 MHz). These frequencies are coherent with a 10.23 MHz
clock related as follows
31
There have been developments on the signal structure of GPS. Currently the L1
frequency carries both the C/A coded signals and the P(Y) signals. The L2 frequency
contains only the P(Y) signal. The P(Y) code is only available for PPS users, while the
C/A code is also available for SPS users. Since the focus of this software receiver design
is on civilian applications,
So only the acquisition and tracking GPS signals at L1 frequency are studied in detail.
The GPS signal at L1 frequency can be expressed aswhere L1 S is the signal at L1
frequency, p A is the amplitude of the P code, P(t) = 1is the phase of the P code,
D(t) = 1 is the data code, 1 f is the L1 frequency, f is the initial phase, c A is the
amplitude of the C/A code, C(t) = 1is the phase of the C/A code [1]. Figure 2.2 shows
the block diagram of how the GPS L1 frequency signal is generated.
32
The P Code
The P code is bi-phase modulated at 10.23 MHz and the main lobe of the spectrum
is 20.46 MHz wide from null-to-null. The code is generated from two pseudorandom
noise (PRN) codes with the same chip rate of 10.23 MHz. One PRN sequence has
15,345,000 chips, which has a period of 1.5 seconds, the other one has 15,345,037 chips,
and the ifference is 37 chips.
The code length generated by these two codes is 23,017,555.5 seconds, which is
slightly longer than 38 weeks. However, the actual length of the P code is 1 week as the
code is reset every week. This 38-week-long code can be divided into 37 different P
codes and each satellite can use a different portion of the code [1]. The first 32 sets of
codes are used for the satellites in orbit. Five of the P code signals (33-37) are reserved
for other uses such as ground transmission. In order to perform acquisition on the signal,
33
the time of the week information must be known very accurately which can be obtained
through the C/A code.
The C/A Code
The C/A code is a bi-phase modulated signal with a chip rate of 1.023 MHz with a
nullto- null bandwidth of the main lobe of the signal spectrum of 2.046 MHz. Each chip
period is 977.5 ns (1/1.023 MHz). However, the transmission bandwidth of the GPS
signal at the L1 frequency is approximately 20 MHz to accommodate the bandwidth
needed for the P code signal. Therefore, in addition to the main lobe of the C/A code
signal, several side lobes of the signal are also transmitted in this bandwidth. Figure 2.3
shows a screen shot of a C/A coded GPS signal on the spectrum analyzer. The L1
frequency GPS signal contains only the C/A code and is simulated by the Spirent GSS
6560 simulator. It can be observed that the null-to-null bandwidth of main lobe is
approximately 2 MHz.
34
The spectrum of the C/A code of satellite 31 sampled at 5 MHz is shown in Figure 2.4.
The C/A code period contains 1,023 chips, and with the chip rate of 1.023 MHz, the code
period is 1 ms. Since the navigation data has a data rate of 50 Hz, one data bit period is
20 ms long and contains 20 complete sets of C/A codes.
Generation of C/A Code
To understand the acquisition and tracking of the C/A coded GPS signal, the
composition of the C/A code is studied. The GPS C/A code is one kind of Pseudorandom
noise (PRN) codes also known as the Gold codes. Two maximum-length linear feedback
shift register (LFSR) of 10 stages, G1 and G2, driven by a 1.023 MHz clock, are used to
generate a maximum length pseudo random code. If the shift register has n bits, the
length of the sequence generated is 2n 1. Since both shift registers in G1 and G2 have
35
10 bits, the sequence length generated is (210 1)= 1023bits. Both G1 and G2 are
initialized to be all ones, since the all-zero state is illegal. The feedback taps of the G1
and G2 LFSRs are defined by the generator polynomials
The output of the G2 LFSR for each C/A code is delayed by the modulo-2
addition of two code phase selection bits specific for each satellite. The C/A code is
generated by the modulo-2 addition of the output of the G1 LFSR and the delayed output
of the G2 LFSR. Figure 2.5 is a graphical presentation of how the C/A code for a
particular satellite is generated. This will work since adding a phase-shifted version of a
PRN sequence to itself will shift the phase of the code, while not changed the code [3].
The positions of the code selection bits determine the satellite identification. There are 32
sets of unique C/A codes for the 32 satellite numbers. Another five are reserved for
various applications such as ground transmission.
36
.
Table 4.5 gps c/a code
37
Correlation Properties of C/A Code
One of the most important properties of the C/A codes is their high
autocorrelation peak and low cross-correlation peaks. However, in order to detect the
presence of a weak signal, the peak of the autocorrelation of the weak signal must be
stronger than the cross-correlation peaks of the strong signals.Theoretically if the codes
are orthogonal, the cross correlation values will be zero. However, the Gold codes are
only near orthogonal codes, so the cross correlation values of the C/A codes are not zero
but rather small values.
The autocorrelation function of a C/A code is
where CAi is the C/A code from the i-th satellite, and t is the phase of the time
shift. The correlation peak repeats every code period. The high correlation peak property
of the autocorrelation function is used to synchronize the receiver locally generated code
with the code of the received signal. The ideal cross-correlation of orthogonal codes are
zero, but since the C/A codes are only near orthogonal, the cross-correlation values are
not zero but small compared to the correlation peak value. The cross-correlation between
the C/A codes of two satellites is defined as
where CAi is the C/A code for the i-th satellite and CAj is the C/A code for the j-
th satellite and i = j . In Figure 2.6 a, the autocorrelation of one set of C/A code for
satellite 15 is plotted. close-up view of the autocorrelation is shown in Figure 2.6 b. The
maximum autocorrelation value is 1023, which corresponds to the number of chips in one
set of the C/A code. The scale of the figure is shifted to show the peak at the center. The
autocorrelation reaches its maximum whent = 0.
38
4.8 c/a code sample
39
The cross-correlation value of two Gold Codes with even n values is one of the
three values calculated using Eq. 2.4
40
In the case of the C/A codes, n = 10 is even, so the P value is calculated to be 1,023.
The cross-correlation values are calculated using Eq. 2.4 and the results are given in Table
2.2.
The cross-correlation values of the C/A codes of satellite 15 and 31 is presented in
the Figure 2.7. Since the values are very small, the GPS satellites can simultaneously
broadcast signals at the same frequency. The cross-correlation takes on one of the three
values 63, -65 and -1 [1].
41
From Figure 2.6 and 2.7, it can be seen that the correlation peak value is much
more significant than any other correlation values. The high peak value helps the
receiver to acquire the GPS signal. The secondary peaks in the autocorrelation are at
least aroximately 24 dB down from the original peak. The ratios of the secondary peaks
are the aximum and are calculated as follow
Navigation Data Message
GPS satellites transmit 50-bit-per-second data streams which are superimposed on the
C/A- and P-codes via modulo-2 additions. Once a receiver has matched its code to the code
of a satellite at the carrier frequency, it can begin to decode the navigation data message from
the particular satellite. Thirty data bits make up a word which is 600 ms long. Ten words
make up a subframe of 6 seconds. A page of data contains 5 subframes and is 30 seconds
long. A satellites entire data message lasts 12.5 minutes and contains 25 pages of data. The
1500 bits navigation message contains information concerning the satellite clock, the satellite
orbit, the satellite health status, and various other data. The information content of the five
subframes can be summarized in Table 2.3
The first three subframes contain information about the ephemeris used to calculate
the user position. Each subframe contains ten words. The first word is the telemetry word
42
(TLM) containing a synchronization pattern and diagnostic messages. The second word of
each subframe is the hand-over word (HOW) which contains among others the Z-count, an
internally derived 1.5 s since the beginning of the current GPS week in each satellite. This
number and the P-code give the reading of the satellite clock at signal transmission time. The
GPS time is given in terms of the number of seconds in a week and is reset at the end/start of
each week. At the end/start of the week, the cyclic paging to subframes one through five will
restart with subframe one regardless of which subframe was last transmitted prior to end/start
of week [1]. All upload and page cutovers will occur on frame boundaries. Each satellite
transmits its own position in three-dimensional coordinates and time. All GPS receivers are
passive, so they are solely dependent on the received signals for the necessary processing.
The receivers make use of one way Time of Arrival (TOA), which is the transmission time
from satellites to the receivers. The navigation data provides the receiver with the location of
the satellite at the time of transmit.
Doppler Shift
The Doppler frequency shift caused by the satellite motion affects both the carrier
frequency and the C/A code. The radius of the earth is 6,378 km around the equator and
6,357 km at the poles. The mean earth radius is considered as 6,371.3 km. The angular
velocity dq / dt and the speed of the satellite s v can be calculated from the approximate radius
of the satellite orbit as
where s r is the mean radius of the satellite orbit and q is the angle between the
user and the satellite. The Doppler frequency is caused by the satellite velocity
component d v direct toward the Receiver
43
where e r is the mean radius of the earth
Figure 2.7 shows the Doppler velocity is zero when the elevation angle is 90.
The maximum Doppler velocity is calculated by taking the derivative of the Doppler
velocity and setting it equal to zero as follows [1]
The maximum Doppler velocity dm v occurs along the horizon and is calculated using Eq.
2.8.
44
The maximum Doppler frequency for the L1 frequency can therefore be calculated using
Eq. 2.9
In the acquisition phase of the receiver, the search range is expanded to 5
kHz.of the carrier frequency to accommodate Doppler Frequency shift. The Doppler
frequency also shifts the C/A code, but the effect is rather small due to the low frequency
of the C/A code (1.023MHz). The Doppler frequency on the C/A code is calculated as
follows
The rate of change of the Doppler frequency is an important factor in determining
the frequency update rate in the tracking process. One simple way to estimate the average
rate of change of the Doppler frequency and another way is to calculate the maximum
rate of change of the Doppler frequency [1]. The elevation angle for the maximum
Doppler velocity can be solved using Eq 2.11
Since the satellite completes one orbit in 11 hours, 58 minutes and 2.05 seconds,
the satellite travels 2p radians. The time it takes to change from the maximum Doppler
angle to minimum Doppler angle is calculated as follows
45
During this time, the Doppler frequency changes from 4.9 kHz to 0, so the average
rate of change of the Doppler frequency can be calculated as
In tracking the GPS signal in a GPS receiver, two factors are necessary to
update the tracking loop: the change of the carrier frequency and the alignment of the
input data signal and the locally generated C/A code. However, since the change in
Doppler frequency is not constant over time, the maximum Doppler frequency change
also needs to be considered. The maximum change in Doppler velocity, d v , over time
can be computed as follows [1]
Since the maximum rate of change of the frequency occurs at q = , the
corresponding maximum rate of change of the speed is.
The maximum rate of change of the Doppler frequency can then be calculated as
46
This value is still relatively small which allows the tracking loop to be updated every
second. From the above calculations, it can be seen that the rate of change of the Doppler
frequency caused by the satellite motion is very low and the update rate of the tracking
program is much more frequent for the satellite motions to have significant effects
4.4.GSM Technology:
4.4.1.. Introduction to the GSM Standard
The GSM (Global System for Mobile communications) network is at the start of
the 21
st
century, the most commonly used mobile telephony standard in Europe. It is
called as Second Generation (2G) standard because communications occur in an entirely
digital mode, unlike the first generation of portable telephones.
When it was first standardized in 1982, it was called as Group Special Mobile
and later, it became an international standard called "Global System for Mobile
communications" in 1991. In Europe, the GSM standard uses the 900 MHz and 1800
MHz frequency bands. In the United States, however, the frequency band used is the
1900 MHz band. For this reason, portable telephones that are able to operate in both
Europe and the United States are called tri-band while those that operate only in Europe
are called bi-band.
The GSM standard allows a maximum throughput of 9.6 kbps which allows
transmission of voice and low-volume digital data like text messages (SMS, for Short
Message Service) or multimedia messages (MMS, for Multimedia Message Service).
GSM Standards:
GSM uses narrowband TDMA, which allows eight simultaneous calls on the
same radio frequency. There are three basic principles in multiple access, FDMA
47
(Frequency Division Multiple Access), TDMA (Time Division Multiple Access), and
CDMA (Code Division Multiple Access). All three principles allow multiple users to
share the same physical channel. But the two competing technologies differ in the way
user sharing the common resource.
TDMA allows the users to share the same frequency channel by dividing the
signal into different time slots. Each user takes turn in a round robin fashion for
transmitting and receiving over the channel. Here, users can only transmit in their
respective time slot. CDMA uses a spread spectrum technology that is it spreads the
information contained in a particular signal of interest over a much greater bandwidth
than the original signal. Unlike TDMA, in CDMA several users can transmit over the
channel at the same time.
Definition of GSM:
GSM (Global System for Mobile communications) is an open, digital cellular
technology used for transmitting mobile voice and data services. GSM (Global System
for Mobile communication) is a digital mobile telephone system that is widely used in
Europe and other parts of the world. GSM uses a variation of Time Division Multiple
Access (TDMA) and is the most widely used of the three digital wireless telephone
technologies (TDMA, GSM, and CDMA). GSM digitizes and compresses data, then
sends it down a channel with two other streams of user data, each in its own time slot. It
operates at either the 900 MHz or 1,800 MHz frequency band. It supports voice calls and
data transfer speeds of up to 9.6 kbit/s, together with the transmission of SMS (Short
Message Service).
History
In 1982, the European Conference of Postal and Telecommunications
Administrations (ECPT) created the Group Special Mobile (GSM) to develop a standard
for a mobile telephone system that could be used across Europe. In 1987, a
memorandum of understanding was signed by 13 countries to develop a common cellular
48
telephone system across Europe. Finally the system created by SINTEF lead by Torleiv
Maseng was selected.
In 1989, GSM responsibility was transferred to the European
Telecommunications Standards Institute (ETSI) and phase I of the GSM specifications
were published in 1990. The first GSM network was launched in 1991 by Radiolinja in
Finland with joint technical infrastructure maintenance from Ericsson.
By the end of 1993, over a million subscribers were using GSM phone networks
being operated by 70 carriers across 48 countries. As of the end of 1997, GSM service
was available in more than 100 countries and has become the de facto standard in Europe
and Asia.
GSM Frequencies
GSM networks operate in a number of different frequency ranges (separated into
GSM frequency ranges for 2G and UMTS frequency bands for 3G). Most 2G GSM
networks operate in the 900 MHz or 1800 MHz bands. Some countries in the Americas
(including Canada and the United States) use the 850 MHz and 1900 MHz bands because
the 900 and 1800 MHz frequency bands were already allocated. Most 3G GSM networks
in Europe operate in the 2100 MHz frequency band. The rarer 400 and 450 MHz
frequency bands are assigned in some countries where these frequencies were previously
used for first-generation systems.
GSM-900 uses 890915 MHz to send information from the mobile station to the
base station (uplink) and 935960 MHz for the other direction (downlink), providing 124
RF channels (channel numbers 1 to 124) spaced at 200 kHz. Duplex spacing of 45 MHz
is used. In some countries the GSM-900 band has been extended to cover a larger
frequency range. This 'extended GSM', E-GSM, uses 880915 MHz (uplink) and 925
960 MHz (downlink), adding 50 channels (channel numbers 975 to 1023 and 0) to the
original GSM-900 band.
49
Time division multiplexing is used to allow eight full-rate or sixteen half-rate
speech channels per radio frequency channel. There are eight radio timeslots (giving
eight burst periods) grouped into what is called a TDMA frame. Half rate channels use
alternate frames in the same timeslot. The channel data rate for all 8 channels is
270.833 Kbit/s, and the frame duration is 4.615 ms.
The transmission power in the handset is limited to a maximum of 2 watts in
GSM850/900 and 1 watt in GSM1800/1900. GSM operates in the 900MHz and 1.8GHz
bands in Europe and the 1.9GHz and 850MHz bands in the US. The 850MHz band is also
used for GSM and 3G in Australia, Canada and many South American countries. By
having harmonized spectrum across most of the globe, GSMs international roaming
capability allows users to access the same services when travelling abroad as at home.
This gives consumers seamless and same number connectivity in more than 218
countries.
Terrestrial GSM networks now cover more than 80% of the worlds population.
GSM satellite roaming has also extended service access to areas where terrestrial
coverage is not available.
Mobile Telephony Standards
Standard Generation Frequency band Throughput
GSM 2G
Allows transfer of voice or low-
volume digital data. 9.6 kbps
9.6
kbps
GPRS 2.5G
Allows transfer of voice or
moderate-volume digital data.
21.4-171.2
kbps
48
kbps
EDGE 2.75G
Allows simultaneous transfer of
voice and digital data.
43.2-345.6
kbps
171
kbps
UMTS 3G
Allows simultaneous transfer of
voice and high-speed digital data. 0.144-2 Mbps
384
kbps
4.4.2. 1G:
50
The first generation of mobile telephony (written 1G) operated using analogue
communications and portable devices that were relatively large. It used primarily the
following standards:
- AMPS (Advanced Mobile Phone System), which appeared in 1976 in the United
States, was the first cellular network standard. It was used primarily in the
Americas, Russia and Asia. This first-generation analogue network had weak
security mechanisms which allowed hacking of telephones lines.
- TACS (Total Access Communication System) is the European version of the
AMPS model. Using the 900 MHz frequency band, this system was largely used
in England and then in Asia (Hong-Kong and Japan).
- ETACS (Extended Total Access Communication System) is an improved version
of the TACS standard developed in the United Kingdom that uses a larger number
of communication channels.
The first-generation cellular networks were made obsolete by the appearance of an
entirely digital second generation.
4.4.3. Second Generation of Mobile Networks (2G):
The second generation of mobile networks marked a break with the first generation of
cellular telephones by switching from analogue to digital. The main 2G mobile telephony
standards are:
- GSM (Global System for Mobile communications) is the most commonly used
standard in Europe at the end of the 20
th
century and supported in the United
States. This standard uses the 900 MHz and 1800 MHz frequency bands in
Europe. In the United States, however, the frequency band used is the 1900 MHz
51
band. Portable telephones that are able to operate in Europe and the United States
are therefore called tri-band.
- CDMA (Code Division Multiple Access) uses a spread spectrum technique that
allows a radio signal to be broadcast over a large frequency range.
- TDMA (Time Division Multiple Access) uses a technique of time division of
communication channels to increase the volume of data transmitted
simultaneously. TDMA technology is primarily used on the American continent,
in New Zealand and in the Asia-Pacific region.
With the 2G networks, it is possible to transmit voice and low volume digital data, for
example text messages (SMS, for Short Message Service) or multimedia messages
(MMS, for Multimedia Message Service). The GSM standard allows a maximum data
rate of 9.6 kbps.
Extensions have been made to the GSM standard to improve throughput. One of these
is the GPRS (General Packet Radio System) service which allows theoretical data rates
on the order of 114 Kbit/s but with throughput closer to 40 Kbit/s in practice. As this
technology does not fit within the "3G" category, it is often referred to as 2.5G
The EDGE (Enhanced Data Rates for Global Evolution) standard, billed as 2.75G,
quadruples the throughput improvements of GPRS with its theoretical data rate of 384
Kbps, thereby allowing the access for multimedia applications. In reality, the EDGE
standard allows maximum theoretical data rates of 473 Kbit/s, but it has been limited in
order to comply with the IMT-2000(International Mobile Telecommunications-2000)
specifications from the ITU (International Telecommunications Union).
4.4.4.3G:
.The IMT-2000 (International Mobile Telecommunications for the year 2000)
specifications from the International Telecommunications Union (ITU) defined the
52
characteristics of 3G (third generation of mobile telephony). The most important of these
characteristics are:
1. High transmission data rate.
2. 144 Kbps with total coverage for mobile use.
3. 384 Kbps with medium coverage for pedestrian use.
4. 2 Mbps with reduced coverage area for stationary use.
5. World compatibility.
6. Compatibility of 3rd generation mobile services with second generation networks.
3G offers data rates of more than 144 Kbit/s, thereby allowing the access to
multimedia uses such as video transmission, video-conferencing or high-speed internet
access. 3G networks use different frequency bands than the previous networks: 1885-
2025 MHz and 2110-2200 MHz.
The main 3G standard used in Europe is called UMTS (Universal Mobile
Telecommunications System) and uses WCDMA (Wideband Code Division Multiple
Access) encoding. UMTS technology uses 5 MHz bands for transferring voice and data,
with data rates that can range from 384 Kbps to 2 Mbps. HSDPA (High Speed Downlink
Packet Access) is a third generation mobile telephony protocol, (considered as "3.5G"),
which is able to reach data rates on the order of 8 to 10 Mbps. HSDPA technology uses
the 5 GHz frequency band and uses WCDMA encoding.
The concept of cellular network
Mobile telephone networks are based on the concept of cells, circular zones that
overlap to cover a geographical area.
53
Cellular networks are based on the use of a central transmitter-receiver in each
cell, called a "base station" (or Base Transceiver Station, written BTS). The smaller the
radius of a cell, the higher is the available bandwidth. So, in highly populated urban
areas, there are cells with a radius of a few hundred meters, while huge cells of up to 30
kilometers provide coverage in rural areas. In a cellular network, each cell is surrounded
by 6 neighbouring cells (thus a cell is generally drawn as a hexagon). To avoid
interference, adjacent cells cannot use the same frequency. In practice, two cells using the
same frequency range must be separated by a distance of two to three times the diameter
of the cell.
4.4.5 Architecture of the GSM Network
In a GSM network, the user terminal is called a mobile station. A mobile station
is made up of a SIM (Subscriber Identity Module) card allowing the user to be uniquely
identified and a mobile terminal. The terminals (devices) are identified by a unique 15-
digit identification number called IMEI (International Mobile Equipment Identity). Each
SIM card also has a unique (and secret) identification number called IMSI (International
Mobile Subscriber Identity). This code can be protected using a 4-digit key called a PIN
code.
The SIM card therefore allows each user to be identified independently of the
terminal used during communication with a base station. Communications occur through
a radio link (air interface) between a mobile station and a base station.
54
All the base stations of a cellular network are connected to a base station
controller (BSC) which is responsible for managing distribution of the resources. The
system consisting of the base station controller and its connected base stations is called
the Base Station Subsystem (BSS).
Finally, the base station controllers are themselves physically connected to
the Mobile Switching Centre (MSC), managed by the telephone network operator,
which connects them to the public telephone network and the Internet. The MSC belongs
to a Network Station Subsystem (NSS), which is responsible for managing user
identities, their location and establishment of communications with other subscribers. The
MSC is generally connected to databases that provide additional functions:
1. The Home Location Register (HLR) is a database containing information
(geographic position, administrative information etc.) of the subscribers registered
in the area of the switch (MSC).
55
2. The Visitor Location Register (VLR) is a database containing information of
users other than the local subscribers. The VLR retrieves the data of a new user
from the HLR of the user's subscriber zone. The data is maintained as long as the
user is in the zone and is deleted when the user leaves or after a long period of
inactivity (terminal off).
3. The Equipment Identify Register (EIR) is a database listing the mobile
terminals.
4. The Authentication Centre (AUC) is responsible for verifying user identities.
5. The cellular network formed in this way is designed to support mobility via
management of handovers (movements from one cell to another).
Finally, GSM networks support the concept of roaming i.e., movement from one
operator network to another.
A GSM modem can be an external device or a PC Card / PCMCIA Card.
Typically, an external GSM modem is connected to a computer through a serial cable or a
USB cable. A GSM modem in the form of a PC Card / PCMCIA Card is designed for use
with a laptop computer. It should be inserted into one of the PC Card / PCMCIA Card
slots of a laptop computer.
56
Like a GSM mobile phone, a GSM modem requires a SIM card from a wireless carrier in
order to operate.
A SIM card contains the following information:
- Subscriber telephone number (MSISDN)
- International subscriber number (IMSI, International Mobile Subscriber
Identity)
- State of the SIM card
- Service code (operator)
- Authentication key
- PIN (Personal Identification Code)
- PUK (Personal Unlock Code)
Computers use AT commands to control modems. Both GSM modems and dial-up
modems support a common set of standard AT commands. In addition to the standard AT
commands, GSM modems support an extended set of AT commands. These extended AT
commands are defined in the GSM standards. With the extended AT commands, the
following operations can be performed:
- Reading, writing and deleting SMS messages.
- Sending SMS messages.
- Monitoring the signal strength.
- Monitoring the charging status and charge level of the battery.
- Reading, writing and searching phone book entries.
57
The number of SMS messages that can be processed by a GSM modem per minute is
very low i.e., about 6 to 10 SMS messages per minute.
Introduction to AT Commands:
AT commands are instructions used to control a modem. AT is the abbreviation of
ATtention. Every command line starts with "AT" or "at". That's the reason, modem
commands are called AT commands. Many of the commands that are used to control
wired dial-up modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and
ATO (Return to online data state) are also supported by GSM modems and mobile
phones.
Besides this common AT command set, GSM modems and mobile phones
support an AT command set that is specific to the GSM technology, which includes
SMS-related commands like AT+CMGS (Send SMS message), AT+CMSS (Send SMS
58
message from storage), AT+CMGL (List SMS messages) and AT+CMGR (Read SMS
messages).
It should be noted that the starting "AT" is the prefix that informs the modem
about the start of a command line. It is not part of the AT command name. For example,
D is the actual AT command name in ATD and +CMGS is the actual AT command name
in AT+CMGS. Some of the tasks that can be done using AT commands with a GSM
modem or mobile phone are listed below:
Get basic information about the mobile phone or GSM modem. For example,
name of manufacturer (AT+CGMI), model number (AT+CGMM), IMEI number
(International Mobile Equipment Identity) (AT+CGSN) and software version
(AT+CGMR).
Get basic information about the subscriber. For example, MSISDN (AT+CNUM)
and IMSI number (International Mobile Subscriber Identity) (AT+CIMI).
Get the current status of the mobile phone or GSM/GPRS modem. For example,
mobile phone activity status (AT+CPAS), mobile network registration status
(AT+CREG), radio signal strength (AT+CSQ), battery charge level and battery
charging status (AT+CBC).
Establish a data connection or voice connection to a remote modem (ATD, ATA,
etc).
Send and receive fax (ATD, ATA, AT+F*).
Send (AT+CMGS, AT+CMSS), read (AT+CMGR, AT+CMGL), write
(AT+CMGW) or delete (AT+CMGD) SMS messages and obtain notifications of
newly received SMS messages (AT+CNMI).
Read (AT+CPBR), write (AT+CPBW) or search (AT+CPBF) phonebook entries.
59
Perform security-related tasks, such as opening or closing facility locks
(AT+CLCK), checking whether a facility is locked (AT+CLCK) and changing
passwords(AT+CPWD).
(Facility lock examples: SIM lock [a password must be given to the SIM card
every time the mobile phone is switched on] and PH-SIM lock [a certain SIM
card is associated with the mobile phone. To use other SIM cards with the mobile
phone, a password must be entered.])
Control the presentation of result codes / error messages of AT commands. For
example, the user can control whether to enable certain error messages
(AT+CMEE) and whether error messages should be displayed in numeric format
or verbose format (AT+CMEE=1 or AT+CMEE=2).
Get or change the configurations of the mobile phone or GSM/GPRS modem. For
example, change the GSM network (AT+COPS), bearer service type
(AT+CBST), radio link protocol parameters (AT+CRLP), SMS center address
(AT+CSCA) and storage of SMS messages (AT+CPMS).
Save and restore configurations of the mobile phone or GSM/GPRS modem. For
example, save (AT+CSAS) and restore (AT+CRES) settings related to SMS
messaging such as the SMS center address.
It should be noted that the mobile phone manufacturers usually do not implement all
AT commands, command parameters and parameter values in their mobile phones. Also,
the behavior of the implemented AT commands may be different from that defined in the
standard. In general, GSM modems, designed for wireless applications, have better
support of AT commands than ordinary mobile phones.
Basic concepts of SMS technology:
1. Validity Period of an SMS Message
An SMS message is stored temporarily in the SMS center if the recipient mobile
phone is offline. It is possible to specify the period after which the SMS message will be
60
deleted from the SMS center so that the SMS message will not be forwarded to the
recipient mobile phone when it becomes online. This period is called the validity period.
A mobile phone should have a menu option that can be used to set the validity period.
After setting it, the mobile phone will include the validity period in the outbound SMS
messages automatically.
2. Message Status Reports
Sometimes the user may want to know whether an SMS message has reached the
recipient mobile phone successfully. To get this information, you need to set a flag in the
SMS message to notify the SMS center that a status report is required about the delivery
of this SMS message. The status report is sent to the user mobile in the form of an SMS
message. A mobile phone should have a menu option that can be used to set whether the
status report feature is on or off. After setting it, the mobile phone will set the
corresponding flag in the outbound SMS messages for you automatically. The status
report feature is turned off by default on most mobile phones and GSM modems.
3. Message Submission Reports
After leaving the mobile phone, an SMS message goes to the SMS center. When
it reaches the SMS center, the SMS center will send back a message submission report to
the mobile phone to inform whether there are any errors or failures (e.g. incorrect SMS
message format, busy SMS center, etc). If there is no error or failure, the SMS center
sends back a positive submission report to the mobile phone. Otherwise it sends back a
negative submission report to the mobile phone. The mobile phone may then notify the
user that the message submission was failed and what caused the failure.
If the mobile phone does not receive the message submission report after a period
of time, it concludes that the message submission report has been lost. The mobile phone
may then send the SMS message again to the SMS center. A flag will be set in the new
SMS message to inform the SMS center that this SMS message has been sent before. If
the previous message submission was successful, the SMS center will ignore the new
SMS message but send back a message submission report to the mobile phone. This
mechanism prevents the sending of the same SMS message to the recipient multiple
61
times. Sometimes the message submission report mechanism is not used and the
acknowledgement of message submission is done in a lower layer.
4. Message Delivery Reports
After receiving an SMS message, the recipient mobile phone will send back a
message delivery report to the SMS center to inform whether there are any errors or
failures (example causes: unsupported SMS message format, not enough storage space,
etc). This process is transparent to the mobile user. If there is no error or failure, the
recipient mobile phone sends back a positive delivery report to the SMS center.
Otherwise it sends back a negative delivery report to the SMS center. If the sender
requested a status report earlier, the SMS center sends a status report to the sender when
it receives the message delivery report from the recipient. If the SMS center does not
receive the message delivery report after a period of time, it concludes that the message
delivery report has been lost. The SMS center then ends the SMS message to the recipient
for the second time.
Sometimes the message delivery report mechanism is not used and the
acknowledgement of message delivery is done in a lower layer.
62
4.5 MAX232:
The MAX232 is an integrated circuit that converts signals from an RS-232 serial
port to signals suitable for use in TTL compatible digital logic circuits. The MAX232 is a
dual driver/receiver and typically converts the RX, TX, CTS and RTS signals.
The drivers provide RS-232 voltage level outputs (approx. 7.5 V) from a single
+ 5 V supply via on-chip charge pumps and external capacitors. This makes it useful for
implementing RS-232 in devices that otherwise do not need any voltages outside the 0 V
to + 5 V range, as power supply design does not need to be made more complicated just
for driving the RS-232 in this case.
The receivers reduce RS-232 inputs (which may be as high as 25 V), to standard
5 V TTL levels. These receivers have a typical threshold of 1.3 V, and a typical
hysteresis of 0.5 V. The later MAX232A is backwards compatible with the original
MAX232 but may operate at higher baud rates and can use smaller external capacitors
0.1 F in place of the 1.0 F capacitors used with the original device.
The newer MAX3232 is also backwards compatible, but operates at a broader
voltage range, from 3 to 5.5V.
VOLTAGE LEVELS:
63
It is helpful to understand what occurs to the voltage levels. When a MAX232 IC
receives a TTL level to convert, it changes a TTL Logic 0 to between +3 and +15V, and
changes TTL Logic 1 to between -3 to -15V, and vice versa for converting from RS232 to
TTL. This can be confusing when you realize that the RS232 Data Transmission voltages
at a certain logic state are opposite from the RS232 Control Line voltages at the same
logic state.
Applications:
Portable Computers
Low-Power Modems
Interface Translation
Battery-Powered RS-232 Systems
Multi drop RS-232 Networks
INTERFACING THE SERIAL / RS232 PORT
The Serial Port is harder to interface than the Parallel Port. In most cases, any
device you connect to the serial port will need the serial transmission converted back to
parallel so that it can be used. This can be done using a UART. On the software side of
things, there are many more registers that you have to attend to than on a Standard
64
Parallel Port. (SPP) So what are the advantages of using serial data transfer rather than
parallel?
1. Serial Cables can be longer than Parallel cables. The serial port transmits a '1' as -3 to -
25 volts and a '0' as +3 to +25 volts where as a parallel port transmits a '0' as 0v and a
'1' as 5v. Therefore the serial port can have a maximum swing of 50V compared to the
parallel port which has a maximum swing of 5 Volts. Therefore cable loss is not going
to be as much of a problem for serial cables than they are for parallel.
2. You don't need as many wires than parallel transmission. If your device needs to be
mounted a far distance away from the computer then 3 core cable (Null Modem
Configuration) is going to be a lot cheaper that running 19 or 25 core cable. However
you must take into account the cost of the interfacing at each end.
3. Infra Red devices have proven quite popular recently. You may of seen many
electronic diaries and palmtop computers which have infra red capabilities build in.
However could you imagine transmitting 8 bits of data at the one time across the room
and being able to (from the devices point of view) decipher which bits are which?
Therefore serial transmission is used where one bit is sent at a time. IrDA-1 (The first
infra red specifications) was capable of 115.2k baud and was interfaced into a UART.
The pulse length however was cut down to 3/16th of a RS232 bit length to conserve
power considering these devices are mainly used on diaries, laptops and palmtops.
4. Microcontroller's have also proven to be quite popular recently. Many of these have in
built SCI (Serial Communications Interfaces) which can be used to talk to the outside
world. Serial Communication reduces the pin count of these MPU's. Only two pins are
commonly used, Transmit Data (TXD) and Receive Data (RXD) compared with at
least 8 pins if you use a 8 bit Parallel method
Devices which use serial cables for their communication are split into two
categories. These are DCE (Data Communications Equipment) and DTE (Data Terminal
Equipment.) Data Communications Equipment are devices such as your modem, TA
adapter, plotter etc while Data Terminal Equipment is your Computer or Terminal. The
65
electrical specifications of the serial port is contained in the EIA (Electronics Industry
Association) RS232C standard. It states many parameters such as
1. A "Space" (logic 0) will be between +3 and +25 Volts.
2. A "Mark" (Logic 1) will be between -3 and -25 Volts.
3. The region between +3 and -3 volts is undefined.
4. An open circuit voltage should never exceed 25 volts. (In Reference
to GND)
5. A short circuit current should not exceed 500mA. The driver should
be able to handle this without damage. (Take note of this one!)
Above is no where near a complete list of the EIA standard. Line Capacitance,
Maximum Baud Rates etc are also included. For more information please consult the EIA
RS232-C standard. It is interesting to note however, that the RS232C standard specifies a
maximum baud rate of 20,000 BPS!, which is rather slow by today's standards. A new
standard, RS-232D has been recently released.
Serial Ports come in two "sizes", There are the D-Type 25 pin connector and the
D-Type 9 pin connector both of which are male on the back of the PC, thus you will
require a female connector on your device. Below is a table of pin connections for the 9
pin and 25 pin D-Type connectors.
HARDWARE PROPERTIES:
Devices which use serial cables for their communication are split into two
categories. These are DCE (Data Communications Equipment) and DTE (Data Terminal
Equipment.) Data Communications Equipment are devices such as your modem, TA
adapter, plotter etc while Data Terminal Equipment is your Computer or Terminal.
66
The electrical specifications of the serial port is contained in the EIA (Electronics
Industry Association) RS232C standard. It states many parameters such as - Above is no
where near a complete list of the EIA standard. Line Capacitance, Maximum Baud Rates
etc are also included. For more information please consult the EIA RS232-C standard. It
is interesting to note however, that the RS232C standard specifies a maximum baud rate
of 20,000 BPS!, which is rather slow by today's standards.
A new standard, RS-232D has been recently released.Serial Ports come in two
"sizes", There are the D-Type 25 pin connector and the D-Type 9 pin connector both of
which are male on the back of the PC, thus you will require a female connector on your
device. Below is a table of pin connections for the 9 pin and 25 pin D-Type connectors
DB9 CONNECTOR:
1. A "Space" (logic 0) will be between +3 and +25 Volts.
2. A "Mark" (Logic 1) will be between -3 and -25 Volts.
3. The region between +3 and -3 volts is undefined.
4. An open circuit voltage should never exceed 25 volts. (In Reference to GND)
5. A short circuit current should not exceed 500mA. The driver should be able to
handle
this without damage.
RS232 DB9Connector Pinout
67
DB-9M Function Abbreviation
Pin #1 Data Carrier Detect CD
Pin #2 Receive Data RD or RX or RXD
Pin #3 Transmitted Data TD or TX or TXD
Pin #4 Data Terminal Ready DTR
Pin #5 Signal Ground GND
Pin #6 Data Set Ready DSR
Pin #7 Request To Send RTS
Pin #8 Clear To Send CTS
Pin #9 Ring Indicator RI.
8051 connection to RS232
The RS232 standard is not TTL compatible; therefore, it requires a line driver
such as the MAX232 chip to convert RS232 voltage levels to TTL levels, and vice versa.
The interfacing of 8051 with RS232 connectors via the MAX232 chip is the main topic.
The 8051 has two pins that are used specifically for transferring and receiving
data serially. These two pins are called TXD and RXD and a part of the port 3 group
(P3.0 and P3.1). Pin 11 of the 8051 is assigned to TXD and pin 10 is designated as RXD.
These pins are TTL compatible; therefore, they require a line driver to make them RS232
compatible. One such line driver is the MAX232 chip.
68
MAX232 converts from RS232 voltage levels to TTL voltage levels, and vice
versa. One advantage of the MAX232 chip is that it uses a +5V power source which, is
the same as the source voltage for the 8051. In the other words, with a single +5V power
supply we can power both the 8051 and MAX232, with no need for the power supplies
that are common in many older systems. The MAX232 has two sets of line drivers for
transferring and receiving data. The line drivers used for TXD are called T1 and T2,
while the line drivers for RXD are designated as R1 and R2. In many applications only
one of each is used.
Embedded
Controller
RXD
TXD
TXD
RXD
2
3
5
GND
MAX 232
69
4.6. LCD (Liquid Crystal Display)
Construction and working of LCD:
Liquid crystal displays (LCD s) have materials which combine the properties of
both liquids and crystals. Rather than having a melting point, they have a temperature
range within which the molecules are almost as mobile as they would be in a liquid, but
are grouped together in an ordered form similar to a crystal.
An LCD consists of two glass panels, with the liquid crystal material sand
witched in between them. The inner surface of the glass plates are coated with transparent
electrodes which define the character, symbols or patterns to be displayed polymeric
layers are present in between the electrodes and the liquid crystal, which makes the liquid
crystal molecules to maintain a defined orientation angle.
One each polarizers are pasted outside the two glass panels. These polarizers
would rotate the light rays passing through them to a definite angle, in a particular
direction
When the LCD is in the off state, light rays are rotated by the two polarizers and
the liquid crystal, such that the light rays come out of the LCD without any orientation,
and hence the LCD appears transparent.
When sufficient voltage is applied to the electrodes, the liquid crystal molecules
would be aligned in a specific direction. The light rays passing through the LCD would
be rotated by the polarizers, which would result in activating / highlighting the desired
characters.
70
The LCDs are lightweight with only a few millimeters thickness. Since the
LCDs consume less power, they are compatible with low power electronic circuits, and
can be powered for long durations.
The LCD s wont generate light and so light is needed to read the display. By
using backlighting, reading is possible in the dark. The LCDs have long life and a wide
operating temperature range.
Changing the display size or the layout size is relatively simple which makes the
LCDs more customer friendly.
LCD DISPLAY HITACHI 44780:
LCD is very helpful in providing user interface as well as for debugging purpose.
The most common type of LCD controller is HITACHI 44780 which provides a simple
interface between the controller & an LCD. These LCD's are very simple to interface
with the controller as well as are cost effective.
The most commonly used ALPHANUMERIC displays are 1x16 (Single Line &
16 characters), 2x16 (Double Line & 16 character per line) & 4x20 (four lines & Twenty
characters per line). The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data
lines. The number on data lines depends on the mode of operation.
If operated in 8-bit mode then 8 data lines + 3 control lines i.e. total 11 lines are
required. And if operated in 4-bit mode then 4 data lines + 3 control lines i.e. 7 lines are
required. How do we decide which mode to use? Its simple if you have sufficient data
lines you can go for 8 bit mode & if there is a time constrain i.e. display should be faster
then we have to use 8-bit mode because basically 4-bit mode takes twice as more time as
compared to 8-bit mode.
Most projects you create with the 8051 CPU require some form of display. The
most common way to accomplish this is with the LCD (Liquid Crystal Display). LCDs
71
have become a cheap and easy way to get text display for embedded system Common
displays are set up as 16 to 20 characters by 1 to 4 lines.
When RS is low (0), the data is to be treated as a command. When RS is high (1),
the data being sent is considered as text data which should be displayed on the screen.
When R/W is low (0), the information on the data bus is being written to the LCD. When
RW is high (1), the program is effectively reading from the LCD. Most of the times there
is no need to read from the LCD so this line can directly be connected to Gnd thus saving
one controller line.
The ENABLE pin is used to latch the data present on the data pins. A HIGH -
LOW signal is required to latch the data. The LCD interprets and executes our command
at the instant the EN line is brought low. If you never bring EN low, your instruction will
never be executed.
UNDERSTANDING LCD:
Pin outline:
8 data pins D7:D0
Bi-directional data/command pins.
Alphanumeric characters are sent in ASCII format.
RS: Register Select
RS = 0 -> Command Register is selected
RS = 1 -> Data Register is selected
R/W: Read or Write
0 -> Write, 1 -> Read
E: Enable (Latch data)
Used to latch the data present on the data pins. A high-to-low edge is needed to latch the
data.
72
VEE : contrast control
NOTE: When writing to the display, data is transferred only on the high to low
transition of this signal. However, when reading from the display, data will become
available shortly after the low to high transition and remain available until the signal falls
low again.
Display Data RAM (DDRAM)
Display data RAM (DDRAM) is where you send the characters (ASCII code) you
want to see on the LCD screen. It stores display data represented in 8-bit character codes.
Its capacity is 80 characters (bytes). Below you see DD RAM address layout of a 2*16
LCD.
In the above memory map, the area shaded in black is the visible display (For
16x2 displays). For first line addresses for first 15 characters is from 00h to 0Fh. But for
second line address of first character is 40h and so on up to 4Fh for the 16th character. So
if you want to display the text at specific positions of LCD , we require to manipulate
address and then to set cursor position accordingly .
Character Generator RAM (CGRAM)-User defined character RAM
In the character generator RAM, we can define our own character patterns by
program. CG RAM is 64 bytes ,allowing for eight 5*8 pixel, character patterns to be
defined. However how to define this and use it is out of scope of this tutorial. So I will
not talk any more about CGRAM
Registers
73
The HD44780 has two 8-bit registers, an instruction register (IR) and a data
register (DR). The IR stores instruction codes. The DR temporarily stores data to be
written into DDRAM or CGRAM and temporarily stores data to be read from DDRAM
or CGRAM. Data written into the DR is automatically written into DDRAM or CGRAM
by an internal operation. . These two registers can be selected by the register selector
(RS) signal. See the table below:
Register Selection
RS R/W Operation
0 0 IR write as an internal operation (display clear, etc.)
0 1 Read busy flag (DB7) and address counter (DB0 to DB6)
1 0 DR write as an internal operation (DR to DDRAM or CGRAM)
1 1 DR read as an internal operation (DDRAM or CGRAM to DR)
Busy Flag (BF)
When the busy flag is 1, the LCD is in the internal operation mode, and the next
instruction will not be accepted. When RS = 0 and R/W = 1 (see the table above), the
busy flag is output to DB7 (MSB of LCD data bus). The next instruction must be written
after ensuring that the busy flag is 0.
LCD Commands
The LCDs internal controller accept several commands and modify the display
accordingly. These commands would be things like:
Clear screen
Return home
Shift display right/left
Instruction Decimal HEX
Function set (8-bit interface, 2 lines, 5*7 Pixels) 56 38
Function set (8-bit interface, 1 line, 5*7 Pixels) 48 30
74
Function set (4-bit interface, 2 lines, 5*7 Pixels) 40 28
Function set (4-bit interface, 1 line, 5*7 Pixels) 32 20
Entry mode set See Below See Below
Scroll display one character right (all lines) 28 1E
Scroll display one character left (all lines) 24 18
Home (move cursor to top/left character position) 2 2
Move cursor one character left 16 10
Move cursor one character right 20 14
Turn on visible underline cursor 14 0E
Turn on visible blinking-block cursor 15 0F
Make cursor invisible 12 0C
Blank the display (without clearing) 8 08
Restore the display (with cursor hidden) 12 0C
Clear Screen 1 01
Set cursor position (DDRAM address) 128 + addr 80+ addr
Set pointer in character-generator RAM (CG RAM address) 64 + addr 40+ addr
Table 4.7 lcd commands
ENTRY MODE SET:
This command sets cursor move direction and display shift ON/OFF. There are 4
possible function set commands;04, 05, 06, and 07. This command changes the direction
the cursor moves by setting the address counter to increment or decrement. This
command is very important. If you do not understand it you may not see anything or what
you actually wanted to see on LCD screen. I have created 4 animated gifs to demonstrate
what the function set command is all about.
Set cursor position (DDRAM address)
As said earlier if we want to display the text at specific positions of LCD , we
require to manipulate address and then to set cursor position accordingly.
75
I want to display "MAHESH" in message "Hi MAHESH" at the right corner of first line
then I should start from 10th character.
So referring to table 80h+0Ah= 8Ah.
INTERFACING LCD TO 8051 :
Sending commands and data to LCDs with a time delay:
4.10 interfacing lcd
To send any command from table 2 to the LCD, make pin RS=0. For data, make
RS=1.Then place a high to low pulse on the E pin to enable the internal latch of the LCD.
The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for
the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or
an 8-bit data bus.
If a 4-bit data bus is used, the LCD will require a total of 7 data lines.
If an 8-bit data bus is used, the LCD will require a total of 11 data lines.
76
The three control lines are EN, RS, and RW.
Note that the EN line must be raised/lowered before/after each instruction sent to
the LCD regardless of whether that instruction is read or write, text or instruction. In
short, you must always manipulate EN when communicating with the LCD. EN is the
LCD's way of knowing that you are talking to it. If you don't raise/lower EN, the LCD
doesn't know you're talking to it on the other lines.
Checking the Busy Flag:
You can use subroutine for checking busy flag or just a big (and safe) delay.
1. Set R/W Pin of the LCD HIGH(read from the LCD)
2. Select the instruction register by setting RS pin LOW
3. Enable the LCD by Setting the enable pin HIGH
4. The most significant bit of the LCD data bus is the state of the busy
flag(1=Busy,0=ready to accept instructions/data). The other bits hold the current
value of the address counter.
If the LCD never come out from "busy" status because of some problems ,The
program will "hang," waiting for DB7 to go low. So in a real applications it would be
wise to put some kind of time limit on the delay--for example, a maximum of 100
attempts to wait for the busy signal to go low. This would guarantee that even if the LCD
hardware fails, the program would not lock up.
LCD operation:
In recent years the LCD is finding widespread use replacing LED s (seven-
segment LED or other multi segment LED s). This is due to the following reasons:
1. The declining prices of LCD s.
2. The ability to display numbers, characters and graphics. This is in
contract to LED s, which are limited to numbers and a few characters.
77
3. Incorporation of a refreshing controller into the LCD, there by
relieving the CPU of the task of refreshing the LCD. In the contrast, the LED
must be refreshed by the CPU to keep displaying the data.
4. Ease of programming for characters and graphics.
LCD pin description:
The LCD discussed in this section has 14 pins. The function of each pin is given
in table.
TABLE 4.8: Pin description for LCD:
Pin Symbol I/O Description
1 VSS -- Ground
2 VCC -- +5V power supply
3 VEE -- Power supply to
control contrast
4 RS I RS=0 to select
command register
RS=1 to select
data register
5 R/W I R/W=0 for write
R/W=1 for read
6 E I/O Enable
7 DB0 I/O The 8-bit data bus
8 DB1 I/O The 8-bit data bus
9 DB2 I/O The 8-bit data bus
10 DB3 I/O The 8-bit data bus
11 DB4 I/O The 8-bit data bus
12 DB5 I/O The 8-bit data bus
13 DB6 I/O The 8-bit data bus
14 DB7 I/O The 8-bit data bus
LCD pin description
78
Uses:
The LCDs used exclusively in watches, calculators and measuring instruments are
the simple seven-segment displays, having a limited amount of numeric data. The recent
advances in technology have resulted in better legibility, more information displaying
capability and a wider temperature range. These have resulted in the LCDs being
extensively used in telecommunications and entertainment electronics.
CODE EXAMPLE
It is easy to make different subroutines and then call them as we need.
Busy flag checking
ready:
setb P1.7 ;D7 as input
clr P3.6 ;RS=0 cmd
setb P3.5 ;RW=1 for read
again:
setb P3.7 ;H->L pulse on E
clr P3.7
jb P1.7, again
ret
Data write Routine
data:
mov P1, A ;move acc. data to port
setb P3.6 ;RS=1 data
79
clr P3.5 ;RW=0 for write
setb P3.7 ;H->L pulse on E
clr P3.7
lcall ready
ret
Command write Routine
command:
mov P1, A ;move acc. data to port
clr P3.6 ;RS=0 for cmd
clr P3.5 ;RW=0 for write
setb P3.7 ;H->L pulse on E
clr P3.7
lcall ready
ret
Initialization
mov A, #38H ; Initialize, 2-lines, 5X7 matrix.
lcall Command
mov A, #0EH ; LCD on, cursor on
lcall Command
mov A, #01H ; Clear LCD Screen
lcall Command
mov A, #06H ; Shift cursor right
lcall Command
Display clear
clear:
setb p3.7 ;enable EN
clr 3.6 ;RS=0 for cmd.
80
mov DATA,#01h
clr p3.7 ;disable EN
lcall ready
RET
Note- As we need to clear the LCD frequently and not the whole initialisation , it is better
to use this routine separately.
Displaying "HI"
lcall initialization
lcall clear
mov A,#'H'
acall data
mov A,#'I'
lcall data
ASSEMBLY LANGUAGE:
lcall Initialization
lcall clear
mov a,#'H'
lcall data
mov a,#'I'
lcall data
81
CHAPTER -5
SOFTWARE DESCRIPTION
5.1 KEIL MICRO VERSION
Installing the Keil software on a Windows PC
- Insert the CD-ROM in your computers CD drive
- On most computers, the CD will auto run, and you will see the Keil installation
menu. If the menu does not appear, manually double click on the Setup icon, in
the root directory: you will then see the Keil menu.
- On the Keil menu, please select Install Evaluation Software. (You will not
require a license number to install this software).
- Follow the installation instructions as they appear.
Loading the Projects:
The example projects for this book are NOT loaded automatically when
you install the Keil compiler.
These files are stored on the CD in a directory /Pont. The files are arranged by chapter:
for example, the project discussed in Chapter 3 is in the directory /Pont/Ch03_00-
Hello.
Rather than using the projects on the CD (where changes cannot be saved), please copy
the files from CD onto an appropriate directory on your hard disk.
Note: you will need to change the file properties after copying: file transferred from the
CD will be read only.
Configuring the Simulator:
Open the Keil Vision2
82
Go to Project Open Project and browse for Hello in Ch03_00 in Pont and open it.
Go to Project Select Device for Target Target1
83
Select 8052(all variants) and click OK
Now we need to check the oscillator frequency:
Go to project Options for Target Target1
84
Make sure that the oscillator frequency is 12MHz.
Building the Target
Build the target as illustrated in the figure below
85
Running the Simulation
Having successfully built the target, we are now ready to start the debug session and run
the simulator.
First start a debug session
The flashing LED we will view will be connected to Port 1. We therefore want to observe
the activity on this port
86
To ensure that the port activity is visible, we need to start the periodic window update
flag
87
Go to Debug - Go
88
While the simulation is running, view the performance analyzer to check the delay
durations.
Go to Debug Performance Analyzer and click on it
89
Double click on DELAY_LOOP_Wait in Function Symbols: and click Define button
90
About Keil
1. Click on the Keil u Vision Icon on Desktop
2. Click on the Project menu from the title bar
3. Then Click on New Project
4. Save the Project by typing suitable project name with no extension in u r own
folder sited in either C:\ or D:\
5. Then Click on save button above.
6. Select the component for u r project. i.e. Atmel
7. Click on the + Symbol beside of Atmel
8. Select AT89C51
9. Then Click on OK
10. Then Click either YES or NOmostly NO
11. Now your project is ready to USE
12. Now double click on the Target1, you would get another option Source
group 1
13. Click on the file option from menu bar and select new
14. The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
15. Now start writing program in either in C or ASM
16. For a program written in Assembly, then save it with extension . asm and
for C based program save it with extension .C
17. Now right click on Source group 1 and click on Add files to Group Source
18. Now you will get another window, on which by default C files will appear.
19. Now select as per your file extension given while saving the file
20. Click only one time on option ADD
21. Now Press function key F7 to compile. Any error will appear if so happen. If the file
contains no error, then press Control+F5 simultaneously.
22. The new window is as follows
91
23. Then Click OK
24. Now Click on the Peripherals from menu bar, and check your required port
25. Drag the port a side and click in the program file.
26. Now keep Pressing function key F11 slowly and observe.
27. You are running your program successfully
5.2 Flash magic :
Flash Magic is Windows software from that microcontroller is easily programmed
using In-System Programming technology to all the ISP feature empowered devices.
92
After installing the software when we click on the icon of the software the
window will open on the screen as shown in figure. We need to change the device and
have to select the device 89V51RD2 , and then we set to erase all flash option on the
flash magic window. If we need to verify the proper dumping of the program in the
microcontroller then we need to set the verify after program option.
Loading of hex file:
After selecting device we load the hex file in the given block by using the
browse option on the FLASH MAGIC window..
93
Programming of device :
After loading the file next step is dumping of code in microcontroller. For that we
first connect the computers serial port to your controller board through serial cable. Then
after give the power supply to the controller board.
Now its time to dump the code in controller. Press the start option on your flash magic
window. Then your microcontroller will be programmed in few seconds.
94
CHAPTER 6
RESULTS AND CONCLUSION
6.1 Result
The project Accident intimation system using gsm and gps was designed
and developed and the loacation of the accident was identified using gps and was alerted
by sending message using gsm
6.2 Applications
Through GSM we control the house hold appliances.
We can control the devices from remote places
We can use in industrial appliances also.
6.3 Conclusion
The project ACCIDENT IDENTIFICATION USING GPS AND GSM has
been successfully designed and tested.
Integrating features of all the hardware components used have developed it.
Presence of every module has been reasoned out and placed carefully thus
contributing to the best working of the unit.
Secondly, using highly advanced ICs and with the help of growing technology
the project has been successfully implemented.
95
6.4 References
[1]The 8051 Micro controller and Embedded Systems
-Muhammad Ali Mazidi
Janice Gillispie Mazidi
[2]The 8051 Micro controller Architecture, Programming & Applications
-Kenneth J. Ayala
[3]Fundamentals Of Micro processors and Micro computers
-B. Ram
[4]Micro processor Architecture, Programming & Applications
- Ramesh S. Gaonkar
[5]Electronic Components
-D.V. Prasad
[6]Wireless Communications
- Theodore S. Rappaport
[7]Mobile Tele Communications
- William C.Y. Lee