vehicle monitoring and_security_system

27
Vehicle Monitoring and Security System ABSTRACT: In this modern, fast moving and insecure world, it is become a basic necessity to be aware of one’s safety. Maximum risks occur in situations wherein an employee travels for money transactions. Also the Company to which he belongs should be aware if there is some problem. What if the person traveling can be tracked and also secured in the case of an emergency?! Fantastic, isn’t it? Of course it is and here’s a system that functions as a tracking and a security system. It’s the VMSS. This system can deal with both pace and security. The VMSS (Vehicle Monitoring and Security System) is a GPS based vehicle tracking system that is used for security applications as well. The project uses two main underlying concepts. These are GPS (Global Positioning System) and GSM (Global System for Mobile Communication). The main application of this system in this context is tracking the vehicle to which the GPS is connected, giving the information about its position whenever required and for the security of each person travelling by the vehicle. This is done with the help of the GPS satellite and the GPS module attached to the vehicle which needs to be tracked. The GPS antenna present in the GPS module receives the information from the GPS satellite in NMEA (National Marine Electronics Association) format and thus it reveals the position information. This information got from the GPS antenna has to be sent to the Base station wherein it is decoded. For this we use GSM module which has an antenna too. Thus we have at the Base station; the complete data about the vehicle. Along with tracking the vehicle, the system is used for security applications as well. Each passenger/employee will have an ID of their own and will be using a remote containing key for Entry, Exit and Panic. The Panic button is used by the driver or the passenger so as to alert the concerned of emergency conditions. On pressing this button, an alarm will be activated which will help the passenger/employee in emergencies and keep them secure throughout the journey. The vehicle can also be immobilized remotely. INTRODUCTION: Of all the applications of GPS, Vehicle tracking and navigational systems have brought this technology to the day-to-day life of the common man. Today GPS fitted cars, ambulances, fleets and police vehicles are common sights on the roads of developed countries. Known by many names such as Automatic Vehicle Locating System (AVLS), Vehicle Tracking and Information System (VTIS), Mobile Asset Management System (MAMS), these systems offer an effective tool for improving the operational efficiency and utilization of the vehicles. GPS is used in the vehicles for both tracking and navigation. Tracking systems enable a base station to keep track of the vehicles without the intervention of the driver whereas navigation system helps the driver to reach the destination. Whether navigation system or tracking system, the architecture is more or less similar. The

Upload: venkatesh-reddy

Post on 08-Jul-2015

264 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Vehicle monitoring and_security_system

Vehicle Monitoring and Security System

ABSTRACT: In this modern, fast moving and insecure world, it is become a basic necessity to be aware of one’s safety. Maximum risks occur in situations wherein an employee travels for money transactions. Also the Company to which he belongs should be aware if there is some problem. What if the person traveling can be tracked and also secured in the case of an emergency?! Fantastic, isn’t it? Of course it is and here’s a system that functions as a tracking and a security system. It’s the VMSS. This system can deal with both pace and security.

The VMSS (Vehicle Monitoring and Security System) is a GPS based vehicle tracking system that is used for security applications as well. The project uses two main underlying concepts. These are GPS (Global Positioning System) and GSM (Global System for Mobile Communication). The main application of this system in this context is tracking the vehicle to which the GPS is connected, giving the information about its position whenever required and for the security of each person travelling by the vehicle. This is done with the help of the GPS satellite and the GPS module attached to the vehicle which needs to be tracked. The GPS antenna present in the GPS module receives the information from the GPS satellite in NMEA (National Marine Electronics Association) format and thus it reveals the position information. This information got from the GPS antenna has to be sent to the Base station wherein it is decoded. For this we use GSM module which has an antenna too. Thus we have at the Base station; the complete data about the vehicle.

Along with tracking the vehicle, the system is used for security applications as well. Each passenger/employee will have an ID of their own and will be using a remote containing key for Entry, Exit and Panic. The Panic button is used by the driver or the passenger so as to alert the concerned of emergency conditions. On pressing this button, an alarm will be activated which will help the passenger/employee in emergencies and keep them secure throughout the journey. The vehicle can also be immobilized remotely.

INTRODUCTION:

Of all the applications of GPS, Vehicle tracking and navigational systems have brought this technology to the day-to-day life of the common man. Today GPS fitted cars, ambulances, fleets and police vehicles are common sights on the roads of developed countries. Known by many names such as Automatic Vehicle Locating System (AVLS), Vehicle Tracking and Information System (VTIS), Mobile Asset Management System (MAMS), these systems offer an effective tool for improving the operational efficiency and utilization of the vehicles.

