Вы находитесь на странице: 1из 94

Automatic road security control system

Project Report

CH APTER 1
INTRODUCTION
Nowadays, excessive or inappropriate speed is a significant factor in serious road
accidents. Road safety authorities around the world devote considerable resources to addressing
the speeding problem. The current legal system involves procedure in which the driver is charged
with a ticket for speeding. But if in any case there is a delay in either the arrival of the notice or
payment of fine, the person will get punishment for this speeding. So the implementation of this
speed governing system can avoid the above complications.

1.1 EXPLANATION
The proposed system consist of 3 sections namely control room section, road section and
vehicle section. The control room gives the information about the speed limit to be followed in
that region using GSM modem. Here in this project we also implemented the vehicle accident
information system. This system is capable of immediate reporting of emergency, like accidents,
to a central monitoring station and also for investigation purpose. Every vehicle equipped with
this reporting unit can be easily located and help can be extended without any delay. The alarm
data generated by the micro controller is sending to a central monitoring station using GSM
network. Also the location of accident is finding with the help of GPS module.
This project is based on Embedded System. Embedded System can be defined as the combination
of both software and hardware. An embedded system has specific requirements and performs predefined tasks unlike a general purpose personal computer. An embedded system is a combination
of computer hardware and software and perhaps additional mechanical or other parts, designed to
perform a dedicated function. This system is proposed to implement in road.

Department of ECE

SETCEM

Automatic road security control system

Project Report

1.2 OBJECTIVE OF THE PROJECT


As a result of the increase in population, the number of automobiles on road is increasing
day by day. This increase in vehicles directly leads to congestion on road which causes traffic jam,
accidents etc. Over speed and careless driving are the major reasons for accidents. a person dies in
a car crash every second. In order to reduce the rate of accidents, it is significant to reduce the
speed of vehicles particularly in crowded areas. Automation of the driving control of vehicle is
one of the most vital need of the hour The government has put forward an idea of speed governing
system. In this mechanism, speed breaker is fixed in vehicles. In these speed breakers, the speed
limit is set by the manufacturer itself. So, when a vehicle exceeds the speed limit, the vehicle will
stop. However, this method has a disadvantage, i.e., we cannot increase the speed in isolated areas
also.
Hence, we have come up with a new idea to control speed only in the restricted areas. In this
paper, we would like to present this new technology Automatic road security control system. By
using this, we can control the speed of automobiles in particular locations such as school, hospital,
crowded junctions etc.

1.3 PROBLEM FORMULATION


Nowadays people are driving very fast, accidents are occurring frequently, we lost our
valuable life by making small mistake while driving (zone wise, hills area, highways). So in order
to avoid such kind of accidents and to alert the drivers and to control their vehicle speed in such
kind of places the highway department have placed the signboards. But sometimes it may to
possible to view that kind of signboards and there is a chance for accident. So to intimate the
driver about the zones and the speed limit automatically, is done by means of using RF
technology.

Department of ECE

SETCEM

Automatic road security control system

Project Report

1.3.1 Literature Review


1.3.1.1 Variable speed limiter system:

In 1990s Carl.H.Smith and Robert.W.Schneider introduced that most speed limits are
fixed and apply at all times. A variable speed limit is one that can be altered to respond to
changing traffic and road conditions, such as bad weather conditions including rain, ice or
wind, a crash or traffic congestion. Whatever the speed limit is set to, it is still a regulatory
speed limit and must not be exceeded. Under the Australian Road Rules, electronic speed limit
signs are treated the same as static speed signs. The sign sets a maximum speed limit and
invariably a lower safer speed will be required. Remember it's a driver's responsibility to drive
to the traffic and road conditions. Variable speed limits are set using high-visibility electronic
signs that can display different speeds. They are similar to the signs you might have seen
operating in school speed zones in Tasmania and on roads in other parts of Australia. The
speed limit is displayed with white numbers surrounded by five red circles. Most of the time,
the speed limits shown on the electronic signs will reflect the existing speed limit for that
section of the highway, and during this time the five red circle will be static. When the speed
limit is reduced three of the five circles will continually flash until the limit returns to the
normal limit. Variable speed limits have been shown to improve safety and improve traffic
flow. In heavy traffic conditions, lowering the speed limit can help smooth traffic flow, as
vehicle speeds tend to even out, lane changing is reduced and drivers are less frustrated by
irregular traffic flow. Changing the speed limit to match the prevailing conditions alerts
drivers to potential hazards. These may be hazards that are not readily visible, either because
of the curve of the road, or weather conditions such as ice or gale-force winds, or a stationary
traffic queue has formed further ahead. Importantly, lowering the speed of traffic approaching
a crash site reduces the likelihood of secondary crashes. The variable speed limit zone will
apply to the Tasman Highway between Liverpool St Hobart and the Cambridge Road
Interchange, including the Tasman Bridge. There will be signs at the entry points to the
variable speed limit zone advising drivers that they have entered the zone and alerting them to
be aware that the speed limit might change.

Department of ECE

SETCEM

Automatic road security control system

Project Report

1.3.1.2 Fuel management system:

In 1990, Datta and Das proposed a system based on a fuel management system. It is
used to control the speed of the vehicle but can be fitted to only diesel vehicles. It consists of a
speed motor, ECU, and a solenoid valve. It is installed between fuel pump and fuel filter. The
ECU is preprogrammed at a fixed speed and the driver cant increase the speed limit. Fuel
management systems are designed to effectively measure and manage the use of fuel within
the transportation and construction industries. They are typically used for fleets of vehicles,
including railway vehicles and aircraft, as well as any vehicle that requires fuel to operate.
They employ various methods and technologies to monitor and track fuel inventories, fuel
purchases and fuel dispensed. They may also employ more sophisticated systems that utilize
remote data collection to gather specific technical information about the vehicle usage and
performance characteristics such as mileage, hours of operation and engine idling time.

1.3.1.3 Wireless Intelligent vehicle speed control or monitoring system:

In 1989 A.J Johny Abraham and Jason Philip introduced a system that, the legal speed
limit is stored at geographical location .Here the driver gets a warning or a notification only
when he exceeds the speed limit. This system makes use of GPS system which is of high cost.

Department of ECE

SETCEM

Automatic road security control system

Project Report

CHAPTER 2
SPECIFICATIONS
2.1 EMBEDDED SYSTEMS
An embedded system is a special purpose computer system, which is completely
encapsulated by the device it controls. It is called embedded because the micro controller is
inside some other system. An embedded system has specific requirements and performs predefined tasks unlike a general purpose personal computer. An embedded system is a
combination of computer hardware and software and perhaps additional mechanical or other
parts, designed to perform a dedicated function.
Features of Embedded Systems

It is a combination of software and hardware.


It is a system that has a computing device embedded into it.

They are designed around a micro controller which integrates memory and
peripherals.

Characteristics and benefits of Embedded Systems

Sophisticated functionality.
Real time operation.
Low manufacturing cost.
Low power consumption.
Eliminates necessity of complex circuitry.
Smarter products.
Smaller size.

Department of ECE

SETCEM

Automatic road security control system

Project Report

2.2 KEIL VISION COMPILER


Vision is an IDE (Integrated Development Environment) that helps you write, compile,
and debug embedded programs. It encapsulates the following components:

A project manager.
A make facility.
Tool configuration.
Editor.
A powerful debugger.

Vision adds many new features to the Editor like Text Templates, Quick Function
Navigation, Syntax Coloring with brace highlighting, Configuration Wizard for dialog based
startup and debugger setup.
2.2.1 Building an Application in Vision
To build (compile, assemble, and link) an application in Vision, you must:
1. Select Project - Open Project (for EG: \C166\EXAMPLES\HELLO\HELLO.UV2).
2. Select Project - Rebuild all target files or Build target.
Vision2 compiles, assembles, and links the files in your project.
2.2.2 Creating Your Own Application in Vision2
To create a new project in Vision, you must:
1. Select Project - New Project.
2. Select a directory and enter the name of the project file.
3. Select Project - Select Device and select an AT89C51 device from the Device
Database.
4. Create source files to add to the project.

Department of ECE

SETCEM

Automatic road security control system

Project Report

5. Select Project - Targets, Groups, and Files. Add/Files, select Source Group1, and add
the source files to the project.
6. Select Project - Options and set the tool options. Note when you select the target
device from the Device Database all special options are set automatically. You
typically only need to configure the memory map of your target hardware. Default
memory model settings are optimal for most applications.
7. Select Project - Rebuild all target files or Build target.
2.2.3 Debugging an Application in Vision2
To debug an application created using Vision2, you must:
1. Select Debug - Start/Stop Debug Session.
2. Use the Step toolbar buttons to single-step through your program. You may enter G,
main in the Output Window to execute to the main C function.
3. Open the Serial Window using the Serial #1 button on the toolbar.
4. Debug your program using standard options like Step, Go, Break, and so on.
2.2.4 Device Database
A unique feature of the Keil Vision2 IDE is the Device Database which contains
information about more than 400 supported microcontrollers. When you create a new
Vision2 project and select the target chip from the database, Vision2 sets all assembler,
compiler, linker, and debugger options for you. The only option you must configure is the
memory map.
As new devices become available, they are added to the database along with data sheets
and header files.

Department of ECE

SETCEM

Automatic road security control system

Project Report

CHAPTER 3
BLOCK DIAGRAM AND DESCRIPTION
The block diagram consists of three sections namely, control room, road section and vehicle
section.

3.1 Control Room:

Fig 3.1 Control room


The figure shows the block diagram of Control room.

Department of ECE

SETCEM

Automatic road security control system

Project Report

Microcontroller
The block diagram consists of the main part of the system is the microcontroller
PIC16F877A. All the processes and control actions are done on the microcontroller. The
microcontroller is interfaced with the GSM Modem. Through the GSM modem, the control
room receives the alert accident information from the vehicle side. Also control room should
forward the road zone details to the road section using the control switches. The GSM Modem
will interfaced with the microcontroller is through a level converter IC. The alert accident
information is display on the Control room.

