1 Realtime Vehicle Tracking System b

Published on January 2017 | Categories: Documents | Downloads: 29 | Comments: 0 | Views: 234
of 15
Download PDF   Embed   Report

Comments

Content


1. 1 REALTIME VEHICLE TRACKING SYSTEM B. Tech. Project Report BY DILIP KUMAR
CHAUDHARY Roll No.- 100103103 DEPARTMENT OF ELECTRONICS & COMMUNICATION
ENGINEERING SHARDA UNIVERSITY, GREATER NOIDA Uttar Pradesh-201306 (INDIA) MAY,
2014
2. 2 CHAPTER 1 INTRODUCTION 1.1 VEHICLE TRACKING SYSTEM A vehicle tracking system
combines the use of automatic vehicle location in individual vehicles with software that collects these
fleet data for a comprehensive picture of vehicle locations. Modern vehicle tracking systems
commonly use GPS technology for locating the vehicle, but other types of automatic vehicle location
technology can also be used. Vehicle information can be viewed on electronic maps via the Internet
or specialized software. 1.1.1 Working This project is based on vehicle tracking and positioning in
which we locate our vehicle in globe with mean see level as a reference. This is done with the help
of Microcontroller 8051, GPS receiver, GSM modem, MAX 232. The instruction is written in the
internal memory of Microcontroller (ROM). With the help of the information it processes the data and
act to it accordingly as it interfaces with GPS and GSM. There is a serial communication of 8051.
Here GPS act as a receiver as it receive the data and GSM transmits and receives the data. GPS
pin transmitter is connected to Microcontroller via MAX232. Pins of GSM transmitter and receiver are
connected to serial ports of microcontroller. Microcontroller will take the data from the GPS receiver
and then send information to the user in the form of coordinates on the LCD with the help of GSM
modem. GPS values of all the satellite are send to the microcontroller P89V51RD2 which are
processed and forwarded to GSM module. At the time of processing GPS receives only GPGGA
values only. Out of these values microcontroller takes only latitude and longitude values excluding
time, altitude, name of satellite, authentication etc. E.g. LAT: 1728:2470 LOG: 7843.3089
3. 3 1.1.2 Block Diagram Fig 1.1- Block diagram of working 1.2 Working process Developing Automatic
Vehicle Location system using GPS for positioning information and GSM/GPRS or information
transmission with following features: Acquisition of vehicle‟s location information ( latitude &
longitude) after specified time interval. Transmission of vehicle‟s location and other information to the
monitoring station/Tracking server after specified interval of time. Developing a web based software
to display all transmitted information to end user along with displaying location of vehicle on a map.
Overall system is partitioned into two major design units. In-Vehicle unit. Tracking, Server/Monitoring
Station. 1.2.1 In-Vehicle Unit This is major part of the system and it will be installed into the vehicle.
It is responsible for capturing the following information for the vehicle Current location of In-vehicle
unit is also responsible for transmitting this information to Tracking Server located anywhere in the
world.
4. 4 Fig 1.2- In-vehicle Unit of VTS 1.2.2 Data Transreceiver When all required information is extracted
and processed, it needs to be transmitted to a remote Tracking Server which will be able to display
this information to the end user. For real time tracking of vehicle, reliable data transmission to
remote server is very important. Wireless network is required to transmit vehicle information to
remote server. Existing GSM network is selected to transmit vehicle information to remote server
because of broad coverage of GSM network. For data transmission over GSM network GSM modem
is required. GSM modem can send and receive data SMS text messages and GPRS data over GSM
network. Location data is transferred to microcontroller through serial interface. After processing of
the data provided by GPS receiver, microcontroller transmits this information to remote location
using GSM/GPRS modem. Microcontroller controls the operation of GSM/GPRS modem through
serial interface using AT commands. 1.2.2.1 Software flow Microcontroller is acting as Central
Processing Unit for In-Vehicle unit. Microcontroller needs instructions to operate the whole system.
These instructions are provided to microcontroller by writing the software into microcontroller‟s flash
memory. It reads the software instruction by instruction and performs the action. 1.2.2.2 Tracking
Server Tracking server maintains all information received from all In-Vehicle units installed in
different vehicles into a central database. This database is accessible from internet to authorized
users through a web interface. Authorized users can track their vehicle and
5. 5 view all previous information stored in database. Tracking server has a GSM/GPRS modem
attached to it that receives SMS from In-Vehicle units and sends those messages to the server
through serial port. Tracking server saves this information into database. Fig 1.3- Tracking server
unit Design of Tracking Server is partitioned into four major parts. ( i ) Web Interface ( ii ) Database (
iii ) Communication Software ( iv ) Hardware design 1.3 Web Interface Design Tracking Server
maintains all information in a database. To display this information to users front end software is
required that can display all information to the user. The system is being installed the In-Vehicle unit
in his vehicle and also the administrator of the system who is managing Vehicle Tracking System.
There may be a number of vehicles installed with In-Vehicle units therefore server must be able to
manage and distinguish information sent by all In-Vehicle units. For this purpose information must be
available to server about all vehicles that are installed with In-Vehicle units. Whenever In-Vehicle
unit is installed, information about that vehicle is stored in the database. Web interface must also
support this functionality. Since web interface will be accessible over the internet therefore access
must be restricted to authorized users only. Therefore information about all users of the system must
be stored in database. 1.4 Database Design Database is designed to store all received vehicle
information, information about In- Vehicle units and users of the system. Information to be stored in
the database is
6. Exchanging information with In-Vehicle units through internet. Main program listens for SMS and
handles all communicat Sending SMS to in vehicle unit as required by user.  Processing received
SMS and saving information into database.  Configuration of GSM for sending and receiving SMS.
 Information about received from vehicles. 1.5 Design of Communication Software The software
