129
VEHICLE TRACKING SYSTEM Description: Global Positioning System (GPS) satellites broadcast signals from space that GPS receivers, use to provide three-dimensional location (latitude, longitude, and altitude) plus precise time. GPS receivers provides reliable positioning, navigation, and timing services to worldwide users on a continuous basis in all weather, day and night, anywhere on or near the Earth. This ultra-sensitive GPS receiver can acquire GPS signals from 65 channels of satellites and output position data with high accuracy in extremely challenging environments and under poor signal conditions due to its active antenna and high sensitivity. The GPS receiver’s -160dBm tracking sensitivity allows continuous position coverage in nearly all application environments. The output is serial data of 9600 baud rate which is standard NMEA 0183 v3.0 protocol offering industry standard data messages and a command set for easy interface to mapping software and embedded devices. In this project microcontroller is connected to GPS and GSM modems. Using this project use can know the position of vehicle in google maps. Microcontroller can take coordinate values from GPS modem and send to particular mobile numbers through GSM modem.GSM modem work under AT commands. Using this latitude and longitude we can know the vehicle position on google maps through internet. But user has to enter coordinate values in google maps. In this project 7805 is a regulator and it avoids noise spikes in power supply. GPS modem is connected microcontroller through serial port. These GPS modem works under 9600 or 4800 baud rates.

137027485 Vehicle Tracking System

  • Upload
    gin220

  • View
    222

  • Download
    6

Embed Size (px)

Citation preview

Page 1: 137027485 Vehicle Tracking System

VEHICLE TRACKING SYSTEM

Description:

Global Positioning System (GPS) satellites broadcast signals from space that GPS

receivers, use to provide three-dimensional location (latitude, longitude, and altitude)

plus precise time. GPS receivers provides reliable positioning, navigation, and timing

services to worldwide users on a continuous basis in all weather, day and night, anywhere

on or near the Earth. This ultra-sensitive GPS receiver can acquire GPS signals from 65

channels of satellites and output position data with high accuracy in extremely

challenging environments and under poor signal conditions due to its active antenna and

high sensitivity. The GPS receiver’s -160dBm tracking sensitivity allows continuous

position coverage in nearly all application environments. The output is serial data of

9600 baud rate which is standard NMEA 0183 v3.0 protocol offering industry standard

data messages and a command set for easy interface to mapping software and embedded

devices.

In this project microcontroller is connected to GPS and GSM modems. Using this

project use can know the position of vehicle in google maps. Microcontroller can take

coordinate values from GPS modem and send to particular mobile numbers through GSM

modem.GSM modem work under AT commands.

Using this latitude and longitude we can know the vehicle position on google maps

through internet. But user has to enter coordinate values in google maps.

In this project 7805 is a regulator and it avoids noise spikes in power supply. GPS

modem is connected microcontroller through serial port. These GPS modem works under

9600 or 4800 baud rates.

Page 2: 137027485 Vehicle Tracking System

TECHNICAL SPECIFICATIONS:

HARDWARE:

Micro controller : AT89S52

Crystal : 11.0592 MHz

LED : 5mm Red LED

Serial Driver : Max 232

GPS modem

GSM modm

Power supply

Transformer : 12V step down

Filter : 1000uf/25V

Voltage Regulator : 7805

SOFTWARE:

Keil micro vision

Proteus

UC flash

APPLICATIONS:

Transport service

Automobiles

Page 3: 137027485 Vehicle Tracking System

BLOCK DIAGRAM:

8

0

5

1

Power Supply

Max-232 GPS Modem

16X2 LCD

Max-232 GSM Modem

Page 4: 137027485 Vehicle Tracking System

POWER SUPPLY BLOCK DIAGRAM

EMBEDDED SYSTEMS:

Introduction:

An embedded system is a system which is going to do a predefined specified task is the

embedded system and is even defined as combination of both software and hardware. A

general-purpose definition of embedded systems is that they are devices used to control,

monitor or assist the operation of equipment, machinery or plant. "Embedded" reflects

the fact that they are an integral part of the system. At the other extreme a general-

purpose computer may be used to control the operation of a large complex processing

plant, and its presence will be obvious.

All embedded systems are including computers or microprocessors. Some of these

computers are however very simple systems as compared with a personal computer.

The very simplest embedded systems are capable of performing only a single function or

set of functions to meet a single predetermined purpose. In more complex systems an

application program that enables the embedded system to be used for a particular purpose

in a specific application determines the functioning of the embedded system. The ability

Step down Transformer

Filter Regulator Output Bridge Rectifier

Page 5: 137027485 Vehicle Tracking System

to have programs means that the same embedded system can be used for a variety of

different purposes. In some cases a microprocessor may be designed in such a way that

application software for a particular purpose can be added to the basic software in a

second process, after which it is not possible to make further changes. The applications

software on such processors is sometimes referred to as firmware.