GSM Modem
The GSM Modem is used for receiving the alert information from the vehicle section.
Also the zonal information will be send to the road section. The GSM modem is interfaced
with the microcontroller is through a level converter IC.
GSM (Global System for Mobile communications) is the most popular standard for
mobile phones in the world. GSM differs from its predecessors in that both signaling and
speech channels are digital, and thus is considered a second generation (2G) mobile phone
system. This has also meant that data communication was easy to build into the system. GSM
also pioneered a low-cost (to the network carrier) alternative to voice calls, the short message
service (SMS, also called "text messaging"), which is now supported on other mobile
standards as well.

Level Converter
The level converter is used for the interfacing of GSM modem with the
microcontroller. The microcontroller has the TTL logic, but the GSM modem has RS232
logic. For this conversion, ie. TTL logic levels are converted into the RS232 logic levels and
vice versa. The level converter IC used here is MAX232.

Department of ECE

SETCEM

Automatic road security control system

Project Report

3.2 Road Section:

Fig 3.2 Road Section

The figure shows the block diagram of Road Section.

Microcontroller
The block diagram consists of the main part of the system is the microcontroller
PIC16F877A. All the processes and control actions are done on the microcontroller. The
microcontroller is interfaced with the RF receiver modem and continuously transmits the
zonal ID. The switches are used to produce that ID. The GSM Modem is interfaced with the
microcontroller is by using zonal information from the control room. The GSM Modem is
interfaced by the microcontroller is through a level converted IC. All the operations should
display on the LCD screen.

Department of ECE

10

SETCEM

Automatic road security control system

Project Report

RF transmitter
The zonal data are transmitted using an RF transmitter. This RF unit has an ASK
modulator which will convert the data into suitable signal prior to transmission. The RF
transmitter is a low power 433MHz unit which has 100ft range in line of sight. The
transmitted data from the microcontroller is firstly encoded using an encoded IC. This data is
given into the RF transmitter module. Here we used the encoder IC is HT 12E.

GSM Modem
The GSM Modem is used for receiving the zonal information from the control room.
I.e. if the zone is active or not. The GSM Modem is interfaced with the microcontroller is
through a level converter IC namely MAX232.

LCD:
LCDS serves as a useful interface for the user. The most common type of LCD
controller is the Hitachi 44780 which provides a relatively simple interface between
microcontroller and LCD. The LCD has 16 character x 2 line display facility. The message to
be displayed is send to the LCD through data-bus. A set of control lines are needed to proper
displaying of the characters in LCD. All the operations should display on the LCD Module.

Department of ECE

11

SETCEM

Automatic road security control system

Project Report

3.3 Vehicle Section:

Fig 3.3 Vehicle section


The figure shows the block diagram of Vehicle Section.

Microcontroller
The block diagram consists of the main part of the system is the microcontroller
PIC16F877A. All the processes and control actions are done on the microcontroller. The
microcontroller is interfaced with the RF receiver Module for receiving the zonal details.
According to the zonal details the vehicle speed will be reduced. When the vehicle section
receives the zonal details, then the system produce a voice announcement for alerting the

Department of ECE

12

SETCEM

Automatic road security control system

Project Report

driver. For voice announcement, there is voice generator and loud speaker will connect. After
a few minutes, if the driver will not gear down the speed, then the system will automatically
down the speed into that zonal area. The wheel of the vehicle will connect with the gear
motors. When the system will adjust the speed, then the system uses PWM technique. The
motors are interfaced with the microcontroller is through a driver IC. When the vehicle will
get any accident, then the system will send an alert information to the control room through
the GSM Modem. The accident condition will detect using the vibration sensor. When any
accident condition will occur, then the system takes the location data using GPS Modem. This
information (i.e. Vehicle ID, Location data and Accident information) will send to the control
room. The GSM Modem will interfaced with the microcontroller is through a level converter
IC. All the operations will display on the LCD.

RF receiver
RF Receiver is used to receive the zonal data that is from the road Section. An antenna
is attached to this unit which receives the incoming signal. RF receiver feed the received data
to decoder circuit. The decoder IC is used to decode the data from the control unit. The RF
receiver receives the data, that is in an encoded format, the decoded IC decode the data and
given to the microcontroller. The decoded IC used here is HT 12D.

Driver IC
The driver IC is used to drive the gear motors. Here two driver IC is used. One is used
to drive the vehicles movement gear motors and the other one is used to drive the webcam s
gear motor. The motors are operated with 12V/ 9V power supply and it has used more current.
So the microcontroller cant operate the motors directly. So the signals from the
microcontroller is fed into the driver IC, then the driver IC amplifies the signals and fed into
the gear motors. Here we used the driver IC is L293D.

Motors
The motor1 and motor2 is used for vehicles movement. The CAM rotation motor is
used for rotating the web cam. Here we used the motors are gear motors with 45 rpm.
Department of ECE

13

SETCEM

Automatic road security control system

Project Report

Voice Generator
The voice generator is used for generating the voice. I.e. when we receive a zonal
information, then the information will announce, that for alerting the driver to gear down the
speed. In the voice generator circuit the main component will be APR 9600. A speaker will
connect to the voice generator for announcing.

Vibration Sensor
The vibration sensor is used for detecting the accident conditions. When any accident
condition will occur, the sensor will detect the condition and produces a digital signal.

GPS Module
The GPS module is interfaced with the microcontroller for taking the location of the
accident place. Using GPS module we can get the longitudinal and latitudinal data of each
place.

GSM Module
The GSM module is interfaced with the microcontroller for sending the emergency
message to the central station. The GSM module is interface with the microcontroller through
a level converter. The level converter is used for changing the voltage levels. Here we used
the level converter IC is MAX232.

LCD Module
LCDS serves as a useful interface for the user. The most common type of LCD
controller is the Hitachi 44780 which provides a relatively simple interface between
microcontroller and LCD. The LCD has 16 character x 2 line display facility. The message to
be displayed is send to the LCD through data-bus. A set of control lines are needed to proper
displaying of the characters in LCD. All the operations are display on the LCD.

Department of ECE

14

SETCEM

Automatic road security control system

Project Report

CHAPTER 4
CIRCUIT DIAGRAM AND DESCRIPTION
4.1 Circuit Diagram of Vehicle Section
U3
TR1

230V AC

TRAN-2P2S

C5
1nF

U2
7805

VI

VO

GND

U1
14

GND

OUT4 GND
11
OUT3

6
OUT2
3
OUT1 VS

VSS

16

C1

C1+

1mF

U4

C114

11

T1IN

T1OUT
13

12

R1OUT

R1IN

T2IN
R2OUT

T2OUT
R2IN

10

2
VS+
6
VS-

C2+

C2-

C2

MAX232

1mF

Fig 4.1 Vehicle section


Department of ECE
Automatic road security control system

15

SETCEM

4.2 Circuit Diagram of Road Section


U3
7805

TR1

230V AC

TRAN-2P2S

C1+
11
12

T1IN
R1OUT

10
T2IN
9

R2OUT

C2+

Project Report

RF TX

LCD1

VSSVDDVEE

LM016L

Fig 4.2 Road section

Department of ECE

16

SETCEM

Automatic road security control system

Project Report

4.3 Circuit Diagram of Control Room

TR1

230V AC

TRAN-2P2S

C1+
11
12

T1IN
R1OUT

10
T2IN
9
R2OUT

C2+
4

LCD1

VSSVDDVEE

LM016L

Fig 4.3 Control Room section


Department of ECE

17

SETCEM

Automatic road security control system

Project Report

4.4 MICROCONTROLLER: PIC 16F877A


PIC is a family of Harvard architecture microcontrollers made by Microchip Technology,
derived from the PIC1640 originally developed by General Instrument's Microelectronics Division.
The name PIC initially referred to "Peripheral Interface Controller".
PICs are popular with developers and hobbyists alike due to their low cost, wide availability,
large user base, extensive collection of application notes, availability of low cost or free development
tools, and serial programming (and re-programming with flash memory) capability.

4.4.1 FEATURES OF PIC MICROCONTROLLER

General Features

High performance RISC CPU.

Only 35 simple word instructions.


All single cycle instructions except for program branches which are two cycles.
Operating speed: clock input (200MHz), instruction cycle (200nS).

Up to 3688bit of RAM (data memory), 2568 of EEPROM (data memory), 8k14 of


flash memory.
Pin out compatible to PIC 16C74B, PIC 16C76, PIC 16C77.
Eight level deep hardware stack.
Interrupt capability (up to 14 sources).
Different types of addressing modes (direct, Indirect, relative addressing modes).
Power on Reset (POR).
Power-Up Timer (PWRT) and oscillator start-up timer.
Low power- high speed CMOS flash/EEPROM.
Fully static design.
Wide operating voltage range (2.0 5.56) volts.
High sink/source current (25mA).
Commercial, industrial and extended temperature ranges.

Department of ECE

18

SETCEM

Automatic road security control system

Project Report

Low power consumption (<0.6mA typical @3v-4MHz, 20A typical @3v-32MHz


and <1 A typical standby).

Peripheral Features

Timer 0: 8 bit timer/counter with pre-scalar.

Timer 1:16 bit timer/counter with pre-scalar.


Timer 2: 8 bit timer/counter with 8 bit period registers with pre-scalar and post-scalar.
Two Capture (16bit/12.5nS), Compare (16 bit/200nS), Pulse Width Modules (10bit).
10bit multi-channel A/D converter
Synchronous Serial Port (SSP) with SPI (master code) and I2C (master/slave).

Universal Synchronous Asynchronous Receiver Transmitter (USART) with 9 bit


address detection.
Parallel Slave Port (PSP) 8 bit wide with external RD, WR and CS controls
(40/46pin).
Brown Out circuitry for Brown-Out Reset (BOR).

Key Features

Maximum operating frequency is 20MHz.

Flash program memory (14 bit words), 8KB.


Data memory (bytes) is 368.
EEPROM data memory (bytes) is 256.
5 input/output ports.
3 timers.
2 CCP modules.
2 serial communication ports (MSSP, USART).
PSP parallel communication port
10bit A/D module (8 channels)

Analog Features

10bit, up to 8 channel A/D converter.

Brown out Reset function.


Analog comparator module.

Department of ECE

19

SETCEM

Automatic road security control system

Project Report

Special Features

100000 times erase/write cycle enhanced memory.