GPS is used in the vehicles for both tracking and navigation. Tracking systems enable a base station to keep track of the vehicles without the intervention of the driver whereas navigation system helps the driver to reach the destination. Whether navigation system or tracking system, the architecture is more or less similar. The

Page 2: Vehicle monitoring and_security_system

navigation system will have convenient, usually a graphic display for the driver which is not needed for the tracking system. Vehicle tracking systems combine a number of well-developed technologies.

To design the VMSS system, we combined the GPS’s ability to pin-point location along with the ability of the Global System for Mobile Communications (GSM) to communicate with a control center in a wireless fashion. The system includes GPS-GSM modules and a base station called the control center.

Let us briefly explain how VMSS works. In order to monitor the vehicle, it is equipped with a GPS-GSM VMSS system. It receives GPS signals from satellites, computes the location information, and then sends it to the control center. With the vehicle location information, the control center displays all of the vehicle positions on an electronic map in order to easily monitor and control their routes. Besides tracking control, the control center can also maintain wireless communication with the GPS units to provide other services such as alarms, status control, and system updates.

The design takes into consideration important factors regarding both position and data communication. Thus, the project integrates location determination (GPS) and cellular (GSM) – two distinct and powerful technologies in a single system.

VMSS is based on a PIC microcontroller-based system equipped with a GPS receiver and a GSM Module operating in the 900 MHz band. We housed the parts in one small plastic unit, which was then mounted on the vehicle and connected to GPS and GSM antennas. The position, identity, heading, and speed are transmitted either automatically at user-defined time intervals or when a certain event occurs with an assigned message (e.g.; accident, alert, or leaving/entering an admissible geographical area).

The GPS Module outputs the vehicle location information such as longitude, latitude, direction, and Greenwich Time every five minutes. The GSM wireless communications function is based on a GSM network established in a valid region and with a valid service provider. Via the SMS provided by the GSM network, the location information and the status of the GPS-GSM VMSS are sent to the control center. Meanwhile, the VMSS receives the control information from the control center via the same SMS. Next, the GPS-GSM VMSS sends the information stored in the microcontroller via an RS-232 interface.

Page 3: Vehicle monitoring and_security_system

There are two ways to use the VMSS’ alarm function, which can be signified by either a buzzer or presented on LCD. The first way is to receive the command from the control center; second way is to manually send the alarm information to the control center with the push of a button.

The base station consists of landline modem(s) and GIS workstation. The information about the vehicle is received at a base station and is then displayed on a PC based map. Vehicle information can be viewed on electronic maps via the Internet or specialized software. Geographic Information Systems (GIS) provides a current, spatial, visual representation of transit operations. It is a special type of computerized database management system in which geographic databases are related to one via a common set of location coordinates.

STAGES OF VMSS

STAGE 1:

1. Driver starts his trip from the transport office.

Page 4: Vehicle monitoring and_security_system

2. VMSS transmits the Driver I.D and the Vehicle I.D along with the position of the vehicle to the base station.

STAGE 2:

1. Taxi picks up the employee/passenger from their residence.2. VMSS transmits the Passenger I.D and the Vehicle I.D along with the

position of the vehicle to the base station. Therefore base station will be able to keep a track of the vehicle and thus the employee/passenger.

STAGE 3:

1. Taxi drops the employee/passenger to the workplace.2. VMSS transmits the Passenger I.D and the Vehicle I.D along with the

position of the vehicle to the base station.

Page 5: Vehicle monitoring and_security_system

STAGE 4:

1. Taxi picks the employee/passenger from the workplace.2. VMSS transmits the Passenger I.D and the Vehicle I.D along with the

position of the vehicle to the base station. Therefore this enables the base station to estimate the time if required and also keep a track of the vehicle, passenger and the driver.

STAGE 5:

1. Taxi drops the employee/passenger to their residence.2. VMSS transmits the Passenger I.D and the vehicle I.D along with the

position of the vehicle to the base station and makes sure that the job is 100% complete.

HI-TECH ‘C’ AND MPLAB – AN OVERVIEW