The simplest devices consist of a single microprocessor (often called a "chip”), which

may itself be packaged with other chips in a hybrid system or Application Specific

Integrated Circuit (ASIC). Its input comes from a detector or sensor and its output goes to

a switch or activator which (for example) may start or stop the operation of a machine or,

by operating a valve, may control the flow of fuel to an engine.

As the embedded system is the combination of both software and hardware

Figure: Block diagram of Embedded System

Software deals with the languages like ALP, C, and VB etc., and Hardware deals with

Processors, Peripherals, and Memory.

Memory: It is used to store data or address.

Peripherals: These are the external devices connected

Processor: It is an IC which is used to perform some task

Applications of embedded systems

• Manufacturing and process control

• Construction industry

Software Hardware

ALP

C

VB Etc.,

Processor

Peripherals

memory

Embedded System

Page 6: 137027485 Vehicle Tracking System

• Transport

• Buildings and premises

• Domestic service

• Communications

• Office systems and mobile equipment

• Banking, finance and commercial

• Medical diagnostics, monitoring and life support

• Testing, monitoring and diagnostic systems

Processors are classified into four types like:

Micro Processor (µp)

Micro controller (µc)

Digital Signal Processor (DSP)

Application Specific Integrated Circuits (ASIC)

Micro Processor (µp):

A silicon chip that contains a CPU. In the world of personal computers, the terms

microprocessor and CPU are used interchangeably. At the heart of all personal computers

and most workstations sits a microprocessor. Microprocessors also control the logic of

almost all digital devices, from clock radios to fuel-injection systems for automobiles.

Three basic characteristics differentiate microprocessors:

Instruction set : The set of instructions that the microprocessor can execute.

Bandwidth : The number of bits processed in a single instruction.

Clock speed : Given in megahertz (MHz), the clock speed determines how many

instructions per second the processor can execute.

In both cases, the higher the value, the more powerful the CPU. For example, a 32-bit

microprocessor that runs at 50MHz is more powerful than a 16-bit microprocessor that

runs at 25MHz. In addition to bandwidth and clock speed, microprocessors are classified

Page 7: 137027485 Vehicle Tracking System

as being either RISC (reduced instruction set computer) or CISC (complex instruction set

computer).

A microprocessor has three basic elements, as shown above. The ALU performs all

arithmetic computations, such as addition, subtraction and logic operations (AND, OR,

etc). It is controlled by the Control Unit and receives its data from the Register Array.

The Register Array is a set of registers used for storing data. These registers can be

accessed by the ALU very quickly. Some registers have specific functions - we will deal

with these later. The Control Unit controls the entire process. It provides the timing and

a control signal for getting data into and out of the registers and the ALU and it

synchronizes the execution of instructions (we will deal with instruction execution at a

later date).

Three Basic Elements of a Microprocessor

Micro Controller (µc):

A microcontroller is a small computer on a single integrated circuit containing a

processor core, memory, and programmable input/output peripherals. Program memory

in the form of NOR flash or OTP ROM is also often included on chip, as well as a

typically small amount of RAM. Microcontrollers are designed for embedded

applications, in contrast to the microprocessors used in personal computers or other

general purpose applications.

Page 8: 137027485 Vehicle Tracking System

Figure: Block Diagram of Micro Controller (µc)

Digital Signal Processors (DSPs):

Digital Signal Processors is one which performs scientific and mathematical operation.

Digital Signal Processor chips - specialized microprocessors with architectures designed

specifically for the types of operations required in digital signal processing. Like a

general-purpose microprocessor, a DSP is a programmable device, with its own native

instruction code. DSP chips are capable of carrying out millions of floating point

operations per second, and like their better-known general-purpose cousins, faster and

more powerful versions are continually being introduced. DSPs can also be embedded

within complex "system-on-chip" devices, often containing both analog and digital

circuitry.

Application Specific Integrated Circuit (ASIC)

ASIC is a combination of digital and analog circuits packed into an IC to achieve the

desired control/computation function

ASIC typically contains

CPU cores for computation and control

Peripherals to control timing critical functions

Memories to store data and program

Timer, Counter, serial communication ROM, ADC, DAC, Timers, USART, Oscillators

Etc.,

ALU

CU

Memory

Page 9: 137027485 Vehicle Tracking System

Analog circuits to provide clocks and interface to the real world which is

analog in nature

I/Os to connect to external components like LEDs, memories, monitors

etc.

Computer Instruction Set

There are two different types of computer instruction set there are:

1. RISC (Reduced Instruction Set Computer) and

2. CISC (Complex Instruction Set computer)

Reduced Instruction Set Computer (RISC)

A RISC (reduced instruction set computer) is a microprocessor that is designed to

perform a smaller number of types of computer instruction so that it can operate at a

higher speed (perform more million instructions per second, or millions of instructions

per second). Since each instruction type that a computer must perform requires additional

transistors and circuitry, a larger list or set of computer instructions tends to make the

microprocessor more complicated and slower in operation.

Besides performance improvement, some advantages of RISC and related design

improvements are:

A new microprocessor can be developed and tested more quickly if one of its

aims is to be less complicated.

Operating system and application programmers who use the microprocessor's

instructions will find it easier to develop code with a smaller instruction set.

The simplicity of RISC allows more freedom to choose how to use the space on a

microprocessor.

Higher-level language compilers produce more efficient code than formerly because they

have always tended to use the smaller set of instructions to be found in a RISC computer.

RISC characteristics

Simpleinstructionset:

In a RISC machine, the instruction set contains simple, basic instructions, from which

more complex instructions can be composed.

Samelengthinstructions.

Each instruction is the same length, so that it may be fetched in a single operation.

Page 10: 137027485 Vehicle Tracking System

1machine-cycleinstructions.

Most instructions complete in one machine cycle, which allows the processor to handle

several instructions at the same time. This pipelining is a key technique used to speed up

RISC machines.

Complex Instruction Set Computer (CISC)

CISC, which stands for Complex Instruction Set Computer, is a philosophy for

designing chips that are easy to program and which make efficient use of memory. Each

instruction in a CISC instruction set might perform a series of operations inside the

processor. This reduces the number of instructions required to implement a given

program, and allows the programmer to learn a small but flexible set of instructions.

TheadvantagesofCISC

At the time of their initial development, CISC machines used available technologies to

optimize computer performance.

Microprogramming is as easy as assembly language to implement, and much less

expensive than hardwiring a control unit.

The ease of micro-coding new instructions allowed designers to make CISC

machines upwardly compatible: a new computer could run the same programs as earlier

computers because the new computer would contain a superset of the instructions of the

earlier computers.

As each instruction became more capable, fewer instructions could be used to

implement a given task. This made more efficient use of the relatively slow main

memory.

Because micro program instruction sets can be written to match the constructs of

high-level languages, the compiler does not have to be as complicated.

ThedisadvantagesofCISC

Still, designers soon realized that the CISC philosophy had its own problems, including:

Earlier generations of a processor family generally were contained as a subset in

every new version --- so instruction set & chip hardware become more complex with

each generation of computers.

Page 11: 137027485 Vehicle Tracking System

So that as many instructions as possible could be stored in memory with the least

possible wasted space, individual instructions could be of almost any length---this means

that different instructions will take different amounts of clock time to execute, slowing

down the overall performance of the machine.

Many specialized instructions aren't used frequently enough to justify their

existence --- approximately 20% of the available instructions are used in a typical

program.

CISC instructions typically set the condition codes as a side effect of the

instruction. Not only does setting the condition codes take time, but programmers have to

remember to examine the condition code bits before a subsequent instruction changes

them.

Memory Architecture

There two different type’s memory architectures there are:

• Harvard Architecture

• Von-Neumann Architecture

Harvard Architecture

Computers have separate memory areas for program instructions and data. There are two

or more internal data buses, which allow simultaneous access to both instructions and

data. The CPU fetches program instructions on the program memory bus.

The Harvard architecture is a computer architecture with physically separate storage

and signal pathways for instructions and data. The term originated from the Harvard

Mark I relay-based computer, which stored instructions on punched tape (24 bits wide)

and data in electro-mechanical counters. These early machines had limited data storage,

entirely contained within the central processing unit, and provided no access to the

instruction storage as data. Programs needed to be loaded by an operator, the processor

could not boot itself.

Page 12: 137027485 Vehicle Tracking System

Figure: Harvard Architecture

Modern uses of the Harvard architecture:

The principal advantage of the pure Harvard architecture - simultaneous access to more

than one memory system - has been reduced by modified Harvard processors using

modern CPU cache systems. Relatively pure Harvard architecture machines are used

mostly in applications where tradeoffs, such as the cost and power savings from omitting

caches, outweigh the programming penalties from having distinct code and data address

spaces.

Digital signal processors (DSPs) generally execute small, highly-optimized audio

or video processing algorithms. They avoid caches because their behavior must be

extremely reproducible. The difficulties of coping with multiple address spaces are of

secondary concern to speed of execution. As a result, some DSPs have multiple data

memories in distinct address spaces to facilitate SIMD and VLIW processing. Texas

Instruments TMS320 C55x processors, as one example, have multiple parallel data

busses (two write, three read) and one instruction bus.

Microcontrollers are characterized by having small amounts of program (flash

memory) and data (SRAM) memory, with no cache, and take advantage of the Harvard

architecture to speed processing by concurrent instruction and data access. The separate

storage means the program and data memories can have different bit depths, for example

using 16-bit wide instructions and 8-bit wide data. They also mean that instruction pre-

fetch can be performed in parallel with other activities. Examples include, the AVR by

Atmel Corp, the PIC by Microchip Technology, Inc. and the ARM Cortex-M3 processor

(not all ARM chips have Harvard architecture).

Page 13: 137027485 Vehicle Tracking System

Even in these cases, it is common to have special instructions to access program memory

as data for read-only tables, or for reprogramming.

Von-Neumann Architecture

A computer has a single, common memory space in which both program instructions and

data are stored. There is a single internal data bus that fetches both instructions and data.

They cannot be performed at the same time

The von Neumann architecture is a design model for a stored-program digital computer

that uses a central processing unit (CPU) and a single separate storage structure

("memory") to hold both instructions and data. It is named after the mathematician and

early computer scientist John von Neumann. Such computers implement a universal

Turing machine and have a sequential architecture.

A stored-program digital computer is one that keeps its programmed instructions, as

well as its data, in read-write, random-access memory (RAM). Stored-program

computers were advancement over the program-controlled computers of the 1940s, such

as the Colossus and the ENIAC, which were programmed by setting switches and

inserting patch leads to route data and to control signals between various functional units.

In the vast majority of modern computers, the same memory is used for both data and

program instructions. The mechanisms for transferring the data and instructions between

the CPU and memory are, however, considerably more complex than the original von

Neumann architecture.

The terms "von Neumann architecture" and "stored-program computer" are generally

used interchangeably, and that usage is followed in this article.

Figure: Schematic of the Von-Neumann Architecture.

Page 14: 137027485 Vehicle Tracking System

Basic Difference between Harvard and Von-Neumann Architecture

The primary difference between Harvard architecture and the Von Neumann

architecture is in the Von Neumann architecture data and programs are stored in the same

memory and managed by the same information handling system.

Whereas the Harvard architecture stores data and programs in separate memory

devices and they are handled by different subsystems.

In a computer using the Von-Neumann architecture without cache; the central

processing unit (CPU) can either be reading and instruction or writing/reading data

to/from the memory. Both of these operations cannot occur simultaneously as the data

and instructions use the same system bus.

In a computer using the Harvard architecture the CPU can both read an instruction

and access data memory at the same time without cache. This means that a computer with

Harvard architecture can potentially be faster for a given circuit complexity because data

access and instruction fetches do not contend for use of a single memory pathway.

Today, the vast majority of computers are designed and built using the Von

Neumann architecture template primarily because of the dynamic capabilities and

efficiencies gained in designing, implementing, operating one memory system as opposed

to two. Von Neumann architecture may be somewhat slower than the contrasting Harvard

Architecture for certain specific tasks, but it is much more flexible and allows for many

concepts unavailable to Harvard architecture such as self programming, word processing

and so on.

Harvard architectures are typically only used in either specialized systems or for

very specific uses. It is used in specialized digital signal processing (DSP), typically for

video and audio processing products. It is also used in many small microcontrollers used

in electronics applications such as Advanced RISK Machine (ARM) based products for

many vendors.

THE MICROCONTROLLER:

A microcontroller is a general purpose device, but that is meant to read data,

perform limited calculations on that data and control its environment based on those

calculations. The prime use of a microcontroller is to control the operation of a machine

Page 15: 137027485 Vehicle Tracking System

using a fixed program that is stored in ROM and that does not change over the lifetime of

the system.

The microcontroller design uses a much more limited set of single and double

byte instructions that are used to move data and code from internal memory to the ALU.

The microcontroller is concerned with getting data from and to its own pins; the

architecture and instruction set are optimized to handle data in bit and byte size.

The AT89C51 is a low-power, high-performance CMOS 8-bit microcontroller

with 4k bytes of Flash Programmable and erasable read only memory (EROM). The

device is manufactured using Atmel’s high-density nonvolatile memory technology and

is functionally compatible with the industry-standard 80C51 microcontroller instruction

set and pin out. By combining versatile 8-bit CPU with Flash on a monolithic chip, the

Atmel’s AT89c51 is a powerful microcomputer, which provides a high flexible and cost-

effective solution to many embedded control applications.

AT89C51 MICROCONTROLLER

FEATURES

80C51 based architecture

4-Kbytes of on-chip Reprogrammable Flash Memory

128 x 8 RAM

Two 16-bit Timer/Counters

Full duplex serial channel

Boolean processor

Four 8-bit I/O ports, 32 I/O lines

Memory addressing capability

– 64K ROM and 64K RAM

Power save modes:

– Idle and power-down

Six interrupt sources

Most instructions execute in 0.3 us

CMOS and TTL compatible

Maximum speed: 40 MHz @ Vcc = 5V

Page 16: 137027485 Vehicle Tracking System

Industrial temperature available

Packages available:

– 40-pin DIP

– 44-pin PLCC

– 44-pin PQFP

Pin configuration:

Page 17: 137027485 Vehicle Tracking System

AT89C51 Block Diagram

Page 18: 137027485 Vehicle Tracking System

PIN DESCRIPTION:

VCC

Supply voltage

Page 19: 137027485 Vehicle Tracking System

GND

Ground

Port 0

Port 0 is an 8-bit open drain bi-directional 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 access to external program and data memory. In this mode, P 0 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 bi-directional I/O port with internal pull-ups. The port 1output

buffers can sink/source four TTL inputs. When 1s are written to port 1 pins, they are

pulled high by the internal pull-ups can be used as inputs. As inputs, Port 1 pins that are

externally being pulled low will source current (1) because of the internal pull-ups.

Port 2

Port 2 is an 8-bit bi-directional 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 can be used as inputs. As inputs, Port 2 pins that are

externally being pulled low will source current because of the internal pull-ups.

Port 2 emits the high-order address byte during fetches from external program

memory and during access to DPTR. In this application Port 2 uses strong internal pull-

ups when emitting 1s. During accesses to external data memory that use 8-bit data

address (MOVX@R1), Port 2 emits the contents of the P2 Special Function Register.

Port 2 also receives the high-order address bits and some control signals during Flash

programming and verification.

Port 3

Port 3 is an 8-bit bi-directional 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

Page 20: 137027485 Vehicle Tracking System

pulled high by the internal pull-ups can be used as inputs. As inputs, Port 3 pins that are

externally being pulled low will source current because of the internal pull-ups.

Port 3 also receives some control signals for Flash Programming and verification.

Port pin Alternate Functions

P3.0 RXD(serial input port)

P3.1 TXD(serial input port)

P3.2 INT0(external interrupt 0)

P3.3 INT1(external interrupt 1)

P3.4 T0(timer 0 external input)

P3.5 T1(timer 1 external input)

P3.6 WR(external data memory write strobe)

P3.7 RD(external data memory read strobe)

RST

Rest input A on this pin for two machine cycles while the oscillator is running resets the

device.

ALE/PROG:

Address Latch Enable is an output pulse for latching the low byte of the address

during access 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/16 the oscillator frequency and

may be used for external timing or clocking purpose. Note, however, that one ALE pulse

is skipped during each access to external Data memory.

PSEN

Program Store Enable is the read strobe to external program memory when the

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

Page 21: 137027485 Vehicle Tracking System

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. EA should be strapped to Vcc for internal program executions. This pin also

receives the 12-volt programming enable voltage (Vpp) during Flash programming when

12-volt programming is selected.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL 2

Output from the inverting oscillator amplifier.

OPERATING DESCRIPTION

The detail description of the AT89C51 included in this description is:

• Memory Map and Registers

• Timer/Counters

• Interrupt System

MEMORY MAP AND REGISTERS

Memory

The AT89C51 has separate address spaces for program and data memory. The

program and data memory can be up to 64K bytes long. The lower 4K program memory

can reside on-chip. The AT89C51 has 128 bytes of on-chip RAM.

The lower 128 bytes can be accessed either by direct addressing or by indirect

addressing. The lower 128 bytes of RAM can be divided into 3 segments as listed below

1. Register Banks 0-3: locations 00H through 1FH (32 bytes). The device after reset

defaults to register bank 0. To use the other register banks, the user must select them in

software. Each register bank contains eight 1-byte registers R0-R7. Reset initializes the

stack point to location 07H, and is incremented once to start from 08H, which is the first

register of the second register bank.

Page 22: 137027485 Vehicle Tracking System

2. Bit Addressable Area: 16 bytes have been assigned for this segment 20H-2FH. Each

one of the 128 bits of this segment can be directly addressed (0-7FH). Each of the 16

bytes in this segment can also be addressed as a byte.

3. Scratch Pad Area: 30H-7FH are available to the user as data RAM. However, if the

data pointer has been initialized to this area, enough bytes should be left aside to prevent

SP data destruction.

SPECIAL FUNCTION REGISTERS:

The Special Function Registers (SFR's) are located in upper 128 Bytes direct

addressing area. The SFR Memory Map in shows that.

Not all of the addresses are occupied. Unoccupied addresses are not implemented

on the chip. Read accesses to these addresses in general return random data, and write

accesses have no effect. User software should not write 1s to these unimplemented

locations, since they may be used in future microcontrollers to invoke new features. In

that case, the reset or inactive values of the new bits will always be 0, and their active

values will be 1.

The functions of the SFR’s are outlined in the following sections.

Page 23: 137027485 Vehicle Tracking System

Accumulator (ACC)

ACC is the Accumulator register. The mnemonics for Accumulator-specific instructions,

however, refer to the Accumulator simply as A.

B Register (B)

The B register is used during multiply and divide operations. For other instructions it can

be treated as another scratch pad register.

Program Status Word (PSW)

The PSW register contains program status information.

Stack Pointer (SP)

The Stack Pointer Register is eight bits wide. It is incremented before data is stored

during PUSH and CALL executions. While the stack may reside anywhere in on chip

RAM, the Stack Pointer is initialized to 07H after a reset. This causes the stack to begin

at location 08H.

Data Pointer (DPTR)

The Data Pointer consists of a high byte (DPH) and a low byte (DPL). Its function is to

hold a 16-bit address. It may be manipulated as a 16-bit register or as two independent 8-

bit registers.

Serial Data Buffer (SBUF)

The Serial Data Buffer is actually two separate registers, a transmit buffer and a receive

buffer register. When data is moved to SBUF, it goes to the transmit buffer, where it is

held for serial transmission. (Moving a byte to SBUF initiates the transmission.) When

data is moved from SBUF, it comes from the receive buffer.

Timer Registers

Register pairs (TH0, TL0) and (TH1, TL1) are the 16-bit Counter registers for

Timer/Counters 0 and 1, respectively.

Control Registers

Special Function Registers IP, IE, TMOD, TCON, SCON, and PCON contain control and

status bits for the interrupt system, the Timer/Counters, and the serial port.

TIMER/COUNTERS

Page 24: 137027485 Vehicle Tracking System

The IS89C51 has two 16-bit Timer/Counter registers: Timer 0 and Timer 1. All

two can be configured to operate either as Timers or event counters. As a Timer, the

register is incremented every machine cycle. Thus, the register counts machine cycles.

Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the

oscillator frequency.

As a Counter, the register is incremented in response to a 1-to-0 transition at its

corresponding external input pin, T0 and T1. The external input is sampled during S5P2

of every machine cycle. When the samples show a high in one cycle and a low in the next

cycle, the count is incremented. The new count value appears in the register during S3P1

of the cycle following the one in which the transition was detected. Since two machine

cycles (24 oscillator periods) are required to recognize a 1-to-0 transition, the maximum

count rate is 1/24 of the oscillator frequency. There are no restrictions on the duty cycle

of the external input signal, but it should be held for at least one full machine cycle to

ensure that a given level is sampled at least once before it changes.

In addition to the Timer or Counter functions, Timer 0 and Timer 1 have four operating

modes: 13-bit timer, 16-bit timer, 8-bit auto-reload, split timer.

TIMERS:

÷12D

OSCILLATOR FREQUENCY

TR TLX THX TFX

SFR’S USED IN TIMERS

The special function registers used in timers are,

• TMOD Register

• TCON Register

Page 25: 137027485 Vehicle Tracking System

• Timer(T0) & timer(T1) Registers

(i) TMOD Register:

TMOD is dedicated solely to the two timers (T0 & T1).

• The timer mode SFR is used to configure the mode of operation of each of the

two timers. Using this SFR your program may configure each timer to be a 16-bit

timer, or 13 bit timer, 8-bit auto reload timer, or two separate timers. Additionally

you may configure the timers to only count when an external pin is activated or to

count “events” that are indicated on an external pin.

• It can consider as two duplicate 4-bit registers, each of which controls the action

of one of the timers.

(ii) TCON Register:

• The timer control SFR is used to configure and modify the way in which the

8051’s two timers operate. This SFR controls whether each of the two timers is

running or stopped and contains a flag to indicate that each timer has overflowed.

Additionally, some non-timer related bits are located in TCON SFR.

• These bits are used to configure the way in which the external interrupt flags are

activated, which are set when an external interrupt occurs.

(iii) TIMER 0 (T0):

• TO (Timer 0 low/high, address 8A/8C h)

These two SFR’s taken together represent timer 0. Their exact behavior

depends on how the timer is configured in the TMOD SFR; however, these timers

always count up. What is configurable is how and when they increment in value.

TH0 T L0

(iv) TIMER 1 (T1):

• T1 (Timer 1 Low/High, address 8B/ 8D h)

Page 26: 137027485 Vehicle Tracking System

These two SFR’s, taken together, represent timer 1. Their exact behavior depends on how

the timer is configured in the TMOD SFR; however, these timers always count up. What

is Configurable is how and when they increment in value.

TH1 TL1

The Timer or Counter function is selected by control bits C/T in the Special Function

Register TMOD. These two Timer/Counters have four operating modes, which are

selected by bit pairs (M1, M0) in TMOD. Modes 0, 1, and 2 are the same for both

Timer/Counters, but Mode 3 is different.

The four modes are described in the following sections.

Mode 0:

Both Timers in Mode 0 are 8-bit Counters with a divide-by-32 pre scalar. Figure 8

shows the Mode 0 operation as it applies to Timer 1. In this mode, the Timer register is

configured as a 13-bit register. As the count rolls over from all 1s to all 0s, it sets the

Timer interrupt flag TF1. The counted input is enabled to the Timer when TR1 = 1 and

either GATE = 0 or INT1 = 1. Setting GATE = 1 allows the Timer to be controlled by

external input INT1, to facilitate pulse width measurements. TR1 is a control bit in the

Special Function Register TCON. Gate is in TMOD.

The 13-bit register consists of all eight bits of TH1 and the lower five bits of TL1.

The upper three bits of TL1 are indeterminate and should be ignored. Setting the run flag

(TR1) does not clear the registers.

Mode 0 operation is the same for Timer 0 as for Timer 1, except that TR0, TF0

and INT0 replace the corresponding Timer 1 signals. There are two different GATE bits,

one for Timer 1 (TMOD.7) and one for Timer 0 (TMOD.3).

Mode 1

Mode 1 is the same as Mode 0, except that the Timer register is run with all 16

bits. The clock is applied to the combined high and low timer registers (TL1/TH1). As

clock pulses are received, the timer counts up: 0000H, 0001H, 0002H, etc. An overflow

occurs on the FFFFH-to-0000H overflow flag. The timer continues to count. The

overflow flag is the TF1 bit in TCON that is read or written by software

Mode 2

Page 27: 137027485 Vehicle Tracking System

Mode 2 configures the Timer register as an 8-bit Counter (TL1) with automatic

reload, as shown in Figure 10. Overflow from TL1 not only sets TF1, but also reloads

TL1 with the contents of TH1, which is preset by software. The reload leaves the TH1

unchanged. Mode 2 operation is the same for Timer/Counter 0.

Mode 3

Timer 1 in Mode 3 simply holds its count. The effect is the same as setting TR1 =

0. Timer 0 in Mode 3 establishes TL0and TH0 as two separate counters. The logic for

Mode 3 on Timer 0 is shown in Figure 11. TL0 uses the Timer 0 control bits: C/T,

GATE, TR0, INT0, and TF0. TH0 is locked into a timer function (counting machine

cycles) and over the use of TR1 and TF1 from Timer 1. Thus, TH0 now controls the

Timer 1 interrupt.

Mode 3 is for applications requiring an extra 8-bit timer or counter. With Timer 0

in Mode 3, the AT89C51 can appear to have three Timer/Counters. When Timer 0 is in

Mode 3, Timer 1 can be turned on and off by switching it out of and into its own Mode 3.

In this case, Timer 1 can still be used by the serial port as a baud rate generator or in any

application not requiring an interrupt.

INTERRUPT SYSTEM

An interrupt is an external or internal event that suspends the operation of micro

controller to inform it that a device needs its service. In interrupt method, whenever any

device needs its service, the device notifies the micro controller by sending it an interrupt

signal. Upon receiving an interrupt signal, the micro controller interrupts whatever it is

doing and serves the device. The program associated with interrupt is called as interrupt

service subroutine (ISR).Main advantage with interrupts is that the micro controller can

serve many devices.

Baud Rate

The baud rate in Mode 0 is fixed as shown in the following equation. Mode 0

Baud Rate = Oscillator Frequency /12 the baud rate in Mode 2 depends on the value of

the SMOD bit in Special Function Register PCON. If SMOD = 0 the baud rate is 1/64 of

the oscillator frequency. If SMOD = 1, the baud rate is 1/32 of the oscillator frequency.

Mode 2 Baud Rate = 2SMODx (Oscillator Frequency)/64.

Page 28: 137027485 Vehicle Tracking System

In the IS89C51, the Timer 1 overflow rate determines the baud rates in Modes 1 and 3.

NUMBER OF INTERRUPTS IN 89C51:

There are basically five interrupts available to the user. Reset is also considered as

an interrupt. There are two interrupts for timer, two interrupts for external hardware

interrupt and one interrupt for serial communication.

Memory location Interrupt name

0000H Reset

0003H External interrupt 0

000BH Timer interrupt 0

0013H External interrupt 1

001BH Timer interrupt 1

0023H Serial COM interrupt

Lower the vector, higher the priority. The External Interrupts INT0 and INT1 can

each be either level-activated or transition-activated, depending on bits IT0 and IT1 in

Register TCON. The flags that actually generate these interrupts are the IE0 and IE1 bits

in TCON. When the service routine is vectored, hardware clears the flag that generated

an external interrupt only if the interrupt was transition-activated. If the interrupt was

level-activated, then the external requesting source (rather than the on-chip hardware)

controls the request flag.

The Timer 0 and Timer 1 Interrupts are generated by TF0and TF1, which are set

by a rollover in their respective Timer/Counter registers (except for Timer 0 in Mode

3).When a timer interrupt is generated, the on-chip hardware clears the flag that is

generated.

The Serial Port Interrupt is generated by the logical OR of RI and TI. The service

routine normally must determine whether RI or TI generated the interrupt, and the bit

must be cleared in software.

All of the bits that generate interrupts can be set or cleared by software, with the

same result as though they had been set or cleared by hardware. That is, interrupts can be

generated and pending interrupts can be canceled in software.

Each of these interrupt sources can be individually enabled or disabled by setting

or clearing a bit in Special Function Register IE (interrupt enable) at address 0A8H.

Page 29: 137027485 Vehicle Tracking System

There is a global enable/disable bit that is cleared to disable all interrupts or to set the

interrupts.

IE (Interrupt enable register):

Steps in enabling an interrupt:

Bit D7 of the IE register must be set to high to allow the rest of register to take

effect. If EA=1, interrupts are enabled and will be responded to if their corresponding bits

in IE are high. If EA=0, no interrupt will be responded to even if the associated bit in the

IE register is high.

Description of each bit in IE register:

D7 bit: Disables all interrupts. If EA =0, no interrupt is acknowledged, if EA=1

each interrupt source is individually enabled or disabled by setting or clearing its enable

bit.

D6 bit: Reserved.

D5 bit: Enables or disables timer 2 over flow interrupt (in 8052).

D4 bit: Enables or disables serial port interrupt.

D3 bit: Enables or disables timer 1 over flow interrupt.

D2 bit: Enables or disables external interrupt 1.

D1 bit: Enables or disables timer 0 over flow interrupt.

D0 bit: Enables or disables external interrupt 0.

Interrupt priority in 89C51:

There is one more SRF to assign priority to the interrupts which is named as

interrupt priority (IP). User has given the provision to assign priority to one interrupt.

Writing one to that particular bit in the IP register fulfils the task of assigning the priority.

Description of each bit in IP register:

D7 bit: Reserved.

D6 bit: Reserved.

D5 bit: Timer 2 interrupt priority bit (in 8052).

D4 bit: Serial port interrupt priority bit.

D3 bit: Timer 1 interrupt priority bit.

D2 bit: External interrupt 1 priority bit.

Page 30: 137027485 Vehicle Tracking System

D1 bit: Timer 0 interrupt priority bit.

D0 bit: External interrupt 0 priority bit.

POWER SUPPLY:

Block diagram:

Figure: Power Supply

Page 31: 137027485 Vehicle Tracking System

Circuitdiagram:

Description:

Transformer:

Page 32: 137027485 Vehicle Tracking System

A transformer is a device that transfers electrical energy from one circuit to another

through inductively coupled conductors—the transformer's coils. A varying current in the

first or primary winding creates a varying magnetic flux in the transformer's core, and

thus a varying magnetic field through the secondary winding. This varying magnetic field

induces a varying electromotive force (EMF) or "voltage" in the secondary winding. This

effect is called mutual induction.

Figure: Transformer Symbol

(or)

Transformer is a device that converts the one form energy to another form of energy like

a transducer.

Figure: Transformer

Basic Principle :

Page 33: 137027485 Vehicle Tracking System

A transformer makes use of Faraday's law and the ferromagnetic properties of an iron

core to efficiently raise or lower AC voltages. It of course cannot increase power so that

if the voltage is raised, the current is proportionally lowered and vice versa.

Figure: Basic Principle

Transformer Working:

Page 34: 137027485 Vehicle Tracking System

A transformer consists of two coils (often called 'windings') linked by an iron core, as

shown in figure below. There is no electrical connection between the coils, instead they

are linked by a magnetic field created in the core.

Figure: Basic Transformer

Transformers are used to convert electricity from one voltage to another with minimal

loss of power. They only work with AC (alternating current) because they require a

changing magnetic field to be created in their core. Transformers can increase voltage

(step-up) as well as reduce voltage (step-down).

Alternating current flowing in the primary (input) coil creates a continually changing

magnetic field in the iron core. This field also passes through the secondary (output) coil

and the changing strength of the magnetic field induces an alternating voltage in the

secondary coil. If the secondary coil is connected to a load the induced voltage will make

an induced current flow. The correct term for the induced voltage is 'induced

electromotive force' which is usually abbreviated to induced e.m.f.

The iron core is laminated to prevent 'eddy currents' flowing in the core. These are

currents produced by the alternating magnetic field inducing a small voltage in the core,

just like that induced in the secondary coil. Eddy currents waste power by needlessly

heating up the core but they are reduced to a negligible amount by laminating the iron

Page 35: 137027485 Vehicle Tracking System

because this increases the electrical resistance of the core without affecting its magnetic

properties.

Transformers have two great advantages over other methods of changing voltage:

1. They provide total electrical isolation between the input and output, so they can

be safely used to reduce the high voltage of the mains supply.

2. Almost no power is wasted in a transformer. They have a high efficiency (power

out / power in) of 95% or more.

Classification of Transformer:

Step-Up Transformer

Step-Down Transformer

Step-Down Transformer:

Step down transformers are designed to reduce electrical voltage. Their primary voltage

is greater than their secondary voltage. This kind of transformer "steps down" the voltage

applied to it. For instance, a step down transformer is needed to use a 110v product in a

country with a 220v supply.

Step down transformers convert electrical voltage from one level or phase configuration

usually down to a lower level. They can include features for electrical isolation, power

distribution, and control and instrumentation applications. Step down transformers

typically rely on the principle of magnetic induction between coils to convert voltage

and/or current levels.

Step down transformers are made from two or more coils of insulated wire wound around

a core made of iron. When voltage is applied to one coil (frequently called the primary or

input) it magnetizes the iron core, which induces a voltage in the other coil, (frequently

called the secondary or output). The turn’s ratio of the two sets of windings determines

the amount of voltage transformation.

Page 36: 137027485 Vehicle Tracking System

Figure: Step-Down Transformer

An example of this would be: 100 turns on the primary and 50 turns on the secondary, a

ratio of 2 to 1.

Step down transformers can be considered nothing more than a voltage ratio device.

With step down transformers the voltage ratio between primary and secondary will mirror

the "turn’s ratio" (except for single phase smaller than 1 kva which have compensated

secondary). A practical application of this 2 to 1 turn’s ratio would be a 480 to 240

voltage step down. Note that if the input were 440 volts then the output would be 220

volts. The ratio between input and output voltage will stay constant. Transformers should

not be operated at voltages higher than the nameplate rating, but may be operated at

lower voltages than rated. Because of this it is possible to do some non-standard

applications using standard transformers.

Single phase step down transformers 1 kva and larger may also be reverse connected to

step-down or step-up voltages. (Note: single phase step up or step down transformers

sized less than 1 KVA should not be reverse connected because the secondary windings

have additional turns to overcome a voltage drop when the load is applied. If reverse

connected, the output voltage will be less than desired.)

Step-Up Transformer:

Page 37: 137027485 Vehicle Tracking System

A step up transformer has more turns of wire on the secondary coil, which makes a larger

induced voltage in the secondary coil. It is called a step up transformer because the

voltage output is larger than the voltage input.

Step-up transformer 110v 220v design is one whose secondary voltage is greater than its

primary voltage. This kind of transformer "steps up" the voltage applied to it. For

instance, a step up transformer is needed to use a 220v product in a country with a 110v

supply.

A step up transformer 110v 220v converts alternating current (AC) from one voltage to

another voltage. It has no moving parts and works on a magnetic induction principle; it

can be designed to "step-up" or "step-down" voltage. So a step up transformer increases

the voltage and a step down transformer decreases the voltage.

The primary components for voltage transformation are the step up transformer core and

coil. The insulation is placed between the turns of wire to prevent shorting to one another

or to ground. This is typically comprised of Mylar, nomex, Kraft paper, varnish, or other

materials. As a transformer has no moving parts, it will typically have a life expectancy

between 20 and 25 years.

Figure: Step-Up Transformer

Applications

Generally these Step-Up Transformers are used in industries applications only.

Page 38: 137027485 Vehicle Tracking System

Turns Ratio and Voltage

The ratio of the number of turns on the primary and secondary coils determines the ratio

of the voltages...

...where Vp is the primary (input) voltage, Vs is the secondary (output) voltage, Np is the

number of turns on the primary coil, and Ns is the number of turns on the secondary coil.

Diodes:

Diodes allow electricity to flow in only one direction. The arrow of the circuit symbol

shows the direction in which the current can flow. Diodes are the electrical version of a

valve and early diodes were actually called valves.

Figure: Diode Symbol

A diode is a device which only allows current to flow through it in one direction. In this

direction, the diode is said to be 'forward-biased' and the only effect on the signal is that

there will be a voltage loss of around 0.7V. In the opposite direction, the diode is said to

be 'reverse-biased' and no current will flow through it.

Rectifier

The purpose of a rectifier is to convert an AC waveform into a DC waveform (OR)

Rectifier converts AC current or voltages into DC current or voltage. There are two

Page 39: 137027485 Vehicle Tracking System

different rectification circuits, known as 'half-wave' and 'full-wave' rectifiers. Both use

components called diodes to convert AC into DC.

The Half-wave Rectifier

The half-wave rectifier is the simplest type of rectifier since it only uses one diode, as

shown in figure .

Figure: Half Wave Rectifier

Figure 2 shows the AC input waveform to this circuit and the resulting output. As you

can see, when the AC input is positive, the diode is forward-biased and lets the current

through. When the AC input is negative, the diode is reverse-biased and the diode does

not let any current through, meaning the output is 0V. Because there is a 0.7V voltage

loss across the diode, the peak output voltage will be 0.7V less than Vs.

Page 40: 137027485 Vehicle Tracking System

Figure: Half-Wave Rectification

While the output of the half-wave rectifier is DC (it is all positive), it would not be

suitable as a power supply for a circuit. Firstly, the output voltage continually varies

between 0V and Vs-0.7V, and secondly, for half the time there is no output at all.

The Full-wave Rectifier

The circuit in figure 3 addresses the second of these problems since at no time is the

output voltage 0V. This time four diodes are arranged so that both the positive and

negative parts of the AC waveform are converted to DC. The resulting waveform is

shown in figure 4.

Page 41: 137027485 Vehicle Tracking System

Figure: Full-Wave Rectifier

Figure: Full-Wave Rectification

When the AC input is positive, diodes A and B are forward-biased, while diodes C and D

are reverse-biased. When the AC input is negative, the opposite is true - diodes C and D

are forward-biased, while diodes A and B are reverse-biased.

While the full-wave rectifier is an improvement on the half-wave rectifier, its output still

isn't suitable as a power supply for most circuits since the output voltage still varies

between 0V and Vs-1.4V. So, if you put 12V AC in, you will 10.6V DC out.

Page 42: 137027485 Vehicle Tracking System

Capacitor Filter

The capacitor-input filter, also called "Pi" filter due to its shape that looks like the

Greek letter pi, is a type of electronic filter. Filter circuits are used to remove unwanted or

undesired frequencies from a signal.

Figure: Capacitor Filter

A typical capacitor input filter consists of a filter capacitor C1, connected across the

rectifier output, an inductor L, in series and another filter capacitor connected across the

load.

1. The capacitor C1 offers low reactance to the AC component of the rectifier output

while it offers infinite reactance to the DC component. As a result the capacitor

shunts an appreciable amount of the AC component while the DC component

continues its journey to the inductor L

2. The inductor L offers high reactance to the AC component but it offers almost

zero reactance to the DC component. As a result the DC component flows through

the inductor while the AC component is blocked.

3. The capacitor C2 bypasses the AC component which the inductor had failed to

block. As a result only the DC component appears across the load RL.

Page 43: 137027485 Vehicle Tracking System

Figure: Centered Tapped Full-Wave Rectifier with a Capacitor Filter

Voltage Regulator:

A voltage regulator is an electrical regulator designed to automatically maintain a

constant voltage level. It may use an electromechanical mechanism, or passive or active

electronic components. Depending on the design, it may be used to regulate one or more

AC or DC voltages. There are two types of regulator are they.

Positive Voltage Series (78xx) and

Negative Voltage Series (79xx)

78xx:’78’ indicate the positive series and ‘xx’indicates the voltage rating. Suppose 7805

produces the maximum 5V.’05’indicates the regulator output is 5V.

79xx:’78’ indicate the negative series and ‘xx’indicates the voltage rating. Suppose 7905

produces the maximum -5V.’05’indicates the regulator output is -5V.

These regulators consists the three pins there are

Pin1: It is used for input pin.

Pin2: This is ground pin for regulator

Page 44: 137027485 Vehicle Tracking System

Pin3: It is used for output pin. Through this pin we get the output.

Figure: Regulator

SERIAL COMMUNICATION

THEORY:

In order to connect micro controller to a modem or a pc to modem a serial port is

used. Serial is a very common protocol for device communication that is standard on

almost every PC. Most computers include two RS-232 based serial ports. Serial is also a

common communication protocol that is used by many devices for instrumentation;

numerous GPIB-compatible devices also come with an RS-232 port. Furthermore, serial

communication can be used for data acquisition in conjunction with a remote sampling

device.

The concept of serial communication is simple. The serial port sends and receives

bytes of information one bit at a time. Although this is slower than parallel

communication, which allows the transmission of an entire byte at once, it is simpler and

can be used over longer distances. For example, the IEEE 488 specifications for parallel

communication state that the cabling between equipment can be no more than 20 meters

total, with no more than 2 meters between any two devices. Serial, however, can extend

as much as 1200 meters.

Typically, serial is used to transmit ASCII data. Communication is completed

using 3 transmission lines: (1) Ground, (2) Transmit, and (3) Receive. Since serial is

Page 45: 137027485 Vehicle Tracking System

asynchronous, the port is able to transmit data on one line while receiving data on

another. Other lines are available for handshaking, but are not required. The important

serial characteristics are baud rate, data bits, stop bits, and parity. For two ports to

communicate, these parameters must match.

Baud rate: It is a speed measurement for communication. It indicates the number of

bit transfers per second. For example, 300 baud is 300 bits per second. When a clock

cycle is referred it means the baud rate. For example, if the protocol calls for a 4800 baud

rate, then the clock is running at 4800Hz. This means that the serial port is sampling the

data line at 4800Hz. Common baud rates for telephone lines are 14400, 28800, and

33600. Baud rates greater than these are possible, but these rates reduce the distance by

which devices can be separated. These high baud rates are used for device

communication where the devices are located together, as is typically the case with GPIB

devices.

Data bits: Measurement of the actual data bits in a transmission. When the computer

sends a packet of information, the amount of actual data may not be a full 8 bits. Standard

values for the data packets are 5, 7, and 8 bits. Which setting chosen depends on what

information transferred. For example, standard ASCII has values from 0 to 127 (7 bits).

Extended ASCII uses 0 to 255 (8 bits). If the data being transferred is simple text

(standard ASCII), then sending 7 bits of data per packet is sufficient for communication.

A packet refers to a single byte transfer, including start/stop bits, data bits, and parity.

Since the number of actual bits depend on the protocol selected, the term packet is used

to cover all instances.

Stop bits: used to signal the end of communication for a single packet. Typical

values are 1, 1.5, and 2 bits. Since the data is clocked across the lines and each device has

its own clock, it is possible for the two devices to become slightly out of sync. Therefore,

the stop bits not only indicate the end of transmission but also give the computers some

room for error in the clock speeds. The more bits that are used for stop bits, the greater

the lenience in synchronizing the different clocks, but the slower the data transmission

rate.

Page 46: 137027485 Vehicle Tracking System

Parity: A simple form of error checking that is used in serial communication. There are

four types of parity: even, odd, marked, and spaced. The option of using no parity is also

available. For even and odd parity, the serial port sets the parity bit (the last bit after the

data bits) to a value to ensure that the transmission has an even or odd number of logic

high bits. For example, if the data is 011, then for even parity, the parity bit is 0 to keep

the number of logic-high bits even. If the parity is odd, then the parity bit is 1, resulting in

3 logic-high bits. Marked and spaced parity does not actually check the data bits, but

simply sets the parity bit high for marked parity or low for spaced parity. This allows the

receiving device to know the state of a bit to enable the device to determine if noise is

corrupting the data or if the transmitting and receiving device clocks are out of sync.

WHAT IS RS –232C

RS-232 (ANSI/EIA-232 Standard) is the serial connection found on IBM-

compatible PCs. It is used for many purposes, such as connecting a mouse, printer, or

modem, as well as industrial instrumentation. Because of improvements in line drivers

and cables, applications often increase the performance of RS-232 beyond the distance

and speed listed in the standard. RS-232 is limited to point-to-point connections between

PC serial ports and devices. RS-232 hardware can be used for serial communication up to

distances of 50 feet .

DB-9 pin connector

1 2 3 4 5

6 7 8 9

(Out of computer and exposed end of cable)

Pin Functions:

Data: TxD on pin 3, RxD on pin 2

Handshake: RTS on pin 7, CTS on pin 8, DSR on pin 6,

Page 47: 137027485 Vehicle Tracking System

CD on pin 1, DTR on pin 4

Common: Common pin 5(ground)

Other: RI on pin 9

The method used by RS-232 for communication allows for a simple connection of three

lines: Tx, Rx, and Ground. The three essential signals for 2 way RS-232

Communications are these:

TXD: carries data from DTE to the DCE.

RXD: carries data from DCE to the DTE

SG: signal ground

Connection Diagram:

Embedded Controller

RXD

TXD

TXD

RXD 2

3

5

GND

MAX 232

Figure.: Interfacing to MCU RS 232

SFRs Used for Serial Communication:

SCON:

SM2 SM1 SM0 REN TB8 RB8 TI RI

TMOD:

T1:

TH1 TL1

Page 48: 137027485 Vehicle Tracking System

CONNECTIONS IN MAX 232:

If you wanted to do a general RS-232 connection, you could take a bunch of long

wires and solder them directly to the electronic circuits of the equipment you are using,

but this tends to make a big mess and often those solder connections tend to break and

other problems can develop. To deal with these issues, and to make it easier to setup or

take down equipment, some standard connectors have been developed that is commonly

found on most equipment using the RS-232 standards.

These connectors come in two forms: A male and a female connector. The female

connector has holes that allow the pins on the male end to be inserted into the connector.

This is a female "DB-9" connector (properly known as DE9F):

Female Connector

The female DB-9 connector is typically used as the "plug" that goes into a typical PC. If

you see one of these on the back of your computer, it is likely not to be used for serial

communication, but rather for things like early VGA or CGA monitors (not SVGA) or

for some special control/joystick equipment.

And this is a male "DB-9" connector (properly known as DE9M):

Page 49: 137027485 Vehicle Tracking System

Male Connector

This is the connector that you are more likely to see for serial communications on a

"generic" PC. Often you will see two of them side by side (for COM1 and COM2).

Special equipment that you might communicate with would have either connector, or

even one of the DB-25 connectors listed below.

The wiring of RS-232 devices involves first identifying the actual pins that are being

used. Here is how a female DB-9 connector is numbered:

Figure.: Front View

If the numbers are hard to read, it starts at the top-right corner as "1", and goes left until

the end of the row and then starts again as pin 6 on the next row until you get to pin 9 on

the bottom-left pin. "Top" is defined as the row with 5 pins.

The male connector (like what you have on your PC) is simply this same order, but

reversed from right to left.

Here each pin is usually defined as:

9-pin 25-pin pin definition

1 8 DCD (Data Carrier Detect)

2 3 RX (Receive Data)

Page 50: 137027485 Vehicle Tracking System

3 2 TX (Transmit Data)

4 20 DTR (Data Terminal Ready)

5 7 GND (Signal Ground)

6 6 DSR (Data Set Ready)

7 4 RTS (Request To Send)

8 5 CTS (Clear To Send))

9 22 RI (Ring Indicator)

Pin Definition of Connectors

One thing to keep in mind when discussing these pins and their meaning is that they are

very closely tied together with modems and modem protocols. Often you don't have a

modem attached in the loop, but you still treat the equipment as if it were a modem on a

theoretical level.

MAX232:

Max 232 is a communications device used mainly for serial commands to and from a

flash ROM.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.

Page 51: 137027485 Vehicle Tracking System

The newer MAX3232 is also backwards compatible, but operates at a broader voltage

range, from 3 to 5.5V.

Voltage levels

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. To clarify the matter, see the table below. For more information see RS-

232 Voltage Levels.

RS232 Line Type & Logic LevelRS232

Voltage

TTL Voltage to/from

MAX232

Data Transmission (Rx/Tx) Logic 0 +3V to +15V 0V

Data Transmission (Rx/Tx) Logic 1 -3V to -15V 5V

Control Signals (RTS/CTS/DTR/DSR)

Logic 0-3V to -15V 5V

Control Signals (RTS/CTS/DTR/DSR)

Logic 1+3V to +15V 0V

Standard serial interfacing of microcontroller (TTL) with PC or any RS232C Standard

device , requires TTL to RS232 Level converter . A MAX232 is used for this purpose. It

provides 2-channel RS232C port and requires external 10uF capacitors. The driver

requires a single supply of +5V.

Page 52: 137027485 Vehicle Tracking System

GSM :

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

Figure 13:MAX 232 Pin DiagramFigure 14:Internal Diagram

Page 53: 137027485 Vehicle Tracking System

History

In 1982, the European Conference of Postal and Telecommunications

Administrations (CEPT) 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

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 890–915 MHz to send information from the mobile station to the

base station (uplink) and 935–960 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 880–915 MHz (uplink) and 925–

Page 54: 137027485 Vehicle Tracking System

960 MHz (downlink), adding 50 channels (channel numbers 975 to 1023 and 0) to the

original GSM-900 band.

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, GSM’s 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 world’s population.

GSM satellite roaming has also extended service access to areas where terrestrial

coverage is not available.

Mobile Telephony Standards

1G

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:

Page 55: 137027485 Vehicle Tracking System

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

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 20th 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

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

Page 56: 137027485 Vehicle Tracking System

(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).

3G

The IMT-2000 (International Mobile Telecommunications for the year 2000)

specifications from the International Telecommunications Union (ITU) defined the

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,

Page 57: 137027485 Vehicle Tracking System

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.

Introduction to the GSM Standard

The GSM (Global System for Mobile communications) network is at the start of

the 21st 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

(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

Page 58: 137027485 Vehicle Tracking System

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.

TDMA in brief:

In late1980’s, as a search to convert the existing analog network to digital as a

means to improve capacity, the cellular telecommunications industry association chose

TDMA over FDMA. Time Division Multiplex Access is a type of multiplexing where

two or more channels of information are transmitted over the same link by allocating a

different time interval for the transmission of each channel. The most complex

implementation using TDMA principle is of GSM’s (Global System for Mobile

communication). To reduce the effect of co-channel interference, fading and multipath,

the GSM technology can use frequency hopping, where a call jumps from one channel to

another channel in a short interval.

TDMA systems still rely on switch to determine when to perform a handoff.

Handoff occurs when a call is switched from one cell site to another while travelling. The

Page 59: 137027485 Vehicle Tracking System

TDMA handset constantly monitors the signals coming from other sites and reports it to

the switch without caller’s awareness. The switch then uses this information for making

better choices for handoff at appropriate times. TDMA handset performs hard handoff,

i.e., whenever the user moves from one site to another, it breaks the connection and then

provides a new connection with the new site.

Advantages of TDMA:

There are lots of advantages of TDMA in cellular technologies.

1. It can easily adapt to transmission of data as well as voice communication.

2. It has an ability to carry 64 kbps to 120 Mbps of data rates. This allows the

operator to do services like fax, voice band data and SMS as well as bandwidth

intensive application such as multimedia and video conferencing.

3. Since TDMA technology separates users according to time, it ensures that there

will be no interference from simultaneous transmissions.

4. It provides users with an extended battery life, since it transmits only portion of

the time during conversations. Since the cell size grows smaller, it proves to save

base station equipment, space and maintenance.

TDMA is the most cost effective technology to convert an analog system to digital.

Disadvantages of TDMA:

One major disadvantage using TDMA technology is that the users has a

predefined time slot. When moving from one cell site to other, if all the time slots in this

cell are full the user might be disconnected. Likewise, if all the time slots in the cell in

which the user is currently in are already occupied, the user will not receive a dial tone.

The second problem in TDMA is that it is subjected to multipath distortion. To

overcome this distortion, a time limit can be used on the system. Once the time limit is

expired, the signal is ignored.

The concept of cellular network

Mobile telephone networks are based on the concept of cells, circular zones that

overlap to cover a geographical area.

Page 60: 137027485 Vehicle Tracking System

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.

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.

Page 61: 137027485 Vehicle Tracking System

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

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

Page 62: 137027485 Vehicle Tracking System

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.

Introduction to Modem:

Modem stands for modulator-demodulator.

A modem is a device or program that enables a computer to transmit data over

telephone or cable lines. Computer information is stored digitally, whereas information

transmitted over telephone lines is transmitted in the form of analog waves. A modem

converts between these two forms.

Fortunately, there is one standard interface for connecting external modems to

computers called RS-232. Consequently, any external modem can be attached to any

computer that has an RS-232 port, which almost all personal computers have. There are

also modems that come as an expansion board that can be inserted into a vacant

expansion slot. These are sometimes called onboard or internal modems.

While the modem interfaces are standardized, a number of different protocols for

formatting data to be transmitted over telephone lines exist. Some, like CCITT V.34 are

official standards, while others have been developed by private companies. Most modems

have built-in support for the more common protocols at slow data transmission speeds at

Page 63: 137027485 Vehicle Tracking System

least, most modems can communicate with each other. At high transmission speeds,

however, the protocols are less standardized.

Apart from the transmission protocols that they support, the following characteristics

distinguish one modem from another:

Bps: How fast the modem can transmit and receive data. At slow rates, modems

are measured in terms of baud rates. The slowest rate is 300 baud (about 25 cps).

At higher speeds, modems are measured in terms of bits per second (bps). The

fastest modems run at 57,600 bps, although they can achieve even higher data

transfer rates by compressing the data. Obviously, the faster the transmission rate,

the faster the data can be sent and received. It should be noted that the data cannot

be received at a faster rate than it is being sent.

Voice/data: Many modems support a switch to change between voice and data

modes. In data mode, the modem acts like a regular modem. In voice mode, the

modem acts like a regular telephone. Modems that support a voice/data switch

have a built-in loudspeaker and microphone for voice communication.

Auto-answer: An auto-answer modem enables the computer to receive calls in

the absence of the operator.

Data compression: Some modems perform data compression, which enables

them to send data at faster rates. However, the modem at the receiving end must

be able to decompress the data using the same compression technique.

Flash memory: Some modems come with flash memory rather than conventional

ROM which means that the communications protocols can be easily updated if

necessary.

Fax capability: Most modern modems are fax modems, which mean that they

can send and receive faxes.

GSM Modem:

A GSM modem is a wireless modem that works with a GSM wireless network. A

wireless modem behaves like a dial-up modem. The main difference between them is that

a dial-up modem sends and receives data through a fixed telephone line while a wireless

modem sends and receives data through radio waves.

Page 64: 137027485 Vehicle Tracking System

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

Page 65: 137027485 Vehicle Tracking System

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.

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

Page 66: 137027485 Vehicle Tracking System

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

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*).

Page 67: 137027485 Vehicle Tracking System

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.

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

Page 68: 137027485 Vehicle Tracking System

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

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

Page 69: 137027485 Vehicle Tracking System

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

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.

GPS

Page 70: 137027485 Vehicle Tracking System

Basic concept of GPS

A GPS receiver calculates its position by precisely timing the signals sent by GPS

satellites high above the Earth. Each satellite continually transmits messages that include

• the time the message was transmitted

• precise orbital information (the ephemeris)

• the general system health and rough orbits of all GPS satellites (the almanac).

The receiver uses the messages it receives to determine the transit time of each message

and computes the distance to each satellite. These distances along with the satellites'

locations are used with the possible aid of trilateration, depending on which algorithm is

used, to compute the position of the receiver. This position is then displayed, perhaps

with a moving map display or latitude and longitude; elevation information may be

Page 71: 137027485 Vehicle Tracking System

included. Many GPS units show derived information such as direction and speed,

calculated from position changes.

Three satellites might seem enough to solve for position since space has three

dimensions and a position near the Earth's surface can be assumed. However, even a very

small clock error multiplied by the very large speed of light[35] — the speed at which

satellite signals propagate — results in a large positional error. Therefore receivers use

four or more satellites to solve for the receiver's location and time. The very accurately

computed time is effectively hidden by most GPS applications, which use only the

location. A few specialized GPS applications do however use the time; these include time

transfer, traffic signal timing, and synchronization of cell phone base stations.

Although four satellites are required for normal operation, fewer apply in special

cases. If one variable is already known, a receiver can determine its position using only

three satellites. For example, a ship or aircraft may have known elevation. Some GPS

receivers may use additional clues or assumptions (such as reusing the last known

altitude, dead reckoning, inertial navigation, or including information from the vehicle

computer) to give a less accurate (degraded) position when fewer than four satellites are

visible.

Position calculation introduction

Two sphere surfaces intersecting in a circle

Page 72: 137027485 Vehicle Tracking System

Surface of sphere intersecting a circle (not a solid disk) at two points

To provide an introductory description of how a GPS receiver works, error effects

are deferred to a later section. Using messages received from a minimum of four visible

satellites, a GPS receiver is able to determine the times sent and then the satellite

positions corresponding to these times sent. The x, y, and z components of position, and

the time sent, are designated as where the subscript i is the satellite number

and has the value 1, 2, 3, or 4. Knowing the indicated time the message was received ,

the GPS receiver could compute the transit time of the message as , if would be

equal to correct reception time, . A pseudorange, , would be the traveling

distance of the message, assuming it traveled at the speed of light, c.

A satellite's position and pseudorange define a sphere, centered on the satellite,

with radius equal to the pseudorange. The position of the receiver is somewhere on the

surface of this sphere. Thus with four satellites, the indicated position of the GPS receiver

is at or near the intersection of the surfaces of four spheres. In the ideal case of no errors,

the GPS receiver would be at a precise intersection of the four surfaces.

If the surfaces of two spheres intersect at more than one point, they intersect in a

circle. The article trilateration shows this mathematically. A figure, Two Sphere Surfaces

Intersecting in a Circle, is shown below. Two points where the surfaces of the spheres

intersect are clearly shown in the figure. The distance between these two points is the

diameter of the circle of intersection. The intersection of a third spherical surface with the

first two will be its intersection with that circle; in most cases of practical interest, this

Page 73: 137027485 Vehicle Tracking System

means they intersect at two points.[39] Another figure, Surface of Sphere Intersecting a

Circle (not a solid disk) at Two Points, illustrates the intersection. The two intersections

are marked with dots. Again the article trilateration clearly shows this mathematically.

For automobiles and other near-earth vehicles, the correct position of the GPS

receiver is the intersection closest to the Earth's surface.[40] For space vehicles, the

intersection farthest from Earth may be the correct one.

The correct position for the GPS receiver is also the intersection closest to the

surface of the sphere corresponding to the fourth satellite.

GPS COMMANDS LIST

NMEA input

Some units also support an NMEA input mode. While not too many programs

support this mode it does provide a standardized way to update or add waypoint and route

data. Note that there is no handshaking or commands in NMEA mode so you just send

the data in the correct sentence and the unit will accept the data and add or overwrite the

information in memory. If the data is not in the correct format it will simply be ignored.

A carriage return/line feed sequence is required. If the waypoint name is the same you

will overwrite existing data but no warning will be issued. The sentence construction is

identical to what the unit downloads so you can, for example, capture a WPL sentence

from one unit and then send that same sentence to another unit but be careful if the two

Page 74: 137027485 Vehicle Tracking System

units support waypoint names of different lengths since the receiving unit might truncate

the name and overwrite a waypoint accidently. If you create a sentence from scratch you

should create a correct checksum. Be sure you know and have set you unit to the correct

datum. Many units support the input of WPL sentences and a few support RTE as well.

On NMEA input the receiver stores information based on interpreting the sentence itself.

While some receivers accept standard NMEA input this can only be used to update a

waypoint or similar task and not to send a command to the unit. Proprietary input

sentences could be used to send commands. Since the Magellan upload and download

maintenance protocol is based on NMEA sentences they support a modified WPL

message that adds comments, altitude, and icon data.

Some marine units may accept input for alarms such as deep or shallow water based on

the DPT sentence or MTW to read the water temperature. For example the Garmin

Map76 supports DPT, MTW (temperature), and VHW (speed) input sentences. Other

units may use NMEA input to provide initialization data via proprietary sentences, or to

select which NMEA sentences to output.

The most important NMEA sentences include the GGA which provides the current Fix

data, the RMC which provides the minimum gps sentences information, and the GSA

which provides the Satellite status data.

GGA - essential fix data which provide 3D location and accuracy data.

$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47

Where:

GGA-Global Positioning System Fix Data

123519-Fix taken at 12:35:19 UTC

4807.038,N-Latitude 48 deg 07.038' N

Page 75: 137027485 Vehicle Tracking System

01131.000,E-Longitude 11 deg 31.000' E

1 Fix quality: 0 = invalid

1 = GPS fix (SPS)

2 = DGPS fix

3 = PPS fix

4 = Real Time Kinematic

5 = Float RTK

6 = estimated (dead reckoning) (2.3 feature)

7 = Manual input mode

8 = Simulation mode

08 Number of satellites being tracked

0.9 Horizontal dilution of position

545.4,M Altitude, Meters, above mean sea level

46.9,M Height of geo id (mean sea level) above WGS84

(empty field) time in seconds since last DGPS update (empty field) DGPS station ID

number

If the height of geoid is missing then the altitude should be suspect. Some non-standard

implementations report altitude with respect to the ellipsoid rather than geoid altitude.

Some units do not report negative altitudes at all. This is the only sentence that reports

altitude.

GSA - GPS DOP and active satellites. This sentence provides details on the nature of the

fix. It includes the numbers of the satellites being used in the current solution and the

DOP. DOP (dilution of precision) is an indication of the effect of satellite geometry on

the accuracy of the fix. It is a unitless number where smaller is better. For 3D fixes using

4 satellites a 1.0 would be considered to be a perfect number, however for

overdetermined solutions it is possible to see numbers below 1.0. There are differences in

the way the PRN's are presented which can effect the ability of some programs to display

Page 76: 137027485 Vehicle Tracking System

this data. For example, in the example shown below there are 5 satellites in the solution

and the null fields are scattered indicating that the almanac would show satellites in the

null positions that are not being used as part of this solution. Other receivers might output

all of the satellites used at the beginning of the sentence with the null field all stacked up

at the end. This difference accounts for some satellite display programs not always being

able to display the satellites being tracked. Some units may show all satellites that have

ephemeris data without regard to their use as part of the solution but this is non-standard.

$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39

Where:

GSA Satellite status

A Auto selection of 2D or 3D fix (M = manual)

3 3D fix - values include: 1 = no fix

2 = 2D fix

3 = 3D fix

04,05... PRNs of satellites used for fix (space for 12)

2.5 PDOP (dilution of precision)

1.3 Horizontal dilution of precision (HDOP)

2.1 Vertical dilution of precision (VDOP)

*39 the checksum data, always begins with *

GSV - Satellites in View shows data about the satellites that the unit might be able to find

based on its viewing mask and almanac data. It also shows current ability to track this

data. Note that one GSV sentence only can provide data for up to 4 satellites and thus

there may need to be 3 sentences for the full information. It is reasonable for the GSV

sentence to contain more satellites than GGA might indicate since GSV may include

satellites that are not used as part of the solution. It is not a requirment that the GSV

sentences all appear in sequence. To avoid overloading the data bandwidth some

receivers may place the various sentences in totally different samples since each sentence

identifies which one it is.

Page 77: 137027485 Vehicle Tracking System

The field called SNR (Signal to Noise Ratio) in the NMEA standard is often referred to

as signal strength. SNR is an indirect but more useful value that raw signal strength. It

can range from 0 to 99 and has units of dB according to the NMEA standard, but the

various manufacturers send different ranges of numbers with different starting numbers

so the values themselves cannot necessarily be used to evaluate different units. The range

of working values in a given gps will usually show a difference of about 25 to 35

between the lowest and highest values, however 0 is a special case and may be shown on

satellites that are in view but not being tracked.

$GPGSV,2,1,08,01,40,083,46,02,17,308,41,12,07,344,39,14,22,228,45*75

Where:

GSV Satellites in view

2 Number of sentences for full data

1 sentence 1 of 2

08 Number of satellites in view

01 Satellite PRN number

40 Elevation, degrees

083 Azimuth, degrees

46 SNR - higher is better

for up to 4 satellites per sentence

*75 the checksum data, always begins with *

RMC - NMEA has its own version of essential gps pvt (position, velocity, time) data. It is

called RMC, The Recommended Minimum, which will look similar to:

$GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A

Page 78: 137027485 Vehicle Tracking System

Where:

RMC Recommended Minimum sentence C

123519 Fix taken at 12:35:19 UTC

A Status A=active or V=Void.

4807.038,N Latitude 48 deg 07.038' N

01131.000,E Longitude 11 deg 31.000' E

022.4 Speed over the ground in knots

084.4 Track angle in degrees True

230394 Date - 23rd of March 1994

003.1,W Magnetic Variation

*6A The checksum data, always begins with *

Note that, as of the 2.3 release of NMEA, there is a new field in the RMC sentence at the

end just prior to the checksum. For more information on this field see here.

GLL - Geographic Latitude and Longitude is a holdover from Loran data and some old

units may not send the time and data active information if they are emulating Loran data.

If a gps is emulating Loran data they may use the LC Loran prefix instead of GP.

$GPGLL,4916.45,N,12311.12,W,225444,A,*1D

Where:

GLL Geographic position, Latitude and Longitude

4916.46,N Latitude 49 deg. 16.45 min. North

12311.12,W Longitude 123 deg. 11.12 min. West

225444 Fix taken at 22:54:44 UTC

A Data Active or V (void)

*iD checksum data

Note that, as of the 2.3 release of NMEA, there is a new field in the GLL sentence at the

end just prior to the checksum. For more information on this field see here.

Page 79: 137027485 Vehicle Tracking System

VTG - Velocity made good. The gps receiver may use the LC prefix instead of GP if it is

emulating Loran output.

$GPVTG,054.7,T,034.4,M,005.5,N,010.2,K*48

where:

VTG Track made good and ground speed

054.7,T True track made good (degrees)

034.4,M Magnetic track made good

005.5,N Ground speed, knots

010.2,K Ground speed, Kilometers per hour

*48 Checksum

Note that, as of the 2.3 release of NMEA, there is a new field in the VTG sentence at the

end just prior to the checksum. For more information on this field see here.

Receivers that don't have a magnetic deviation (variation) table built in will null out the

Magnetic track made good.

Decode of some Navigation Sentences

WPL - Waypoint Location data provides essential waypoint data. It is output when

navigating to indicate data about the destination and is sometimes supported on input to

redefine a waypoint location. Note that waypoint data as defined in the standard does not

define altitude, comments, or icon data. When a route is active, this sentence is sent once

for each waypoint in the route, in sequence. When all waypoints have been reported, the

RTE sentence is sent in the next data set. In any group of sentences, only one WPL

sentence, or an RTE sentence, will be sent.

$GPWPL,4807.038,N,01131.000,E,WPTNME*5C

Page 80: 137027485 Vehicle Tracking System

With an interpretation of:

WPL Waypoint Location

4807.038,N Latitude

01131.000,E Longitude

WPTNME Waypoint Name

*5C The checksum data, always begins with *

AAM - Waypoint Arrival Alarm is generated by some units to indicate the Status of

arrival (entering the arrival circle, or passing the perpendicular of the course line) at the

destination waypoint.

$GPAAM,A,A,0.10,N,WPTNME*32

Where:

AAM Arrival Alarm

A Arrival circle entered

A Perpendicular passed

0.10 Circle radius

N Nautical miles

WPTNME Waypoint name

*32 Checksum data

APB - Autopilot format B is sent by some gps receivers to allow them to be used to

control an autopilot unit. This sentence is commonly used by autopilots and contains

navigation receiver warning flag status, cross-track-error, waypoint arrival status, initial

bearing from origin waypoint to the destination, continuous bearing from present position

to destination and recommended heading-to-steer to destination waypoint for the active

navigation leg of the journey.

Note: some autopilots, Robertson in particular, misinterpret "bearing from origin to

Page 81: 137027485 Vehicle Tracking System

destination" as "bearing from present position to destination". This is likely due to the

difference between the APB sentence and the APA sentence. for the APA sentence this

would be the correct thing to do for the data in the same field. APA only differs from

APB in this one field and APA leaves off the last two fields where this distinction is

clearly spelled out. This will result in poor performance if the boat is sufficiently off-

course that the two bearings are different.

$GPAPB,A,A,0.10,R,N,V,V,011,M,DEST,011,M,011,M*3C

where:

APB Autopilot format B

A Loran-C blink/SNR warning, general warning

A Loran-C cycle warning

0.10 cross-track error distance

R steer Right to correct (or L for Left)

N cross-track error units - nautical miles (K for kilometers)

V arrival alarm - circle

V arrival alarm - perpendicular

011,M magnetic bearing, origin to destination

DEST destination waypoint ID

011,M magnetic bearing, present position to destination

011,M magnetic heading to steer (bearings could True as 033,T)

BOD - Bearing - Origin to Destination shows the bearing angle of the line, calculated at

the origin waypoint, extending to the destination waypoint from the origin waypoint for

the active navigation leg of the journey.

$GPBOD,045.,T,023.,M,DEST,START*01

where:

BOD Bearing - origin to destination waypoint

Page 82: 137027485 Vehicle Tracking System

045.,T bearing 045 True from "START" to "DEST"

023.,M bearing 023 Magnetic from "START" to "DEST"

DEST destination waypoint ID

START origin waypoint ID

*01 checksum

BWC - Bearing & Distance to Waypoint using a Great Circle route. Time (UTC) and

distance & bearing to, and location of, a specified waypoint from present position along

the great circle path.

$GPBWC,225444,4917.24,N,12309.57,W,051.9,T,031.6,M,001.3,N,004*29

where:

BWC Bearing and distance to waypoint - great circle

225444 UTC time of fix 22:54:44

4917.24,N Latitude of waypoint

12309.57,W Longitude of waypoint

051.9,T Bearing to waypoint, degrees true

031.6,M Bearing to waypoint, degrees magnetic

001.3,N Distance to waypoint, Nautical miles

004 Waypoint ID

*29 checksum

RMB - The recommended minimum navigation sentence is sent whenever a route or a

goto is active. On some systems it is sent all of the time with null data. The Arrival alarm

flag is similar to the arrival alarm inside the unit and can be decoded to drive an external

alarm. Note the use of leading zeros in this message to preserve the character spacing.

This is done, I believe, because some autopilots may depend on exact character spacing.

$GPRMB,A,0.66,L,003,004,4917.24,N,12309.57,W,001.3,052.5,000.5,V*20

Page 83: 137027485 Vehicle Tracking System

where:

RMB Recommended minimum navigation information

A Data status A = OK, V = Void (warning)

0.66,L Cross-track error (nautical miles, 9.99 max),

steer Left to correct (or R = right)

003 Origin waypoint ID

004 Destination waypoint ID

4917.24,N Destination waypoint latitude 49 deg. 17.24 min. N

12309.57,W Destination waypoint longitude 123 deg. 09.57 min. W

001.3 Range to destination, nautical miles (999.9 max)

052.5 True bearing to destination

000.5 Velocity towards destination, knots

V Arrival alarm A = arrived, V = not arrived

*20 checksum

RTE - RTE is sent to indicate the names of the waypoints used in an active route. There

are two types of RTE sentences. This route sentence can list all of the waypoints in the

entire route or it can list only those still ahead. Because an NMEA sentence is limited to

80 characters there may need to be multiple sentences to identify all of the waypoints.

The data about the waypoints themselves will be sent in subsequent WPL sentences

which will be sent in future cycles of the NMEA data.

$GPRTE,2,1,c,0,W3IWI,DRIVWY,32CEDR,32-29,32BKLD,32-I95,32-US1,BW-

32,BW-198*69

Where:

RTE Waypoints in active route

2 total number of sentences needed for full data

1 this is sentence 1 of 2

c Type c = complete list of waypoints in this route

w = first listed waypoint is start of current leg

Page 84: 137027485 Vehicle Tracking System

0 Route identifier

W3IWI,... Waypoint identifiers (names)

*69 checksum

XTE - Measured cross track error is a small subset of the RMB message for compatibility

with some older equipment designed to work with Loran. Note that the same limitations

apply to this message as the ones in the RMB since it is expected to be decoded by an

autopilot.

$GPXTE,A,A,0.67,L,N*6F

Where:

XTE Cross track error, measured

A General warning flag V = warning

(Loran-C Blink or SNR warning)

A Not used for GPS (Loran-C cycle lock flag)

0.67 cross track error distance

L Steer left to correct error (or R for right)

N Distance units - Nautical miles

*6F checksum

Other sentences that may be useful

ALM - GPS Almanac Data contains GPS week number, satellite health and the complete

almanac data for one satellite. Multiple messages may be transmitted, one for each

satellite in the GPS constellation, up to maximum of 32 messages. Note that these

sentences can take a long time to send so they are not generally sent automatically by the

gps receiver. (Sorry I don't have an exact example of the sentence.) Note that this

sentence breaks the 80 character rule. Also note that this sentence is often accepted as

input so that you can preload a new almanac in a receiver.

Page 85: 137027485 Vehicle Tracking System

$GPALM,A.B,C.D,E,F,hh,hhhh,...

Where:

ALM Almanac Data being sent

A Total number of messages

B Message number

C Satellite PRN number

D GPS week number (0-1023)

E Satellite health (bits 17-24 of message)

F eccentricity

hh t index OA, almanac reference time

hhhh sigma index 1, inclination angle

... OMEGADOT rate of right ascension

SQRA(A) root of semi-major axis

Omega, argument of perigee

Omega index 0, longitude of ascension node

M index 0, mean anomaly

a index f0, clock parameter

a index f1, clock parameter

HCHDG - Compass output is used on Garmin etrex summit, vista , and 76S receivers to

output the value of the internal flux-gate compass. Only the magnetic heading and

magnetic variation is shown in the message.

$HCHDG,101.1,,,7.1,W*3C

where:

HCHDG Magnetic heading, deviation, variation

101.1 heading

,, deviation (no data)

7.1,W variation

Page 86: 137027485 Vehicle Tracking System

ZDA - Data and Time

$GPZDA,hhmmss.ss,dd,mm,yyyy,xx,yy*CC

$GPZDA,201530.00,04,07,2002,00,00*60

where:

hhmmss HrMinSec(UTC)

dd,mm,yyy Day,Month,Year

xx local zone hours -13..13

yy local zone minutes 0..59

*CC checksum

MSK - Control for a Beacon Receiver

$GPMSK,318.0,A,100,M,2*45

where:

318.0 Frequency to use

A Frequency mode, A=auto, M=manual

100 Beacon bit rate

M Bitrate, A=auto, M=manual

2 frequency for MSS message status (null for no status)

*45 checksum

MSS - Beacon Receiver Status

$GPMSS,55,27,318.0,100,*66

where:

55 signal strength in dB

Page 87: 137027485 Vehicle Tracking System

27 signal to noise ratio in dB

318.0 Beacon Frequency in KHz

100 Beacon bitrate in bps

*66 checksum

Proprietary Sentences

Proprietary sentences can either be output from the gps or used as input to control

information. They always start with P which is followed by a 3 character manufactures

code and additional characters to define the sentence type.

Garmin

The following are Garmin proprietary sentences. "P" denotes proprietary, "GRM" is

Garmin's manufacturer code, and "M" or "Z" indicates the specific sentence type. Note

that the PGRME sentence is not set if the output is set to NMEA 1.5 mode.

$PGRME,15.0,M,45.0,M,25.0,M*1C

where:

15.0,M Estimated horizontal position error in meters (HPE)

45.0,M Estimated vertical error (VPE) in meters

25.0,M Overall spherical equivalent position error

$PGRMZ,93,f,3*21

where:

93,f Altitude in feet

3 Position fix dimensions 2 = user altitude

3 = GPS altitude

This sentence shows in feet, regardless of units shown on the display.

Page 88: 137027485 Vehicle Tracking System

Note that for units with an altimeter this will be altitude computed

by the internal altimeter.

$PGRMM,NAD27 Canada*2F

Currently active horizontal datum

PSLIB

Proprietary sentences are used to control a Starlink differential beacon receiver.

(Garmin's DBR is Starlink compatible as are many others.) When the GPS receiver is set

to change the DBR frequency or b/s rate, the "J" sentence is replaced (just once) by (for

example): $PSLIB,320.0,200*59 to set the DBR to 320 KHz, 200 b/s.

$PSLIB,,,J*22 Status request

$PSLIB,,,K*23 configuration request

These two sentences are normally sent together in each group of sentences from the GPS.

The three fields are: Frequency, bit Rate, Request Type. The value in the third field may

be: J = status request, K = configuration request, or null (blank) = tuning message. The

correct values for frequency range from 283.5-325.0 KHz while the bit rate can be set to

0, 25, 50, 100 or 200 bps.

Magellan

Magellan uses proprietary sentences to do all of their waypoint and route maintenance.

They use the MGN prefix for their sentences. This use is documented in their interface

specification and will not be repeated here. However, they also send proprietary

sentences to augment the gps data just like Garmin does. Here is an example of a

sentence sent by the GPS Companion product:

$PMGNST,02.12,3,T,534,05.0,+03327,00*40

Page 89: 137027485 Vehicle Tracking System

where:

ST status information

02.12 Version number?

3 2D or 3D

T True if we have a fix False otherwise

534 numbers change - unknown

05.0 time left on the gps battery in hours

+03327 numbers change (freq. compensation?)

00 PRN number receiving current focus

*40 checksum

A tracklog on a Meridian is made up of propretary sentences that look like:

$PMGNTRK,4322.061,N,07948.473,W,00116,M,173949.42,A,,020602*67

$PMGNTRK,4322.058,N,07948.483,W,00090,M,174202.45,A,,020602*69.

where

TRK Tracklog

4322.071 Latitude

N North or South

07948.473 Longitude

W East or West

00116 Altitude

M Meters or Feet

173949.42 UTC time

A Active or Void

,, Track Name

020602 date

*67 checksum

Page 90: 137027485 Vehicle Tracking System

Motorola

The PMOTG is used by Motorola Oncore receivers to send a command to the receiver.

This command is used to set the output of the sentence to a particular frequency in

seconds (or to 0) or to switch the output formula to motorola binary, gps, or loran.

$PMOTG,xxx,yyyy

where:

xxx the sentence to be controlled

yyyy the time interval (0-9999 seconds)

or $PMOTG,FOR,y

where:

y MPB=0, GPS=1, Loran=2

Rockwell International

The Rockwell chipset is used on a number of gps receivers. It outputs some proprietary

sentences with the PRWI prefix and accepts input from some special sentences similar to

the approach used by Magellan. It can also be switched to a separate binary mode using a

proprietary sentence. The input sentence most used to initialize the unit is $PRWIINIT

and one output sentence is $PRWIRID

$PRWIRID,12,01.83,12/15/97,0003,*42

where:

$PRWIRID

12 12 channel unit

01.83 software version

Page 91: 137027485 Vehicle Tracking System

12/15/97 software date

0003 software options (HEX value)

Bit 0 minimize ROM usage

Bit 1 minimize RAM usage

*42 checksum

An input sentence that will define which NMEA sentences are to be output from the

Rockwell unit is:

$PRWIILOG,GGA,A,T,1,0

where:

$PRWIILOG

GGA type of sentence

A A=activate, V=deactivate

T cyclic

1 every 1 second

0 ??

The initialization sentence which can be input to speed up acquisition looks like:

$PRWIINIT,V,,,4308.750,N,07159.791,W,100.0,0.0,M,0.0,T,175244,230503*77

where:

$PRWIINIT INIT = initialization

V V = reset, A = no reset

,, Reserved for future use

4308.750 Latitude

N N = North, S = South

07159.791 Longitude

W W = West, E = East

Page 92: 137027485 Vehicle Tracking System

100.0 Altitude in meters

0.0 Speed

M M = m/s, N = knots, K = km/hr

0.0 Heading

T T = True, M = Magnetic

175244 UTC time (hour, min, sec)

230503 UTC date (day, month, year)

*77 Checksum

Note: Commas may be used to signify using existing data. If units are supplied then the

data must be present. Speed and direction must be supplied together. Lat/Lon must be

supplied together. UTC time and date must be supplied together. If heading is magnetic

then lat/lon needs to be supplied along with UTC time and date.

The sentences available for the Rockwell Jupiter chipset are: GGA, GSA, GSV, VTG,

RMC and some proprietary sentences.

SiRF

The SiRF line of chips support several input sentences that permit the user to customize

the way the chip behaves. In addition SiRF has a binary protocol that is even more

powerful permitting different implementations to behave entirely differently. However,

most applications do not attempt to customize the behavior so a user will need to make

sure that the any customization is compatible with the application they are planning to

use. There are 5 input sentences defined that begin with $PSRF which is followed by

three digits. Each sentence takes a fix amount of input fields which must exist, no null

fields, and is terminated with the standard CR/LF sequence. The checksum is required.

The sentences 100 and 102 set the serial ports. 100 sets the main port A while 102 sets

the DGPS input port B. 100 has an extra field that can be used to switch the interface to

binary mode. Binary mode requires 8 bits, 1 stop bit, no parity. There is a command in

binary mode that will switch the interface back to NMEA. Do not use the NMEA

Page 93: 137027485 Vehicle Tracking System

command to switch to binary mode unless you have the ability to switch it back. You

could render your gps inoperative.

$PSRF100,0,9600,8,1,0*0C

$PSRF102,9600,8,1,0*3C

where

$PSRF100

0 0=SiRF, 1=NMEA - This is where the protocol is changed.

9600 b/s rate 4800, 9600, 19200, 38400

8 7, 8 Databits

1 0, 1 Stopbits

0 0=none, 1=odd, 2=even Parity

*0C checksum

The sentences 101 and 104 can be used to initialize values to be used by the gps.

Supplying these values can shorten the initial lock time. If the clock offset is set to 0 then

an internal default will be used. Sentence 101 supplies data in the internal ECEF (Earth

centered, Earth Fixed) format in meters while sentence 104 supplies the data in the

traditional Lat / Lon format.

$PSRF101,-2686700,-4304200,3851624,95000,497260,921,12,3*22

$PSRF104,37.3875111,-121.97232,0,95000,237759,922,12,3*3A

where

$PSRF104

37.3875111 Latitude in degrees

-121.97232 Longitude in degrees

0 Ellipsoid Altitude in meters

95000 Clock offset

237759 GPS Time of Week in seconds

Page 94: 137027485 Vehicle Tracking System

922 GPS Week Number

12 Channel count (1 to 12)

3 Reset config where

1 = warm start, ephemeris valid

2 = clear ephemeris, warm start (First Fix)

3 = initialize with data, clear ephemeris

4 = cold start, clear all data

8 = cold start, set factory defaults

*3A checksum

The sentence 103 is used to control which NMEA sentences are to be sent and how often.

Each sentence type is controlled individually. If the query bit is set then the gps responds

by sending this message in the next second no matter what the rate is set to. Note that if

trickle power is in use (can only be set in binary mode) then the actual update rate will be

the selected update rate times the trickle rate which could mean that the data will be sent

less frequently than was set here.

$PSRF103,05,00,01,01*20

where

$PSRF103

05 00=GGA

01=GLL

02=GSA

03=GSV

04=RMC

05=VTG

00 mode, 0=set rate, 1=query

01 rate in seconds, 0-255

01 checksum 0=no, 1=yes

*20 checksum

Page 95: 137027485 Vehicle Tracking System

The 105 sentence controls a debug mode which causes the gps to report any errors it finds

with the input data. $PSRF105,1*3E would turn debug on while $PSRF105,0*3F would

turn it off.

Magnavox

The old Magnavox system used mostly proprietary sentences. The Magnavox system was

acquired by Leica Geosystems in 1994. Information on this system can be found at this

site. The NMEA sentences themselves are described here. They all use the MVX prefix

and include:

Control Port Input sentences

* $PMVXG,000 Initialization/Mode Control - Part A

* $PMVXG,001 Initialization/Mode Control - Part B

* $PMVXG,007 Control Port Configuration

* $PMVXG,023 Time Recovery Configuration

* $CDGPQ,YYY Query From a Remote Device / Request to Output a Sentence

Control Port Output Sentences

* $PMVXG,000 Receiver Status

* $PMVXG,021 Position, Height, Velocity

* $PMVXG,022 DOPs

* $PMVXG,030 Software Configuration

* $PMVXG,101 Control Sentence Accept/Reject

* $PMVXG,523 Time Recovery Configuration

* $PMVXG,830 Time Recovery Results

Sony

Page 96: 137027485 Vehicle Tracking System

The Sony interface uses a proprietary sentence that looks like:

$PSNY,0,00,05,500,06,06,06,06*14

where

PSNY

0 Preamp (external antenna) status

0 = Normal

1 = Open

2 = shorted

00 Geodesic system (datum) 0-25, 0 = WGS84

05 Elevation mask in degrees

500 Speed Limit in Km

06 PDOP limit with DGPS on

06 HDOP limit with DGPS on

06 PDOP limit with DGPS off

06 HDOP limit with DGPS off

*14 Checksum

Sample Streams

These streams will be modified when a route is active with the inclusion of route specific

data.

Garmin

Garmin g12 sentences for version 4.57

$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F

$GPRMB,A,,,,,,,,,,,,V*71

$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75

$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D

Page 97: 137027485 Vehicle Tracking System

$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71

$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77

$PGRME,22.0,M,52.9,M,51.0,M*14

$GPGLL,3907.360,N,12102.481,W,183730,A*33

$PGRMZ,2062,f,3*2D

$PGRMM,WGS 84*06

$GPBOD,,T,,M,,*47

$GPRTE,1,1,c,0*07

$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67

$GPRMB,A,,,,,,,,,,,,V*71

While originally a military project, GPS is considered a dual-use technology, meaning it

has significant military and civilian applications.

GPS has become a widely deployed and useful tool for commerce, scientific uses,

tracking, and surveillance. GPS's accurate time facilitates everyday activities such as

banking, mobile phone operations, and even the control of power grids by allowing well

synchronized hand-off switching

LCD (Liquid Cristal Display):

A liquid crystal display (LCD) is a thin, flat display device made up of any number of

color or monochrome pixels arrayed in front of a light source or reflector. Each pixel

consists of a column of liquid crystal molecules suspended between two transparent

electrodes, and two polarizing filters, the axes of polarity of which are perpendicular to

each other. Without the liquid crystals between them, light passing through one would be

blocked by the other. The liquid crystal twists the polarization of light entering one filter

to allow it to pass through the other.

Page 98: 137027485 Vehicle Tracking System

A program must interact with the outside world using input and output devices that

communicate directly with a human being. One of the most common devices attached to

an controller is an LCD display. Some of the most common LCDs connected to the

contollers are 16X1, 16x2 and 20x2 displays. This means 16 characters per line by 1 line

16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively.

Page 99: 137027485 Vehicle Tracking System

Many microcontroller devices use 'smart LCD' displays to output visual information.

LCD displays designed around LCD NT-C1611 module, are inexpensive, easy to use,

and it is even possible to produce a readout using the 5X7 dots plus cursor of the display.

They have a standard ASCII set of characters and mathematical symbols. For an 8-bit

data bus, the display requires a +5V supply plus 10 I/O lines (RS RW D7 D6 D5 D4 D3

D2 D1 D0). For a 4-bit data bus it only requires the supply lines plus 6 extra lines(RS

RW D7 D6 D5 D4). When the LCD display is not enabled, data lines are tri-state and

they do not interfere with the operation of the microcontroller.

available. Line lengths of

8, 16,

20, 24,

32 and

40

charact

ers are

all

standar

d, in

one,

two

Page 100: 137027485 Vehicle Tracking System

Features:

(1) Interface with either 4-bit or 8-bit microprocessor.

(2) Display data RAM

(3) 80x8 bits (80 characters).

(4) Character generator ROM

(5). 160 different 5 7 dot-matrix character patterns.

(6). Character generator RAM

(7) 8 different user programmed 5 7 dot-matrix patterns.

(8).Display data RAM and character generator RAM may be

Accessed by the microprocessor.

(9) Numerous instructions

(10) .Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF,

Blink Character, Cursor Shift, Display Shift.

(11). Built-in reset circuit is triggered at power ON.

(12). Built-in oscillator.

Description Of 16x2:

This is the first interfacing example for the Parallel Port. We will start with something

simple. This example doesn't use the Bi-directional feature found on newer ports, thus it

should work with most, if no all Parallel Ports. It however doesn't show the use of the

Status Port as an input. So what are we interfacing? A 16 Character x 2 Line LCD

Module to the Parallel Port. These LCD Modules are very common these days, and are

quite simple to work with, as all the logic required to run them is on board.

Schematic Diagram:

Page 101: 137027485 Vehicle Tracking System

o Above is the quite simple schematic. The LCD

panel's Enable and Register Select is connected to the Control Port. The

Control Port is an open collector / open drain output. While most Parallel

Ports have internal pull-up resistors, there are a few which don't. Therefore

by incorporating the two 10K external pull up resistors, the circuit is more

portable for a wider range of computers, some of which may have no

internal pull up resistors.

o We make no effort to place the Data bus into reverse direction. Therefore

we hard wire the R/W line of the LCD panel, into write mode. This will

cause no bus conflicts on the data lines. As a result we cannot read back

the LCD's internal Busy Flag which tells us if the LCD has accepted and

finished processing the last instruction. This problem is overcome by

inserting known delays into our program.

o The 10k Potentiometer controls the contrast of the LCD panel. Nothing

fancy here. As with all the examples, I've left the power supply out. You

can use a bench power supply set to 5v or use a onboard +5 regulator.

Remember a few de-coupling capacitors, especially if you have trouble

with the circuit working properly.

• The 2 line x 16 character LCD modules are available from a wide range of

Page 102: 137027485 Vehicle Tracking System

manufacturers and should all be compatible with the HD44780. The one I

used to test this circuit was a Power tip PC-1602F and an old Philips

LTN211F-10 which was extracted from a Poker Machine! The diagram to

the right, shows the pin numbers for these devices. When viewed from the

front, the left pin is pin 14 and the right pin is pin 1

.

16 x 2 Alphanumeric LCD Module Features:

• Intelligent, with built-in Hitachi HD44780 compatible LCD controller and RAM

providing simple interfacing

• 61 x 15.8 mm viewing area

• 5 x 7 dot matrix format for 2.96 x 5.56 mm characters, plus cursor line

• Can display 224 different symbols

• Low power consumption (1 mA typical)

• Powerful command set and user-produced characters

• TTL and CMOS compatible

• Connector for standard 0.1-pitch pin headers

16 x 2 Alphanumeric LCD Module Specifications:

PinSymbol Level Function

1 VSS - Power, GND

2 VDD - Power, 5V

3 Vo - Power, for LCD Drive

4 RS H/L

Register Select Signal

H: Data Input

L: Instruction Input

5 R/W H/LH: Data Read (LCD->MPU)

L: Data Write (MPU->LCD)

6 E H,H->L Enable

Page 103: 137027485 Vehicle Tracking System

7-14 DB0-DB7 H/L Data Bus; Software selectable 4- or 8-bit mode

15 NC - NOT CONNECTED

16 NC - NOT CONNECTED

FEATURES:

• 5 x 8 dots with cursor

• Built-in controller (KS 0066 or Equivalent)

• + 5V power supply (Also available for + 3V)

• 1/16 duty cycle

• B/L to be driven by pin 1, pin 2 or pin 15, pin 16 or A.K (LED)

• N.V. optional for + 3V power supply

Data can be placed at any location on the LCD. For 16×1 LCD, the address

locations are:

Fig :15: Address locations for a 1x16 line LCD

Even limited to character based modules, there is still a wide variety of shapes and sizes

available. Line lengths of 8,16,20,24,32 and 40 characters are all standard, in one, two

and four line versions.

Several different LC technologies exists. “supertwist” types, for example, offer

Improved contrast and viewing angle over the older “twisted nematic” types. Some

modules are available with back lighting, so that they can be viewed in dimly-lit

conditions. The back lighting may be either “electro-luminescent”, requiring a high

voltage inverter circuit, or simple LED illumination.

Page 104: 137027485 Vehicle Tracking System

Electrical Block Diagrm

Power supply for LCD driving:

Fig: 18:power supply for LCD

PIN DESCRIPTION:

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two

pins are extra in both for back-light LED connections).

Page 105: 137027485 Vehicle Tracking System

Fig 19: pin diagram of 1x16 lines LCD

Fig 17: Pin specifications

CONTROL LINES:

EN: Line is called "Enable." This control line is used to tell the LCD that you are

sending it data. To send data to the LCD, your program should make sure this line is low

(0) and then set the other two control lines and/or put data on the data bus. When the

other lines are completely ready, bring EN high (1) and wait for the minimum amount of

time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing

it low (0) again.

Page 106: 137027485 Vehicle Tracking System

RS:

Line is the "Register Select" line. When RS is low (0), the data is to be treated as

a command or special instruction (such as clear screen, position cursor, etc.). When RS is

high (1), the data being sent is text data which sould be displayed on the screen. For

example, to display the letter "T" on the screen you would set RS high.

RW:

Line is the "Read/Write" control line. When RW is low (0), the information on the

data bus is being written to the LCD. When RW is high (1), the program is effectively

querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read

command. All others are write commands, so RW will almost always be low.

Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation

selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0,

DB1, DB2, DB3, DB4, DB5, DB6, and DB7.

Logic status on control lines:

• E - 0 Access to LCD disabled

- 1 Access to LCD enabled

• R/W - 0 Writing data to LCD

- 1 Reading data from LCD

• RS - 0 Instructions

- 1 Character

Writing data to the LCD:

1) Set R/W bit to low

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low

Page 107: 137027485 Vehicle Tracking System

Read data from data lines (if it is reading) on LCD:

1) Set R/W bit to high

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low