1000000 times erase/write cycle data EEPROM memory.


Self programmable under software control.
In-circuit serial programming and in-circuit debugging capability.
Single 5V,DC supply for circuit serial programming
WDT with its own RC oscillator for reliable operation.
Programmable code protection.
Power saving sleep modes.
Selectable oscillator options.

4.4.2 PIN OUT DIAGRAM

Fig 4.4 Pin out diagram


Department of ECE

20

SETCEM

Automatic road security control system

Project Report

Input/output ports
PIC16F877 has 5 basic input/output ports. They are usually denoted by PORT A (R A),
PORT B (RB), PORT C (RC), PORT D (RD), and PORT E (RE). These ports are used for
input/ output interfacing. In this controller, PORT A is only 6 bits wide (RA-0 to RA-7),
PORT B , PORT C,PORT D are only 8 bits wide (RB-0 to RB-7,RC-0 to RC-7,RD-0 to
RD-7), PORT E has only 3 bit wide (RE-0 to RE-7).

PORT-A
PORT-B
PORT-C
PORT-D
PORT-E

All these ports are bi-directional. The direction of the port is controlled by using
TRIS(X) registers (TRIS A used to set the direction of PORT-A, TRIS B used to set the
direction for PORT-B, etc.). Setting a TRIS(X) bit 1 will set the corresponding PORT(X) bit
as input. Clearing a TRIS(X) bit 0 will set the corresponding PORT(X) bit as output.
(If we want to set PORT A as an input, just set TRIS(A) bit to logical 1 and want to
set PORT B as an output, just set the PORT B bits to logical 0.)

Analog input port (AN0 TO AN7): these ports are used for interfacing analog inputs.
TX and RX: These are the USART transmission and reception ports.
SCK: these pins are used for giving synchronous serial clock input.
SCL: these pins act as an output for both SPI and I2C modes.
DT: these are synchronous data terminals.
CK: synchronous clock input.
SD0: SPI data output (SPI Mode).
SD1: SPI Data input (SPI mode).
SDA: data input/output in I2C Mode.

Department of ECE

21

SETCEM

Automatic road security control system

Project Report

CCP1 and CCP2: these are capture/compare/PWM modules.


OSC1: oscillator input/external clock.
OSC2: oscillator output/clock out.
MCLR: master clear pin (Active low reset).
Vpp : programming voltage input.
THV: High voltage test mode controlling.
Vref (+/-): reference voltage.
SS: Slave select for the synchronous serial port.
T0CK1: clock input to TIMER 0.
T1OSO: Timer 1 oscillator output.
T1OS1: Timer 1 oscillator input.
T1CK1: clock input to Timer 1.
PGD: Serial programming data.
PGC: serial programming clock.
PGM: Low Voltage Programming input.
INT: external interrupt.
RD: Read control for parallel slave port.
CS: Select control for parallel slave.
PSP0 to PSP7: Parallel slave port.
VDD: positive supply for logic and input pins.
VSS: Ground reference for logic and input/output pins.

Department of ECE

22

SETCEM

Automatic road security control system

Project Report

4.4.3 BLOCK DIAGRAM OF PIC 16F877A:-

Fig 4.5 Block diagram of PIC16F877


Department of ECE

23

SETCEM

Automatic road security control system

Project Report

4.4.4 MEMORY ORGANIZATION


There are three memory blocks in each of these PIC micro MCUs: The Program
Memory, Data Memory and EEPROM data memory.

Program Memory Organization

The PIC16F87X devices have a 13-bit program counter capable of addressing an


8K x 14 program memory space. The PIC16F877/876 devices have 8K x 14 words of FLASH
program memory. Accessing a location above the physically implemented address will cause a
wrap around. The reset vector is at 0000h and the interrupt vector is at 0004h.

Data Memory Organization

The data memory is partitioned into multiple banks which contain the General
Purpose Registers and the Special Function Registers. Bits RP1 (STATUS<6>) and RP0
(STATUS<5>) are the bank select bits.
RP1:RP0
00
01
10
11
Table 4.2 Data memory organization

Each bank extends up to 7Fh (128 bytes). The lower locations of each bank are reserved for
the Special Function Registers. Above the Special Function Registers are General Purpose
Registers, implemented as static RAM. All implemented banks contain Special Function
Registers. Some high use Special Function Registers from one bank may be mirrored in
another bank for code reduction and quicker access
Department of ECE

24

SETCEM

Automatic road security control system

Project Report

Data EEPROM and FLASH program memory

The Data EEPROM and FLASH Program Memory are readable and writable during
normal operation over the entire VDD range. The EEPROM data memory allows byte read
and write.
When interfacing to the data memory block, EEDATA holds the 8-bit data for
read/write and EEADR holds the address of the EEPROM location being accessed. The
registers EEDATH and EEADRH are not used for data EEPROM access. These devices have
up to 256 bytes of data EEPROM with an address range from 0h to FFh. The EEPROM data
memory is rated for high erase/write cycles. The write time is controlled by an on-chip timer.
The write time will vary with voltage and temperature, as well as from chip-to-chip. Please
refer to the specifications for exact limits.

4.4.5 TIMER MODULES

TIMER0 MODULE
The Timer0 module timer/counter has the following features:
8-bit timer/counter
Readable and writable
8-bit software programmable prescaler
Internal or external clock select
Interrupt on overflow from FFh to 00h
Edge select for external clock

TIMER1 MODULE

The Timer1 module is a 16-bit timer/counter consisting of two 8-bit registers


(TMR1H and TMR1L), which are readable and writable. The TMR1 Register pair
(TMR1H:TMR1L) increments from 0000h to FFFFh and rolls over to 0000h. The TMR1
Department of ECE

25

SETCEM

Automatic road security control system

Project Report

Interrupt, if enabled, is generated on overflow, which is latched in interrupt flag bit TMR1IF
(PIR1<0>). This interrupt can be enabled/disabled by setting/clearing TMR1 interrupt enable
bit TMR1IE (PIE1<0>).
Timer1 can operate in one of two modes:
As a timer
As a counter
The operating mode is determined by the clock select bit, TMR1CS (T1CON<1>).
In timer mode , Timer1 increments in every instruction cycle. In counter mode, it
increments on every rising edge of the external clock input.Timer1 can be enabled/disabled by
setting/clearing control bit TMR1ON (T1CON<0>).Timer1 also has an internal reset input.
This reset can be generated by either of the two CCP modules

TIMER2 MODULE

Timer2 is an 8-bit timer with a prescaler and a postscaler. It can be used as the
PWM time-base for the PWM mode of the CCP module(s). The TMR2 register is readable
and writable, and is cleared on any device reset. The Timer2 module has an 8-bit period
register PR2.Timer2 increments from 00h until it matches PR2 and then resets to 00h on the
next increment cycle. PR2 is a readable and writable register. The PR2 register is initialized to
FFh upon reset.

4.4.6 CAPTURE/COMPARE/PWM MODULES

Each Capture/Compare/PWM (CCP) module contains a 16-bit register which can


operate as a:
16-bit Capture register
16-bit Compare register
PWM master/slave Duty Cycle register

Department of ECE

26

SETCEM

Automatic road security control system

Project Report

Both the CCP1 and CCP2 modules are identical in operation, with the exception being
the operation of the special event trigger.

4.5 GSM MODULE


During the early 1980s, analog cellular telephone systems were experiencing rapid
growth in Europe, particularly in Scandinavia and the United Kingdom, but also in France and
Germany. Each country developed its own system, which was in compatible with everyone
else's in equipment and operation. This was an undesirable situation, because not only was the
mobile equipment limited to operation within national boundaries, which in a unified Europe
were increasingly unimportant, but there was also a very limited market for each type of
equipment, so economies of scale and the subsequent savings could not be realized. The
Europeans realized this early on, and in 1982 the Conference of European Posts and
Telegraphs (CEPT) formed a study group called the Group Spcial Mobile (GSM) to study
and develop a pan-European public land mobile system. The proposed system had to meet
certain criteria:

Good subjective speech quality

Low terminal and service cost

Support for international roaming

Ability to support handheld terminals

Support for range of new services and facilities

Spectral efficiency

ISDN compatibility And interaction with the Integrated service digital network (ISDN) which
offers the capability to extend the single-subscriber line system with the various to a
multiservice system. The first commercial GSM system, called D2, was implemented in
Germany in 1982.2 This valuable channel of communication can equip us with a powerful
tool for controlling desired device or process parameter from distant location, through
electromagnetic waves. With a little effort logic can be setup to even receive a feedback on the
status of the device or the process being controlled.

Department of ECE

27

SETCEM

Automatic road security control system

Project Report

4.5.1 SERVICES PROVIDED BY GSM


From the beginning, the planners of GSM wanted ISDN compatibility in terms of the
services offered and the control signalling used. However, radio transmission limitations, in
terms of bandwidth and cost, do not allow the standard ISDN B-channel bit rate of 64kbps to
be practically achieved. Using the ITU-T definitions, telecommunication services can be
divided into bearer services, tele services, and supplementary services. The most basic tele
service supported by GSM is telephony. As with all other communications, speech is digitally
encoded and transmitted through the GSM network as a digital stream. There is also an
emergency service, where the nearest emergency-service provider is notified by dialing three
digits. A variety of data services is offered. GSM users can send and receive data, at rates up
to9600 bps, to users on POTS (Plain Old Telephone Service), ISDN, Packet Switched Public
Data Networks, and Circuit Switched Public Data Networks using a variety of access methods
and protocols, such as X.25 or X.32. Since GSM is a digital network, a modem is not required
between the user and GSM network, although an audio modem is required inside the GSM
network to interwork with POTS. Other data services include Group 3 facsimile, as described
in ITU-T recommendationT.30, which is supported by use of an appropriate fax adaptor. A
unique feature of GSM, not found in older analog systems, is the Short Message Service
(SMS). SMS is a bidirectional service for short alphanumeric (up to 160 bytes) messages.
Messages are transported in a store-and-forward fashion. as traffic updates or news updates.
Messages can also be stored in the SIM card for later retrieval .Supplementary services are
provided on top of tele services or bearer services. In the current (Phase I) specifications, they
include several forms of call forward (such as call forwarding when the mobile subscriber is
unreachable by the network), and call barring of outgoing or incoming calls, for example
when roaming in another country. Many additional supplementary services will be provided in
the Phase 2 specifications, such as caller identification, call waiting, multi-party
conversations.