1. HI-TECH software makes industrial-strength development tools and C compilers that help software developers write compact, efficient embedded processor code. HI-TECH PICC-18™ is a powerful C compiler for the Microchip PICmicro® PIC18 family of microcontrollers. HI-TECH PICC-18 delivers unrivalled code density combined with excellent reliability. Tightly tuned to the PIC18 architecture, it allows firmware development in a fraction of the time, but with no greater use of RAM or ROM, required for conventional assembly language programming. It is also a USER FRIENDLY language.

2. HI-TECH PICC-18™ Compiler Features:3. ANSI C – full featured and portable4. Efficient – equals or betters hand-written assembler code5. Reliable – mature, field-proven technology6. Modular – includes full object code linker and library manager7. Cost-effective – productivity gains rapidly repay purchase cost8. Compatible – integrates into the MPLAB® IDE, MPLAB ICE2000 and9. 4000, ICD2 and most 3rd-party development tools10. Library source – for standard libraries and sample code for various11. peripherals and applications12. Complete – includes macro assembler, preprocessor and one-step driver

Page 6: Vehicle monitoring and_security_system

MPLAB IDE – AN OVERVIEW

MPLAB 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 a PC. MPLAB allows you to write, debug, and optimize the PICmicro MCU applications for firmware product designs. Integrated Development Environment (IDE) is an application that has multiple functions for software development. MPLAB IDE an executable program that integrates a compiler, an assembler, a project manager, an editor, a debugger, simulator, and an assortment of other tools within one Windows application. A user developing an application should be able to write code, compile, debug and test and application without leaving the MPLAB IDE desktop. MPLAB IDE runs as a 32-bit application on MS Windows, is easy to use and includes a host of free software components for fast application development and super- charged debugging.

MPLAB ICD 2 – AN OVERVIEWTraditionally, embedded systems engineers use in-circuit emulators (ICE) to develop and debug their designs and then programmers to transfer the code to the devices. The in-circuit debugging logic, when implemented, is part of the actual microcontroller silicon and provides a low-cost alternative to a more expensive ICE. In-circuit debugging offers these benefits:

• Low cost• Minimum of extra hardware• Expensive sockets or adapters are not needed• Debugging and programming a production line board is possible.

An ICE uses custom hardware to emulate the target microcontroller. An ICD uses hardware on the target microcontroller to do some of the functions of an ICE. An ICD also employs software running on the target to do ICE-like functions and, as a result, relies upon the target microcontroller for some memory space, CPU control, stack storage and I/O pins for communication.

The MPLAB ICD 2 (In-Circuit Debugger 2) allows debugging and programming of PIC microcontrollers using the powerful graphical user interface of the MPLAB Integrated Development Environment (IDE). The MPLAB ICD 2 is connected to the

Page 7: Vehicle monitoring and_security_system

design engineer’s PC using USB or RS-232 interface and can be connected to the target via an ICD connector.

MPLAB ICD 2 SYSTEM COMPONENTS:In addition to the MPLAB ICD 2 module, the following components are required:

• MPLAB IDE software (version 6.20 or later) – Installed on the PC to control MPLAB ICD 2.

• RS-232 or USB cable – To connect the MPLAB ICD 2 module to a COM or USB port on the PC.

• Modular interface cable – To connect the MPLAB ICD 2 module to a demo board or the user’s application.

• Demo board or target application – To connect the PICmicro MCU with on- board debug capabilities to the modular interface (and the MPLAB ICD 2). Although the serial or USB communications from the MPLAB IDE to the

• Power adapter(s) – To power MPLAB ICD 2 and the target application.

GPS – AN OVERVIEW:

The GPS (Global Positioning System) is a “constellation” of 24 well-spaced satellites that orbit the earth and make it possible for people with ground receivers to pinpoint their geographic location. The location accuracy is anywhere from 100 to 10 meters for most equipment. Accuracy can be pinpointed to within 1 meter with special military-approved equipment .GPS equipment is widely used in science and has now become sufficiently low-cost so that almost anyone can own a GPS receiver.

The GPS has three components namely:

1. The space segment: consisting of 24 satellites orbiting the earth at an altitude of 11000 nautical miles.

2. The user segment: consisting of a receiver, which is mounted on the unit whose location has to be determined.

3. The control segment: consists of various ground stations controlling the satellites.

GSM – AN OVERVIEW

GSM, Global System for Mobile communications, is today the most successful digital mobile telecommunication system. This second-generation (2G) system provides voice and limited data services and uses digital modulation with improved audio quality.