Entering Text:

First, a little tip: it is manually a lot easier to enter characters and commands in

hexadecimal rather than binary (although, of course, you will need to translate commands

from binary couple of sub-miniature hexadecimal rotary switches is a simple matter,

although a little bit into hex so that you know which bits you are setting). Replacing the

d.i.l. switch pack with a of re-wiring is necessary.

SWITCHES:

The switches must be the type where On = 0, so that when they are turned to the zero

position, all four outputs are shorted to the common pin, and in position “F”, all four

outputs are open circuit.

All the available characters that are built into the module are shown in Table 3. Studying

the table, you will see that codes associated with the characters are quoted in binary and

hexadecimal, most significant bits (“left-hand” four bits) across the top, and least

significant bits (“right-hand” four bits) down the left.

Most of the characters conform to the ASCII standard, although the Japanese and Greek

characters (and a few other things) are obvious exceptions. Since these intelligent modules

were designed in the “Land of the Rising Sun,” it seems only fair that their Katakana

phonetic symbols should also be incorporated. The more extensive Kanji character set,

which the Japanese share with the Chinese, consisting of several thousand different

characters, is not included!

Using the switches, of whatever type, and referring to Table 3, enter a few characters onto

the display, both letters and numbers. The RS switch (S10) must be “up” (logic 1) when

