You are on page 1of 61

3.

5 MICROCONTROLLER

PIC is a family of modified Harvard architecture microcontrollers


made by Microchip Technology, derived from the PIC1650 originally
developed by General Instrument's Microelectronics Division. The name
PIC initially referred to Peripheral Interface Controller. The first parts of
the family were available in 1976; by 2013 the company had shipped
more than twelve billion individual parts, used in a wide variety of
embedded systems. Early models of PIC had read-only memory (ROM)
or field-programmable EPROM for program storage, some with provision
for erasing memory. All current models use Flash memory for program
storage, and newer models allow the PIC to reprogram itself. Program
memory and data memory are separated. Data memory is 8-bit, 16-bit and
in latest models, 32-bit wide. Program instructions vary in bit-count by
family of PIC, and may be 12, 14, 16, or 24 bits long.

17

1
Fig 3.11 PIC16F877A

The hardware capabilities of PIC devices range from 8-pin DIP


chips up to 100-pin SMD chips, with discrete I/O pins, ADC and DAC
modules, and communications ports such as UART, I2C, CAN, and even
USB. Low-power and high-speed variations exist for many types.The
manufacturer supplies computer software for development known as
MPLAB, assemblers and C/C++ compilers, and programmer/debugger
hardware under the MPLAB and PICKit series. Third party and some
open-source tools are also available. Some parts have in-circuit
programming capability; low-cost development programmers are
available as well has high-production programmers.

The PIC microcontroller is used to interface the energy


measurement unit and GSM module. The PIC microcontroller used here
is PIC16F877A.PIC devices are popular with both industrial developers
and hobbyists due to their low cost, wide availability, large user base,
extensive collection of application notes, availability of low cost or free
development tools, serial programming, and re-programmable Flash-
memory capability.

218
3.5.1 Pin Diagram of PIC16F877A

Fig 3.12 Pin Diagram of PIC16F877A

319
3.5.2 Block Diagram of PIC

Fig 3.13 Block Diagram of PIC16F877A

3.5.3 High Performance RISC CPU

 Only 35 single word instructions to learn.


 All single cycle instructions except for program branches,
which are two-cycle.

420
 Operating speed: DC - 20 MHz clock input DC - 200 ns
instruction cycle.
 2K x 14 words of Program Memory, 128 x 8 bytes of Data
Memory (RAM).
 Pin out compatible to PIC16C72/72A and PIC16F872.
 Interrupt capability.
 Eight-level deep hardware stack.
 Direct, Indirect and Relative Addressing modes.

3.5.4 Peripheral Features

 High Sink/Source Current: 25 mA.


 Timer0: 8-bit timer/counter with 8-bit prescaler.
 Timer1: 16-bit timer/counter with prescaler, can be incremented
during SLEEP via external crystal/clock.
 Timer2: 8-bit timer/counter with 8-bit period register, prescaler
and postscaler.
 Capture, Compare, PWM (CCP) module.
 Capture is 16-bit, max. resolution is 12.5 ns.
 Compare is 16-bit, max. resolution is 200 ns.
 PWM max. resolution is 10-bit.
 8-bit, 5-channel analog-to-digital converter.
 Synchronous Serial Port (SSP) with SPI™ (Master/Slave) and
I2C™ (Slave).
 Brown-out detection circuitry for Brown-out Reset (BOR).

3.5.5 Memory Organization

There are two memory blocks in the PIC16F72 device. These are
the program memory and the data memory. Each block has separate

521
buses so that concurrent access can occur. Program memory and data
memory are explained in this section. Program memory can be read
internally by the user code. The data memory can further be broken down
into the general purpose RAM and the Special Function Registers
(SFRs). The operations of the SFRs that control the “core” are described
here. The SFRs used to control the peripheral modules are described in
the section discussing each individual peripheral module.

3.5.6 Program Memory Organization

The PIC16F87XA devices have a 13-bit program counter capable


of addressing an 8K word x 14 bit program memory space. The
PIC16F876A/877A devices have 8K words x 14 bits of Flash program
memory, while PIC16F873A/874A devices have 4K words x 14 bits.
Accessing a location above the physically implemented address will
cause a wraparound. The Reset vector is at 0000h and the interrupt vector
is at 0004h.

3.5.7 Data Memory Organization

The data memory is partitioned into multiple banks which contain


the General Purpose Registers and the Special Function Registers. Bits
RP1 (Status<6>) and RP0 (Status<5>) are the bank select bits. Each bank
extends up to 7Fh (128 bytes). The lower locations of each bank are
reserved for the Special Function Registers. Above the Special Function
Registers are General Purpose Registers, implemented as static
RAM.Some frequently used Special Function Registers from one bank
may be mirrored in another bank for code reduction and quicker access.

622
3.5.8 Data EEPROM and Flash Program Memory

The data EEPROM and Flash program memory is readable and


writable during normal operation (over the full VDD range). This
memory is not directly mapped in the register file space. Instead, it is
indirectly addressed through the Special Function Registers. There are six
SFRs used to read and write this memory:

 EECON1
 EECON2
 EEDATA
 EEDATH
 EEADR
 EEADRH

When interfacing to the data memory block, EEDATA holds the 8-


bit data for read/write and EEADR holds the address of the EEPROM
location being accessed. These devices have 128 or 256 bytes of data
EEPROM (depending on the device), with an address range from 00h to
FFh. On devices with 128 bytes, addresses from 80h to FFh are
unimplemented and will wraparound to the beginning of data EEPROM
memory. When writing to unimplemented locations, the on-chip charge
pump will be turned off. When interfacing the program memory block,
the EEDATA and EEDATH registers form a two-byte word that holds
the 14-bit data for read/write and the EEADR and EEADRH registers
form a two-byte word that holds the 13-bit address of the program
memory location being accessed.

These devices have 4 or 8K words of program Flash, with an


address range from 0000h to 0FFFh for the PIC16F873A/874A and