Department of ECE

28

SETCEM

Automatic road security control system

Project Report

4.5.2 ARCHITECTURE OF THE GSM NETWORK

A GSM network is composed of several functional entities, whose functions and


interfaces are specified. Figure 1.1 shows the layout of a generic GSM network. The GSM
network can be divided into three broad parts. The Mobile Station is carried by the subscriber.
The Base Station Subsystem controls the radio link with the Mobile Station. The Network
Subsystem, the main part of which is the Mobile services Switching Center (MSC), performs
the switching of calls between the mobile users, and between mobile and fixed network users.
The MSC also handles the mobility management operations. Not shown is the Operations and
Maintenance Center, which oversees the proper operation and setup of the network. The
Mobile Station and the Base Station Subsystem communicate across the Um interface, also
known as the air interface or radio link.

Figure 4.6 General Architecture of a GSM Network

Department of ECE

29

SETCEM

Automatic road security control system

Project Report

4.5.2.1 Mobile Station


The mobile station (MS) consists of the mobile equipment (the terminal) and a smart
card called the Subscriber Identity Module (SIM). The SIM provides personal mobility, so
that the user can have access to subscribed services irrespective of a specific terminal. By
inserting the SIM card into another GSM terminal, the user is able to receive calls at that
terminal, make calls from that terminal, and receive other subscribed services. The mobile
equipment is uniquely identified by the International Mobile Equipment Identity (IMEI). The
SIM card contains the International Mobile Subscriber Identity(IMSI) used to identify the
subscriber to the system, a secret key for authentication, and other information. The IMEI and
the IMSI are independent, thereby allowing personal mobility. The SIM card may be protected
against unauthorized use by a password or personal identity number.
4.5.2.2 Base Station Subsystem
The Base Station Subsystem is composed of two parts, the Base Transceiver
Station(BTS) and the Base Station Controller (BSC). These communicate across the
standardized Abis interface, allowing (as in the rest of the system) operation between
components made by different suppliers. The Base Transceiver Station houses the radio
transceivers that define a cell and handles the radio-link protocols with the Mobile Station. In
a large urban area, there will potentially be a large number of BTSs deployed, thus the
requirements for a BTS are ruggedness, reliability, portability, and minimum cost. The Base
Station Controller manages the radio resources for one or more BTSs. It handles radiochannel setup, frequency hopping, and handovers, as described below. The BSC is the
connection between the mobile station and the Mobile service Switching Center (MSC).
4.5.2.3Network Subsystem
The central component of the Network Subsystem is the Mobile services Switching
Center (MSC). It acts like a normal switching node of the PSTN or ISDN, and additionally
provides all the functionality needed to handle a mobile subscriber, such as registration,
Department of ECE

30

SETCEM

Automatic road security control system

Project Report

authentication, location updating, handovers, and call routing to a roaming subscriber. These
services are provided in conjuction with several functional entities, which together form the
Network Subsystem. The MSC provides the connection to the fixed networks (such as the
PSTN or ISDN). Signalling between functional entities in the Network Subsystem uses
Signalling System Number 7 (SS7), used for trunk signalling in ISDN and widely used in
current public networks. The Home Location Register (HLR) and Visitor Location Register
(VLR), together with the MSC, provide the call-routing and roaming capabilities of GSM.
The HLR contains all the administrative information of each subscriber registered in the
corresponding GSM network, along with the current location of the mobile. The location of
the mobile is typically in the form of the signalling address of the VLR associated with the
mobile station. The actual routing procedure will be described later. There is logically one
HLR per GSM network, although it may be implemented as a distributed database. The
Visitor Location Register (VLR) contains selected administrative information from the HLR,
necessary for call control and provision of the subscribed services, for each mobile currently
located in the geographical area controlled by the VLR. Although each functional entity can
be implemented as an independent unit, all manufacturers of switching equipment to date
implement the VLR together with the MSC, so that the geographical area controlled by the
MSC corresponds to that controlled by the VLR, thus simplifying the signalling required.
Note that the MSC contains no information about particular mobile stations --- this
information is stored in the location registers. The other two registers are used for
authentication and security purposes. The Equipment Identity Register (EIR) is a database that
contains a list of all valid mobile equipment on the network, where each mobile station is
identified by its International Mobile Equipment Identity (IMEI). An IMEI is marked as
invalid if it has been reported stolen or is not type approved. The Authentication Center (AuC)
is a protected database that storesa copy of the secret key stored in each subscriber's SIM card,
which is used for authentication and encryption over the radio channel.

Department of ECE

31

SETCEM

Automatic road security control system

Project Report

4.5.3 APPLICATION AREAS

Mobile Transport vehicles.

LAN based SMS servers

Alarm notification of critical events including Servers

Network Monitoring and SMS reporting

Data Transfer applications from remote locations

Monitor and control of Serial services through GSM Network

Integration to custom software for Warehouse, Stock, Production, Dispat


chnotification through SMS.

AMR- Automatic Meter ReadingAnd many more

4.5.4 Role GSM modem in project (900/1800 MHz)


Semens GSM/GPRS Smart Modem is a multi-functional, ready to use, rugged unit that
can be embedded or plugged into any application. The Smart Modem can be controlled and
customized to various levels by using the standard AT commands. The modem is fully typeapproved, it can speed up the operational time with full range of Voice, Data, Fax and Short
Messages (Point to Point and Cell Broadcast), the modem also supports GPRS (Class 2*) for
spontaneous data transfer.
Description of the interfaces
The modem comprises several interfaces:

LED Function including operating Status

External antenna ( via SMA)

Serial and control link

Power Supply ( Via 2 pin Phoenix

SIM card holder

tm

contact )

LED Status Indicator


The LED will indicate different status of the modem:
Department of ECE

32

SETCEM

Automatic road security control system

OFF

ON

Flashing Slowly

Flashing rapidly

4.5.5 WORKING PRINCIPLE:

The working principle of SMS controller is based upon the use of sending & receiving
SMS through serial communication over GSM network. After receiving new SMS we have to
process these SMS to perform the desired task.
To perform this task we need a GSM MODEM & a microcontroller. The task of the GSM
MODEM is to receive the SMS & inform the connected microcontroller on its serial port
about its availability. Once the microcontroller has detected a new message it will read it from
GSM MODEM and process it to perform the desired task.
The work on this project one should have good knowledge of Microcontroller & Its
programming as well as GSM MODEM & Its Commands.

4.6 LCD DISPLAY

Liquid crystal displays are generally more flexible than LED displays because they
allow for a variety of text and/or graphics. LCDs require less power LEDs making them
suitable for lose power requirements.) LCDs are more readable in sunlight and an use
backlights for night viewing. However, LCDs are more expensive than LED displays. LCDs
come in a variety of sizes. Text displays are specified by their character size, the number of
lines, and the number of characters per line.

Department of ECE

33

SETCEM

Automatic road security control system

Project Report

4.6.1 LCD MODULE

The LCD module, made by Crystallonics, is 16x2 line interactive displays. It needs
power supply of +5v. The module has inbuilt controller chip, such as an HD44780, which acts
as an interface between CPU and the row and column drivers. The controller takes care of
generating characters, refreshing the display, and so on. The module has a back light driven by
a pair of pads separate from the interface pads .The LCD module works in two modes for
communicating with the micro controller - 8 bit (byte) mode & 4 bit (nibble) mode. In the
later case only the higher nibble i.e. pins DB4-DB7 is used for communication. For
controlling the LCD module we have used only the port D.

Fig 4.7 LCD MODULE

4.6.2PINOUT DESCRIPTION:

Fig 4.8Pin out of LCD Module

Department of ECE
Automatic road security control system

34

SETCEM

PIN NO.
1
2
3
4

6
7
8
9
10
11
12
13
14
15
16

Table 4.3 LCD module


Department of ECE

35
SETCEM

Automatic road security control system

Project Report

Pin out description


Contrast: A variable voltage applied to this pin controls the contrast. Use a

potentiometer

and adjust until you see the background.


Register Select: This pin selects whether you are sending the module a command or data.
Read/Write: This pin allows for bi-directional communications. For the discussions here, unidirectional communications will be used. Ground this pin.
Enable: This is the latch pin. A high-to-low transition causes the value on the data lines to be
latched by the module.
DB0-DB7: Apply the data or commands to these pins.

4.7 DRIVER
Driver is used to boost the current. The current from microcontroller is not sufficient
enough to rotate the motor so a current amplifier is used .L293D is used to drive the motor.
4.7.1 L293D

L293D is used as a driver IC. The two motors that for crane movements are connected
st

th

to the microcontroller through L293D. The 1 and 9 pin of L293D is connected to P1.0, this
for enabling the two motors. The 2
The 2

nd

nd

th

and 7 pins are two input pins from the microcontroller.


th

rd

th

pin is connected to P1.1 and 7 pin is connected to P1.2. The 3 and 6 pins are two
th

th

output pins of Motor 1. These two pins are connected to the motor1. The 4 and 5 pins are
th

th

connected to GND. The 10 and 15 pins are next two input pins from the controller. The
th

th

th

th

10 pin is connected to P1.3 and 15 pin is connected to P1.4. The 11 and 14 pins are two
th

th

output pins of Motor 2. These two pins are connected to the Motor 2. The 12 and 13 pins
are connected to GND. The L293D IC is helps to the direction control and to avoid kick
th

th

backs. The 8 pin is connected to a 12V supply, that for driving the motors. The 16 pin is
connected to a 5V supply.
Department of ECE

36

SETCEM

Automatic road security control system

Project Report

4.8 LEVEL CONVERTER (MAX 232)

Fig 4.9 Pin out diagram of MAX 232