Page 108: 137027485 Vehicle Tracking System

sending the characters, and switch E (S9) must be pressed for each of them. Thus the

operational order is: set RS high, enter character, trigger E, leave RS high, enter another

character, trigger E, and so on.

The first 16 codes in Table 3, 00000000 to 00001111, ($00 to $0F) refer to the CGRAM.

This is the Character Generator RAM (random access memory), which can be used to hold

user-defined graphics characters. This is where these modules really start to show their

potential,

offering such capabilities as bar graphs, flashing symbols, even animated characters.

Before the user-defined characters are set up, these codes will just bring up strange

looking symbols.

Codes 00010000 to 00011111 ($10 to $1F) are not used and just display blank characters.

ASCII codes “proper” start at 00100000 ($20) and end with 01111111 ($7F). Codes

10000000 to 10011111 ($80 to $9F) are not used, and 10100000 to 11011111 ($A0 to

$DF) are the Japanese characters.

Page 109: 137027485 Vehicle Tracking System

Fig 20: character details in LCD

Page 110: 137027485 Vehicle Tracking System

SOFTWARE EXPLANATION

a) ABOUT SOFTWARE

Software’s used are:

*Keil software for c programming

*Express PCB for lay out design

*Express SCH for schematic design

What's New in µVision3?

µVision3 adds many new features to the Editor like Text Templates, Quick