The different versions of GSM are:

Page 8: Vehicle monitoring and_security_system

1. GSM 900 band (850-915MHz up-link frequency and 935-960MHz downlink frequency)

2. GSM 1800 band or digital cellular system (DCS) 1800 band (1710-1785MHz up-link frequency and 1805-1880MHz downlink frequency)

3. Personal Communication service (PCS) 1900 band (1850-1910MHz up-link frequency and 1930-1990MHz downlink frequency)

SYSTEM DESCRIPTION

The entire Vehicle Monitoring and Security System is built around the PIC 18F8722 IC. It consists of 5 units comprising of

1. A Keyboard Unit2. An LCD Unit3. An RF Unit4. A GPS Unit5. A GSM Unit

Each unit in the Vehicle Monitoring and Security System undertakes a specific job and can be explained as follows:

• The keyboard unit is used to type in the password and other information that needs to be keyed in.

• The LCD unit is used to display the information that is keyed into the keyboard and for other menu applications.

• The RF receiver unit is used to provide a unique code about each employee/passenger and for security applications.

• The GPS module containing the GPS antenna receives the information from the GPS satellite in NMEA format.

• The GSM module transfers the information got by the GPS receiver to the Base Station. The Base Station decodes the information to the required form.

Page 9: Vehicle monitoring and_security_system

THE KEYBOARD UNIT:

The keyboard is organized as a matrix of 4 rows and 3 columns. The columns are connected to an output port and the rows are connected to an input port. In this unit the keyboard is interfaced to the PIC18F722 IC with PORTB as the input port and PORTG as the output port. Pins RB2-RB5 of Port B and pins RG0-RG2 of Port G are connected to the keyboard.

If no key has been pressed, reading the input port will yield 0s for all rows since they are all connected to low (GND). It is the function of the PIC microcontroller to scan the keyboard continuously to detect and identify the key pressed. To identify a pressed key, the PIC microcontroller sends a 1 to each of the columns, starting with the first column; then it reads the rows. If the data read is all 0s, no key in that column is activated and the process is moved to the next column. A high is given to the next row, reads the columns, and checks for any 1’s. This process continues until the row is identified. After the identification of the row in which the key has been pressed, the next task is to find out which column the pressed key belongs to. This should be easy since the microcontroller knows at any time which row and column are being accessed.

Page 10: Vehicle monitoring and_security_system

THE LCD UNIT:

The LCD that is used in this project is LAMPEX 16101 LCD display, which is a one line 16-character display. The display contains two internal byte-wide registers, one for commands (RS=0) and the second for characters to be displayed. It also contains a user-programmed RAM area (the character RAM) that can be programmed to generate any desired character that can be formed using a dot matrix.

LCD PIN DESCRIPTIONS:The LCD used for this project has 14 pins. The function of each pin is given in the table below:

LCD INITIALIZATION:

The module automatically performs initialization when powered on (using internal reset circuit).The following instructions are executed during initialization:

Page 11: Vehicle monitoring and_security_system

1. CLEAR DISPLAY: The Busy flag is kept in the Busy state (BF=1).Unit initialization ends. The time is 15ms.

2. FUNCTION SET: DL=1 ; 8-bits long interface data.N=0 ; 1 line display.

3. DISPLAY ON/OFF CONTROL:D=0 ; display off.C=0 ; cursor off.B=0 ; blink off.

4. ENTRY MODE SET:I/D=1 ; increment (+1) .S=0 ; No shift.

5. DDRAM: DDRAM is selected. Power on initialization depends on rise time of the supply when it is turned on.

When the above power supply condition is not satisfied, the internal reset circuitry doesn’t operate correctly. In this case, perform the needed initialization by sending function set instructions thrice from MPU after turning the power on.

For example, to designate an 8–bit data length, send the following instruction thrice:

When this ends, the module enters 8-bits data length mode without fail, then enters 4-bits data length instruction for 4-bits data length interface.

The RF section consists of an RF transmitter and an RF receiver. The RF transmitter mainly consists of a remote key that contains a code hopping encoder, HCS301 along with 2 buttons and two LEDs. The RF receiver section consists of a Low Power ASK receiver IC. The key encoder will generate the company specific “Company ID”, which will be decoded by the low power ASK receiver IC. The LEDS are used to show the status of the remote key. The two buttons provided are used for ‘entry’ and ‘exit’. When both the buttons are pressed together, the system goes into a ‘panic’ state wherein the system will turn on the siren and immobilize the vehicle in emergency condition after a 10sec delay.