The RS232 is the most widely used serial I/O interfacing standard. This standard is
used in PCs and numerous types of equipment. In RS232 1 is represented by -3 to -25 V,
while a 0 bit is +3 to +25 V. For this reason, to connect any RS232 to a microcontroller
system we must use voltage converters such as MAX232 to convert the TTL logic levels to
the RS232 voltage levels, and vice versa. MAX232 IC chips are commonly referred to as line
drivers.
One advantage of the MAX232 chip is that it uses a +5V power source which, is the
same as the source voltage for the 8051. The MAX232 has two sets of line drivers for
transferring and receiving data. The line drivers used for TxD are called T1 and T2, while the
line drivers for RxD are designated as R1 and R2. T1 and R1 used together for TxD and RxD
f the 8051, and the second set is left unused. T1 line driver has a designation of T1in and
T1out of pin numbers11 and 14, respectively. The T1in pin is the TTL side and is connected to
TxD of the microcontroller, while T1out is the RS232 side that is connected to the RxD pin of
the RS232 DB connecter. The R1 line driver has a designation of R1in and R1out on pin
numbers 13 and12, respectively. The R1in is the RS232 side that is connected to the TxD pin
Department of ECE

37

SETCEM

Automatic road security control system

Project Report

of the RS232 DB connecter, and R1out is the TTL side that is connected to the RxD pin of the
microcontroller. MAX232 requires four capacitors ranging from 1 to 22 mf.
RF Specifics (stolen right from the book)
Parameter

Value

Downstream Frequencies 935-960MHz, 1805-1880MHz


Upstream Frequency

890-915MHz, 1710-1785MHz

Channel Spacing

200kHz

Duplex Spacing

45MHz

Radio Power

13-39dBm, 2dB steps

Data Rise/Fall Time

28 microseconds

Emissions

< -36dBm

Phase Error

5 deg RMS

Freq Error

95Hz

Recv Sensitivity

104dBm

Co-channel Rejection

96dBm below signal

Intermodulation Rejection 100dBm below signal


Signal Blocking Level

100dBm

Packets and data


During a single time slot is your phone transmitting, and the contents of the time slot is called
a packet. Packets are made of bits, and bits are made of magic.
Department of ECE

38

SETCEM

Automatic road security control system

Project Report

A packet can be 4 different things:

random access burst - shorter than the normal burst.

synchronization burst - same length as the normal burst but a different structure

normal burst - carries speech or data information. lasts approximately 0.577 ms and
has a length of 156.25 bits

frequency correction burst - same length as the normal burst but a different structure

Each type has a different packet structure, and is visible here:

Fig 4.10 different packet structure


The Network Subsystem
The main component here is the MSC. The MSC contains the Home Locator Register
(HLR), Visitor Locator Register (VLR), and Authentication Center (AUC). These are the most
interesting non-RF related parts of the system back end.

Department of ECE

39

SETCEM

Automatic road security control system

Project Report

HLR
The HLR contains a lot of interesting information. The HLR is responsible for
subscription details, and supplementary services. It also maintains information on the last
know location and status of a particular phone.
Since a user can use any phone with his or her SIM card, there's a protocol necessary
to manage accessing the network. Information contained on the SIM card is transmitted to the
HLR to verify the identity of the subscriber. Location and status are continually updated in the
HLR based on the base station reports and cell phone status. Any messages to be sent to the
subscriber are queued in the HLR. All call setup queries ask the HLR for information before
doing anything else.
VLR
Like the HLR, the VLR keeps track of users but only within the area thet the VLR is
assigned. The VLR communicates with the HLR to figure out where to route calls, and to
keep track of peple as they move around.
AUC
The AUC is basically just a database full onf confidential subscriber information
attached to the back of the HLR. Its located in a "secure place" and the data is stored in
"coded" form (sounds like encryption to me). The AUC is responsible for controlling the
rights of usage of the network services, i.e. phone calls, data, internet, etc... The AUC allows
the Network Operator (Cingular, AT&T) to know "unambiguiusly" who is on the network for
billing purposes. The AUC also protects the user from fraud (somehow ...) and contains the
secret information necessary to handle authentication and encryption.
Authentication with the network
Authentication on the network works as follows. First the mobile terminal is asked to
perform a computation on a random number supplied by the system using a secret key stored
on the SIM card. The system does this calculation internally, and compares the outputs. Both
the algorithm and key are stored in secure formats.

Department of ECE

40

SETCEM

Automatic road security control system

Project Report

More detailed authentication ... When a terminal connects to the network, a RNG gives
it a number N which is encrypted with a secret personal key Kp. The resulting number is
encrypted with an algorithm called A3 and transmitted back to the network and compared.
The subscriber then generates a session key for encrpytion using the algorithm A8. The
encryption algorithm A5 is used to encrypt each packet.
After the subscriber is verified, the encryption of radio packets is handled by a
different algorithm, called A5 (A3 is used during subscriber verification). The encryption key
is supplied during authentication, using some key agreement scheme and each packet is also
encrypted using a changing IV of some variety, which appears to be a packet number. I do not
think either of these algorithms are officially public (LINKS?).
Encryption and Security
There are 3 main algorithms used in GSM. Each of these algorithms is a trade secret
and only released to people who the GSM committee determines has a need-to-know.
Name Use
A3

Authentication
Encryption/Decryption

A5

packet encryption

A8

Cipher Key Generator

4.9 GPS MODULE


GPS module A1080-A is a highly integrated GPS receiver module that can be used as
an SMT component. It is capable to receive signals from up to 20 GPS satellites and
transferring them into position and timing information that can be read over a serial port. This
new generation of GPS module combines small size and high-end GPS functionality at low
power consumption:

Department of ECE

41

SETCEM

Automatic road security control system

Project Report

Operable at 3.3V / 36mA (typ.) @ 1fix per second

Small form factor of 19 x 16.2 mm (0.75 x 0.64)

Cost-effective antenna input

Single-sided SMD component, for reflow soldering

Tape & reel packaging

The A1080-A GPS receivers are available as off-the-shelf component, 100% tested
and shipped in standard tape-and-reel package.

GPS Characteristics

Channels 20, parallel tracking

Correlators 200.000 plus

Frequency L1 (= 1575 MHz)

Tracking Sensitivity -159dBm

Position Accuracy Stand alone < 10m CEP (SA off)

Obscuration recovery (1) 0.1s

Hot start (2) < 1s

Warm (3) < 32s

Time To First Fix TTFF

Antenna
It is recommended to use an active GPS antenna with supply voltage of 3 to 5VDC
and a current draw of 50mA maximum. The quality of the GPS antenna chosen is of
paramount importance for the overall sensitivity of the GPS system. An active antenna should
have a gain 20dB and a noise figure 1.5dB, which applies to more than 95% of the active
antennas available in the market
Serial Port Settings
The default configuration within the standard GPS firmware is:
Department of ECE

42

SETCEM

Automatic road security control system

Project Report

Serial 0 (NMEA) 4800 baud, 8 data bits, no parity, 1 stop bit, no flow
Control.
Serial 1 (binary) 38400 baud, 8 data bits, no parity, 1 stop bit, no flow
Control.
General Comments
The following comments should be considered for a design with and use of the
module:
Standard configuration of serial port (standard GPS software):
Serial 0 (NMEA) 4800 baud, 8 data bits, no parity, 1 stop bit, no flow
control
Antenna (Antenna connected to Antenna Pin)
Use ground pins (pin 18, pin 20) close to the antenna input for RF groun
Electrical Characteristics
Vcc
Peak Acquisition Current
Average Acquisition Current
Tracking Current
Standby Current

(1) Peak acquisition current is characterized by millisecond bursts above


average acquisition current

Department of ECE

43

SETCEM

Automatic road security control system

Project Report

(2) Average current is typically only the first two seconds of TTFF
(3) Tracking current typically includes tracking and the post acquisition
portion of TTFF
(4) During standby state: RTC block and core powered on and clock off.

Absolute maximum ratings


Vcc power supply
Vin voltage to any pin
Iov input current on any pin
Itdv absolute sum of all input currents during overload condition
Tst storage temperature
Vant antenna supply voltage
Iant antenna supply current
Stresses beyond those listed under Absolute Maximum Ratings may cause
permanent damage to the device. This is a stress rating only. Functional operation of the
device at these or any other conditions beyond those indicated in the operational sections of
this specification is not implied. Exposure to absolute maximum rating conditions for
extended periods may affect device reliability.

Department of ECE

44

SETCEM

Automatic road security control system

Project Report

4.10 POWER SUPPLY


The input to the circuit is applied from the regulated power supply. The a.c. input i.e.,
230V from the mains supply is step down by the transformer to 12V and is fed to a rectifier.
The output obtained from the rectifier is a pulsating d.c voltage. So in order to get a pure d.c
voltage, the output voltage from the rectifier is fed to a filter to remove any a.c components
present even after rectification. Now, this voltage is given to a voltage regulator to obtain a
pure constant dc voltage.

Fig 4.11 Power supply

4.10.1 Transformer:
Usually, DC voltages are required to operate various electronic equipment and these
voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c input
available at the mains supply i.e., 230V is to be brought down to the required voltage level.
This is done by a transformer. Thus, a step down transformer is employed to decrease the
voltage to a required level.

Department of ECE

45

SETCEM

Automatic road security control system

Project Report

Fig 4.12 Step down transformer

4.10.2 Rectifier:
The output from the transformer is fed to the rectifier. It converts A.C. into pulsating
D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier
is used because of its merits like good stability and full wave rectification.

Fig 4.13 Rectifier

The Bridge rectifier is a circuit, which converts an ac voltage to dc voltage using both
half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure. The
circuit has four diodes connected to form a bridge. The ac input voltage is applied to the
diagonally opposite ends of the bridge. The load resistance is connected between the other two
ends of the bridge.
Department of ECE

46

SETCEM

Automatic road security control system

Project Report

For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas diodes
D2 and D4 remain in the OFF state. The conducting diodes will be in series with the load
resistance RL and hence the load current flows through RL.
For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct whereas, D1
and D3 remain OFF. The conducting diodes D2 and D4 will be in series with the load
resistance RL and hence the current flows through RL in the same direction as in the previous
half cycle. Thus a bi-directional wave is converted into a unidirectional wave.

8.3 Filter:
Capacitive filter is used in this project. It removes the ripples from the output of
rectifier and smoothens the D.C. Output received from this filter is constant until the mains
voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage
received at this point changes. Therefore a regulator is applied at the output stage.

8.4 Voltage regulator:


As the name itself implies, it regulates the input applied to it. A voltage regulator is an
electrical regulator designed to automatically maintain a constant voltage level. In this project,
power supply of 5V and 12V are required. In order to obtain these voltage levels, 7805 and
7812 voltage regulators are to be used.

Fig 4.14 Voltage regulator.

Department of ECE
Automatic road security control system

Project Report

The 78xx (sometimes LM78xx) is a family of self-contained fixed linear voltage


regulator integrated circuits. The 78xx family is commonly used in electronic circuits
requiring a regulated power supply due to their ease-of-use and low cost. For ICs within the
family, the first number 78 represents positive supply and the xx is replaced with two digits,
indicating the output voltage. 78xx ICs have three terminals and are commonly found in the
TO220 form factor, although smaller surface-mount and larger TO3 packages are available.
These devices support an input voltage anywhere from a couple of volts over the intended
output voltage, up to a maximum of 35 to 40 volts depending on the make, and typically
provide 1 or 1.5 amperes of current. These regulators can provide local on-card regulation,
eliminating the distribution problems associated with single point regulation. The voltages
available allow these regulators to be used in logic systems, instrumentation, HiFi, and other
solid state electronic equipment. Each type employs internal current limiting, thermal shutdown and safe area protection, making it essentially indestructible. If adequate heat sinking is
provided, they can deliver over 1 A output current. Although designed primarily as fixed
voltage regulators, these devices can be used with external components to obtain adjustable
voltage and currents.

Department of ECE

48

SETCEM

Automatic road security control system

Project Report

CHAPTER 5
PCB DESIGN AND LAYOUT
5.1 PROCEDURE
5.1.1 PCB Design

The PCB design starts right from the selection of the laminates .The two main types of base
laminate are epoxy glass and phenolic paper laminates are generally used for simple circuits. Though it
is very cheap and can easily be drilled, phenolic paper has poor electrical characteristics and it absorbs
more moisture than epoxy glass. Epoxy glass has higher mechanical strength.

The important properties that have to be considered for selecting the PCB substrate are
the dielectric strength, insulation resistance, water absorption property, coefficient of thermal
expansion, shear strength, hardness, dimensional stability etc.

5.1.2 Manufacturing Process

The steps involved in manufacture are


a) Artwork preparation.
b) Resist preparation.
c) Resist application an fixing.
d) Acid etches.
e) Cleaning and inspection.
f) Resist removal.

5.1.3 PCB Fabrication

The fabrication of a PCB basically of four steps.


a) Preparing the PCB pattern.
b) Transferring the pattern onto the PCB.
Department of ECE

49

SETCEM

Automatic road security control system

Project Report

c) Developing the PCB.


d) Finishing i.e.) drilling, cutting, smoothing, turning etc.

5.1.4 Preparing the PCB pattern.

Pattern designing is the primary step in fabricating a PCB in this step, all
interconnection between the components in the given circuit are converted into PCB tracks
several factors such as positioning ,the diameter of holes, the area that each component
would occupy ,the type of end terminal should be considered.

5.1.5 Transferring the PCB Pattern

The copper side of the PCB should be thoroughly cleaned with the help of alcoholic
spirit or petrol must be completely free from dust and other contaminants. The mirror image
of the pattern must be carbon copied and to the laminate the complete pattern may now be
made each resistant with the screen printing technology.

5.1.6 Developing
In this developing all excessive copper is removed from the board and only the printed
pattern is left behind. About 100ml of tape water should be heated to 75 C and 30.5 grams of
FeCl3 added to it, the mixture should be thoroughly stirred and a few drops of HCl may be
added to speed up the process.
The board with its copper side facing upward should be placed in a flat bottomed
plastic tray and the aqueous solution of FeCl2 poured in the etching process would take 40 to
60 min to complete.
After etching the board it should be washed under running water and then held against
light .the printed pattern should be cleanly visible. The paint should be removed with the help
of thinner.

Department of ECE

50

SETCEM

Automatic road security control system

Project Report

5.1.7 Finishing Touches

After the etching is completed, hole of suitable diameter should be drilled, then the
PCB may be tin plated using an ordinary 35 Watts soldering rod along with the solder core,
the copper side may be given a coat of varnish to prevent oxidation.

5.1.8 Drilling

Drills for PCB use usually come with either a set of collects of various sizes or a 3Jaw chuck. For accuracy however 3-jaw chunks arent brilliant and small drill below 1 mm
from grooves in the jaws preventing good grips.

5.1.9 Soldering

Begin the construction by soldering the resistors followed by the capacitors and the
LEDs diodes and IC sockets. Dont try soldering an IC directly unless you trust your skill in
soldering. All components should be soldered as shown in the figure. Now connect the switch
and then solder/screw if on the PCB using multiple washers or spaces. Soldering it directly
will only reduce its height above other components and hamper in its easy fixation in the
cabinet. Now connect the battery lead.

5.1.10 Assembling

The circuit can be enclosed in any kind of cabinet. Before fitting the PCB suitable holes
must be drilled in the cabinet for the switch, LED and buzzer. Note that a rotary switch can be
used instead of a slide type.
Switch on the circuit to be desired range. It will automatically start its timing cycles.
To be sure that it is working properly watch the LED flash. The components are selected to
trigger the alarm a few minutes before the set limit.

Department of ECE

51

SETCEM

Automatic road security control system

Project Report

5.2 PCB LAYOUT

Department of ECE

52

SETCEM

Automatic road security control system

Project Report

ADVANTAGES AND DISADVANTAGES

ADVANTAGES
Since speed control in automobile is necessary, Automatic road security control system
have many advantages. The main advantage is that speed control can be done in particular
locations where speed control is necessary. Smooth traffic flow can be maintained due to lane
driving. Since the speed is maintained at a constant 30km/h, it is fast enough for travelling and
slow enough for the driver to escape unhurt in a unlikely accident. We can decrease road
accidents to an extent. Petrol consumption is reduced at starting time. It also increases battery
life span. Only a few components are added to get all these advantages. This method is
extremely cost effective and easily implementable as the parts required are available in any
garage.
Its usefulness for long drives (reducing driver fatigue, improving comfort by allowing
positioning changes more safely) across highways and sparsely populated roads. This usually
results in better fuel efficiency.
Some drivers use it to avoid subconsciously violating speed limits. A driver who
otherwise tends to subconsciously increase speed over the course of a highway journey may
avoid a speeding ticket. Such drivers should note, however, that a cruise control may go over
its setting on a downhill which is steep enough to accelerate with an idling engine.

DISADVANTAGES
This system is not without limitations in its present form.
1) We have to set transmitters in all locations where speed control is necessary.
2) Cost is slightly more than existing one.

Department of ECE

53

SETCEM

Automatic road security control system

Project Report

APPLICATIONS

Governors can be used to limit the top speed for vehicles and for some classes of
vehicle such devices are a legal requirement

They can more generally be used to limit the rotational speed of internal combustion
engine or protect the engine from damage due to excessive rotational speed.

Aircraft propellers are another application; The governor senses shaft rpm, and adjusts
or controls the angle of the blades to vary the torque load on the engine. Thus as the
aircraft speeds up (as in a dive) or slows (in climb) the RPM is held constant

Small engines, such as used to power lawn mowers, portable generator, and lawn and
garden tractors, are equipped with a governor to gas limit the engine to a maximum
safe speed when unloaded and to maintain a relatively constant speed despite changes
in loading.

Department of ECE

54

SETCEM

Automatic road security control system

Project Report

FUTURE WORKS
As the first step towards our project, we have created a layout of Automatic road
security control system using GSM module.
In the second step we have to introduce an accident alert system with vibrating sensors.
According to the threshold level variations from the sensors will alert the control room. GPS
modem introduced for location tracking by satellite communication. We get the basic idea of
existing system and its drawbacks. So that it will help us to achieve our target.

Department of ECE

55

SETCEM

Automatic road security control system

Project Report

CONCLUSION
Nowadays, number of road accidents ,traffic rule violations are on the rise such as in
speed limited areas such as metropolitan cities, school areas etcBy the implementation of
this speed governing system in practice, we aim to reduce the repetitive occurrence of such
incidents. Since it is cost efficient, it can be implemented in developing countries like India as
we all know the restless people will not voluntarily take action for speed control. So we hope
there by this project will be able to save at least a few lives.

Department of ECE

56

SETCEM

Automatic road security control system

Project Report

REFERENCES
1) Biding T (2002) Intelligent speed adaptation, Swedish national road administration.
2) Carsha B and Hedlund J (2007) Changing Americas culture of speed on the roads
3) Harsten O (2000) External vehicle speed control-executive summary of projects result,
university of Leeds july 2000.
4) Johnson Mark (No Date), Future of speed control Available
5) Julliere M(1970) speed control methods Available.
6) M Carl Smith and Robert N Schneider (No Date) Road development
7) Wolf SA (2006) speed control- IBM Journal of Research and Development

Department of ECE

57

SETCEM

Automatic road security control system

Project Report