Function Navigation, and Syntax Coloring with brace high lighting

Configuration Wizard for dialog based startup and debugger setup. µVision3

is fully compatible to µVision2 and can be used in parallel with µVision2.

What is µVision3?

µVision3 is an IDE (Integrated Development Environment) that helps you

write, compile, and debug embedded programs. It encapsulates the following

components:

• A project manager.

• A make facility.

• Tool configuration.

• Editor.

• A powerful debugger.

To help you get started, several example programs (located in the

\C51\Examples, \C251\Examples, \C166\Examples, and

\ARM\...\Examples) are provided.

Page 111: 137027485 Vehicle Tracking System

• HELLO is a simple program that prints the string "Hello World"

using the Serial Interface.

• MEASURE is a data acquisition system for analog and digital

systems.

• TRAFFIC is a traffic light controller with the RTX Tiny operating

system.

• SIEVE is the SIEVE Benchmark.

• DHRY is the Dhrystone Benchmark.

• WHETS is the Single-Precision Whetstone Benchmark.

Additional example programs not listed here are provided for each device

architecture.

Building an Application in µVision2

To build (compile, assemble, and link) an application in µVision2, you must:

1. Select Project -

(forexample,166\EXAMPLES\HELLO\HELLO.UV2).

2. Select Project - Rebuild all target files or Build target.