723
0000h to 1FFFh for the PIC16F876A/877A. Addresses above the range
of the respective device will wraparound to the beginning of program
memory. The EEPROM data memory allows single-byte read and writes.
The Flash program memory allows single-word reads and four-word
block writes. Program memory write operations automatically perform an
erase-before write on blocks of four words. A byte write in data
EEPROM memory automatically erases the location and writes the new
data (erase-before-write). The write time is controlled by an on-chip
timer. The write/erase voltages are generated by an on-chip charge pump,
rated to operate over the voltage range of the device for byte or word
operations. When the device is code-protected, the CPU may continue to
read and write the data EEPROM memory. Depending on the settings of
the write-protect bits, the device may or may not be able to write certain
blocks of the program memory; however, reads of the program memory
are allowed. When code-protected, the device programmer can no longer
access data or program memory; this does NOT inhibit internal reads or
writes.

3.5.9 Advantages of Microcontroller

 Small instruction set to learn.


 RISC architecture.
 Built-in oscillator with selectable speeds.
 Easy entry level, in-circuit programming plus in-circuit
debugging PICkit units available for less than $50.
 Inexpensive microcontrollers.
 Wide range of interfaces including I²C, SPI, USB, USART,
A/D, programmable comparators, PWM, LIN, CAN, PSP, and
Ethernet.
824
 Availability of processors in DIL package make them easy to
handle for hobby use.

3.5.10 Limitations of Microcontroller

 One accumulator.
 Register-bank switching is required to access the entire RAM of
many devices.
 Operations and registers are not orthogonal; some instructions
can address RAM and/or immediate constants, while others can
use the accumulator only.

3.5.11 Features of Microcontroller

 Operating speed: 20 MHz.


 Operating voltage: 4.0-5.5V.
 Industrial temperature range (-40° to +85°C).
 Flash Memory: 14.3 Kbytes.
 Data SRAM: 368 bytes.
 Data EEPROM: 256 bytes.
 Self-reprogrammable.
 Programmable code protection.
 Power-saving Sleep mode.

3.6 LCD

A liquid-crystal display (LCD) is a flat panel display, electronic


visual display, or video display that uses the light modulating properties
of liquid crystals. Liquid crystals do not emit light directly.LCDs are
available to display arbitrary images (as in a general-purpose computer

925
display) or fixed images which can be displayed or hidden, such as preset
words, digits, and 7-segment displays as in a digital clock.

LCDs are used in a wide range of applications including computer


monitors, televisions, instrument panels, aircraft cockpit displays, and
signage. They are common in consumer devices such as video players,
gaming devices, clocks, watches, calculators, and telephones, and have
replaced cathode ray tube (CRT) displays in most applications. They are
available in a wider range of screen sizes than CRT and plasma displays,
and since they do not use phosphors, they do not suffer image burn-in.
LCDs are, however, susceptible to image persistence.

The LCD screen is more energy efficient and can be disposed of


more safely than a CRT. Its low electrical power consumption enables it
to be used in battery-powered electronic equipment. It is an electronically
modulated optical device made up of any number of segments filled
with liquid crystals and arrayed in front of a light source (backlight)
or reflector to produce images in colour or monochrome. Liquid crystals
were first discovered in 1888. By 2008, annual sales of televisions with
LCD screens exceeded sales of CRT units worldwide, and the CRT
became obsolescent for most purposes.

The LCD display used here is especially meant for deaf people
since they cannot be able to hear the voice signals from loudspeaker. The
hand movements done by the action doer is converted into text and it is
displayed in the LCD monitor. In order to get more efficiency 16x2
character LCD-016M002B is used. LCDs do not emit light directly.
Liquid crystal displays (LCDs) are a passive display technology. This
means they do not emit light; instead, they use the ambient light in the
environment. By manipulating this light, they display images using very

26
10
little power. This has made LCDs the preferred technology whenever low
power consumption and compact size are critical. LCDs have displaced
cathode ray tube (CRT) displays in most applications.

Fig 3.14 LCD Display

LCD (Liquid Crystal Display) screen is an electronic display


module and find a wide range of applications. A 16x2 LCD display is
very basic module and is very commonly used in various devices
and circuits. These modules are preferred over seven segments and other
multi segment LEDs. The reasons being: LCDs are economical; easily
programmable; have no limitation of displaying special &
even custom characters (unlike in seven segments), animations and so on.
A 16x2 LCD means it can display 16 characters per line and there
are 2 such lines. In this LCD each character is displayed in 5x7 pixel
matrix. This LCD has two registers, namely, Command and Data. The
command register stores the command instructions given to the LCD. A
command is an instruction given to LCD to do a predefined task like
initializing it, clearing its screen, setting the cursor position, controlling
display etc. The data register stores the data to be displayed on the LCD.
The data is the ASCII value of the character to be displayed on the LCD.

27
11
3.6.1 Pin Diagram

Fig 3.15 Pin Diagram of LCD

3.6.2 Pin Information of LCD

Pin No Symbol Details


1 GND Ground
2 Vcc supply voltage+5v
3 Vo Contrast Adjust
4 RS 0>Control input 1>Data Input
5 R/W Read/Write
6 E Enable
7 to 14 D0 to D7 Data
15 VB1 BackLight +5V
16 VB2 BackLight Ground

Table 3.1 Pin Information of LCD

12
28
3.6.3 Pin Description

Pin
Function Name
No
1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V – 5.3V) Vcc
3 Contrast adjustment; through a variable VEE
resistor
4 Selects command register when low; and data Register
register when high Select
5 Low to write to the register; High to read from Read/write
the register
6 Sends data to data pins when a high to low Enable
pulse is given
7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-

Table 3.2 Pin description of LCD

29
3.6.4 LCD Initialization

Working of LCD depend on the how the LCD is initialized. We


have to send few command bytes to initialize the LCD. Simple steps to
initialize the LCD.

1. Specify function set:


Send 38H for 8-bit, double line and 5x7 dot character format.
2. Display On-Off control:
Send 0FH for display and blink cursor on.
3. Entry mode set:
Send 06H for cursor in increment position and shift is invisible.
4. Clear display:
Send 01H to clear display and return cursor to home position.

3.7 POWER SUPPLY

The power supply is very important section of all electronic


devices as all the electronic devices works only in DC. One important
aspect of the project is that the power supply should be compact. Most
electronic devices need a source of DC power.

Fig 3.16 Circuit Diagram of Power Supply

30
Power supply unit consists of following units:

1. Step down transformer


2. Rectifier unit
3. Input filter
4. Regulator unit
5. Output filter

The circuit is powered by a 12V dc adapter, which is given to


LM7805 voltage regulator by means of a forward voltage protection
diode and is decoupled by means of a 0.1 uf capacitor. The voltage
regulator gives an output of exactly 5V dc supply. The 5V dc supply is
given to all the components including the Microcontroller, the serial port,
and the IR transmitters and sensors.

The AC supply which when fed to the step down transformer is


leveled down to 12 volts AC. This is then fed to full wave rectifier which
converts it in to 12 volts DC. This is then passed to a filter to remove the
ripples. Then it is fed to a voltage regulator that converts 12 V to 5 V
stable voltages and currents.

3.7.1 Step-Down Transformer

The step down transformer is used to step down the main supply
voltage from 230AC to lower value. This 230AC voltage cannot be used
directly, thus its stepped down. The transformer consists of primary and
secondary coils. To reduce or step down the voltage, the transformer is
designed to contain less number of turns in its secondary core. Thus the
conversion from AC to DC is essential. This conversion is achieved by
using the rectifier circuit.

31
3.7.2 Rectifier Unit

The Rectifier circuit is used to convert AC voltage into its


corresponding DC voltage. There are Half-Wave and Full-Wave rectifiers
available for this specific function. The most important and simple device
used in rectifier circuit is the diode. The simple function of the diode is to
conduct when forward biased and not to conduct when reverse biased.
The forward bias is achieved by connecting the diode’s positive with of
positive of battery and negative with battery’s negative. The efficient
circuit used is full wave bridge rectifier circuit. The output voltage of the
rectifier is in rippled form, the ripples from the obtained DC voltage are
removed using other circuits available. The circuit used for removing the
ripples is called Filter circuit.

3.7.3 Input Filter

Capacitors are used as filters. The ripples from the DC voltage are
removed and pure DC voltage is obtained. The primary action performed
by capacitor is charging and discharging. It charges in positive half cycle
of the AC voltage and it will discharge in its negative half cycle, so it
allows only ACC voltage and does not allow the DC voltage. This filter
is fixed before the regulator. Thus the output is free from ripples.

3.7.4 Regulator Unit

Regulator regulates the output voltage to be always constant. The


output voltage is maintained irrespective of the fluctuations in the input
AC voltage. As and then the AC voltage changes, the DC voltage also
changes. To avoid this, regulators are used. Also when the internal
resistance of the power supply is greater than 30 ohms, the pull up gets

32
affected. Thus this can be successfully reduced here. The regulators are
mainly classified for low voltage and for high voltage.

3.7.4.1 IC Voltage Regulator

Voltage regulators comprise a class of widely used ICs. Regulator


IC units contain the circuitry for reference source, comparator amplifier,
control device and overload protection all in a single IC. Although the
internal construction of the IC somewhat is different from that described
for discrete voltage regulator circuits, the external operation is much the
same.
A Power Supply can be built using a transformer connected to the
AC supply line to step the ac voltage to desired amplitude, then rectifying
that ac voltage using IC regulator. The regulators can be selected for
operation with load currents from hundreds of milli amperes to tens of
amperes, corresponding to power ratings from milli watts to tens of watts.
The purpose of the regulator is to maintain the output voltage constant
irrespective of the fluctuations in the input voltage. The Micro controller
and PC work at a constant supply voltage of +5V,-5Vand +12V and -12V
respectively. The regulators are mainly classified for positive and
negative voltage.

3.7.4.2 LM 7805 Voltage Regulator

It has several features:


 Output Current up to 1A.
 Output Voltages of 5, 6, 8, 9, 10, 11, 12, 15, 18, 24.
 Thermal Overload Protection.
 Short Circuit Protection.
 Output Transistor Safe Operating area Protection.
33
3.7.5 Output Filter

The filter circuit is often fixed after the regulator circuit. Capacitor
is most often used as filter. The principle of the capacitor is to charge and
discharge. It charges during the positive half cycle of the AC voltage and
discharges during the negative half cycle. So it allows AC voltage and not
DC voltage. This filter is fixed after the regulator circuit to filter any of
the possibly found ripples in the output received finally.

3.8 GSM MODEM

The GSM system is the most widely used cellular technology in


use in the world today. It has been a particularly successful cellular phone
technology for a variety of reasons including the ability to roam
worldwide with the certainty of being able to be able to operation GSM
networks in exactly the same way - provided billing agreements are in
place.

Fig 3.17 GSM Modem

The letters GSM originally stood for the words Grouped Special
Mobile, but as it became clear this cellular technology was being used
worldwide the meaning of GSM was changed to Global System for
Mobile Communications. Since this cellular technology was first
34
deployed in 1991, the use of GSM has grown steadily, and it is now the
most widely cell phone system in the world. GSM reached the 1 billion
subscriber point in February 2004, and is now well over the 3 billion
subscriber mark and still steadily increasing.

3.8.1 GSM System Overview

Fig 3.18 Mobile Phones

The GSM system was designed as a second generation (2G)


cellular phone technology(Ref:3.18). One of the basic aims was to
provide a system that would enable greater capacity to be achieved than
the previous first generation analogue systems. GSM achieved this by
using a digital TDMA (time division multiple access approach).
By adopting this technique more users could be accommodated within the
available bandwidth. In addition to this, ciphering of the digitally encoded
speech was adopted to retain privacy. Using the earlier analogue cellular
technologies it was possible for anyone with a scanner receiver to listen
to calls and a number of famous personalities had been "eavesdropped"
with embarrassing consequences.