Page 12: Vehicle monitoring and_security_system

HARDWARE

Click the image to enlarge

POWER SUPPLY SECTION:

The power supply section consists of LM309, which is a 5V regulator fabricated on a single silicon chip. Current limiting is included to limit the peak output current to a safe value.

Page 13: Vehicle monitoring and_security_system

KEYBOARD SECTION:

Here we are making use of a 4X3 matrix keyboard. The columns are connected to an output port and the rows are connected to an input port. In this unit the keyboard is interfaced to the PIC18F722 IC with PORTB as the input port and PORTG as the output port. Pins RB2-RB5 of Port B and pins RG0-RG2 of Port G are connected to the keyboard. Pull-down resistors of 27k ohms are used.

LCD SECTION:

The LAMPEX 16101 LCD module is interfaced to the PIC18F8722 microcontroller. The data lines are connected to Port E and the control lines are connected to Port D of the PIC microcontroller. Only four of the eight data lines are used. The LCD is used in 4-bit mode with the hardware connected as follows:

• PORTE bits 0-3 are connected to the LCD data bits 4-7 (high nibble)

Page 14: Vehicle monitoring and_security_system

• PORTD bit 1 is connected to the LCD RS input (register select)• PORTD bit 2 is connected to the LCD R/W input (Read/Write)• PORTA bit 3 is connected to the LCD EN bit (enable)

RF SECTION:RF TransmitterThe RF transmitter (2-button remote) mainly consists of a code hopping encoder, HCS301. S0 (pin1) and S1 (pin2) of HCS301 are connected to the two buttons, which are used as “Enter” and “Exit”. Pin 5(Vdd) is connected to +12V supply and pin8 is grounded. Pin 7 is the transmitter output. The LED is connected to pin 7.

Page 15: Vehicle monitoring and_security_system

PROJECT CODE:

#include <pic.h>#include <string.h>

__CONFIG(BORDIS & UNPROTECT & XT & WDTDIS & PWRTEN );

#define PORTBIT(adr, bit) ((unsigned)(&adr)*8+(bit))

//----------------------InPort--------------------static bit learn_key @ PORTBIT(PORTB,4);

//old value 1static bit RFIN @ PORTBIT(PORTB,5);

// old value 2

static bit IM_SENSE @ PORTBIT(PORTB,6);static bit IGNITION @ PORTBIT(PORTB,7);//----------------------OutPort--------------------static bit FLASH @ PORTBIT(PORTC,0);static bit Immob_Relay @ PORTBIT(PORTC,1);

//old value 3static bit SIREN @ PORTBIT(PORTC,2);

//old value ?

Page 16: Vehicle monitoring and_security_system

static bit D_OUT @ PORTBIT(PORTC,3);// old value 4

static bit D_IN @ PORTBIT(PORTC,4);// old value 4

static bit MEM_CLK @ PORTBIT(PORTC,5);// old value 4

static bit MEM_CS @ PORTBIT(PORTC,6);// old value 4

static bit learn_LED @ PORTBIT(PORTC,7); // old value 4

#define BIT_TEST(X,Y) (((X) &(1<<(Y)))!=0)

#define NOP() asm("nop")#define MAX_USER 2#define MEM_SIZE 4

#define TRUE 1#define FALSE 0#define ON 1#define OFF 0#define FOUND 1#define NOTFOUND 0#define ENABLE 1#define DISABLE 0

#define EE_WRITE_OP 0x05 //00000101#define EE_READ_OP 0x06 //00000110#define EE_ERASE_OP 0x07 //00000111#define EE_EWDS_OP 0x10 //00010000#define EE_WRAL_OP 0x11 //00010001#define EE_ERAL_OP 0x12 //00010010#define EE_EWEN_OP 0x13 //00010011

#define TOUT 5#define FTOUT 7#define TFLASH 2 // 72mS * 2 = 144.00 mS#define TLEARN 280 // 72mS * 280 = 020.16 sec (Learn waiting time)

#define s0 5#define s1 6#define s2 7#define s3 4

#define HopLo buffer[0]#define HopHi buffer[1]#define DisLo buffer[2]#define DoK buffer[3]#define IDLo buffer[4]#define IDMi buffer[5]#define IDHi buffer[6]#define Key_in buffer[7]