µVision2 compiles, assembles, and links the files in your project.

Creating Your Own Application in µVision2

To create a new project in µVision2, you must:

1. Select Project - New Project.

2. Select a directory and enter the name of the project file.

3. Select Project - Select Device and select an 8051, 251, or C16x/ST10

device from the Device Database™.

4. Create source files to add to the project.

Page 112: 137027485 Vehicle Tracking System

5. Select Project - Targets, Groups, Files. Add/Files, select Source

Group1, and add the source files to the project.

6. Select Project - Options and set the tool options. Note when you select

the target device from the Device Database™ all special options are

set automatically. You typically only need to configure the memory

map of your target hardware. Default memory model settings are

optimal for most applications.

7. Select Project - Rebuild all target files or Build target.

Debugging an Application in µVision2

To debug an application created using µVision2, you must:

1. Select Debug - Start/Stop Debug Session.

2. Use the Step toolbar buttons to single-step through your program. You

may enter G, main in the Output Window to execute to the main C

function.

3. Open the Serial Window using the Serial #1 button on the toolbar.

Debug your program using standard options like Step, Go, Break, and so on.

Starting µVision2 and Creating a Project

µVision2 is a standard Windows application and started by clicking on the

program icon. To create a new project file select from the µVision2 menu

Project – New Project…. This opens a standard Windows dialog that asks