that is to be designed will provide communication interface to the GSM modem attached to
computers serial port. It will control the operations of GSM. This software must be able to support
following functions  Information about vehicles.  Information about users of the system. 6
Transport service. Airlines services.  Defense service.  Industrial Transport tracking.  Police
department tracking.  School vehicle tracking.  Manages the route.  Real time alert.  Historical
Report.  Theft protection.  Better way to track an individual vehicle. ion with In-Vehicle units
using SMS. 1.6 Application
7. 7 CHAPTER 2 POWER SUPPLY 2.1 INTRODUCTION These days almost all the electronic
equipments include a circuit that converts AC supply into DC supply. The part of equipment that
converts AC into DC is known as AC to DC converter. In general, at the input of the power supply is
a transformer. It is followed by a rectifier, a smoothing filter and then by a voltage regulator circuit.
2.2 COMPONENTS OF POWER SUPPLY Power supply consists of four components:- (i) Step-
Down Transformer (ii) Rectifier (iii) Filter (iv) Voltage Regulator Block diagram of such a supply is
shown below:- Fig. 2.1 Block diagram of Power Circuit 2.2.1 Step Down Transformer A transformer
in which the output (secondary) voltage is less than the input (primary) voltage is called step down
transformer. Alternating current is passed through the primary coil which creates the changing
magnetic field in iron core. The changing magnetic field then induces alternating current of the same
frequency in the secondary coil (the output). A step down transformer has more turns of wire on the
primary coil than in secondary coil which makes a smaller induced voltage in the secondary coil. The
transformer equation relates the number of turns of wire to the difference in voltage between the
primary and secondary coils. Vp /Vs = Np /Ns ...(2.1) TRANSFORME R VOLTAGE REGULATO R
RECTIFIER FILTER
8. 8 Vp is the voltage in the primary coil. Vs is the voltage in the secondary coil. Np is the number of
turns of wire on the primary coil. Ns is the number of turns of wire on the secondary coil. 2.2.2
Rectifier Rectifier is defined as an electronic device used for converting A.C voltage into
unidirectional voltage. A rectifier utilizes unidirectional conduction device like P-N junction diode.
There are three types of rectifier:- a. Half wave rectifier. b. Full wave center tap rectifier. c. Full wave
bridge rectifier. 2.2.3 Filter The output from any of the rectifier circuits is not purely D.C but also has
some A.C components, called ripples, along it. Therefore such supply is not useful for driving
sophisticated electronic devices/circuits. Hence, it becomes essential to reduce the ripples from the
pulsating D.C supply available from rectifier circuits to the minimum. This is achieved by using a filter
or smoothing circuit which removes the A.C components and allows only the D.C component to
reach the load. A filter circuit should be placed between the rectifier and the load. 2.2.4 Voltage
Regulator Voltage Regulator (regulator), usually having three legs, converts varying input voltage
and produces a constant regulated output voltage. 7805 voltage regulator has three pins:- a. Input:-
For 7805 the rectified and filtered voltage coming at this pin must be between 8 to 18V in order to
get stable 5V DC output at the output pin. b. b. Ground:- This pin is connected to the ground of the
circuit to which this 5V DC supply is provided. c. Output:- If the input voltage at input pin is between
8-18V then at the output pin a stable 5V DC voltage will be available. 7805 can give +5V output at
about
9. 9 150 mA current, but it can be increased to 1A when good cooling is added to 7805 regulator chi
INPUT O OUTPUT GND Fig. 2.2 Pin configuration 2.3 5V DC POWER SUPPLY USING FULL
WAVE CENTER TAP RECTIFIER The transformer supplies the source voltage for two diode
rectifiers, D1 and D2. This transformer has a center-tapped, low-voltage secondary winding that is
divided into two equal parts (W1 and W2). W1 provides the source voltage for D1, and W2 provides
the source voltage for D2. The connections to the diodes are arranged so that the diodes conduct on
alternate half cycles. When the center tap is grounded, the voltages at the opposite ends of the
secondary windings are 180 degrees out of phase with each other. Thus, when the voltage at point
A is positive with respect to ground, the voltage at point B is negative with respect to ground. Let's
examine the operation of the circuit during one complete cycle. During the first half cycle (indicated
by the solid arrows), the anode of D1 is positive with respect to ground and the anode of D2 is
negative. As shown, current flows from ground (center tap) to point A, through diode D1 to point B
and to point D. When D1 conducts, it acts like a closed switch so that the positive half cycle is felt
across the load (RL). During the second half cycle (indicated by the dotted lines), the polarity of the
applied voltage has reversed. Now the anode of D2 is positive with respect to ground and the anode
of D1 is negative. Now only D2 can conduct. Current now flows, as shown, from point C to point B
through diode D2 then to point F and back to point D. 7805
10. 10 Now during both the cycles the capacitor C1 quickly charges to the peak voltage but when the
input voltage becomes less than peak voltage the capacitor discharges through load resistance and
loses charge. But because of large load resistance the discharging time is large and hence capacitor
does not have sufficient time to discharge appreciably. Due to this the capacitor maintains a
sufficiently large voltage across the load. Fig. 2.3 Centre-tap full-wave rectifier The voltage across
the capacitor is applied to 7805 voltage regulator which provides a constant 5V D.C. voltage at its
output. Fig. 2.4 Output waveforms of centre-tap full-wave rectifier
11. 11 Fig. 2.5 Output waveform of voltage regulator.
12. 12 CHAPTER 3 SERIAL COMMUNICATIO USING RS-232 & MAX-232 3.1 Introduction Serial
communication is often used either to control or to receive data from an embedded microprocessor.
Serial communication is a form of I/O in which the bits of a byte begin transferred appear one after
the other in a timed sequence on a single wire. Serial communication has become the standard for
inter-computer communication. 3.1.1 RS-232 IBM introduced the DB-9 RS-232 version of serial I/O
standard, which is most widely used in PCs and several devices. In RS232, high and low bits are
represented by flowing voltage ranges: Bit Voltage range ( in V ) 0 +3 +25 1 -25 -3 Table No. 3.1-
Voltage Range The range -3V to +3V is undefined. The TTL standards came a long time after the
RS232 standard was set. Due to this reason RS232 voltage levels are not compatible with TTL logic.
Therefore, while connecting an RS232 to microcontroller system, a voltage converter is required.
This converter converts the microcontroller output level to the RS232 voltage levels, and vice versa.
IC MAX232, also known as line driver, is very commonly used for this purpose. The simplest
connection between a PC and microcontroller requires a minimum of three pins, RxD (receiver,
pin2), TxD (transmitter, pin3) and ground (pin5) of the serial port of computer.
13. 13 Fig. 3.1 RS-232 3.1.1.1 Pin Description RS-232 Pin Signal Pin Signal 1 Data Carrier Detect 6
Data Set Ready 2 Received Data 7 Request to Send 3 Transmitted Data 8 Clear to Send 4 Data
Terminal Ready 9 RingIndicator 5 Signal Ground Table No. 3.2- Pin Description of RS-232 Fig. 3.2
USB to SERIAL cable 3.1.2 MAX-232 The MAX 232 device is a dual driver/receiver that includes a
capacitive voltage generator to supply EIA-232 voltage levels from a single 5V supply. The voltage
level
14. 14 in the RS232 bus is about 30V. Each receiver converts EIA-232 inputs to 5V TTL/CMOS levels.
These receivers have a typical threshold of 1.3V and a typical hysteresis of 0.5 V, and can accept
±30V inputs. Each driver converts TTL/CMOS input levels into EIA-232 levels. It is used in battery-
powered systems, Terminals, modems, computer and many other applications. Fig. 3.3 MAX-232
3.1.2.1 Pin description of MAX-232 Pin No. Function Name 1 Capacitor connection pins Capacitor 1
+ 2 Capacitor 3 + 3 Capacitor 1 - 4 Capacitor 2 + 5 Capacitor 2 - 6 Capacitor 4 - 7 Output pin;
outputs the serially transmitted data at RS232 logic level; connected to receiver pin of PC serial port
T2 Out 8 Input pin; receives serially transmitted data at RS 232 logic level; connected to transmitter
pin of PC serial port R2 In 9 Output pin; outputs the serially transmitted data at TTL logic level;
connected to receiver pin of controller. R2 Out 10 Input pins; receive the serial data at TTL logic
level; connected T2 In
15. 15 11 to serial transmitter pin of controller. T1 In 12 Output pin; outputs the serially transmitted data
at TTL logic level; connected to receiver pin of controller R1 Out 13 Input pin; receives serially
transmitted data at RS 232 logic level; connected to transmitter pin of PC serial port R1 In 14 Output
pin; outputs the serially transmitted data at RS232 logic level; connected to receiver pin of PC serial
port T1 Out 15 Ground (0V) Ground 16 Supply voltage; 5V (4.5V – 5.5V) Vcc Table No.3.3-
Description of Pin Diagram of MAX232 3.2 Serial Communication TxD pin of serial port connects to
RxD pin of controller via MAX232. And similarly, RxD pin of serial port connects to the TxD pin of
controller through MAX232. MAX232 has two sets of line drivers for transferring and receiving data.
The line drivers used for transmission are called T1 and T2, where as the line drivers for receiver are
designated as R1 and R2. The connection of MAX232 with computer and the controller is shown in
the circuit diagram. The MAX232 IC is used to convert the TTL/CMOS logic levels to RS232 logic
levels during serial communication of microcontrollers with PC. The controller operates at TTL logic
level (0-5V) whereas the serial communication in PC works on RS232 standards (- 25 V to + 25V).
This makes it difficult to establish a direct link between them to communicate with each other. The
intermediate link is provided through MAX232. It is a dual driver/receiver that includes a capacitive
voltage generator to supply RS232 voltage levels from a single 5V supply. Each receiver converts
RS232 inputs to 5V TTL/CMOS levels. These receivers (R1 & R2) can accept ±30V inputs. The
drivers (T1 & T2), also called transmitters, convert the TTL/CMOS input level into RS232 level. The
transmitters take input from controller‟s serial transmission pin and send the output to RS232‟s
receiver. The receivers, on the other hand, take input from transmission pin of RS232 serial port and
give serial output to microcontroller‟s receiver pin. MAX232 needs four external capacitors whose
value ranges from 1µF to 22µF.
16. 16 Fig. 3.4Connection between RS232 & Microcontroller An important parameter considered while
interfacing serial port is the Baud rate which is the speed at which data is transmitted serially. It is
defined as number of bits transmitted or received per second. It is generally expressed in bps (bits
per second). AT89C51 microcontroller can be set to transfer and receive serial data at different baud
rates using software instructions. Timer1 is used to set the baud rate of serial communication for the
microcontroller. For this purpose, Timer1 is used in mode2 which is an 8-bit auto reload mode. To
get baud rates compatible with the PC, TH1 should be loaded with the values as shown: Baud Rate (
bps ) TH1 ( Hex Value ) 9600 FD 4800 FA 2400 F4 1200 E8 Table No. 3.4 - TH1 Values In this
project baud rate 9600bps is used. For serial communication P89v51RD2 has registers SBUF and
SCON (Serial control register). SBUF is an 8-bit register. For transmitting a data byte serially, it
needs to be placed in the SBUF register. Similarly whenever a data byte is received serially, it
comes in the SBUF register, i.e., SBUF register should be read to receive the serial byte.
17. 17 3.2.1 SCON (Serial Control) Register SCON register is used to set the mode of serial
communication. The project uses Mode1,in which the data length is of 8 bits and there is a start and
a stop bit. The SCON register is bit addressable register. The following table shows the configuration
of each bit SM0 SM1 SM2 REN TB8 RB8 TI RI D7 D6 D5 D4 D3 D2 D1 D0 Table No.3.5-SCON
Register Values SM0 SM1 Mode 0 0 Serial Mode 0 0 1 Serial Mode 1, 8 bit Data, 1 start bit, 1 stop
bit. 1 0 Serial Mode 2 1 1 Serial Mode 3 Table No.3.6- Serial Mode TI (transmit interrupt): It is an
important flag bit in the SCON register. The controller raises the TI flag when the 8-bit character is
transferred. This indicates that the next byte can be transferred now. The TI bit is raised at the
beginning of the stop bit. RI (receive interrupt): It is also a flag bit of the SCON register. On receiving
the serial data, the microcontroller skips the start and stop bits, and puts the byte is SBUF register.
The RI flag bit is then raised to indicate that the byte has been received and should be picked up.
3.3 HyperTerminal Hyper Terminal, a Windows XP application, can be used to receive or transmit
serial data through RS232. To open Hyper Terminal, go to Start Menu, select all programs, go to
Accessories, click on Communications and select Hyper Terminal. To start a new connection, go to
File menu and click on new connection. The connection window opens up. Give a name to your
connection and select 1st icon and click on OK.
18. 18 Connection property window opens here. Select Bit rate as 9600bps, Data bits 8, Parity as none,
Stop bit 1, Flow control none and click OK. Now the serial data can be read on hyper terminal. In
program, Timer1 is used with auto reload setting. The baud rate is fixed to 9600bps by loading TH1
to 0xFD. The value 0x50 is loaded in the SCON register. This will initialize the serial port in Mode1.
The program continuously receives a character (say “Sharda University”) from the serial port of the
computer and transmits it back. Fig. 3.5 HperTerminal
19. 19 CHAPTER 4 GPS MODULE INTERFACING 4.1 GPS (Global Positioning System) GPS (Global
Position System) is a space based satellite navigation system that provides the location and time of
a person or vehicle or any devices in every weather and anywhere on the earth 24hours a day. The
GPS receiver will receive the signal information from the GPS satellite and with the help of
triangulation; the exact location of the vehicle is traced. Fig. 4.1 GPS module 4.2 Interfacing GPS
Fig. 4.2 shows how to interface the GPS with microcontroller. The GPS module continuously
transmits serial data (RS232 protocol) in the form of sentences according to NMEA standards. The
latitude and longitude values of the location are contained in the GPGGA sentence (refer NMEA
format).To communicate over UART or USART, we just need three basic signals which are namely,
RXD (receive), TXD (transmit), GND (common ground). So to interface UART with 8051, we just
need the basic signals.
20. 20 Fig. 4.2 Interfacing GPS to Microcontroller 4.2.1 Interfacing GPS with 8051 We now want to
receive data from satellite to 8051 Primer Board by using GPS module through UART0. The serial
data is taken from the GPS module through MAX232 into the SBUF register of 8051 microcontroller
(refer serial interfacing with 8051). The serial data from the GPS receiver is taken by using the Serial
Interrupt of the controller. This data consists of a sequence of NMEA sentences from which GPGGA
sentence is identified and processed. Fig. 4.3Circuit Diagram to Interface GPS with 8051
21. 21 4.3 Source Code The first six bytes of the data received are compared with the pre-stored string
and if matched then only data is further accounted for; otherwise the process is repeated again.
From the comma delimited GPGGA sentence, latitude and longitude positions are extracted by
finding the respective comma positions and extracting the data. 3.4 Compilation of Code To compile
the above C code we use the KEIL software. We properly set up the KIEL and we correctly set the
project to proper compilation of the code. To compile the above code, 1st we had created Hex file fro
the C file and then added it to the project. 3.5 Testing of GPS To test GPS we connected GPS
modem to the PC through USB to SERIAL cable with the help of RS-232. Then we open the Hyper
Terminal screen, select which port we are using and set the default settings. Now the screen shows
some text messages.
22. LDB9 connector (Serial Port) provided for easy interfacing Input Voltage : 5V to 12V DC  Normal
Operation Temperature : -20 °C to +55 °C  Most Status and Controlling pins are available  Audio
Interface Connectors (Audio in and Audio out)  Inbuilt Powerful TCP / IP (Transfer Control Protocol
/ Internet Protocol) stack for internet data transfer through GPRS (General Packet Radio Service) 
Built in Network Status LED  Built in SIM (Subscriber Identity Module) Card holder  SMA (Sub
Miniature version A) connector with GSM L Type Antenna  Configurable Baud Rate  Built in
RS232 to TTL or viceversa Logic Converter (MAX232)  Quad Band GSM/GPRS : 850 / 900 / 1800
/ 1900 MHz 22 CHAPTER 5 GSM MODULE Interfacing 5.1 GSM (Global System for Mobile
Communication) A GSM modem is a special type of modem which accepts a SIM card, and
operates over a subscription to a mobile operator, just like a mobile phone. GSM (Global system for
mobile) uses a process called circuit switching. This method of communication allows a path to be
established between two devices. Once the two devices are connected, a constant stream of digital
data is relayed. Fig. 5.1 GSM Module. 5.1.1 Features of GSM
23. 23 Fig. 5.2 GSM Component Description. 5.2 Interfacing GPS Fig. 5.3 shows how to interface the
GSM with microcontroller. The GSM module is communicate the microcontroller with mobile phones
through UART. To communicate over UART or USART, we just need three basic signals which are
namely, RXD (receive), TXD (transmit), GND (common ground). GSM modem interfacing with
microcontroller for SMS control of industrial equipments. The sending SMS through GSM modem
when interfaced with microcontroller or PC is much simpler as compared with sending SMS through
UART. Text message may be sent through the modem by interfacing only three signals of the serial
interface of modem with microcontroller i.e., TxD, RxD and GND. The transmit signal of serial port of
microcontroller is connected with receive signal (RxD) of the serial interface of GSM Modem while
receive signal of microcontroller serial port is connected with transmite signal (TxD) of serial
interface of GSM Modem. The SMS message in text mode can contain only 140 characters at the
most. It depends upon the amount of information collected from GPS Engine that you need at the
base station for tracking vehicle or person.
24. 24 Fig. 5.3 Interfacing GSM to Microcontroller 5.2.1 Interfacing GSM with 8051 We now want to
display a text in mobile from 8051 by using GSM module through UART. 8051 contains two serial
interfaces that are UART0 & UART1. Here we are using UART0. The GSM modem is being
interfaced with the microcontroller 8051 for SMS communication. The SMS can be sending and
receiving for the data sharing and situation information and control. Fig. 5.4 Circuit Diagram to
Interface GSM with 8051 5.3 AT Commands The following Commands and sequence of events
performed for sending text message to a mobile phone through GSM Modem interfaced with
microcontroller:
25. 25 1. First select the text mode for SMS by sending the following AT Command to GSM Modem :
AT+CMGF = 1 . This command configures the GSM modem in text mode. 2. Send the following AT
Command for sending SMS message in text mode along with mobile number to the GSM Modem :
AT+CMGS =+923005281046 . This command sends the mobile number of the recipient mobile to
the GSM modem. 3. Send the text message string ("GSM Modem Test") to the GSM Modem This is
a test message from UART". 4. Send ASCII code for CTRL+Z i.e., 0x1A to GSM Modem to transmit
the message to mobile phone. After message string has been sent to the modem, send CTRL+Z to
the micro-controller, which is equivalent to 0x1A (ASCII value).
26. Low EMI mode (ALE inhibit) Second DPTR register  Eight interrupt sources with four priority
levels  Programmable Watchdog timer (WDT)  Three 16-bit timers/counters  Four 8-bit I/O ports
with three high-current Port 1 pins (16 mA each)  PCA (Programmable Counter Array) with PWM
and Capture/Compare functions  SPI (Serial Peripheral Interface) and enhanced UART  Supports
12-clock (default) or 6-clock mode selection via software or ISP  64 kB of on-chip Flash program
memory with ISP (In-System Programming) and IAP (In-Application Programming)  5 V Operating
voltage from 0 to 40 MHz  80C51 Central Processing Unit 26 CHAPTER 6
MICROCONTROLLER P89V51RD2 6.1 INTRODUCTION The P89V51RD2 is an 80C51
microcontroller with 64 kB Flash and 1024 bytes of data RAM. A key feature of the P89V51RD2 is its
X2 mode option. The design engineer can choose to run the application with the conventional 80C51
clock rate (12 clocks per machine cycle) or select the X2 mode (6 clocks per machine cycle) to
achieve twice the throughput at the same clock frequency. Another way to benefit from this feature is
to keep the same performance by reducing the clock frequency by half, thus dramatically reducing
the EMI. The Flash program memory supports both parallel programming and in serial In-System
Programming (ISP). Parallel programming mode offers gang- programming at high speed, reducing
programming costs and time to market. ISP allows a device to be reprogrammed in the end product
under software control. The capability to field/update the application firmware makes a wide range of
applications possible. The P89V51RD2 is also In-Application Programmable (IAP), allowing the
Flash program memory to be reconfigured even while the application is running. 6.2 FEATURES
27. Idle mode 6.3 BLOCK DIAGRA Figure 6.1 Architecture of P89V51 6.4 PIN DESCRIPTION Figure
6.2 Pin Diagram of P89V51 Power-down mode with external interrupt wake-up  Low power modes
 Brown-out detection  TTL- and CMOS-compatible logic levels 27