Page 17: Vehicle monitoring and_security_system

#define CLOCK 4#define TE 400#define OVERSAMPLING 3#define PERIOD TE / OVERSAMPLING * 4 / CLOCK

#define Nbit 64

#define TRFreset 0#define TRFsync 1#define TRFuno 2#define TRFzero 3

#define HIGH_TO -10#define LOW_TO 10#define SHORT_HEAD 20#define LONG_HEAD 45

typedef unsigned int byte;typedef signed int sbyte;typedef signed long word;

char Clearn,CFlash,CTFlash,Cout,status,IM_TIMER,EE_data;byte CTlearn;

bit Flearn;bit Fsame;bit R_DIS;bit R_EN;bit R_PANIC;bit PREV_DIS;bit IMP_EN;bit SECURITY;bit Panic_flag;bit Immob_ON_flag;bit Immob_OFF_flag;bit A_REARM;bit IG_1_SENSE;bit IG_ENABLED;

volatile bit RFFull;volatile bit RFBit;

char buffer[8],addr,data[3];char eeprom_data;word XTMR,cdl_timer;unsigned int

i,F_CNTR,COUNTER1,COUNTER2,IMP_CNTR,Im_debounce_CNTR,sound_CNTR,REARM_CNTR;char RFstate;char BPtr;char Bitcntr;sbyte RFcount;int IGNITION_CNTR;

char find(void);

Page 18: Vehicle monitoring and_security_system

void remote(void);void SL_Write(void);void ClearMem(void);void SL_Check(void);void display(void);

void PUT_EEPROM_DATA(char,char);char GET_EEPROM_DATA(char);char find(void);char space(void);void operate(void);void int_en(void);void int_dis(void);void remote_scan(void); //Sets or cleares the flag bits accoding to the valide received data void one_beep(void); //Generates one Beep sound of duration _____________void two_beep(void); //Generates two beep sounds void one_flash(void); //Generates one flash void two_flash(void); //Generates two flashes void panic_beep(void); //Generates continuous beep sounds void panic_flash(void); //Generates continuous flashesvoid long_beep(void); //Generates long beep sound of duration 3 Secvoid scan_impact(void); //Scan Impactvoid immob_ON(void); // Switch ON the Immobvoid immob_OFF(void); // Switch OFF the Immobvoid panic_SET(void); // Set the panic flag bitvoid remote_result(void);void send_ee_cmd(char);void send_ee_bit(char,char);

RECEIVER

void interrupttmr0_isr(){

RFBit = RFIN;TMR0 -=PERIOD;T0IF = 0;

XTMR++; cdl_timer++;

if(RFFull)return;

switch(RFstate){case TRFuno:

if(RFBit == 0){RFstate = TRFzero;}

else{RFcount--;if(RFcount<HIGH_TO)RFstate = TRFreset;}

break;

Page 19: Vehicle monitoring and_security_system

case TRFzero:if(RFBit)

{RFstate = TRFuno;buffer[BPtr]>>=1;

if(RFcount >= 0){buffer[BPtr]+=0x80;}

RFcount = 0;

if((++Bitcntr & 7 )==0) BPtr++;

if(Bitcntr == Nbit){RFstate = TRFreset;RFFull = TRUE;}

}

else{RFcount++;if(RFcount >= LOW_TO)

{RFstate = TRFsync;BPtr = 0;Bitcntr = 0;}

}break;

case TRFsync:if(RFBit){

if((RFcount < SHORT_HEAD) ||(RFcount >= LONG_HEAD)){RFstate = TRFreset;break;}else{RFcount = 0;RFstate = TRFuno;}

}else{

RFcount++;}break;

case TRFreset:default:

RFstate = TRFsync;RFcount = 0;BPtr = 0;Bitcntr = 0;break;

}

Page 20: Vehicle monitoring and_security_system

}

/********************************************************************* *

* iQ PUMA CUB *

* (Bike security system for TVS motors) *

*

***********************************************************************

** Filename :Ncubmain1.c

** date :12.11.2003

** File Version :V1.00

**

** IDE :MPLAB IDE V6.13.0.0

*

* Compiler :HI-TECH PICC Compiler V8.01PL3(Demo ver) *

* Written By :Sudhindra Rao*

*

**

** Copyright :iQ infotech Ltd

** :Bangalore - 560 074

**

***********************************************************************

** Files Required:

**

** ncubmain1.c - Source file

**

** pic.h - Processor

** cubdef.h - Def

** cubint.h - Interrupt

*

Page 21: Vehicle monitoring and_security_system

* cubmem.h - Memory *

* cubrem.h - Remote *

* *

*********************************************************************/