you

for the new project file name.

We suggest that you use a separate folder for each project. You can simply

use

the icon Create New Folder in this dialog to get a new empty folder. Then

select this folder and enter the file name for the new project, i.e. Project1.

Page 113: 137027485 Vehicle Tracking System

µVision2 creates a new project file with the name PROJECT1.UV2 which

contains

a default target and file group name. You can see these names in the Project

Window – Files.

Now use from the menu Project – Select Device for Target and select a CPU

for your project. The Select Device dialog box shows the µVision2 device

database. Just select the micro controller you use. We are using for our

examples the Philips 80C51RD+ CPU. This selection sets necessary tool

options for the 80C51RD+ device and simplifies in this way the tool

Configuration

Building Projects and Creating a HEX Files

Typical, the tool settings under Options – Target are all you need to start a

new

application. You may translate all source files and line the application with a

click on the Build Target toolbar icon. When you build an application with

syntax errors, µVision2 will display errors and warning messages in the

Output

Window – Build page. A double click on a message line opens the source

file

on the correct location in a µVision2 editor window.

Once you have successfully generated your application you can start

debugging.

After you have tested your application, it is required to create an Intel

HEX file to download the software into an EPROM programmer or

simulator. µVision2 creates HEX files with each build process when Create

HEX files under Options for Target – Output is enabled. You may start your