35
3.8.2 GSM Services

Speech or voice calls are obviously the primary function for the
GSM cellular system. To achieve this the speech is digitally encoded and
later decoded using a vocoder. A variety of vocoders are available for
use, being aimed at different scenarios.In addition to the voice services,
GSM cellular technology supports a variety of other data services.
Although their performance is nowhere near the level of those provided
by 3G, they are nevertheless still important and useful. A variety of data
services are supported with user data rates up to 9.6 kbps. Services
including Group 3 facsimile, videotext and teletex can be supported.

One service that has grown enormously is the


short message service. Developed as part of the GSM specification, it has
also been incorporated into other cellular technologies. It can be thought
of as being similar to the paging service but is far more comprehensive
allowing bi-directional messaging, store and forward delivery, and it also
allows alphanumeric messages of a reasonable length. This service has
become particularly popular, initially with the young as it provided a
simple, low fixed cost.

3.8.3 GSM Basics

The GSM cellular technology had a number of design aims when


the development started:
 It should offer good subjective speech quality.
 It should have a low phone or terminal cost.
 Terminals should be able to be handheld.
 The system should support international roaming.
 It should offer good spectral efficiency.

36
Fig 3.19 Configuration of GSM Modem

A GSM modem is connected to each Telecontrol unit. The central


server calls up each of the Telecontrol units in sample homes to pick up
the data stored therein. aMap's technology architecture enables instant
data collection from the sample homes as often as desired. It also enables
conducting of instant opinion polls about the programs being telecast.
The collected data is instantaneously incorporated into the aMap reports.
At present the central server calls up all the sample homes between
2:00 AM and 4:00 AM IST (Indian Standard Time) to collect the data. In
case the data from some of the homes/ units can not be collected in the
first attempt, the server dials that home again after 5 minutes, and makes
the third attempt after 1.30 hours. After 3 trials, the server gives up. If
non-collection of data is caused by the problems with cellular connection,
the data can be collected later at any time over next seven days.
The system generates a list of sample homes from which the data
could not be collected. These failures are investigated on the same day.
The possible causes of failure in data collection are

 The Telecontrol power failure.


37
 The Telecontrol unit disconnection/dysfunctional.
 The sample home being locked.
 The problems with cellular connection etc.

The Telecontrol system can respond to every possible use of a


television screen, including viewing videos, playing TV games and using
Teletext. Moreover, the design of the Telecontrol unit and its interactive
system can be adapted to the psychological requirements of the panel
household members, a key reason for its very high degree of acceptance
and the widespread willingness to enter information.

3.8.4 GSM Specification

Before looking at the GSM specification, it is important to understand


the following basics terms.

1. Bandwidth:
The range of channels limits, the border the bandwidth, the faster
data can be sent.
2. Bits Per Second(BPS):
A single on – off pulse data, eight bits are equivalent to 1 byte.
3. Frequency:
The number of cycles per unit of time frequency is measured in
hertz (hz).
4. KILO:
Kilo is the designation of 1,000; the abbreviation kbps represents
1,000 bits per second.
5. MEGAHERTZ:
1000000 hertz (cycles per second)

38
6. MILLISECOND:
One thousandth of a second.
7. WATT(W):
A measure of power of transmitter.
8. Frequency Band:
The frequency range specified for gsm is 1850 to 1990 MHZ
(mobile station to base station).
9. Duplex Distance:
The duplex distance is 80 MHZ. duplex distance is the distance
between uplink and downlink frequencies. A channel has two
frequencies, 80 MHZ apart.
10.Channel Separation:
The separation between adjacent carrier frequencies. In gsm it is
200 khz.
11.Modulation:
Modulation is process of sending a signal by changing the
characteristics of carrier frequency. This is done in gsm ie (GMSK)
Gaussian minimum shift keying.
12.Transmission Rate:
GSM is a digital system with an over – the – air bit rate of 270
kbps.
13.Access Method:
GSM utilizes the time division multiple accesses (TDMA) concept.
TDMA is a technique in which several different calls may share the
same carrier. Each call is assigned a particular time slot.
14.Speech Coder:
GSM used linear predictive coding (LPC). The purpose of LPC is
used to reduce the bit rate. The LPC provides the parameters for a filter

39
that mimics the vocal tract. The signal passes through this filer leaving
behind a residual signal. Speech is encoded in a 13 kbps.

3.9 RS232 Communication

Fig 3.20 RS232 Cable

To allow compatibly among data communication equipment made


by various manufacturers, an interfacing standard called RS232 was set
by the Electronics Industries Association (EIA). It was modified and
called RS232. It is most widely used for serial I/O interfacing standard.
This standard is used for communicating between PIC microcontroller
and GSM module. In this standard, a ‘1’ is represented by -3 to -15V,
while a ‘0’ bit is +3 to +25V, making -3 to +3 undefined. For this reason,
to connect any RS232 to a microcontroller system we must use voltage
converter such as MAX 232 to convert the TTL logic levels to the RS232
voltage level, and vice versa.

INTRODUCTION TO GPS (GLOBAL POSITIONING


SYSTEM):

24
24
The Global Positioning System, usually called GPS, and originally
named NAVSTAR, is a satellite navigation system used for
determining one's precise location almost anywhere on Earth. A GPS
unit receives time signal transmissions from multiple satellites, and
calculates its position by triangulating this data. The GPS was
designed by and is controlled by the United States Department of
Defense and can be used by anybody for free. The cost of maintaining
the system is approximately

$400 million per year.