#include "cubdef.h"#include "cubint.h"#include "cubrem.h"#include "cubmem.h"

void main(){

ADCON1=0X07; //PORTA as digital input TRISA = 0XFF; //InportTRISB = 0XFF; //InportTRISC = 0X08; //Outport

PORTA = 0X00;PORTB = 0X00;PORTC = 0X00;

OPTION = 0X8f;

GIE = 1;T0IE = 1;T0IF = 0;RFstate = TRFreset;

XTMR = 0;

IGNITION_CNTR=0;SIREN = OFF;FLASH = OFF;Immob_Relay = OFF;learn_LED = OFF;PREV_DIS= FALSE;IMP_CNTR = 0;sound_CNTR = 0;Immob_ON_flag = FALSE;Immob_OFF_flag = FALSE;Panic_flag = FALSE;REARM_CNTR = 0;COUNTER1 = 0;

while(1){if(RFFull){

int_dis();RFFull=FALSE;remote();int_en();

}if(cdl_timer > 75)

remote_result();if(XTMR < 512) // is time is < 72mS

continue; // if YES goto re scan

XTMR = 0; // if no clear time

Page 22: Vehicle monitoring and_security_system

if(SIREN) // if siren is ON{

sound_CNTR++; // increment sound counterif(sound_CNTR==138) // is sound counter is 138 i.e

10 Sec // old value is 400{SIREN = OFF; // switch off sirenFLASH = OFF; // switch off flashR_PANIC = FALSE; // clear remote panic flagsound_CNTR = 0; // clear sound

counter}

}else

sound_CNTR=0; // if siren is off , clear sound counter

if(A_REARM ){REARM_CNTR++; // increment counter step of

72mSif(REARM_CNTR < 833) // if counter reaches 850 i.e. 1 Min

{if(IGNITION)

{REARM_CNTR = 0;A_REARM = 0;}

}else

{if(!IGNITION ) // if ignition is OFF and Remote ignition

enabled{REARM_CNTR = 0; // clear counterA_REARM = 0;Immob_Relay = 1; // Remote ignition disablePREV_DIS = 1; // indicate Remote ignition

disabledIMP_EN = 1; // Impact enabledR_DIS = 0;R_EN = 0;R_PANIC = 0;one_beep(); // make one beepone_flash(); // make one flash}

elseA_REARM = 0;

}}if(!learn_key) // if learn key pressed{

Clearn++; // increment learn counter

if(Clearn == 128) // if counter reaches 9.2 Sec{learn_LED = OFF; // Learn LED offwhile(!learn_key); // wait for Learn LED releaselearn_LED = ON; // after releasing

Learn LED ONClearMem(); // erase

EEPROM

Page 23: Vehicle monitoring and_security_system

Cout = TOUT; // load output counter with timeout(TOUT) value

Clearn = 0; // clear Learn counter

Flearn = FALSE; // clearn Learn Flag}

if(Clearn == 4) // if learn counter reaches 280mS : debounce delay

{ Flearn = TRUE; // Learn flag enable

CTlearn = TLEARN; // Load "learn time out counter" with "Time to Learn" (TLEARN) value

learn_LED = ON; // Switch ON learn LED

}}else // if learn key not pressed

Clearn = 0; // clear learn counterif(Cout > 0) // if output counter is > 0{

Cout--; // decrement output counterif(Cout == 0) // if output counter is Zero

{learn_LED = OFF; // Switch off Learn LEDImmob_ON_flag = FALSE; // clear Immob On flagImmob_OFF_flag = FALSE; // clear immob Off

flagPanic_flag = FALSE; // clear panic flag}

}if(CTlearn > 0) // if Learn time out counter is > 0{

CTlearn --; // decrement Learn time out counter

if(CTlearn == 0) // if Learn time out counter is zero{learn_LED = OFF; // switch off learn LEDFlearn = FALSE; // clear learn flag}

}if(CFlash > 0) // if learn LED flash counter is > 0{

CTFlash--; // decrement flash time counter