Page 114: 137027485 Vehicle Tracking System

PROM programming utility after the make process when you specify the

program under the option Run User Program #1.

CPU Simulation

µVision2 simulates up to 16 Mbytes of memory from which areas can be

mapped for read, write, or code execution access. The µVision2 simulator

traps

and reports illegal memory accesses.

In addition to memory mapping, the simulator also provides support for the

integrated peripherals of the various 8051 derivatives. The on-chip

peripherals

of the CPU you have selected are configured from the Device

Database selection

you have made when you create your project target. Refer to page 58 for

more

Information about selecting a device. You may select and display the on-

chip peripheral components using the Debug menu. You can also change the

aspects of each peripheral using the controls in the dialog boxes.

Start Debugging

You start the debug mode of µVision2 with the Debug – Start/Stop Debug

Session command. Depending on the Options for Target – Debug

Configuration, µVision2 will load the application program and run the

startup

code µVision2 saves the editor screen layout and restores the screen layout

of the last debug session. If the program execution stops, µVision2 opens an

editor window with the source text or shows CPU instructions in the

disassembly window. The next executable statement is marked with a

yellow arrow. During debugging, most editor features are still available.

Page 115: 137027485 Vehicle Tracking System

For example, you can use the find command or correct program errors.

Program source text of your application is shown in the same windows. The

µVision2 debug mode differs from the edit mode in the following aspects:

_ The “Debug Menu and Debug Commands” described on page 28 are

Available. The additional debug windows are discussed in the following.

_ The project structure or tool parameters cannot be modified. All build

Commands are disabled.

Disassembly Window

The Disassembly window shows your target program as mixed source and

assembly program or just assembly code. A trace history of previously

executed instructions may be displayed with Debug – View Trace Records.

To enable the trace history, set Debug – Enable/Disable Trace Recording.

If you select the Disassembly Window as the active window all program

step commands work on CPU instruction level rather than program source

lines. You can select a text line and set or modify code breakpoints using

toolbar buttons or the context menu commands.

You may use the dialog Debug – Inline Assembly… to modify the

CPU instructions. That allows you to correct mistakes or to make temporary

changes to the target program you are debugging.

B)Keil Software

Installing the Keil software on a Windows PC

• Insert the CD-ROM in your computer’s 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

Page 116: 137027485 Vehicle Tracking System

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

go to Project – Open Project and browse for Hello in Ch03_00 in Pont and

open it.

Initialization by Instructions:

Page 117: 137027485 Vehicle Tracking System

Fig 21: flow chart of lcd

If the power conditions for the normal operation of the internal reset circuit are not

satisfied, then executing a series of instructions must initialize LCD unit. The procedure

for this initialization process is as above show.

Page 118: 137027485 Vehicle Tracking System

FLOWCHART:

Copy Data in to Accumulator

Is LCD Free

Wait

No

Yes

Set RS Bit

Enable LCD

Send Data

Disable LCD

Is Data Count Zero No

1

STOP

Copy Data in to Accumulator

Is LCD Free

Wait

No

Yes

Set RS Bit

Enable LCD

Send Data

Disable LCD

Is Data Count Zero No

1

STOP

KEIL SOFTWARE TOOL (STEPS)

1. Click on the Keil uVision Icon on DeskTop

2. The following fig will appear

Page 119: 137027485 Vehicle Tracking System

3. Click on the Project menu from the title bar

4. Then Click on New Project

Page 120: 137027485 Vehicle Tracking System

5. Save the Project by typing suitable project name with no extension

in u r own folder sited in either C:\ or D:\

6. Then Click on Save button above.

7. Select the component for u r project. i.e. Atmel……

8. Click on the + Symbol beside of Atmel

Page 121: 137027485 Vehicle Tracking System

9. Select AT89C52 as shown below

10. Then Click on “OK”

Page 122: 137027485 Vehicle Tracking System

11. The Following fig will appear

12. Then Click either YES or NO………mostly “NO”

13. Now your project is ready to USE

14. Now double click on the Target1, you would get another option

“Source group 1” as shown in next page.

Page 123: 137027485 Vehicle Tracking System

15. Click on the file option from menu bar and select “new”

Page 124: 137027485 Vehicle Tracking System

16. The next screen will be as shown in next page, and just maximize

it by double clicking on its blue boarder.

17. Now start writing program in either in “C” or “ASM”

18. For a program written in Assembly, then save it with extension “.

asm” and for “C” based program save it with extension “ .C”

Page 125: 137027485 Vehicle Tracking System

19. Now right click on Source group 1 and click on “Add files to

Group Source”

20. Now you will get another window, on which by default “C” files

will appear.

Page 126: 137027485 Vehicle Tracking System

21. Now select as per your file extension given while saving the file

22. Click only one time on option “ADD”

23. Now Press function key F7 to compile. Any error will appear if so

happen.

Page 127: 137027485 Vehicle Tracking System

24. If the file contains no error, then press Control+F5 simultaneously.

25. The new window is as follows

26. Then Click “OK”

27. Now Click on the Peripherals from menu bar, and check your

required port as shown in fig below

Page 128: 137027485 Vehicle Tracking System

28. Drag the port a side and click in the program file.

29. Now keep Pressing function key “F11” slowly and observe.

30. You are running your program successfully

BIBLOGRAPHY:

The 8051 Micro controller and Embedded Systems

o Muhammad

AliMazidi

o JaniceGillis

pieMazidi

Page 129: 137027485 Vehicle Tracking System

The8051MicrocontrollerArchitecture,Programming&

Applications

o KennethJ.A

yala

Fundamentals of Micro processors and Micro computers

o B. Ram

Electronic Components

D.V.Prasad

References on the Web:

www.national.com

www.atmel.com

www.microsoftsearch.com

www.geocities.com