25
25
Measurement uncertainty of the majority of commercial GPS
receivers varies from 10-11 to 10-13 by the frequency scale, and from
100 ns to 50 ns by the time scale, being dependent on the receiver design.
The main sources of uncertainty in GPS measurements are the GPS
receiver position error, the orbital error, the satellite and receiver clock
errors, the ionosphere and the troposphere delays, the receiver internal
delay, the satellite antenna and cable delay, the receiver noise, and the
multipath error. The frequency uncertainty for a GPS receiver is larger
than that for Cs-standard by 2-3 orders within a short-time interval (1 –

1000 s), and by one order within a long-term interval of about one week.

It may help to think of a GPS receiver as similar to a standard


radio. Like the radio in your car, a GPS receiver is collecting radio
signals from the “ether” and magically turning these signals into
information we can use. In the case of a GPS receiver the
“stations” are satellites broadcasting 11,000 miles away in space and the
music is a binary code, but the antenna and radio hardware are subject
to similar kinds of interference that affect your car radio’s ability to
produce a clear sound. In your car speaker we hear this interference as
“static”; in your GPS receiver the interference may result in positional
“static”, i.e., degradation of accuracy.

A better radio receiver and antenna system, fewer terrain


obstructions, a stronger connection to the broadcasting station all result
in better sound quality for your car radio and better positional quality
26
26
for your GPS radio. A GPS receiver derives its location or positional
“fix” with distance measurements (called pseudo ranges) from multiple
satellites at precisely the same time, a “measurement epoch”. Attributes
collected and stored with the position for each feature can be used in
GIS map making and analysis. While there are only so many things you
can do to improve your car radio’s performance, by contrast there are
many more things users can do to influence GPS positional quality.

27
27
Satellites

The United States Global Positioning System (GPS) is the first


fully operational Global Navigation Satellite System (GNSS). Each
satellite broadcasts a signal that is used by receivers to determine precise
position anywhere in the world. The receiver tracks multiple satellites
and determines a pseudo range measurement (a range measurement
based on time) that is then used to determine the user location. A
minimum of four satellites is necessary to establish an accurate three-
dimensional position.

The Department of Defense (DOD) is responsible for operating


the GPS satellite constellation and monitors the GPS satellites to
ensure proper operation. Every satellite's orbital parameters
(ephemeris data) are sent to each satellite for broadcast as part of
the data message embedded in the GPS signal. The GPS
coordinate system is the Cartesian earth-centered earth-fixed
coordinates as specified in the World Geodetic System reference
system 1984 (WGS-84).

28
28
24 GPS satellites are currently in orbit around the earth. the first
was launched in 1972 and the latest satellite was launched in 2012. The
maximum available at any time from a point in Oregon is generally
between 4 to 11. The satellites send out radio signals that are collected
and read by the GPS receiver.

29
29
Fig: 3.5 Working of GPS modem

The GPS is made up of three parts:

1. Satellites orbiting the Earth

2. Control and monitoring stations on Earth

3. The GPS receivers owned by users.

30
30
GPS satellites broadcast signals from space that are picked up and
identified by GPS receivers. Each GPS receiver then provides
three- dimensional location (latitude, longitude, and altitude) plus the
time.

SPACE SEGMENT:

 24+ satellites

 20,200 km altitude

 55 degrees’ inclination

 12-hour orbital period

 5 ground control stations

31
31
 Each satellite passes over a ground monitoring station every 12
hours

Fig: 3.5.1 GPS Satellite


System

The space segment is composed of the orbiting GPS satellites or

Space Vehicles (SV) in GPS parlance. The GPS design originally called
for