28. 28 VDD Supply voltage. VSS Ground. Port 0 Port 0 is an 8-bit open drain bi-directional I/O port. Port
0 pins that have „1‟s written to them float, and in this state can be used as high-impedance inputs.
Port 0 is also the multiplexed low-order address and data bus during accesses to external code and
data memory. In this application, it uses strong internal pull-ups when transitioning to „1‟s. Port 0 also
receives the code bytes during the external host mode programming, and outputs the code bytes
during the external host mode verification. External pull-ups are required during program verification
or as a general purpose I/O port. Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pull-ups.
The Port 1 pins are pulled high by the internal pull-ups when „1‟s are written to them and can be
used as inputs in this state. As inputs, Port 1 pins that are externally pulled LOW will source current
(IIL) because of the internal pull-ups. P1.5, P1.6, P1.7 have high current drive of 16 mA. Port 1 also
receives the low-order address bytes during the external host mode programming and verification.
Table 6.1 Alternate function of Port-1 Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pull-
ups. Port 2 pins are pulled HIGH by the internal pull-ups when „1‟s are written to them and can be
used as inputs in this state. As inputs, Port 2 pins that are externally pulled LOW will source current
(IIL) because of the internal pull-ups. Port 2 sends the high-order address byte during fetches from
external program memory and during accesses to external Data Memory that use 16-bit address
(MOVX@DPTR). In this application, it uses strong internal pull-ups when
29. 29 transitioning to „1‟s. Port 2 also receives some control signals and a partial of high-order address
bits during the external host mode programming and verification. Port 3 Port 3 is an 8-bit
bidirectional I/O port with internal pull-ups. Port 3 pins are pulled HIGH by the internal pull-ups when
„1‟s are written to them and can be used as inputs in this state. As inputs, Port 3 pins that are
externally pulled LOW will source current (IIL) because of the internal pull-ups. Port 3 also receives
some control signals and a partial of high-order address bits during the external host mode
programming and verification. Table 6.2 Alternate Function of Port-3 RXD: serial input port TXD:
serial output port INT0: external interrupt 0 input INT1: external interrupt 1 input T0: external count
input to Timer/Counter 0 T1: external count input to Timer/Counter 1 WR: external data memory
write strobe RD: external data memory read strobe Program Store Enable: PSEN is the read strobe
for external program memory. When the device is executing from internal program memory, PSEN is
inactive (HIGH). When the device is executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are skipped during each
30. 30 access to external data memory. A forced HIGH-to-LOW input transition on the PSEN pin while
the RST input is continually held HIGH for more than 10 machine cycles will cause the device to
enter external host mode programming. Reset: While the oscillator is running, a HIGH logic state on
this pin for two machine cycles will reset the device. If the PSEN pin is driven by a HIGH-to-LOW
input transition while the RST input pin is held HIGH, the device will enter the external host mode,
otherwise the device will enter the normal operation mode. Figure 6.3 Reset Circuit External Access
Enable: EA must be connected to VSS in order to enable the device to fetch code from the external
program memory. EA must be strapped to VDD for internal program execution. However, Security
lock level 4 will disable EA, and program execution is only possible from internal program memory.
The EA pin can tolerate a high voltage of 12 V. Address Latch Enable: ALE is the output signal for
latching the low byte of the address during an access to external memory. This pin is also the
programming pulse input (PROG) for flash programming. Normally the ALE is emitted at a constant
rate of 1¤6 the crystal frequency and an be used for external timing and clocking. One ALE pulse is
skipped during each access to external data memory. However, if AO is set to „1‟, ALE is disabled.
Crystal 1: Input to the inverting oscillator amplifier and input to the internal clock generator circuits.
31. 31 Crystal 2: Output from the inverting oscillator amplifier. Figure 6.4 Oscillator Circuit 6.5 Functional
Description 6.5.1 Memory organization The device has separate address spaces for program and
data memory. 6.5.1.1 Flash program memory There are two internal flash memory blocks in the
device. Block 0 has 64 kbytes and contains the user‟s code. Block 1 contains the Philips-provided
ISP/IAP routines and may be enabled such that it overlays the first 8 kbytes of the user code
memory. The 64 kB Block 0 is organized as 512 sectors, each sector consists of 128 bytes. Access
to the IAP routines may be enabled by clearing the BSEL bit in the FCF register. However, caution
must be taken when dynamically changing the BSEL bit. Since this will cause different physical
memory to be mapped to the logical program address space, the user must avoid clearing the BSEL
bit when executing user code within the address range 0000H to 1FFFH. 6.5.1.2 Data RAM memory
The data RAM has 1024 bytes of internal memory. The device can also address up to 64 kB for
external data memory. 6.5.1.3 Expanded data RAM addressing The P89V51RD2 has 1 kB of RAM.
The device has four sections of internal data memory: 1. The lower 128 bytes of RAM (00H to 7FH)
are directly and indirectly addressable.
32. 32 2. The higher 128 bytes of RAM (80H to FFH) are indirectly addressable. 3. The special function
registers (80H to FFH) are directly addressable only. 4. The expanded RAM of 768 bytes (00H to
2FFH) is indirectly addressable by the move external instruction (MOVX) and clearing the EXTRAM
bit Since the upper 128 bytes occupy the same addresses as the SFRs, the RAM must be accessed
indirectly. The RAM and SFRs space are physically separate even though they have the same
addresses. 6.5.2 Flash memory In-Application Programming 6.5.2.1 Flash organization The
P89V51RD2 program memory consists of a 64 kB block. An In-System Programming (ISP)
capability, in a second 8 kB block, is provided to allow the user code to be programmed in-circuit
through the serial port. There are three methods of erasing or programming of the Flash memory
that may be used. First, the Flash may be programmed or erased in the end-user application by
calling low-level routines through a common entry point (IAP). Second, the on-chip ISP boot loader
may be invoked. This ISP boot loader will, in turn, call low-level routines through the same common
entry point that can be used by the end-user application. Third, the Flash may be programmed or
erased using the parallel method by using a commercially available EPROM programmer which
supports this device. 6.5.2.2 Boot block When the microcontroller programs its own Flash memory,
all of the low level details are handled by code that is contained in a Boot block that is separate from
the user Flash memory. A user program calls the common entry point in the Boot block with
appropriate parameters to accomplish the desired operation. Boot block operations include erase
user code, program user code, program security bits, etc. A Chip-Erase operation can be performed
using a commercially available parallel programer. This operation will erase the contents of this Boot
Block and it will be necessary for the user to reprogram this Boot Block (Block 1) with the Philips-
provided ISP/IAP code in order to use the ISP or IAP capabilities of this device.
33. 33 6.5.2.3 Power-On reset code execution Following reset, the P89V51RD2 will either enter the
SoftICE mode (if previously enabled via ISP command) or attempt to autobaud to the ISP boot
loader. If this autobaud is not successful within about 400 ms, the device will begin execution of the
user code. 6.5.2.4 In-System Programming (ISP) In-System Programming is performed without
removing the microcontroller from the system. The In-System Programming facility consists of a
series of internal hardware resources coupled with internal firmware to facilitate remote
programming of the P89V51RD2 through the serial port. This firmware is provided by Philips and
embedded within each P89V51RD2 device. The Philips In-System Programming facility has made
in-circuit programming in an embedded application possible with a minimum of additional expense in
components and circuit board area. The ISP function uses five pins (VDD, VSS, TxD, RxD, and
RST). Only a small connector needs to be available to interface your application to an external circuit
in order to use this feature. 6.5.2.5 Using the In-System Programming The ISP feature allows for a
wide range of baud rates to be used in your application, independent of the oscillator frequency. It is
also adaptable to a wide range of oscillator frequencies. This is accomplished by measuring the bit-
time of a single bit in a received character. This information is then used to program the baud rate in
terms of timer counts based on the oscillator frequency. The ISP feature requires that an initial
character (an uppercase U) be sent to the P89V51RD2 to establish the baud rate. The ISP firmware
provides auto-echo of received characters. Once baud rate initialization has been performed, the
ISP firmware will only accept Intel Hex-type records. In the Intel Hex record, the „NN‟ represents the
number of data bytes in the record. The P89V51RD2 will accept up to 32 data bytes. The „AAAA‟
string represents the address of the first byte in the record. If there are zero bytes in the record, this
field is often set to 0000. The „RR‟ string indicates the record type. A record type of „00‟ is a data
record. A record type of „01‟ indicates the end-of-file mark. In this application, additional record types
will be added to indicate either commands or data for the ISP facility. The maximum number of
34. 34 data bytes in a record is limited to 32 (decimal). As a record is received by the P89V51RD2, the
information in the record is stored internally and a checksum calculation is performed. The operation
indicated by the record type is not performed until the entire record has been received. Should an
error occur in the checksum, the P89V51RD2 will send an „X‟ out the serial port indicating a
checksum error. If the checksum calculation is found to match the checksum in the record, then the
command will be executed. In most cases, successful reception of the record will be indicated by
transmitting a „.‟ character out the serial port. 6.6 FUNCTIONAL DESCRIPTION The function of the
pins of microcontroller P89V51 used in the REAL TIME VEHICLE TRACKING SYSTEM can be
described as follows: – Pin no 9 is connected to the reset button to reset the microcontroller
automatically when we switch on the power. It is a Power on reset. – Pin no 10 & 11 of PORT 3 is
connected MAX-232 and GSM Module. – Pin no 14 and 15 of PORT 3 is connected to RS and
ENABLE pin of LCD respectively. – Crystal is connected to the pin no 18(XTAL 1) and pin no
19(XTAL 2) providing 11.0592 MHz frequency. – Pin no 20 is connected to the ground (GND). – Pin
no 31( EA/Vpp) should be strapped to VCC for internal program executions, this pin also receives
the 12-volt programming enable voltage (VPP) during flash programming. – Pin no 32 – 39 of PORT
0 are connected to the DB0-DB7 (8-bit) data lines of LCD display. – Pin no 40 is connected to the
positive supply (Vcc)
35. 35 CHAPTER 7 LIQUID CRYSTAL DISPLAY 7.1 INTRODUCTION Fig. 7.1 LCD ry simple to
interface with the controller as well as are cost effective. The most commonly used
ALPHANUMERIC displays are 1x16 (Single Line & 16 characters), 2x16 (Double Line & 16
character per line) & 4x20 (four lines & Twenty characters per line). The LCD requires 3 control lines
(RS, R/W & EN) & 8 (or 4) data lines. The number on data lines depends on the mode of operation.
If operated in 8-bit mode then 8 data lines + 3 control lines i.e. total 11 lines are required. And if
operated in 4-bit mode then 4 data lines + 3 control lines i.e. 7 lines are required. How do we decide
which mode to use? It‟s simple if you have sufficient data lines you can go for 8 bit mode & if there is
a time constrain i.e. display should be faster then we have to use 8-bit mode because basically 4- bit
mode takes twice as more time as compared to 8-bit mode. 7.2 PIN DESCRIPTION Pin Symbol
Function 1 Vss Ground 2 Vdd Supply Voltage 3 Vo Contrast Setting
36. 36 4 RS Register Select 5 R/W Read/Write Select 6 En Chip Enable Signal 7-14 DB0-DB7 Data
Lines 15 A/Vee Gnd for the backlight 16 K Vcc for backlight Table 7.1 Pin Description of LCD Figure
7.2 Pin Discription 1.RS(Register Select) When RS is low (0), the data is to be treated as a
command. When RS is high (1), the data being sent is considered as text data which should be
displayed on the screen. 2. R/W(Read/Write)
37. Wait for 1Ms Select bus width (0x30 - for 8-bit and 0x20 for 4-bit)  Wait for 1mS  Send third init
value (0x30)  Wait for about 1mS  Send second init value (0x30)  Wait for about 10mS  Send
the first init value (0x30)  Wait for about 20mS 37 When R/W is low (0), the information on the
data bus is being written to the LCD. When RW is high (1), the program is effectively reading from
the LCD. Most of the times there is no need to read from the LCD so this line can directly be
connected to GND thus saving one controller line. 3. E(enable) The ENABLE pin is used to latch the
data present on the data pins. A HIGH - LOW signal is required to latch the data. The LCD interprets
and executes our command at the instant the EN line is brought low. If you never bring EN low, your
instruction will never be executed. 4. D0-D7 The 8 bit data pins D0-D7 are used to send information
to the LCD or read the contents of the LCD‟s internal registers. .To display any character on LCD
micro controller has to send its ASCII value to the data bus of LCD. For e.g. to display 'AB'
microcontroller has to send two hex bytes 41h and 42h respectively LCD display used here is having
16x2 size. It means 2 lines each with 16 characters. In 4-bit mode the data is sent in nibbles, first we
send the higher nibble and then the lower nibble. To enable the 4-bit mode of LCD, we need to
follow special sequence of initialization that tells the LCD controller that user has selected 4-bit mode
of operation. We call this special sequence as resetting the LCD. Following is the reset sequence of
LCD.
38. 38 7.3 LCD CONNECTIONS IN 8-BIT MODE Figure 7.3 LCD Connection in 8-bit Mode 7.4
FUNCTIONAL DESCRIPTION 7.4.1 Writing and reading the data from the LCD Writing data to the
LCD is done in several steps: 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 Read data
from data lines (if it is reading): 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
EXAMPLE: Fig. 7.4 Example LCD connection.
39. 39 7.5 LCD COMMAND CODES 1. CLEAR DISPLAY SCREEN 2. RETURN HOME 4 DECREMENT
CURSOR ( SHIFT CURSOR TO LEFT) 5 SHIFT DISPLAY RIGHT. 6. INCREMENT CURSOR (
SHIFT CURSOR TO RIGHT) 7. SHIFT DISPLAY LEFT 8. DISPLAY OFF, CURSOR OFF A
DISPLAY OFF CURSOR ON C DISPLAY ON CURSOR OFF E DISPLAY ON CURSOR BLINKING
F. DISPLAY ON CURSOR BLINKING. 10. SHIFT CURSOR POSITION TO LEFT 14. SHIFT
CURSOR POSITION TO RIGHT 18. SHIFT THE ENTIRE DISPLAY TO THE LEFT 1C SHIFT THE
ENTIRE DISPLAY TO THE RIGHT 80 FORCE CURSOR TO BEGINNING OF IST LINE C0 FORCE
CURSOR TO BEGINNING OF 2ND LINE 38 2 LINES AND 5 X 7 MATRIX 7.5.1 Checking the busy
status of LCD The code to check the status of LCD whether it is busy or not is as follows:
WAIT_LCD: SETB EN ;Start LCD command CLR RS ;It's a command SETB RW ;It's a read
command MOV DATA, #0FFh ;Set all pins to FF initially MOV A,DATA ;Read the return value JB
ACC.7,WAIT_LCD ;If bit 7 high, LCD still busy CLR EN ;Finish the command
40. 40 CLR RW ;Turn off RW for future commands RET Thus, our standard practice will be to send an
instruction to the LCD and then call our WAIT_LCD routine to wait until the instruction is completely
executed by the LCD. This will assure that our program gives the LCD the time it needs to execute
instructions and also makes our program compatible with any LCD, regardless of how fast or slow it
is. 7.5.2 Initializing the LCD The code to initialize the LCD is as follows: INIT_LCD: SETB EN CLR
RS MOV DATA, #38h CLR EN LCALL WAIT_LCD SETB EN CLR RS MOV DATA, #0Eh CLR EN
LCALL WAIT_LCD SETB EN CLR RS MOV DATA, #06h CLR EN LCALL WAIT_LCD RET Having
executed this code the LCD will be fully initialized and ready for us to send display data to it. 7.5.3
Clearing the display The code to clear the LCD display is as follows:
41. 41 CLEAR_LCD: SETB EN CLR RS MOV DATA,#01h CLR EN LCALL WAIT_LCD RET we may
clear the LCD at any time by simply executing an LCALL CLEAR_LCD. 7.5.4 Writing text to the LCD
The code to write any text to the LCD is as follows: WRITE_TEXT: SETB EN SETB RS MOV
DATA,A CLR EN LCALL WAIT_LCD RET The WRITE_TEXT routine that we just wrote will send the
character in the accumulator to the LCD which will, in turn, display it. Thus to display text on the LCD
all we need to do is load the accumulator with the byte to display and make a call to this routine.
42. 42 CHAPTER 8 PROJECT DESCRIPTION 8.1 CIRCUIT DIAGRAM Figure 8.1 Circuit Diagram of
VTS 8.2 Functional Description The function of the pins of microcontroller P89V51RD2 used in the
REAL TIME VEHICLE TRACKING SYSTEM can be described as follows: – Pin no 9 is connected to
the reset button to reset the microcontroller automatically when we switch on the power. It is a
Power on reset. – Pin no 10 & 11 of PORT 3 is connected MAX-232 and GSM Module. – Pin no 14
and 15 of PORT 3 is connected to RS and ENABLE pin of LCD respectively. – Crystal is connected
to the pin no 18(XTAL 1) and pin no 19(XTAL 2) providing 11.0592 MHz frequency. – Pin no 20 is
connected to the ground (GND). – Pin no 31( EA/Vpp) should be strapped to VCC for internal
program executions, this pin also receives the 12-volt programming enable voltage (VPP) during
flash programming.
43. 43 – Pin no 32 – 39 of PORT 0 are connected to the DB0-DB7 (8-bit) data lines of LCD display. –
Pin no 40 is connected to the positive supply (Vcc) 8.3 WORKING OF THE SYSTEM The working of
this project is controlled by a microcontroller PHILIPS P89V51RD2. The project works in the
following ways: 1. Switch on power supply. 2. Message “vts using gps & gsm” will appear on LCD. 3.
GPS start receiving the data from the satellite and then send the data to tha microcontroller. 4.
Microcontroller extract the useful data received from GPS. 5. Longitude and Latitude will appear on
LCD. 6. Microcontroller send the Longitude and Latitude by SMS using GSM modem. 8.4 LIST OF
COMPONENTS S. NO. Components Name Quantity 1. 12V Adepter 4 2. 7805 Voltage regulater 2
3. Capacitor 33pF 2 4. Crystal oscillator 11.0592MHz 1 5. Capacitor 10 uF 10 6. Push button 2 7.
LCD 1 8. Max-232 1 9 RS-232 1 10. Male and female connectors 8 11. GPS Module 1 12. GSM
Module 2 Table 8.1 List of Components
44. 44 CHAPTER 9 SOFTWARE 9.1 Keil 9.1.1 Introduction Compilers are programs used to convert a
High Level Language to object code. Desktop compilers produce an output object code for the
underlying microprocessor, but not for other microprocessors. I.E the programs written in one of the
HLL like „C‟ will compile the code to run on the system for a particular processor like x86 (underlying
microprocessor in the computer). For example compilers for Dos platform is different from the
Compilers for Unix platform So if one wants to define a compiler then compiler is a program that
translates source code into object code. The compiler derives its name from the way it works,
looking at the entire piece of source code and collecting and reorganizing the instruction. See there
is a bit little difference between compiler and an interpreter. Interpreter just interprets whole program
at a time while compiler analyzes and execute each line of source code in succession, without
looking at the entire program. Fig. 9.1 Keil 9.1.2 Keil cross compiler Keil is a German based
Software development company. It provides several development tools like • IDE (Integrated
Development environment) • Project Manager • Simulator
45. 45 • Debugger • C Cross Compiler , Cross Assembler, Locator/Linker Keil Software provides you
with software development tools for the 8051 family of microcontrollers. With these tools, you can
generate embedded applications for the multitude of 8051 derivatives. Keil provides following tools
for 8051 development 1. C51 Optimizing C Cross Compiler, 2. A51 Macro Assembler, 3. 8051
Utilities (linker, object file converter, library manager), 4. Source-Level Debugger/Simulator, 5.
µVision for Windows Integrated Development Environment. The keil 8051 tool kit includes three
main tools, assembler, compiler and linker. An assembler is used to assemble your 8051 assembly
program A compiler is used to compile your C source code into an object file A linker is used to
create an absolute object module suitable for your in-circuit emulator. 8051 project development
cycle: - these are the steps to develop 8051 project using keil 1. Create source files in C or
assembly. 2. Compile or assemble source files. 3. Correct errors in source files. 4. Link object files
from compiler and assembler. 5. Test linked application. 9.2 Proteus 9.2.1 Introduction Proteus is a
software for microprocessor/microcontroller simulation, schematic capture, and printed circuit board
(PCB) design. It is developed by Labcenter Electronics. Proteus PCB design combines the ISIS
schematic capture and ARES PCB layout programs to provide a powerful, integrated and easy to
use suite of tools for professional PCB Design. All Proteus PCB design products include an
integrated shape based autorouter and a basic SPICE simulation capability as standard. More
advanced routing
46. PROSPICE Mixed mode SPICE simulation - industr ISIS Schematic Capture - a tool for entering
designs. 46 modes are included in Proteus PCB Design Level 2 and higher whilst simulation
capabilities can be enhanced by purchasing the Advanced Simulation option and/or micro-controller
simulation capabilities. Fig 9.2 Proteus 9.2.2 System Components System Benefits Integrated
package with common user interface and fully context sensitive help. 9.3 Flash Magic Flash Magic is
a tool which used to program hex code in EEPROM of micro-controller. it is a freeware tool. It only
supports the micro-controller of Philips and NXP. You can burn a hex code into those controller
which supports ISP (in system programming) feature. To check whether your micro-controller
supports ISP or not take look at its datasheet. So if your device supports ISP then you can easily
burn a hex code into EEPROM of your device. VSM - Virtual System Modeling lets co-simulate
embedded software for popular microcontrollers alongside hardware design.  ARES PCB Layout -
PCB design system with automatic component placer, rip- up and retry auto-router and interactive
design rule checking. y standard SPICE3F5 simulator combined with a digital simulator.
47. 47 Flash magic supports several chips like ARM Cortex M0, M3, M4, ARM7 and 8051. The
procedure to program code memory is very easy and needs only five steps to configure Flash magic
for better operation. Flash magic use Serial or Ethernet protocol to program the flash of device. Fig.
9.3 FlashMagic
48. 48 CHAPTER 10 CONCLUSIONS The three potential of this project is reach, relevant and result.
Firstly it will provide marketers a fantastic reach. Today almost all people carry their mobile phones.
Secondly, this system gives customer control since they get more precise information, personalized
message and targeted offer. Thirdly, it is a unique medium since marketers have better
understanding of customers need. This will result in high impact of advertisement and greater human
satisfaction. This system has both strength and weakness. Some consumers think that this system
hack their privacy and they feel the risk of being monitored. In order to have the system in the
market, it is necessary to establish and maintain the trust of a consumer. The best way is to give
confidence to the consumers that they will only receive the relevant information.
49. 49 CHAPTER 11 RESULTS AND FUTUTRE SCOPE Result With the help of this system position of
a device or person can be detected. This system coves all the theoretical and practical areas related
to n this project. A small movement of a person or a device is noticeable with this system. It enables
its user to track and trace their vehicle, mobile assets. It performs the task which can be used by
military or police and also it can be used for personal security. This project presents the automotive
localization system using GPS and GSM services. The system permits localization of automobile
and transmitting the position to the owner on his mobile phone as a short message (SMS) at his
request. The system can be interconnected with the car alarm system and alert the owner on his
mobile phone. The present application is a low cost solution for automobile position and status, very
useful in case of car theft situation, for monitoring adolescent drivers by their parents as well as in
car tracking system applications. The proposed solution can be used in other types of application,
where the information needed is requested rarely and at irregular period of time (when requested).
Scope Vehicle tracking system is becoming increasingly important in large cities and it is more
secured than other systems. Now a day‟s vehicle thefting is rapidly increasing , with this we can
have a good control in it. The vehicle can be turned off by only with a simple SMS. Since, now a
days the cost of the vehicles are increasing they will not step back to offord it. This setup can be
made more interactive by adding a display to show some basic information about the vehicle and
also add emergency numbers which can be used in case of emergency. Upgrading this setup is very
easy which makes it open to future requirements without the need of rebuilding everything from
scratch, which also makes it more efficient.
50. 50 APPENDIX-A GPS Coding #include<reg51.h> //Define 8051 Registers void serial(void); //Serial
Communication Register void DelayMs(unsigned int); //Delay Function unsigned int i,j; unsigned
char b[25],d; //--------------------------- // Main Program //--------------------------- void main() { EA=1;
//Enable All Interrupt ES=1; //Enable Serial Port Interrupt serial(); //Serial Communication while(1);
//Loop Forever } //---------------------------------------------------------- // Serial Communication Register
Initialization //---------------------------------------------------------- void serial(void) { TMOD=0X20; //Timer1,
Mode2 SCON=0X50; //Serial Mode1, Receive Enable TH1=0XFD; //Baud Rate 9600bps TR1=1;
//Timer1 ON } //----------------------------------------- // Serial Interrupt Function //----------------------------------
-------
51. 51 void serin (void) interrupt 4 //Serial Port Interrupt { if(RI==1) //Receive Interrupt Gets Enabled {
//after Stop Bit get Received d=SBUF; //Serial Buffer value moved to a variable b[j]=d; SBUF=b[j];
DelayMs(20); //Delay Function j++; } SCON=0X50; //Initialising Receive and Transmit Interrupt } //----
----------------------------- // Delay Function //--------------------------------- void DelayMs(unsigned int k) {
unsigned int i; for(i=0;i<=k;i++); }
52. 52 APPENDIX-B GSM Coding in C //------------------------------------------------- Setup the serial port for
9600 baud at 11.0592MHz. //------------------------------------------------- void serial_init(void) { SCON =
0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit
reload */ TH1 = 0xFD; /* TH1: reload value for 9600 baud @ 11.0592MHz*/ TR1 = 1; /* TR1: timer 1
run */ TI = 1; /* TI: set TI to send first char of UART */ } //------------------------------------- // Main program
starts here //------------------------------------- void main(void) { serial_init(); //serial initialization
printf("AT+CMGF=1%c",13); delay(20); //Text Mode | hex value of 13 is 0x0D (CR )
printf("AT+CMGS="9136701213"%c",13); delay(20); //Type your mobile number Eg : "9136701213"
printf("Hi :-) GSM Modem Test"); delay(20); //Type text as u want printf("%c",0x1A); delay(20); //line
feed command while(1); }
53. 53 APPENDIX-C Coding of VTS #include<reg51.h> #include<string.h> sfr dt=0x80; sbit rs=P3^4;
sbit en=P3^5; void init(); void cmd(unsigned char); void ldt(unsigned char); void delay(int); void
lcd(unsigned char*); void serial(char*); void send1(char); unsigned char n[70],i=0,k=0,j=0; unsigned
char aa[12],bb[12]; unsigned char code l1[]="longitude"; unsigned char code l2[]="latitude"; unsigned
char code l3[]="$GPGSA,"; void srl1() interrupt 4 { if(SBUF=='$') { if(k>0) { IE=0X00; } k++; i=0; }
n[i]=SBUF; i++; RI=0; } //----------------------------------------------------------- MAIN PROGRAM ----------------
--------------------------------------------// void main() { int m=0,a1=0,b1=0; TMOD=0X20; IE=0X90; TH1=-
3;
54. 54 SCON=0X50; TR1=1; init(); lcd("vts with gps&gsm"); IE=0X00; serial("at"); send1(13); delay(200);
serial("at+cmgf=1"); send1(13); delay(200); IE=0X90; while(1) { m=0,a1=0,b1=0; while(n[m++]!=',');
while(n[m++]!=','); while(n[m]!=',') aa[a1++]=n[m++]; m=m+3; while(n[m]!=',') bb[b1++]=n[m++];
cmd(0x01); cmd(0x83); lcd(l2); cmd(0xc5); lcd(aa); delay(500); cmd(0x01); cmd(0x83); lcd(l1);
cmd(0xc5); lcd(bb); IE=0X00; serial("at+cmgs="); send1('"'); serial("9136701213"); send1('"');
send1(13); delay(200); serial(l2); send1(13); serial(aa); send1(13); serial(l1); send1(13);
55. 55 serial(bb); send1(26); delay(200); IE=0X90; delay(500); while(1); } } //-------------------------------------
---- LCD INITIATION ------------------------------------------// void init() { cmd(0x38); delay(20); cmd(0x0c);
delay(20); cmd(0x01); delay(20); cmd(0x80); delay(20); } //--------------------------------------------- LCD
COMMAND MODE ---------------------------------------------// void cmd(unsigned char a) { rs=0; dt=a;
en=1; delay(1); en=0; } //----------------------------------------------- LCD DATA MODE ---------------------------
---------------------// void ldt(unsigned char a) { rs=1; dt=a; en=1; delay(1); en=0; } //--------------------------
-------------------------
56. 56 DELAY PROGRAM ----------------------------------------------------// void delay(int x) { int y,z;
for(y=0;y<x;y++) for(z=0;z<1275;z++); } //--------------------------------------------------- SENDING STRING
TO LCD ----------------------------------------------------// void lcd(unsigned char *s) { while(*s!='0') { ldt(*s);
s++; } } //------------------------------------------------- SERIAL COMMUNICATION ---------------------------------
-----------------// void serial(char *t) { while(*t!='0') { SBUF=*t; while(TI==0); TI=0; t++; } } //-----------------
-------------------------------------- SENDING STRING SERIALLY -----------------------------------------------------
---// void send1(char aa) { SBUF=aa; while(TI==0); TI=0; }
57. 57 APPENDIX-D JAVA Application Code import gnu.io.CommPort; import
gnu.io.CommPortIdentifier; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import
gnu.io.SerialPortEventListener; import java.awt.Desktop; import java.io.IOException; import
java.io.InputStream; import java.io.OutputStream; import java.net.*; import java.util.*; public class
Test { public Test() { super(); } void connect ( String portName ) throws Exception {
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); if (
portIdentifier.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else {
CommPort commPort = portIdentifier.open(this.getClass().getName(),2000); if ( commPort
instanceof SerialPort ) { SerialPort serialPort = (SerialPort) commPort;
serialPort.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,S
erialPort.PARITY_NONE); InputStream in = serialPort.getInputStream(); OutputStream out =
serialPort.getOutputStream(); serialPort.addEventListener(new SerialReader(in));
58. 58 serialPort.notifyOnDataAvailable(true); (new Thread(new SerialWriter(out))).start(); } else {
System.out.println("Error: Only serial ports are handled by this example."); } } } /** * Handles the
input coming from the serial port. A new line character * is treated as the end of a block in this
example. */ public static class SerialReader implements SerialPortEventListener { private
InputStream in; private byte[] buffer = new byte[1024]; public static StringBuffer sb=new
StringBuffer(); public static int count=0; public SerialReader(InputStream in) { this.in = in; } public
void serialEvent(SerialPortEvent arg0) { int data; try { new Timer().scheduleAtFixedRate(new
TimerTask() { @Override public void run() { System.out.println(sb);
System.out.println("=========================="); String str=new String(sb); String
sp[]=str.split("latitude"); String latitude=sp[1].substring(0,5); String sp1[]=sp[1].split("longitude");
String longitude=sp1[1].substring(2,6); StringBuffer sb1=new StringBuffer(latitude); sb1.insert(3,'.');
//sb1.append('N'); System.out.println(sb1);
59. 59 StringBuffer sb2=new StringBuffer(longitude); sb2.insert(2,'.'); //sb2.append('E'); try{
//LatLong.main(new String(sb1),new String(sb2)); // String
str1="http://maps.google.com/maps?q="+sb1+","+sb2; // URI u=new URI(str1); //
System.out.println("hello welcome"+str1); // Desktop.getDesktop().browse(u); new LatLong(new
String(sb1),new String(sb2)); } catch (Exception e) { System.out.println(e); // TODO: handle
exception } System.out.println(sb2); System.out.println("latitude ="+latitude);
System.out.println("longitude ="+longitude); System.out.println("==========================");
sb=new StringBuffer(); count=0; } },1000,1000000); int len = 0; while ((data = in.read()) > -1) { if (data
== 'n') { break; } buffer[len++] = (byte) data; if(true){ sb.append((char)data); } } //System.out.print(new
String(buffer, 0, len)); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } }
60. 60 } /** */ public static class SerialWriter implements Runnable { OutputStream out; public
SerialWriter ( OutputStream out ) { this.out = out; } public void run () { try { int c = 0; while ( ( c =
System.in.read()) > -1 ) { this.out.write(c); } } catch ( IOException e ) { e.printStackTrace();
System.exit(-1); } } } public static void main ( String[] args ) { try { (new Test()).connect("COM5"); }
catch ( Exception e ) { // TODO Auto-generated catch block e.printStackTrace(); } } }
61. www.indian-elections.com/electoralsystem/electricvotingmachine.html
www.rajasthan.net/election/guide/evm.htm 
www.eci.gov.in/Audio_VideoClips/presentation/EVM.ppt  www.google.com  www.efyprojects.com
 www.alldatasheets.com  www.howstuffworks.com  www.8051projects.net/lcd-interfacing/
WEBSITES  www.8051projects.net/microcontroller_tutorials/Tutorial on LCD:  K. J. Ayala. Third
edition, “The 8051 MICROCONTROLLER” Tutorial on microcontroller:  Muhammad Ali Mazidi ,
Janice Gillispie Mazidi, Rolin D. Mckinlay. Second edition, “THE 8051 MICROCONTROLLER AND
EMBEDDED SYSTEM” 61 REFRENCES

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close