if(CTFlash == 0) // flash time counter is zero{CTFlash = TFLASH; // load flash time counter with flash

time(TFLASH)CFlash--; // decrement LED flash

counterlearn_LED = OFF; // switch off learn LEDif(CFlash &1) // if cflash is ODD no

learn_LED = ON; // switch ON learn LED}

}}

}

void remote_result(){

cdl_timer = 00;if(Immob_ON_flag)

{

Page 24: Vehicle monitoring and_security_system

R_DIS = 1;R_EN = 0;}

if(Immob_OFF_flag){R_DIS = 0;R_EN = 1;}

if(Panic_flag ){R_DIS = 0;R_EN = 0;R_PANIC=1;}

if(R_DIS && !R_EN){if(R_PANIC)

{

SIREN=OFF;FLASH=OFF;R_PANIC = 0;}

else if(!PREV_DIS){IG_1_SENSE = 1;Immob_Relay = 1;PREV_DIS = 1;IMP_EN = 1;one_beep();one_flash();}

}

if(!R_DIS && R_EN && PREV_DIS && !R_PANIC ){

Immob_Relay = 0;PREV_DIS=0;IMP_CNTR = 0;A_REARM = 1;REARM_CNTR = 0;two_beep();two_flash();

}

// if(IG_1_SENSE && PREV_DIS)// {// IGNITION_CNTR++;// if(IGNITION_CNTR>580)// {// IG_1_SENSE = 0;// IG_ENABLED = 1;// IGNITION_CNTR=0;// }// else// IG_ENABLED = 0;// }

if(IGNITION && PREV_DIS && !SIREN && !FLASH) //&& IG_ENABLED{

Page 25: Vehicle monitoring and_security_system

IGNITION_CNTR++;if(IGNITION_CNTR>25)

{IGNITION_CNTR = 0;IG_ENABLED = 1;R_DIS = 0;R_EN = 0;R_PANIC = 1;}

}

if(R_PANIC && !SIREN) {SIREN = ON;}

if(R_PANIC){ F_CNTR++;

if(F_CNTR == 50){F_CNTR=0;FLASH^= ON;}

}else

FLASH = OFF;

if(IMP_EN==1){

COUNTER2++;if(COUNTER2==100){

COUNTER2=0;IMP_EN=0;

}}

if(PREV_DIS && !IMP_EN && !R_PANIC){if(!IM_SENSE)

{IMP_CNTR++;

if(IMP_CNTR>5){IMP_CNTR=0;SIREN = ON;for(i=0;i<10000;i++);for(i=0;i<10000;i++);for(i=0;i<10000;i++);for(i=0;i<10000;i++);SIREN = OFF;IMP_EN = 1;}

else{one_beep();one_flash();IMP_EN = 1;}

}}

}

Page 26: Vehicle monitoring and_security_system

void one_beep(){

SIREN = 1;for(i=0;i<2500;i++);SIREN = 0;

}

void one_flash(){

FLASH = 1;for(i=0;i<3300;i++);FLASH = 0;

}

void two_beep(){

SIREN=1;for(i=0;i<2500;i++);SIREN=0;for(i=0;i<5000;i++);SIREN=1;for(i=0;i<2500;i++);SIREN=0;

}

void two_flash(){

FLASH=1;for(i=0;i<3300;i++);FLASH=0;for(i=0;i<7000;i++);FLASH=1;for(i=0;i<3300;i++);FLASH=0;

}

Page 27: Vehicle monitoring and_security_system

CONCLUSION:

The outcomes of this project will be anticipated to show that it will alert unaware drivers from preventing a traffic accident, recognizing some unusual situations or gaining more response time whenever the EV (Emergency Vehicle) was approaching. Furthermore, its commercial achievements will especially be used in ITS (intelligent Transport System). It will pre-warn the involving drivers to avoid the emergencies and accidents as soon as he encounters an EV along the roadways.

BIBLIOGRAPHY:

BOOKS:

• PIC18F8722 Microcontroller Data Sheet• Max 232 Data Sheet• LAMPEX 16101 LCD Data Sheet• Let Us C – Yashwant Kanetkar• Microcontroller Basics – Ayala• Electronic Communication- Wayne Tomasi

INTERNET:

• www.google.com• www.microchip.com• www.epanorama.net• www.wirelessintegrated.com• www.wavecom.com• www.garmin.com• www.atmel.com• www.commlinx.com• www.alldatasheet.com