24 SVs, this was modified to six planes with four satellites each.
The orbital planes are centered on the Earth, not rotating with respect to
the distant stars. The six planes have approximately 55° inclination
(tilt relative to Earth's equator) and are separated by 60° right ascension
of the ascending node (angle along the equator from a reference point to
the orbit's intersection.

32
32
The full constellation of 24 satellites that make up the GPS space
segment are orbiting the earth about 20,200 km above us. They are
constantly moving, making two complete orbits in less than 24 hours.
These satellites are travelling at speeds of roughly 7,000 miles an hour.

GPS satellites are powered by solar energy. They have backup


batteries onboard to keep them running in the event of a solar eclipse,
when there's no solar power. Small rocket boosters on each satellite keep
them flying in the correct path.

Here are some other interesting facts about the GPS satellites (also
called NAVSTAR, the official U.S. Department of Defense name for
GPS):

33
33
 The first GPS satellite was launched in 1978.

 A full constellation of 24 satellites was achieved in 1994.

 Each satellite is built to last about 10 years. Replacements are


constantly being built and launched into orbit.

 A GPS satellite weighs approximately 2,000 pounds and is about

17 feet across with the solar panels extended.

 Transmitter power is only 50 watts or less.

 The orbits are arranged so that at anytime, anywhere on Earth,


there are at least four satellites "visible" in the sky.

 All satellites broadcast at the same two frequencies,

1.57542 GHz (L1 signal) and 1.2276 GHz (L2 signal).

 The satellite network uses a CDMA spread-spectrum


technique where the low-bitrate message data is encoded with a
high-rate pseudo-random (PRN) sequence that is different
for each satellite.

The receiver must be aware of the PRN codes for each satellite
to reconstruct the actual message data. The C/A code, for civilian
use, transmits data at 1.023 million chips per second, whereas the P code,
for U.S. military use.

Control and monitoring stations on Earth:

These stations monitor the GPS satellites, checking both their


operational health and their exact position in space. The master ground
station transmits corrections for the satellite's ephemeris constants and
clock offsets back to the satellites themselves. The satellites can then
incorporate these updates in the signals they send to GPS receivers.
There are five monitor stations: Hawaii, Ascension Island, Diego
Garcia, Kwajalein, and Colorado Springs.

The GPS Receivers:

 Receiver determines location, speed, direction, and time


 3 satellite signals are necessary to locate the receiver in 3D space

 4th satellite is used for time accuracy

 Position calculated within sub-centimeter scale

Individuals may purchase GPS handsets that are readily available


through commercial retailers. Equipped with these GPS receivers, users
can accurately locate where they are and easily navigate to where they
want to go, whether walking, driving, flying, or boating.

Today's GPS receivers are extremely accurate, thanks to their


parallel multi-channel design. Garmin's 12 parallel channel receivers are
quick to lock onto satellites when first turned on and they maintain
strong locks, even in dense foliage or urban settings with tall
buildings. Certain atmospheric factors and other sources of error can
affect.
Fig: 3.5.2 Newer Garmin GPS Receivers with WAAS

The user segment is composed of hundreds of thousands of U.S.


and allied military users of the secure GPS Precise Positioning
Service, and tens of millions of civil, commercial and scientific
users of the Standard Positioning Service. In general, GPS receivers
are composed of an antenna, tuned to the frequencies transmitted by
the satellites, receiver-processors, and a highly stable clock (often a
crystal oscillator).

They may also include a display for providing location and


speed information to the user. A receiver is often described by its
number of channels: this signifies how many satellites it
can monitor simultaneously. Originally limited to four or five, this
has progressively increased over the years so that, as of 2007,
receivers typically have between 12 and 20 channels.

The Global Positioning System is vast, expensive and involves a


lot of technical ingenuity, but the fundamental concepts at work are
quite simple and intuitive.

When people talk about "a GPS," they usually mean a GPS
receiver. The Global Positioning System (GPS) is actually a
constellation of 24
Earth-orbiting satellites The U.S. military developed and implemented
this satellite network as a military navigation system, but soon opened it
up to everybody else.

40
CHAPTER 4

SOFTWARE DESCRIPTION

4.1 MPLAB Program

MPLAB is a software program that runs on your PC to provide a


development environment for your embedded system design. In other
words it is a Windows program package that makes writing and
developing a program easier. It could best be described as developing
environment for a standard program language that is intended for
programming microcontrollers. Getting started to MPLAB:
1. Open the program by double-clicking on its icon on the desktop.
2. From the project menu choose project wizard.
3. Choose PIC 16F877A.
4. Browse and name the project.
5. From view menu choose project, to view the project.
6. Then add a file to the source files by right clicking on source
files, and choose add files and then name the file anyName.asm.

4.2 PROTEUS PROFESSIONAL V7.6 SP4

Proteus Professional - software for automated design of electronic


circuits. The package is a system of circuit simulation, based on the
models of electronic components in PSpice. A distinctive feature of the
package Proteus Professional is the possibility of modeling of the
programmable devices: microcontrollers, microprocessors, DSP and
others. Additionally, the package of Proteus Professional is a system
design of printed circuit boards. Proteus Professional can simulate the
following microcontrollers: 8051, ARM7, AVR, Motorola, PIC, Basic
Stamp.
41
4.2.1 PROTEUS Program

Proteus contains everything you need to develop; test and virtually


prototype your embedded system designs based around the Microchip
Technologies™ PIC16 series of microcontrollers. The unique nature of
schematic based microcontroller simulation with Proteus facilitates rapid,
flexible and parallel development of both the system hardware and the
system firmware. This design synergy allows engineers to evolve their
projects more quickly, empowering them with the flexibility to make
hardware or firmware changes at will and reducing the time to market.
Proteus VSM models will fundamentally work with the exact same HEX
file as you would program the physical device with, binary files (i.e. Intel
or Motorola Hex files) produced by any assembler or compiler.

4.2.2 PROTEUS Program Setup

 Start-up the Microsoft Windows.


 Place the ECOM 4315 CD into CD ROM drive.
 Double-click on the software tools folder and then choose
Proteus Simulator after that double click Proteus 7.6 folder and
run the setup.
 Press next until you reach the window, which ask for the key.
 From browse for key; browse until you reach the same folder
where the setup exists, and then open the second folder and
chose the MAXIM_LICENCE folder.
 Then click on the top icon which is MAXIM and then press
install.
 Then choose yes and then close the window, after that browse
and install the program.

42
 After that run the patch which exist in the same folder where the
MAXIM_LICENCE exists.
 Then browse for c:\Program files\Lab center electronics
\Proteus.
 Finally choose next, and then select finish.
Getting started to PROTEUS:
 From Start menu choose PROTEUS, and then choose ISIS.
 To get a part click on Devices (P).
 Write the name of the PIC16F877A.
 To get LED write led then choose red led.
 To get a resistor write 1k and choose the first part.

43
Chapter-4

SCHEMATIC AND FLOW CHARTS


4.1 SCHEMATIC DIAGRAM :

Fig: 4.1 SCHEMATIC DIAGRAM


4.2 FLOW CHART

Fig: 4.2 FLOW CHART


5.1 ADVANTAGES:

 Sophisticated security

 Monitors all hazards and threats

 Alert message to mobile phone for remote information

 Mobile number can be changed at any time

5.2 APPLICATIONS:

 Auto motives and transport vehicles

 Security, Remote monitoring, Transportation and logistics

 This system is also can be interfaced with Vehicle airbag system.

5.3 DISADVANTAGES:

 When Power Is Off, Then The Total System Is Off, So Always

Required
Battery.

 GSM module should be handled smoothly.


5.4 LIMITATIONS:

 It should be operated in an open area in order to detect the


latitude and longitude locations faster.

 If the kit is moved a little bit, the GPS modem again takes time to
detect the location.

44
CHAPTER 6

CONCLUSION

In this project work, we have studied and implemented a

complete working model using a Microcontroller. The programming and

interfacing of microcontroller has been mastered during the

implementation. This work includes the study of GSM and GPS modems

using sensors.

The biggest advantage of using this project is, whenever the

switch is pressed we will be getting the location from GSM modem to our

mobile numbers which are stored in EEPROM and GSM network so that

one can save the women who is in threat.

7.1 FUTURE SCOPE

 By encrypting the GOOGLE MAPS in the GPS sensor it can detect


the area instead of latitude and longitude information.

 By using Nano sized materials, the kit size gets reduced.

 Using wireless GPS modem and wireless Panic button the carrying

of the kit can be avoided.


 More effective system can be designed by adding MOTION
DETECTOR Technology.
Chapter-8

REFERENCE BOOKS AND BIBLIOGRAPHY


8.1 REFERENCE BOOKS:

1. "The ARM Microcontroller & Embedded Systems” by Mohammed

Ali Mazidi and Janice Gillispie Mazidi

2. "Power Electronics” by M D Singh and K B Khanchandan

3. "Linear Integrated Circuits” by D Roy Choudhry & Shail Jain

4. "Electrical Machines” by S K Bhattacharya

5. "Electrical Machines II” by B L Thereja

8.2 BIBLIOGRAPHY:

1. WWW.MI TEL.DATABOOK.COM

2. WWW.ATMEL.DATABOOK.COM

3. WWW.FRANKLIN.COM

4. WWW.KEI L.COM

5. WWW.EMBEDDED.COM
6. WWW.ATMELCORPORATION.COM

7. WWW.WIKIPEDIA.COM

8. WWW.I KALOGIC.COM/CAT_MICROCONTROLLERS.PHP

47
APPENDICES
///9786300345

#include<pic.h>
__CONFIG(0x3f72);

#define rs RE2
#define en RE0
#define PIR RD0

void lcd_init();
void command(unsigned char);
void lcd_disp(unsigned char);
void lcdcmd(unsigned char);
void lcd_data(unsigned char);
void lcd_display(unsigned char ,unsigned char);
void sms();
void mob_init();
void ser_init();

void ser_out(unsigned char);

void delay(unsigned int del)


{
while(del--);
}

void lcd_condis(const char *q)


{
while(*q)
{
lcd_disp(*q++);
delay(1000);
}
}

typedef unsigned char INT8U;


typedef signed char INT8S;
typedef unsigned int INT16U;;
typedef unsigned long INT;
typedef signed int INT16S32U;
typedef signed long INT32S;
typedef float FP32;
typedef double FP64;
unsigned int i,ii;
bit Reach_10ms,SECOND,RSL_Bit;
unsigned char msec_count,onesec_count,sec20count,blink;
unsigned char RfidBuf[13],RecvReg,recstage,rccount;
unsigned char GSM_Count;
void ser_dis(const unsigned char*da,unsigned char no);
///GPS Variables
INT8U GPS_Date[7];
bank1 INT8U GPS_Time[10];
bank1 INT8U GPS_Latitude[11];
bank1 INT8U GPS_Longitude[12];
bank1 INT8U GPS_Speed[6];
INT8U GPS_Lat_Direction;
INT8U GPS_Lon_Direction;
INT8U GPS_Check,Gps_Disp;
INT8U GPS_COUNT;
INT8U GPS_string_check,Placevalue;

50
//__CONFIG ( XT & WDTDIS & PWRTEN & BOREN & DUNPROT & PROTECT & DEBUGDIS &
LVPDIS & DP) ;

void Transmit_power_on(void);
unsigned char IntialCount;
void Latlongdisplay(void);

void cpu_seq(const unsigned char *word)


{
while(*word)
{
ser_out(*word++);
}
}

void main()
{
TRISB=0X00;
TRISD=0X01;
TRISE=0x00;
ADCON1=0X07;
TRISC=0X80;PIR=0;
INTCON=0XE0;//eXTERNAL INTERRRUPT ENABLED
OPTION=0XC4;//3;
TMR0=193;
ser_init();
lcd_init();
mob_init();// LCD Initialization
cpu_seq("TESTD");
ser_out(0x0d);

GSM_Count=0;
command(0x01);
command(0x80);
lcd_condis(" Welcome To GPS");
recstage=0;

IntialCount=0;
while(IntialCount < 3);
cpu_seq("TESTD");
ser_out(0x0d);

RCIF=0;
Placevalue=0;
Latlongdisplay();
while(1)
{
if(RC0==1)
{
Latlongdisplay();
sms();
}
if (RC1==1)
{
sms();
}
else
{
Latlongdisplay();
}
}
51
}

void interrupt isr(void)


{
if(TMR0IF)
{
TMR0IF=0;
TMR0=100;
if(msec_count++ >= 10)
{
msec_count=0;
Reach_10ms=1;
if(onesec_count++ >= 12)
{
onesec_count=0;
SECOND=1;
IntialCount++;
}
}
}

else if(RCIF==1)
{
RCIF =0;
RecvReg = RCREG;
switch(GPS_Check)
{
case 0:
if(RecvReg!= '$')
GPS_Check=0;
else
GPS_Check++;
break;
case 1:
if(RecvReg=='G')
GPS_Check++;
else
GPS_Check=0;
break;
case 2:
if(RecvReg=='P')
GPS_Check++;
else
GPS_Check=0;
break;
case 3:
switch(RecvReg)
{
case 'G':
GPS_Check++;
break;
case 'L':
GPS_Check++;
break;
//case 'L':
//GPS_Check++;
//break;
default:
GPS_Check=0;
}
break;
case 4:
switch(RecvReg)
{
52
case 'M':
GPS_Check++;
break;
case 'G':
GPS_Check++;
break;
case 'T':
GPS_Check++;
break;
default:
GPS_Check=0;
}
break;
case 5:
switch(RecvReg)
{
case 'C':
GPS_Check++;
GPS_COUNT=0;
GPS_string_check=0;
break;
case 'A':
GPS_Check++;
break;
case 'G':
GPS_Check++;
break;
default:
GPS_Check=0;
}
break;

case 6:
switch(GPS_string_check)
{
case 2://GPS VALID OR INVALID
switch (RecvReg)
{
case 'A':
break;
case 'V':
GPS_string_check=0;
GPS_Check=0;
break;
}
break;
case 3:///LATITUDE
if(RecvReg!=',')
{
GPS_Latitude[GPS_COUNT++]=RecvReg;
if(GPS_COUNT==10)
GPS_Latitude[GPS_COUNT++]='\0';
}
break;
case 5://LONGITUDE
if(RecvReg!=',')
{
GPS_Longitude[GPS_COUNT++]=RecvReg;
if(GPS_COUNT==11)
GPS_Longitude[GPS_COUNT++]='\0';
Gps_Disp=1;
}
break;
}
switch(RecvReg)
{
case 0X0D :
GPS_Check=0;
53
break;
case ',':
GPS_COUNT=0;
GPS_string_check++;
break;
}
break;
}
}
}

void lcd_init()
{
command(0x02); // To initialize LCD in 4-bit mode.
command(0x28); // To initialize LCD in 2 lines, 5x7 dots and 4bit mode.
command(0x0C);
command(0x06);
}

void command(unsigned char cmd_value)


{
unsigned char cmd_value1;
cmd_value1 = (cmd_value & 0xf0);
lcdcmd(cmd_value1);
cmd_value1 = ((cmd_value & 0x0f)<<4);
lcdcmd(cmd_value1);
}

void lcd_disp(unsigned char data_value)


{
unsigned char data_value1;
data_value1=((data_value & 0xf0));
lcd_data(data_value1);
data_value1=((data_value & 0x0f)<<4);
lcd_data(data_value1);
}

void lcdcmd(unsigned char cmdout)


{
PORTD=cmdout;
rs=0;
en=1;
delay(1);
en=0;
}

void lcd_data(unsigned char dataout)


{
PORTD=dataout;
rs=1;
en=1;
delay(1);
en=0;
}

void ser_init()
{
SPBRG=64; // for 1200 baud rate
BRGH = 1; // baud rate low
SYNC = 0; // asynchronous mode
SPEN = 1; // serial port enable
TXEN = 1; // tx enable
RCIE = 1; // interrupt set
CREN = 1; // rx enable
GIE=1;
PEIE=1;
}
54
void ser_out(unsigned char val)
{
TXREG =val;
while(!TXIF);
TXIF = 0;
delay(250);
}

void Latlongdisplay(void)
{
//command(0x01);
command(0x80);
lcd_condis(" LAT: ");
command(0x85);
lcd_condis(GPS_Latitude);
command(0xc0);
lcd_condis("LON: ");
command(0xc4);
lcd_condis(GPS_Longitude);
//ser_out(0x0d);
//cpu_seq("LATITUDE:");
//cpu_seq(GPS_Latitude);
//ser_out(0x0d);
//cpu_seq("LONGITUDE:");
//cpu_seq(GPS_Longitude);
//ser_out(0x0d);
}
void mob_init()
{

command(0x01);
command(0x80);
lcd_condis("GSM INITILIZATION");
command(0xc0);
lcd_condis("WAITING..........");
for(ii=0;ii<=15;ii++)
{
command(0xce);
lcd_disp(ii/10+0x30);
lcd_disp(ii%10+0x30);
delay(5000); delay(5000);
delay(5000);
delay(5000); delay(5000);
delay(5000);

ser_dis("AT",2);
ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
ser_dis("ATE0",4);
ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
ser_dis("AT",2);
ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
ser_dis("AT+CMGF=1",9);
ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
//ser_out(0x0A);
ser_dis("AT+CNMI=2,2,0,0,0",17);
ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
// ser_out(0x0A);
}

void sms()
{
ser_dis("AT",2);

ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(
5000);delay(5000);delay(5000);delay(5000);
ser_dis("AT",2);
ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
55
delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
ser_dis("ATE0",4);

ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(
5000);delay(5000); delay(5000);delay(5000);delay(5000);delay(5000);
delay(5000);delay(5000);delay(5000);delay(5000); delay(5000);delay(5000);delay(5000);delay(5000);

ser_dis("AT+CMGF=1",9);

ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(
5000);delay(5000);delay(5000);delay(5000);
ser_dis("AT+CSCS=",8);
ser_out('"');
ser_dis("GSM",3);
ser_out('"');

ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(
5000);delay(5000);delay(5000);delay(5000);
ser_dis("AT+CMGS=",8);
ser_out('"');
ser_dis("7598029071",10);
ser_out('"');

ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(
5000);delay(5000);delay(5000);delay(5000);delay(5000);
//ser_out(0x0A);
ser_dis("LAT&LON: 8.42 77.03",20);
ser_dis(GPS_Latitude,12);
//ser_dis("E012084.0312",12);
ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(
5000);
// ser_out(0x0A);
ser_out(0x1A);delay(99999999);

//ser_dis("AT",2);
//
ser_out(0x0d);delay(99999999);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);d
elay(5000);delay(5000);delay(5000);delay(5000);
//ser_dis("AT",2);
// ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
//ser_dis("ATE0",4);
//
ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(
5000);delay(5000); delay(5000);delay(5000);delay(5000);delay(5000);
//delay(5000);delay(5000);delay(5000);delay(5000); delay(5000);delay(5000);delay(5000);delay(5000);

//ser_dis("AT+CMGF=1",9);
//ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);
//ser_dis("AT+CSCS=",8);
//ser_out('"');
//ser_dis("GSM",3);
//ser_out('"');
//

ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(
5000);delay(5000);delay(5000);delay(5000);
// ser_dis("AT+CMGS=",8);
// ser_out('"');
// ser_dis("8124252728",10);
// ser_out('"');
//

ser_out(0x0d);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(
5000);delay(5000);delay(5000);delay(5000);delay(5000);
56
//ser_out(0x0A);
//ser_dis("E012084.0312",12);
//ser_out(0x0d);
//delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5000);delay(5
000);delay(5000);delay(5000);
//delay(5000);delay(5000);delay(5000);delay(5000);
// ser_out(0x0A);
// ser_out(0x1A);delay(5000);

void ser_dis(const unsigned char*da,unsigned char no)


{
unsigned char ss;
for(ss=0;ss<no;ss++) ser_out(da[ss]);

57

You might also like