APPENDIX
#include "SMS_RELAY_SWITCHING.h"
void main (void)
{
ADCON1=0x07;
TRISA=0x00;
PORTA=0x00;
TRISC=0x80;
PORTC=0x80;
TRISD=0x00;
PORTD=0x00;
TRISB=0x00;
PORTB=0x00;
all_relay_controll(ALL_RELAY_OFF);
LED_GSM_READY_OFF;
LED_GSM_INIT_OFF;
sci_Init(9600);
Delay_ms(50);
while(1)
{
if(gsm_power_flag==0)gsm_power_on();
Department of ECE
Automatic road security control system

58

SETCEM

if(gsm_boot_ok==1)LED_GSM_INIT_ON; /

Project Report

/***************gsm receive check


gsm_receive();

}
}
void latch_relay(unsigned char relay_port,unsigned char relay_control)
{
if((relay_port=='1')&&(relay_control==RELAY_ON))
{
RELAY1_ON;
}
else if((relay_port=='1')&&(relay_control==RELAY_OFF))
{
RELAY1_OFF;
}
else if((relay_port=='2')&&(relay_control==RELAY_ON))
{
RELAY2_ON;
}
else if((relay_port=='2')&&(relay_control==RELAY_OFF))
{

Department of ECE
SETCEM

Automatic road security control system

Project Report

RELAY2_OFF;
}
else if((relay_port=='3')&&(relay_control==RELAY_ON))
{
RELAY3_ON;
}
else if((relay_port=='3')&&(relay_control==RELAY_OFF))
{
RELAY3_OFF;
}
else if((relay_port=='4')&&(relay_control==RELAY_ON))
{
RELAY4_ON;
}
else if((relay_port=='4')&&(relay_control==RELAY_OFF))
{

RELAY4_OFF;
}
else if((relay_port=='5')&&(relay_control==RELAY_ON))RELAY5_ON;
else if((relay_port=='5')&&(relay_control==RELAY_OFF))RELAY5_OFF;

Department of ECE
Automatic road security control system

60

SETCEM

else if((relay_port=='6')&&(relay_control==RELAY_ON))RELAY6_ON;
TXSTA.SYNC = 0;
else
if((relay_port=='6')&&(relay_control==RELAY_OFF))RELAY6_OFF;
else if((relay_port=='7')&&(relay_control==RELAY_ON))RELAY7_ON;
else
if((relay_port=='7')&&(relay_control==RELAY_OFF))RELAY7_OFF;
else if((relay_port=='8')&&(relay_control==RELAY_ON))RELAY8_ON;
else
if((relay_port=='8')&&(relay_control==RELAY_OFF))RELAY8_OFF;
}

void sci_Init(unsigned long baud)


{
TRISC.F7=1;TRISC.F6=0;
PIR1 = 0;
INTCON.PEIE = 1;
INTCON.GIE
TXSTA.BRGH = 0;
if(baud==1200)SPBRG = 155;
if(baud==2400)SPBRG = 78;
if(baud==9600)SPBRG = 19;
if(baud==19200)SPBRG = 9;

Project Report

Department of ECE
Automatic road security control system

61

RCSTA.SPEN = 1;
RCSTA.CREN = 1;
RCSTA.SREN = 0;
RCSTA.ADDEN=1;
PIE1.TXIE = 0;
PIE1.RCIE = 0;
TXSTA.TX9
RCSTA.RX9
TXSTA.TXEN = 1;
RCSTA.SPEN = 1;
PIR1.RCIF=0;
PIE1.RCIE = 1;
}
void sci_PutByte(unsigned char byte)
{
while(!TXSTA.TRMT); TXREG= byte;
while(!TXSTA.TRMT);
}
void send_to_rs232_fix(unsigned char* char_ptr,unsigned char char_count)
{

SETCEM

Department of ECE
Project Report

SETCEM

Automatic road security control system

for(;char_count!
=0;char_count--) { while(!
TXSTA.TRMT);
TXREG= *char_ptr++;
}
while(!TXSTA.TRMT);
}
void send_to_rs232(unsigned char* char_ptr)
{
while(*char_ptr!=0)
{ while(!TXSTA.TRMT);
TXREG= *char_ptr++;
}
while(!TXSTA.TRMT);
}

void send_to_gsm_fix(unsigned char* char_ptr,unsigned char char_count)


{
for(;char_count!
=0;char_count--) { while(!
TXSTA.TRMT);
TXREG= *char_ptr++;

Project Report

Department of ECE

63

SETCEM

Automatic road security control system

Project Report

while(!TXSTA.TRMT);
}
void send_to_gsm(unsigned char *char_ptr)
{
while(*char_ptr!=0x00)
{
while(!TXSTA.TRMT);
TXREG= *char_ptr++;
}
while(!TXSTA.TRMT);
}
//**************************************************************************
******************
//return caller add count(master=0),(no match=0xff)
unsigned char caller_id_test(unsigned char char_ptr,unsigned char phone_ptr)
{ unsigned char result,code_count;
if(phone_ptr==0)
{
for(code_count=0;code_count<max_phone_char;code_count++)sms_receive_phoneno[code_
count] = 0x00;
code_count = 0; if((rx0_buffer[char_ptr]!
='+')&&(rx0_buffer[char_ptr]!='0'))
Department of ECE
Automatic road security control system

64

SETCEM

{ sms_receive_phoneno[code_count] ='+';

Project Report

code_count++;
}
result = 0xff;
for(;code_count<max_phone_char;code_count++)
{ if(rx0_buffer[char_ptr]!='"')
{
if(rx0_buffer[char_ptr]='9')
{ result = 0xFE; // number is alphanuric
break;
}
sms_receive_phoneno[code_count] = rx0_buffer[char_ptr];
char_ptr++;
}
else phone_buffer[code_count] = 0x00;
}
if(code_count <= 8)result = 0xFE;
if(result == 0xFE)goto ee1;
}
ee1: return(result);
}

Department of ECE
SETCEM

Automatic road security control system

Project Report

//**************************************************************************
******************
//**************************************************************************
******************
//gsm module location to datetime_buffer
void send_to_datetime(unsigned char* char_ptr)
{ unsigned char digit_count;//,temp[2];
for(digit_count=0;digit_count<max_date_time;digit_count++)
{ if(*char_ptr != '+')datetime_buffer[digit_count]=*char_ptr++;
else datetime_buffer[digit_count] == 0x00;
}
}
//**************************************************************************
******************
void send_to_sms(unsigned char* char_ptr)
{ unsigned char digit_count;
for(digit_count=0;digit_count<max_sms_char;digit_count++)
{
sms_buffer[digit_count]=*char_ptr++;
if((*char_ptr == CR)||(*char_ptr
==LF)) { digit_count++;
sms_buffer[digit_count]=*char_ptr++;
Department of ECE

66

SETCEM

Automatic road security control system

Project Report

digit_count++;
for(;digit_count<max_sms_char;digit_count++)sms_buffer[digit_count]==0x00;
break;
}
}
}
//**************************************************************************
******************
/////////////////
//**************************************************************************
******************
void gsm_power_on(void)
{ //power_on & intialize gsm module

rx0_buff_count=0;
rx0_buff_ready=0;
sms_receive=0;
gsm_power_flag = 1;
update_lcd=1;
gsm_boot_ok=0;
gsm_rdy_flag=0;
}
Department of ECE

67

SETCEM

Automatic road security control system

Project Report

//**************************************************************************
******************
//***********************************************************************
//9410602447
void gsm_receive(void)
{
unsigned char usp_temp,result,temp_usp;
if(rx0_buff_ready==1)
{ //if(gsm_send_flag==0)
rx0_ptr = 0;
while(select_rx0_ptr()==1)
{
if(msg_test((unsigned char*)msg_rdy,&rx0_buffer[rx0_start_ptr],0)==1) //"Call Ready"
{
if(gsm_rdy_flag==0)gsm_rdy_flag=1; //call_ready_flag = 1;
else if(gsm_rdy_flag==1)
{
gsm_rdy_flag=1; //call_ready_flag = 1;
gsm_boot_ok=01 //call_ready_flag = 1;
}
rx0_ptr = rx0_end_ptr;//Not Required

Department of ECE

68

SETCEM

Automatic road security control system

Project Report

}
else if(msg_test((unsigned
char*)msg_call_ready,&rx0_buffer[rx0_start_ptr],0)==1) //"Call Ready"
{
gsm_boot_ok=1; //call_ready_flag = 1;
rx0_ptr = rx0_end_ptr;//Not Required
}
else if(msg_test((unsigned
char*)msg_error,&rx0_buffer[rx0_start_ptr],0)==1)//"ERROR"
{
flag_error=1;// error_flag = 1;
rx0_ptr = rx0_end_ptr;//Not Required
}
else if(msg_test((unsigned char*)msg_ok,&rx0_buffer[rx0_start_ptr],0)==1)//"OK"
{
flag_ok=1;

}
else if(msg_test((unsigned
char*)msg_cms_error,&rx0_buffer[rx0_start_ptr],0)==1) //"+CMS ERROR:" sms not send
{
flag_cms_error=1; //error_flag = 1;
Department of ECE

69

SETCEM

Automatic road security control system

Project Report

rx0_ptr = rx0_end_ptr;//Not Required


}
else if(msg_test((unsigned
char*)msg_cmgs,&rx0_buffer[rx0_start_ptr],0)==1) //"+CMGS:" sms send
{
flag_cmgs=1; //error_flag = 0;
rx0_ptr = rx0_end_ptr;//Not Required
}
else if(msg_test((unsigned
char*)msg_cmt,&rx0_buffer[rx0_start_ptr],0)==1) //"+CMT:" phone no from 7th location,
message from 2rd
{ //SET LXON OR SET LXOFF,HERE X=1 TO 8
LED_GSM_READY_ON;
for(usp_temp=0;usp_temp<13;usp_temp++)
{
if(rx0_buffer[rx0_start_ptr+usp_temp+7]==0x22)
{
sms_receive_phoneno[rx0_start_ptr+usp_temp+7]=0x00;
break;
}
else sms_receive_phoneno[usp_temp]=rx0_buffer[rx0_start_ptr+usp_temp+7];
}
sms_receive_phoneno[13]=0x00;

Department of ECE

70

SETCEM

Automatic road security control system

Project Report

if((select_rx0_ptr()==1)&&(strlen((char *)sms_receive_phoneno)>10))
{
send_to_sms((unsigned char*)&rx0_buffer[rx0_start_ptr]);
result=0;
sms_receive=0;

//o-paramter wrong,1-ok,2 get detail

if((sms_buffer[0]=='S')&&(sms_buffer[1]=='E')&&(sms_buffer[2]=='T')&&(sms_b
uffer[3]==' ')&&(sms_buffer[4]=='L'))
{

if(strlen((char *)sms_buffer)==9)
{
if((sms_buffer[5]>='1')&&(sms_buffer[5]<='9')&&(sms_buffer[6]=='O')&&(sms_bu
ffer[7]=='N'))
{
sms_receive=1;
latch_relay((unsigned char)sms_buffer[5],(unsigned char)RELAY_ON);
goto sms_exit;
}
else
{
sms_receive=0;
goto sms_exit;
Department of ECE

71

SETCEM

Automatic road security control system

Project Report

}
}
else if(strlen((char *)sms_buffer)==10)
{
if((sms_buffer[5]>='1')&&(sms_buffer[5]<='9')&&(sms_buffer[10]=='O')&&(sms_b
uffer[7]=='F')&&(sms_buffer[8]=='F'))
{
sms_receive=1;
latch_relay((unsigned char)sms_buffer[10],(unsigned char)RELAY_OFF);
goto sms_exit;
}
else
{
sms_receive=0;
goto sms_exit;
}
}
else
{ //error
sms_receive=0;
goto sms_exit;

Department of ECE

72

SETCEM

Automatic road security control system

Project Report

}
}
else
if((sms_buffer[0]=='G')&&(sms_buffer[1]=='E')&&(sms_buffer[2]=='T')&&(strlen((char
*)sms_buffer)==4))
{
sms_receive=2;
goto sms_exit;
}
else
{
sms_receive=0;
goto sms_exit;
}
//reply for sms
sms_exit:rx0_ptr = rx0_end_ptr;//Not Required
rx0_buff_count=0;
rx0_buff_ready=0;
if(sms_receive==0)sms_to_gsm(&sms_receive_phoneno[0],(unsigned char
*)msg_sms_syntax_error,0);//syntax error
else if(sms_receive==1)sms_to_gsm(&sms_receive_phoneno[0],(unsigned char
*)msg_successfully_done,0);//acknowledgement

Department of ECE

73

SETCEM

Automatic road security control system

Project Report

else if(sms_receive==2)sms_to_gsm(&sms_receive_phoneno[0],(unsigned char


*)msg_sms_status,1); //send status
}

rx0_ptr = rx0_end_ptr;//Not Required


}
Delay_ms(500);
LED_GSM_READY_OFF;
rx0_buff_count=0;
rx0_buff_ready=0;
}
}
}

//***********************************************************************
void load_status_buffer(void)
{
/ 'L','1','O',' ',' ',',',
/ 'L','2','O',' ',' ',',',
/ 'L','3','O',' ',' ',',',
/ 'L','4','O',' ',' ',',',

Department of ECE

74

SETCEM

Automatic road security control system

Project Report

/ 'L','5','O',' ',' ',',',


/ 'L','6','O',' ',' ',',',
/ 'L','7','O',' ',' ',',',
/ 'L','8','O',' ',' ','.',
//relay 1 data status
if(RELAY1==RELAY_ON)
{
buffer_status[3]='N';
buffer_status[4]=' ';
}
else
{
buffer_status[3]='F';
buffer_status[4]='F';
}
//relay 2 data status
if(RELAY2==RELAY_ON)
{
buffer_status[9]='N';
buffer_status[10]=' ';

Department of ECE

75

SETCEM

Automatic road security control system

Project Report

else
{
buffer_status[9]='F';
buffer_status[10]='F';
}
//relay 3 data status
if(RELAY3==RELAY_ON)
{
buffer_status[15]='N';
buffer_status[16]=' ';
}
else
{
buffer_status[15]='F';
buffer_status[16]='F';
}
//relay 4 data status
if(RELAY4==RELAY_ON)
{
buffer_status[21]='N';
buffer_status[22]=' ';
Department of ECE

76

SETCEM

Automatic road security control system

Project Report

}
else
{
buffer_status[21]='F';
buffer_status[22]='F';
}
//relay 5 data status
if(RELAY5==RELAY_ON)
{
buffer_status[27]='N';
buffer_status[28]=' ';
}
else
{
buffer_status[27]='F';
buffer_status[28]='F';
}
//relay 6 data status
if(RELAY6==RELAY_ON)
{
buffer_status[33]='N';

Department of ECE

77

SETCEM

Automatic road security control system

Project Report

buffer_status[34]=' ';
}
else
{
buffer_status[33]='F';
buffer_status[34]='F';
}
//relay 7 data status
if(RELAY7==RELAY_ON)
{
buffer_status[39]='N';
buffer_status[40]=' ';
}
else
{
buffer_status[39]='F';
buffer_status[40]='F';
}
//relay 8 data status
if(RELAY8==RELAY_ON)
{

Department of ECE

78

SETCEM

Automatic road security control system

Project Report

buffer_status[45]='N';
buffer_status[46]=' ';
}
else
{
buffer_status[45]='F';
buffer_status[46]='F';
}

}
//**************************************************************************
******************
//***********************************************************************
void send_status_buffer(void)
{
send_to_rs232_fix("STATUS:",7); /
/relay 1 data status

if(RELAY1==RELAY_ON)send_to_rs232_fix("1",1);
else send_to_rs232_fix("0",1);

Department of ECE
Automatic road security control system

79

SETCEM

//relay 2 data status

Project Report

if(RELAY2==RELAY_ON)send_to_rs232_fix("1",1);
else send_to_rs232_fix("0",1);
//relay 3 data status
if(RELAY3==RELAY_ON)send_to_rs232_fix("1",1);
else send_to_rs232_fix("0",1);
//relay 4 data status
if(RELAY4==RELAY_ON)send_to_rs232_fix("1",1);
else send_to_rs232_fix("0",1);
//relay 5 data status
if(RELAY5==RELAY_ON)send_to_rs232_fix("1",1);
else send_to_rs232_fix("0",1);
//relay 6 data status
if(RELAY6==RELAY_ON)send_to_rs232_fix("1",1);
else send_to_rs232_fix("0",1);
//relay 7 data status
if(RELAY7==RELAY_ON)send_to_rs232_fix("1",1);
else send_to_rs232_fix("0",1);
//relay 8 data status
if(RELAY8==RELAY_ON)send_to_rs232_fix("1",1);
else send_to_rs232_fix("0",1);

Department of ECE
SETCEM
Automatic road security control system

/*

Project Report

if(RELAY1==RELAY_ON)send_to_rs232_fix("L1ON ",5);
else send_to_rs232_fix("L1OFF ",6);
//relay 2 data status
if(RELAY2==RELAY_ON)send_to_rs232_fix("L2ON ",5);
else send_to_rs232_fix("L2OFF ",6);
//relay 3 data status
if(RELAY3==RELAY_ON)send_to_rs232_fix("L3ON ",5);
else send_to_rs232_fix("L3OFF ",6);
//relay 4 data status
if(RELAY4==RELAY_ON)send_to_rs232_fix("L4ON ",5);
else send_to_rs232_fix("L4OFF ",6);
//relay 5 data status
if(RELAY5==RELAY_ON)send_to_rs232_fix("L5ON ",5);
else send_to_rs232_fix("L5OFF ",6);
//relay 6 data status
if(RELAY6==RELAY_ON)send_to_rs232_fix("L6ON ",5);
else send_to_rs232_fix("L6OFF ",6);
//relay 7 data status
if(RELAY7==RELAY_ON)send_to_rs232_fix("L7ON ",5);
else send_to_rs232_fix("L7OFF ",6);

Department of ECE
SETCEM

Automatic road security control system

Project Report

//relay 8 data status


if(RELAY8==RELAY_ON)send_to_rs232_fix("L8ON",4);
else send_to_rs232_fix("L8OFF",5);*/
}
//**************************************************************************
******************
unsigned char sms_to_gsm(unsigned char *phone_ptr,unsigned char *message_ptr1,unsigned
char stg_mode)
{

unsigned char result,temp_usp;//,rx0_ptr_temp;//,count,temp_ptr

rx0_buff_ready=0;
send_to_gsm((unsigned char*)sms_send);

greater_flag = 0;
flag_ok=0;
flag_cmgs=0;
flag_cms_error=0;
flag_error=0; while(!
TXSTA.TRMT);
TXREG=CR;
Department of ECE
Automatic road security control system

82

SETCEM

Project Report

//wait for '>' 0x3E or wait for > 4 sec


count_10ms = 2000;
while(count_10ms!=0)
{ if(greater_flag == 1)break;
//wdtr = 0x00;
}
result=0;

if(stg_mode==0)send_to_gsm(message_ptr1);// send ptr message1


if(stg_mode==1)send_status_buffer();
while(!TXSTA.TRMT);
TXREG= CTRL_Z;
rx0_buff_ready=0;
Delay_ms(500);
sms_end:
greater_flag = 0;
flag_ok=0;
flag_cmgs=0;
flag_cms_error=1;
flag_error=0;

Department of ECE

83

SETCEM

Automatic road security control system

Project Report

//rx0_ptr = rx0_ptr_temp;
return(result);
}
//**************************************************************************
******************
//from rx0_ptr,rx0_start_ptr,rx0_end_ptr=rx0_ptr
unsigned char select_rx0_ptr(void)

{ unsigned char result = 0;

//not valid data

while(rx0_ptr<=rx0_buff_count)
{ if((rx0_buffer[rx0_ptr]!=0x0a)&&(rx0_buffer[rx0_ptr]!=0x0d))break;
rx0_ptr++;
}
if(rx0_ptr<=rx0_buff_count)
{ rx0_start_ptr = rx0_ptr;
while(rx0_ptr<=rx0_buff_count)
{ if((rx0_buffer[rx0_ptr]==0x0a)||(rx0_buffer[rx0_ptr]==0x0d))break;
rx0_ptr++;
}
}
if(rx0_ptr<=rx0_buff_count)
{ rx0_end_ptr = rx0_ptr;

Department of ECE

84

SETCEM

Automatic road security control system

result = 1;

Project Report

//valid recieved data

}
return(result);
}
unsigned char msg_test(unsigned char* temp,unsigned char* char_ptr,unsigned char test_any)
{ unsigned char result,x,y;
result = 0;
while(*temp>=0x20)
{ x=*char_ptr;y=*temp;
if(test_any==1)
{ if(x >= 0x60)x = x - 0x20;
if(y >= 0x60)y = y - 0x20;
}
if(x == y)
{ char_ptr++;
temp++;
result = 1;
}
else
{ result=0;
break;
Department of ECE

85

SETCEM

Automatic road security control system

Project Report

}
}
return(result);
}

5.3 PROCEDURE DEATIL:-

SMS SYNTAX:SET LXON or SET LXOFF


here X-1 to 8
SET L1ON
SET L2ON
SET L3ON
SET L4OFF
SET L5OFF

Exampleif you want to on L1 send-SET L1ON and if you want to off SET L1OFF

Department of ECE

86

SETCEM

Вам также может понравиться