GHANA TECHNOLOGY UNIVERSITY COLLEGE - WordPress.com
-
Upload
khangminh22 -
Category
Documents
-
view
0 -
download
0
Transcript of GHANA TECHNOLOGY UNIVERSITY COLLEGE - WordPress.com
GHANA TECHNOLOGY UNIVERSITY COLLEGE
FACULTY OF ENGINEERING
DEPARTMENT OF TELECOMMUNICATIONS ENGINEERING
TITLE:
AN INTELLIGENT TRAFFIC SIGNALLING SYSTEM FOR
SELECTED ROAD INTERSECTIONS IN KUMASI
A Project Work Submitted in Partial Fulfilment of the Requirements for
BSc. In Telecommunications Engineering
BY:
KONADU YIADOM KWASI (B010113504)
SUPERVISOR:
MR FRANCIS KWABENA ODURO – GYIMAH
JUNE 2016
II
DECLARATION
This project is presented as part of the requirements for Bsc. in Telecommunications
Engineering awarded by Ghana Technology University College. I hereby declare that this
project is entirely the result of hard work, research and enquires. I am confident that this
project work is not copied from any other person. All sources of information have however
been acknowledged with due respect.
AUTOR:
Konadu Yiadom Kwasi DATE: ……………………………
STUDENT ID: B010113504 SIGNATURE: ……………………
SUPERVISOR:
Mr. Francis Kwabena Oduro - Gyimah DATE: …………………………
SIGNATURE: …………………….
HEAD OF DEPARTMENT:
Mr. Francis Kwabena Oduro - Gyimah DATE: ……………………………
SIGNATURE: …………………….
III
ACKNOWLEDGEMENT
First and foremost my utmost appreciation goes to God Almighty for His protection and
favour upon my life throughout my studies. I owe Him every success and achievement in this
project.
I express my profound gratitude to my supervisor Mr Francis K. Oduro – Gyimah for his
encouragement, direction and guidance throughout this project. His forward thinking and
dedicated mentoring have been an invaluable source of inspiration in this project.
Much appreciation goes to Mr Ngala whose lucid explanations on traffic variation on roads
were a great help in my research into intelligent traffic light systems. His readiness response
to my enquiries were also much appreciated.
I am deeply grateful to Mr Kusi Ankrah of Sunyani Polytechnic, who was incredibly
welcoming and forthcoming in providing assistance when contacted.
My sincere gratitude goes to Kodom, who gave me my first Proteus ISIS 7 tutorial and thus
opened up to me the immense potential of the software.
To all my course mates, I am eternally grateful for the constantly willing input and
contributions to problems pertaining to this project.
Finally to my friends and family I am highly indebted to you all for your support both
physically and spiritually. I say God bless you all.
IV
LIST OF ABBREVIATIONS
AC: Alternating Current
ADC/DAC: Analog to Digital Converters / Digital to Analog Converters
CAN: Controller Area Network
CPU: Central Processing Unit
DC: Direct Current
DIP: Dual In-line Package
EEPROM: Electrically Erasable Programmable Read-only Memory
FTTLC: Fixed Time Traffic Light Controllers
GPS: Global Positioning System
GSM: Global System for Mobile Communication
IR: Infrared
IVS: Intelligent Video Sensor
LED: Light Emitting Diodes
LCD: Liquid Crystal Display
MCLR: Master Clear
MAC: Medium Access Control
NEMA: National Electrical Manufacturers Association
OSC1/CLK IN: Oscillator Crystal Input
V
OSC2/CLKOUT: Oscillator Crystal Output
PLC: Programmable Logic Controller
PIC: Peripheral Interface Controller
PWM: Pulse Width Modulation
RAM: Random Access Memory
ROM: Read only Memory
RFID: Radio Frequency Identification
RSU: Road Side Unit
RF: Radio Frequency
SPI: Serial Peripheral Interface
TX/RX: Transmitter/Receiver
UART: Universal Asynchronous Receiver/ Transmitter
VIP: Video Image Processors
VSS and VDD: Voltage supply
VSM: Virtual System Modelling
WPAN: Wireless Personal Area Network
VI
ABSTRACT
Vehicular traffic is increasing tremendously in Ghana, especially in the cities which is
contributing huge negative impact on transportation in the country. Traffic in the cities is
mainly regularized by traffic lights, which may contribute to the unnecessary long waiting
times for vehicles if not efficiently configured. This inefficient configuration is unfortunately
the case for the traffic lights on the Tech to Adum road in Kumasi. The traffic lights situated
at the Bomso, Anloga and Amakom intersections are based on fixed time cycle protocol
hence cannot better accommodate the increasing traffic variations that occur at different times
on the road. Moreover, emergency vehicles such as ambulance and fire trucks sometimes get
delayed at the intersections since the traffic lights lack the intelligence to detect such vehicles
and provide access for them. Therefore, this study proposes a traffic signalling system that
can work on real time basis to help optimize congestion and wastage of time at the
intersections. The proposed system provides automatic switching of the traffic light based on
traffic density, remote override feature for emergency vehicles on priority basis and
monitoring and detection of system breakdown or malfunctioning of the LED lights. During
normal time the signal timing changes automatically on sensing the traffic density at the
junction but in the event of any emergency vehicle like ambulance, fire trucks etc. requiring
priority are built in with RF remote control to override the set timing by providing
instantaneous green signal in the desired direction while blocking the other lanes by red
signal for some time. However in the advent of malfunctioning of the LED lights, the
controller reports “fault” to the main traffic control room to the maintenance team via the RF
device. The system was designed and simulated using Proteus ISIS 7 software together with
MikroC programming language.
VII
TABLE OF CONTENTS
Contents
DECLARATION..................................................................................................................... II
ACKNOWLEDGEMENT ..................................................................................................... III
LIST OF ABBREVIATIONS ............................................................................................... IV
ABSTRACT ............................................................................................................................ VI
TABLE OF CONTENTS .................................................................................................... VII
LIST OF FIGURES ............................................................................................................... XI
LIST OF TABLES ............................................................................................................... XII
CHAPTER ONE ...................................................................................................................... 1
1.1 Introduction ..................................................................................................................... 1
1.2 Background study ........................................................................................................... 2
1.2.1 Overview of traffic flow in Kumasi ................................................................................ 3
1.2.2 Bomso Road intersection ................................................................................................ 5
1.2.3 Anloga Intersection ......................................................................................................... 6
1.2.4 Amakom intersection ...................................................................................................... 7
1.3 Problem Statement .......................................................................................................... 7
1.4 Objective ......................................................................................................................... 8
1.4.1 Main objective ................................................................................................................ 8
1.4.2 Specific Objectives ......................................................................................................... 8
1.5 Significance of the project .............................................................................................. 9
1.6 Scope of the Project ........................................................................................................ 9
VIII
1.7 Organisation of Study ................................................................................................... 10
CHAPTER TWO ................................................................................................................... 11
LITERATURE REVIEW ..................................................................................................... 11
2.1 Introduction ................................................................................................................... 11
2.2 The Traffic Light........................................................................................................... 11
2.2.1 First Four Way Traffic Signal ....................................................................................... 11
2.2.2 Light Emitting Diodes (LEDs) traffic light .................................................................. 12
2.3 The Controller Unit ....................................................................................................... 13
2.3.1 Electromechanical Controller ....................................................................................... 13
2.3.2 Peripheral Interface Controller (PIC Microcontroller) ................................................. 14
2.4 Sensors .......................................................................................................................... 15
2.4.1 Video/image sensors ..................................................................................................... 15
2.4.2 Inductive loop detector ................................................................................................. 16
2.4.3 Infra-red sensors............................................................................................................ 17
2.5 Strategies in Traffic Control ......................................................................................... 18
2.5.1 Fixed or Pre-timed Signal ............................................................................................. 18
2.5.2 Real Time Signal........................................................................................................... 19
2.6 Related works................................................................................................................ 19
CHAPTER THREE ............................................................................................................... 23
DESIGN METHODOLOGY ................................................................................................ 23
3.1 Introduction ................................................................................................................... 23
IX
3.2 Design of the ITSS ........................................................................................................ 23
3.2.1 Main Traffic Control Unit ............................................................................................. 24
3.2.2 The Emergency System Unit ........................................................................................ 25
3.2.3 The Monitoring Control Unit ........................................................................................ 26
3.3 Hardware Components Description .............................................................................. 27
3.3.1 Power Supply ................................................................................................................ 27
3.3.2 PIC 16F877A Microcontroller ...................................................................................... 28
3.3.3 The Radio Frequency (RF) Module .............................................................................. 32
3.3.4 Liquid crystal display (LCD) ........................................................................................ 34
3.3.5 Global Positioning System (GPS) ................................................................................. 35
3.3.6 Buzzer ........................................................................................................................... 36
3.3.7 Infrared Transmitter ...................................................................................................... 37
3.3.8 Infrared Receiver .......................................................................................................... 38
3.4 Software Developing tools (description) ...................................................................... 39
3.4.1 Proteus ISIS 7 ............................................................................................................... 39
3.4.2 MikroC .......................................................................................................................... 40
3.4.3 Flow chart for the ITSS................................................................................................. 41
CHAPTER FOUR .................................................................................................................. 42
ANALYSIS AND RESULTS ................................................................................................ 42
4.1 Implementation of the Intelligent Traffic Signalling System (ITSS) ........................... 42
4.2 Results for high density at lane two (L2) ...................................................................... 43
X
4.3 Results for emergency override .................................................................................... 44
4.4 Results for system failure of the LED traffic light ....................................................... 45
4.5 Results for malfunctioning of a particular LED traffic light ........................................ 46
CHAPTER FIVE ................................................................................................................... 47
Conclusion and Recommendations ...................................................................................... 47
5.1 Conclusion .................................................................................................................... 47
5.2 Recommendations ......................................................................................................... 47
References ............................................................................................................................... 49
Appendix ................................................................................................................................................
XI
LIST OF FIGURES
Figure 1. 1 Map showing Location of Road Intersections ................................................................ 4
Figure 1. 2 Layout of Bomso Intersection ........................................................................................ 6
Figure 1. 3 Layout of Anloga Road Intersection .............................................................................. 6
Figure 2. 1 First Four Way Traffic Signal ....................................................................................... 11
Figure 2. 3 A PIC16F877A Microcontroller ................................................................................... 14
Figure 2. 4 Traffic Signal Control using Inductive Loop Detector ................................................. 16
Figure 2. 5 Traffic Control using IR Sensors .................................................................................. 17
Figure 3. 2 Block Diagram of Main Traffic Control Unit ............................................................... 24
Figure 3. 3 Block Diagram of Emergency System Unit .................................................................. 25
Figure 3. 4 Block Diagram of Monitoring Control Unit ................................................................. 26
Figure 3. 5 circuit diagram of the power supply.............................................................................. 28
Figure 3. 6 Pin Diagram of the PIC 16F877A ................................................................................. 31
Table 3. 1 pin description of the PIC circuit .................................................................................. 32
Figure 3. 7 pin diagram of RF transmitter and receiver ................................................................. 33
Figure 3. 8 Pin Diagram of 20×4 LCD Display .............................................................................. 35
Figure 3. 9 GPS Module ................................................................................................................. 36
Figure 3. 10 schematic diagram of 5v buzzer module ....................................................................... 37
Figure 3. 11 circuit diagram of IR Transmitter ................................................................................. 37
Figure 3.12 circuit diagram of IR receiver ....................................................................................... 38
Figure 3. 13 Proteus ISIS 7 development environment ..................................................................... 40
Figure 4. 1 schematic diagram of the ITSS ..................................................................................... 42
Figure 4. 2 traffic light at lane two switched to green light for 6000ms ......................................... 43
Figure 4. 3 simulation of the emergency override ........................................................................... 44
Figure 4. 4 results for system failure of the LED traffic light ......................................................... 45
Figure 4. 5 shows simulation results for malfunctioning of a particular LED traffic light ............. 46
XII
LIST OF TABLES
Table 3. 2 Pin description of RF transmitter ....................................................................... 33
Table 3. 3 Pin description of RF receiver ........................................................................... 33
Table 3. 4 Pin description of 20×4 LCD display ................................................................ 34
CHAPTER ONE
1.1 Introduction
Mobility as one of the essential activities of life can be said to be inevitable in the lives of
living things (William, 2015). In human life, people migrate from one place to another by air,
water or road. From the Stone Age, movement of people and goods was through the use of
chariots and some animals such as donkeys, horses etc. Today, science and technology has
improved transportation with the introduction of vehicles, aeroplanes and other systems to
ease movement. Among the various modes of transportation, Road transportation has become
the predominant way for transporting goods and people from one point to another (Arasan,
2012). However with the rapid growth of population of the people in the world, there is an
upsurge in the number of vehicles and traffic demand on our road. This has resulted to issues
of traffic congestion, air pollution, sound pollution, weariness and time and energy wastage,
consequently the need for the practice of minimising road traffic congestion gaining more
popularity as the importance becomes apparent (Bagheri et al., 2007; Madhavi and Banga,
2012).
Moreover with the improvement of technology, several studies and findings are being worked
up to optimize and eradicate completely these prevailing problems that motorists and
pedestrians encounter and also enhance the road network system to facilitate economic
growth and reduce environmental hazards (Arasan, 2012). Efforts have been made to improve
the traffic flow which includes broadening of the roads around an intersection, prohibition of
turning movements at a junction, introduction of traffic circles at the road intersection and
traffic light. Among these, traffic light is doubtlessly the most familiar, important and
effective method of traffic control at intersections. They are generally installed to ensure
safety, decrease the average time of proceeding and increase flow of vehicles across the
2
intersection. All these systems and measures are put in place based on certain data or
information collected over time. However, since the traffic situation at the cities varies over
time, the whole system has to be re-planned again because the road may have exceeded its
designed carrying capacity (Baffour, 2011). Hence, this study proposes a traffic signalling
system that can work on real time basis to help optimize congestion and wastage of time at
the intersections.
1.2 Background study
Traffic congestion is a serious problem encountered by many metro cities around the world.
Getting stuck within a dense traffic is a headache for every motorist and even traffic wardens
in controlling the traffic. According to David (2014), anyone who has ever driven a city street
and been frustrated by having to stop again and again for red lights has probably thought that
there must be a better way.
One of the oldest methods of controlling traffic was having a policeman positioned at each
junction and physically controlling the influx of traffic via hand signalling. However this was
quite arduous and complicated and then came the need for a different type of control using
traffic signals. Traditional traffic light controllers used fixed pre-set time for traffic influx for
each route at the junction. The controller was an electromechanical controller system
consisting of a dial timer, a solenoid and a cam assembly (Tarun, 2013).
However the whole concept of a fixed time traffic light controller (FTTLC) is not convenient
for cities where traffic flow is variable. Traffic load is highly dependent on parameters such
as time, day, season, weather and unpredictable situations such as accidents, special events or
construction activities. If these parameters are not taken into account, the traffic control
system will create bottlenecks and delays. A traffic control system that solves these problems
by continuously sensing and monitoring traffic conditions and adjusting the timing of traffic
3
lights according to the actual traffic load is called an intelligent traffic control system
(Muhammad, 2011).
1.2.1 Overview of traffic flow in Kumasi
Traffic flow is simply defined in the McGraw-Hill Dictionary as the number of vehicles
passing a given point in a given time. Traffic flow is expressed as vehicles per hour. Kumasi
is the second largest city and almost the hub of urbanized and densely inhabited Ghana. Road
transportation has been dominant in Kumasi, since air and rail transport just account for less
than one per cent of the daily movements of goods and persons within the Metropolis. The
road network is radial with Kejetia and Adum being the hub of the network. There are four
major arterial primary roads connecting Kumasi to other parts of the country consisting of the
Accra Road, the Tamale Road, the Sunyani Road, and the cape Coast Road. The inner and the
arterial roads have traffic lights and roundabout to regulate the flow of vehicle. Figure 1.1
shows the map of Kumasi with Selected intersections indicated in a rectangular box and
labelled accordingly which are located on Tech to Adum road (Kumasi Metropolitan
Assembly, 2015).
4
Figure 1. 1 Map showing Location of Road Intersections (Source: Obiri-Yeboah et al., 2013)
This study focuses on the problems associated with the traffic lights situated at the three
selected intersections highlighted on the map above; which include the Amakom intersection,
Anloga intersection and the Bomso intersection.
The traffic light was introduced at the intersections to control traffic congestion, ease the
stress of road users and reduce the time delay experienced by motorists at the intersections.
Unfortunately the system operates on fixed cycle time which does not consider the waiting
time on signals of different intersections. It controls vehicular movement and pedestrian
crossing based on certain time intervals that changes the lights accordingly whether there is
traffic or no traffic at the junctions (Syed et al., 2007).
Emergency vehicles such as police cars, fire trucks and ambulances are generally permitted to
cross an intersection against a traffic signal. These vehicles normally use horns, sirens and
flashing lights to prompt other motorists moving toward the intersection that an emergency
vehicle intends to cross that intersection. However, some motorists play adamant to the
warning signals issued by these emergency vehicles especially in a situation where the traffic
5
light gives way for traffic to flow across the intersection from a different direction. This
results in more delay of the emergency vehicle (Sahar et al., 2012).
There is no monitoring system to check the status of the traffic light and so in the case of
system failure or malfunctioning, vehicles get stacked in the traffic and the whole place get
jammed. Most at times the traffic at the intersections is controlled manually by a policeman
due to frequent system failure. In view of this, the FTTLC installed at these intersections on
the Tech to Adum road lacks the intelligence to identify the road with the higher density of
vehicles and also give special access to emergency vehicles such as Ambulance, Fire trucks
etc. As such it has worsened the traffic problems faced by road users and has failed to deal
with the congestions that occurs at different traffic situations (Syed et al., 2007). A general
observation of the traffic systems in Ghana was made by Baffour (2011). He recommended
that there is the need to refit the whole timing process to maximize the usefulness of the
traffic control devices to better serve the driving public.
1.2.2 Bomso Road intersection
The intersection at Bomso is signalised and is a few meters away from tech junction. The
intersection has four main lanes and two minor lanes .The main lanes consist of two lanes
approaching Tech from Adum and the other two lanes exiting Tech to Adum with one
approach and exit lanes connecting to the two minor lanes on the Bomso to Ayiggya road.
6
Figure 1. 2 Layout of Bomso Intersection (Source: Obiri-Yeboah et al., 2013)
1.2.3 Anloga Intersection
The intersection at Anloga consists of many configurations. Considering the Asokwa to
Aboabo road, it has four major lanes consisting of two entries and two exit lanes with two
minor lanes that connect to the Adum to Tech road. The Adum to Tech road also has the
same configuration with two minor lanes connecting to the Asokwa to Aboabo road.
Figure 1. 3 Layout of Anloga Road Intersection (Source: Obiri-Yeboah et al., 2013)
7
1.2.4 Amakom intersection
The Amakom signalised intersection has four lanes consisting of two approaches and two
exits on the Tech to Adum road. The Adum road has a short lane that branches to the stadium
road whiles the tech road also has a short lane that branches to the Asawase road. The
Asawase to stadium road has two lanes connecting the two towns. Each exiting lane has a
short branch road that connects to the Adum to Tech road. The figure below shows the road
configuration at the Amakom intersection.
Figure 1. 4 Layout of Amakom Signalised Intersection (Source: Obiri-Yeboah et al., 2013)
1.3 Problem Statement
Traffic control has become a major problem in Ghana especially in Kumasi. Traffic situation
at the Tech to Adum road is becoming overwhelming and inharmonious since the traffic
controllers situated at the intersections on the road are operated by fixed time controllers.
The fixed time traffic controllers (FTTLC) are programmed in a particular time interval to
control the flow of traffic at different directions with fixed time delay following a particular
cycle. In this study, it was observed that the traffic situation at the intersections varies
randomly at different periods within a day such that at a particular period, one side of the
intersection becomes denser when compared to the other. But since the controller is
8
programmed with a particular fixed time interval, regardless of the traffic changes that
occurs, it fails to efficiently control the variation of the traffic situation which consequently
leads to congestion especially during hours of heavy traffic, resulting in more unwanted time
delays.
Emergency vehicles such as ambulances, fire trucks etc. generally depend on horns, sirens
and flashing lights to alert other vehicles approaching the intersections. In situations where
the traffic light switches green light to clear the traffic from a different lane across the
intersection, the emergency vehicles are delayed for a while, which cause noise pollution and
threat to life and properties.
In the case of system failure or malfunctioning of the traffic light, it takes a longer time
before being fixed or serviced by the traffic control unit. This also creates huge congestion on
the road. In conclusion, the FTTLC clearly fails to adequately improve traffic flow and
reduce the time spent at the intersections.
1.4 Objective
1.4.1 Main objective
The objective of this project is to design an intelligent traffic signalling system to reduce
traffic congestion, unwanted time delay, detect LED light malfunctioning and to provide
smooth access for emergency vehicles.
1.4.2 Specific Objectives
a. Be able to simulate changing red and green times based on traffic density.
b. Be able to simulate detection of traffic light malfunctioning.
c. Be able to simulate the override feature to provide green light for emergency vehicles.
9
1.5 Significance of the project
This project will help reduce the time spent on the road intersections in cities and
urban areas in Ghana.
Through the provision of overrides for emergency vehicles, the end result will be the
saving of life and assisting in promoting state security.
The introduction of a monitoring system will help check the status of the traffic
systems and update the maintenance team to service any system failure and
malfunctions.
Moreover the findings of this work will add to existing knowledge.
1.6 Scope of the Project
The scope of the project encompasses the areas enlisted below;
a. Studying the traffic situation at the intersections on the Tech to Adum road in
Kumasi.
b. Designing a traffic signalling system that will operate based on traffic variation on an
intersection.
c. Reducing traffic congestion on intersections using Infra-red sensors to detect the
density of traffic on the roads and
d. Using radio frequency modules effectively to provide override feature for emergency
vehicles.
10
1.7 Organisation of Study
The research work is organised as follows:
The first chapter outlines;
The introduction of the project and discuss the objectives and significance of the
project
The background study of traffic flow in Kumasi: define traffic flow, description of
Kumasi road network and the traffic situation at Bomso, Amakom and Anloga road
intersections.
The second Chapter introduces;
Traffic light system: historical background of traffic light, different types of traffic
light.
Strategies in traffic control: fixed and real time signals in controlling traffic.
Review of components such as PIC Microcontroller and sensors
Previous related works: findings of related researches done by others.
The third chapter illustrates;
The design methodology
Detailed description of components and item specifications
The fourth chapter presents;
System implementation and Simulations: simulate changing traffic density on an
intersection, simulate changing red and green times based on traffic density
Circuit analysis and results.
The fifth chapter gives;
Conclusion and relevance of the intelligent traffic system.
Limitation of the project work and recommended future works.
11
CHAPTER TWO
LITERATURE REVIEW
2.1 Introduction
This chapter introduces the literature review of the project. The content of literature review is
one of the important steps to gather information about the project. It will explore the basic
history and evolution of traffic light system and also give some basic knowledge or
theoretical base that will serve as a foundation to successfully achieve the main objective of
the project. Most of the literatures are from the related articles, books and previous works of
the same field.
2.2 The Traffic Light
2.2.1 First Four Way Traffic Signal
William Potts of the Detroit Department is generally credited as the originator of the red-
yellow-green traffic signal. The signal, probably of the overhead suspension type, marked
another pioneering venture for Detroit when it was installed. He instituted electrical
interconnection of the signal of fifteen of Detroit’s traffic towers so that they could be
controlled by a police officer from a single location (Signalfan, 2015). With this system, a
timer controls the switching of the lights instead of a police controlling the traffic at the
intersection (Osborne, 2014; Willis, 2015).
Figure 2. 1 First Four Way Traffic Signal (Source: Willis, 2015)
12
2.2.2 Light Emitting Diodes (LEDs) traffic light
It is made of arrays of light emitting diodes (LEDs). These are tiny electronic lights that are
energy efficient and last for long. Due to the tiny size of the LED hundreds of them are used
together in an array. The incandescent halogen bulbs are been replaced by LEDs in most
cities in the world because of its numerous advantages such as:
LEDs bulbs last for years, while halogen bulbs last for months. Replacing bulbs cost
huge sums of money and also create traffic on roads.
LED bulbs save a lot of money because it consumes less wattage of power as
compared to the incandescent halogen bulbs. Assuming a traffic light uses 100-watt
bulbs today and the lights are on 24 hours in a day, it means it will use 2.4kilowatt-
hours per day. The power consumption drops by a factor of five or six. These energy
bulbs can be run on solar energy instead of electrical lines to save money especially in
remote areas (Yakima Washington Department of Public Works Streets and Traffic
Division, 2015).
LED traffic lights can also be used as transmitters. According to Emad and Aman (2011)
several research has been done on LED traffic lights which suggest that its implementation
requires total overhaul of all the traffic lights and the introduction of cameras in vehicles to
facilitate communication.
Ibrahim and Beasley (1998) discussed the technical aspects of LED traffic lights and
provided estimates on expected savings if all traffic lights were to be replaced by LEDs.
Akanegawa et al., (2001) proposed a traffic information system using existing LED traffic
lights. Their study focused on the power and rays of the LED used in traffic control.
13
2.3 The Controller Unit
Traffic signal controllers are control units that control and coordinate the traffic signals to
ensure traffic flow at a junction. They are classified into electromechanical and electronic
controllers. The electronic controllers include programmable logic control (PLC) controller,
peripheral Interface controller etc.
2.3.1 Electromechanical Controller
The electromechanical controllers are made of mechanical systems operated electrically.
They are mainly composed of movable parts - a dial timer, a solenoid and a cam assembly
together with electrical relays to control the signals. Cycle lengths of signalized intersections
are determined by small gears that are located within dial timers. Since a dial timer has only
one signalized intersection time plan, it control phases at a signalized intersection in only one
way. A motor and a gear assembly operate the dial timer which in turn is responsible to
energize or de energize a solenoid. The motor rotates a camshaft with cams which provides
current to each signal indications. The dial timer provides repetition of fixed time intervals
(Tarun, 2014). A lot of human ingenuity was involved to make this controller function so
well and fairly reliable in its time. There are quite a few of these in operation today, although
their numbers are slowly dwindling.
Figure 2. 2 An Electromechanical Controller (Source: the traffic signal museum, 2015)
14
2.3.2 Peripheral Interface Controller (PIC Microcontroller)
Peripheral interface controller (PIC) is a type of microcontroller developed by microchip. It is
fast and easy to implement programs and interface with other peripheral PIC as compared to
other microcontrollers like 8051. PIC consists of RAM, ROM, CPU, Timers, Counter Analog
to digital converters (ADC) and Digital to Analog (DAC). It supports protocols like CAN,
SPI, UART for interfacing with other peripherals (electronicshub, 2015)
PIC16F877A is an 8-bit microcontroller which has 40 pin DIP and is based on Harvard
Architecture. It features 256 bytes of EEPROM data memory, self-programming, an LCD, 2
Comparators, 8 channels of 10-bit ADC, 2 capture/compare/PWM functions, the synchronous
serial port can be configured as either 3-wire Serial Peripheral Interface for the 2-wire Inter-
Integrated Circuit bus and a Universal Asynchronous Receiver Transmitter. All of these
features make it deal for more advanced level A/D applications in automobile, industrial,
appliances and consumer applications. It has 8kb flash memory which can be used to erase
and rewrite the programs for the controller. Hence the device can be re-programmed up to
100, 000 times. The controller works with a low power supply such as 5V DC
(Shanmugasundaram et. al., 2013).
Figure 2. 3 A PIC16F877A Microcontroller (Source: electronicshub, 2015)
15
2.4 Sensors
There is a wide range of sensor technologies available for vehicle detection and traffic
monitoring systems. These include infrared sensors, inductive loop detector, video/ image
sensors etc.
2.4.1 Video/image sensors
An intelligent video sensor (IVS) combines image processing with video sensing and data
communication. It can be realized as an embedded system and capture a stream of video,
compute the data pertaining to high-level traffic parameters and transfer this video stream and
the computed traffic parameters to a base station. Traffic parameters may include vehicle
flow rate, average vehicle velocity as well as detection of obstacles. Video sensors usually
include video image processors (VIP) for processing the obtained images and videos. It is a
combination of hardware and software which extracts desired information from data provided
by an imaging/video sensor. The VIP can detect speed, count, occupancy and presence.
Because these sensors produce an image of several lanes, there is potential for a VIP to
provide a wealth of traffic information such as vehicle classification and incident detection.
The basic operation of a VIP can be described in the following manner: the operator selects
several vehicle detection zones within the field of view of the camera. Various image
processing algorithms are then applied in real time zones in order to extract the required
information such as vehicle speed or occupancy (Ashwini et al., 2014).
However advantages offered by these sensors are that, they are mounted above the road
instead of in the road, the placement of vehicle detection zones can be made by the operator,
the shape of the detection zones can be programmed for specific applications and the system
can be used to track vehicles.
16
Moreover the disadvantages associated with the sensors are that, detection of vehicles can be
blocked by objects and flying birds, reflections from the roadway and varying weather
conditions such as fog, rainfall etc. affect the sensor in monitoring vehicles on the road.
2.4.2 Inductive loop detector
It consists of wire embedded into a groove on the road surface which is sealed with a rubber.
It detects change in frequency. The inductor coil is connected with the detector which detects
the change in resonant frequency of the coil loop and accordingly controls the triggering of
the relay which is used to trigger the traffic signals. Basically it works on the principle that
when a car moves over the inductor coil, the inductance of the coil decreases, causing
resonant or oscillation frequency to increase. The electronic unit accordingly sends electric
pulses to the control unit to control the switching of traffic lights.
However a disadvantage of such system is that, the inductor loops are prone to
electromagnetic interference, i.e. electromagnetic radiation from other devices can also affect
the magnetic field and hence the inductance of the coil. They are also more prone to failure
and require high installation cost and also cause disruption of traffic (Tarun, 2013).
Figure 2. 4 Traffic Signal Control using Inductive Loop Detector (Source: Tarun, 2013)
17
2.4.3 Infra-red sensors
There are two types of infrared (IR) detectors. These are active and passive type detectors.
Active IR sensors operate by transmitting energy from either a light emitting diode (LED) or
a laser diode. A passive IR system detects energy emitted by objects in the field of view and
many use signal processing algorithms to extract the desired information. All objects emit
some form of energy, which is in the form of heat or thermal radiation. This radiation most
often falls in the IR spectrum which cannot be seen with the naked eye but can be detected by
an infrared sensor that accepts and interprets it. In vehicle sensing and detection, infrared
sensors are placed in line of sight across the road. Any time a vehicle blocks the
communication between the sensors, it sends information to the control unit which interprets
the signal and switches the traffic light to glow for a particle time based on the vehicle count
by the sensors (Ashwini et al., 2014).
Infra-red waves offer many advantages which include: transmission and reception of large
amount of data due to high frequency, not susceptible to adverse weather conditions and low
cost and power requirements. However it also has some disadvantages which include;
requires line of sight transmission which can easily be blocked by people and animals, it
cannot penetrate through walls, doors etc. and easily distracted by objects.
Figure 2. 5 Traffic Control using IR Sensors (Source: Tarun, 2013)
18
2.5 Strategies in Traffic Control
Traffic control is the supervision of the movement of people, goods or vehicles to ensure
efficiency and safety. A traffic light system is an electronic device that assigns right of way at
an intersection or street crossing by means of displaying the standard red, yellow and green
coloured indications. Traffic light provides many advantages to cities and urban areas. It
ensures that pedestrians and bicyclists get their fair share of the road. It also prevents
accidents at road intersections since it regulates the movement of vehicles (Muhammad,
2011; Adewoye et al., 2014).
There are different strategies employed in controlling traffic which include fixed or pre-timed
signal and real time signal.
2.5.1 Fixed or Pre-timed Signal
At fixed timed traffic signals each signal phase or traffic movement is serviced in a
programmed sequence that is repeated throughout the day. Main street traffic receives a fixed
amount of green time followed by the amber and red clearance intervals. The same interval
timing is then repeated for the minor or side street. The amount of time it takes to service all
conflicting traffic movements is referred to as the cycle length. The signal timings and cycle
lengths may vary by time of day to reflect changes in traffic volumes and patterns. During
peak traffic periods for example, cycle lengths may range from 90-128 seconds to
accommodate heavier volumes, particularly on the busier arterial roadways. During off peak
times of day cycle lengths are reduced as traffic volumes are much lighter and therefore not
as much green time is required to effectively service all movements. With pre-timed signals
the pedestrian walk/don’t walk signal indications are automatically displayed in conjunction
with the green signal for vehicles. Fixed time control clearly defines signal program
19
elements, such as cycle time, stage sequence and duration of the green period. The signal
program is processed periodically (Sonja, 2012)
Pre-timed signals are best suited for intersections where traffic volumes are predictable,
stable and fairly constant. Once the timing programs are set, they remain fixed until they are
changed manually in the field. Pre-timed signals are cheaper to purchase, install and
maintained than real time signals (Ravi et al., 2012).
2.5.2 Real Time Signal
Real time signal combines preset cycle time with proximity sensors, which can activate a
change in the cycle time or the light. The real time data about traffic processes are used to
determine control or its modification. The proximity sensors in this system are used to detect
the presence of traffic waiting at the light and thus can avoid giving the green light to an
empty road while motorists on a different route are stopped. This reduces the delay at
intersections by providing the most effective green and red times and eliminate signal
changing altogether if there is no demand from any particular part of the road intersections.
However a timer is frequently used as a backup in case the sensors fail in real time control
(Adewoye et al., 2014).
2.6 Related works
Vikramaditya et al. (2012) designed an Image Processing Based intelligent Traffic Controller
with a camera fixed on poles and other tall structures to overlook the traffic scene. Images
extracted from the video are then analysed to detect and count vehicles. Their system was
able to allot time to each lane depending on the signal cycle. In addition, emergency vehicles
at road intersection were provided access when detected on a particular lane by giving the
lane a priority over the other lanes. One shortcoming with this system is that the camera is not
20
robust. The second problem is that when ambulances arrive from different lanes, the system
fails and gives green light to all lanes.
An algorithm to determine the number of vehicles on the road is presented in Naeem et al.
(2013). The density counting algorithm works by comparing the real time frame of live video
by the reference image. The computed vehicle density can be compared with other direction
of the traffic in order to control the traffic. A disadvantage of this system is that, video
processing is more time consuming and can often lead to delays during processing and thus
delays in transitions of traffic signal to various states (Red, Yellow, or Green). It is also
affected by the bad weather conditions like wind, rain, fog, etc. such that the images received
by the camera are distorted by noise and not clear for the system to identify the vehicle.
Priority Based Traffic Lights Controller using Wireless Sensor Networks was designed by
Shruthi and Vinodha (2012). Their system provided priority access for emergency vehicles.
Wireless Sensor Network is being used as communication infrastructure in the proposed
traffic light controller. System uses fuzzy logic to define direction of emergency vehicle.
Central monitoring system collects all information and gives appropriate response. A
disadvantage to this system is that data exchange in between sensors is not reliable and can
lead to more time delay at the junction when network is unavailable.
Dinesh and Swapnili (2012) designed an intelligent traffic signal control system which
incorporated infra-red sensors, microcontroller with programmable flash memory and built in
8-channels ADC. Their system was able to provide priority access for emergency vehicles via
detection by an infra-red sensor. However the limitation found in this system is that, the
infra-red device is not reliable since it is easily affected by climatic conditions.
Sarika and Gajanan (2013) designed an embedded system for Intelligent Ambulance and
Traffic control Management. Their system was able to provide the best path for emergency
21
vehicles by collecting information about the moving emergency vehicles through global
positioning system (GPS) and Global system for mobile communication (GSM) whiles
monitoring the density of traffic on roads to provide access to the more dense lanes through
the RFID device. Secondly the heart beat and temperature sensors in the ambulance provided
constant monitoring and reports on the health status of the patients through the GSM device
to a corresponding hospital. However the system is quite expensive in the implementation
since all vehicles on road should be equipped with RFID device and all ambulances should be
equipped with special instruments other than medical instruments which come with extra
cost.
Shweta and Amit (2014) designed a density signal management system with a Road Side
Unit (RSU) placed at junctions to track traffic density on roads. Their system also
implements wireless communication technology in every vehicle that communicates with the
RSUs. It provided access for multiple priority-based vehicles and controlled traffic
dynamically through the communication between the RSUs and wireless device placed in the
vehicles. The limitation associated with this system is that it is very expensive and difficult to
implement since all vehicles should be equipped with special communication device.
Nitksaz P. (2012) implemented an automatic traffic estimation using image processing. The
system estimates the size of traffic in highways by using a camera to detect the number of
vehicles on the highways and also detects the occurrence of accidents and violations on
highways. However the limitation associated with the system is that, it has extreme
sensitivity to light as sunlight causes interference with camera.
Hashim et al., (2013) designed a traffic light control system for emergency vehicles using
Radio Frequency. Their system receives signal from emergency vehicles based on radio
frequency transmission (RF) and uses a PIC16F877A microcontroller to trigger the system to
22
emergency mode giving priority for the emergency vehicle to move across the intersection.
However the limitation associated with their system is that, the system cannot identify the
direction of the emergency vehicle whether it is approaching from the north, east, west or
south towards the intersection and hence switch the whole system into emergency mode.
23
CHAPTER THREE
DESIGN METHODOLOGY
3.1 Introduction
The methodology used to address the research problem is described in this chapter. It consists
of two sections. The first section introduces the design of the proposed system. The second
section describes the detailed hardware and software components used to implement the
system.
3.2 Design of the ITSS
The proposed system consists of three parts, namely: Main traffic control unit, the override
system unit and a monitoring control unit. The main block diagram of the ITSS is show in the
figure below;
Figure 3. 1 Block Diagram of Intelligent Traffic light Signalling system
24
3.2.1 Main Traffic Control Unit
In this system, infra-red sensors are used to measure the density of the vehicles which are
fixed within a particular distance. All the sensors are interfaced with the PIC16F877A
microcontroller which in turn controls the traffic signal system according to the density
detected by the sensors. The density of vehicles is measured in three zones, i.e.; low, medium
and high based on which timings are allotted accordingly. Three Infra-red sensors are placed
across the road at a particular interval marking as low, medium and high. Each IR transmitter
faces an IR receiver opposite to each other across the road which is interfaced with a
microcontroller. The IR system gets activated whenever vehicles pass between the IR
transmitter and receiver. The microcontroller controls the IR sensors and assumes either low
medium or high density of traffic based on the activation of the IR sensors. At each direction
thus; north, south, east or west of the intersection, the microcontroller re-time the green light
signal based on the density at that particular direction. For high density, there will be more
time allotted and low density, less time allotted for traffic to flow respectively.
The block diagram of the traffic control unit is displayed in the figure below;
Figure 3. 2 Block Diagram of Main Traffic Control Unit
25
3.2.2 The Emergency System Unit
The override system provides priority access to emergency vehicles approaching the
intersection. It consists of a microcontroller, Global positioning System (GPS), a wireless
module (Radio frequency module) and a Liquid Crystal Display unit (LCD). The system gets
activated automatically at the start of the ignition key. The GPS device receives GPS
coordinates from orbiting satellites to locate the position of the emergency vehicle. The
coordinates received by the GPS are transmitted via the wireless RF transmitter to the control
unit of the traffic system. The LCD unit displays the status of the system to indicate whether
it is connected to the traffic system. The control unit in turn computes position, speed and
location of the emergency vehicle. The traffic controller overrides the set timing and switches
the green light till the vehicle cross the intersection.
The figure below displays the block diagram of the emergency system
Figure 3. 3 Block Diagram of Emergency System Unit
26
3.2.3 The Monitoring Control Unit
The monitoring control unit consists of a microcontroller, an alarm, Liquid Crystal Display
unit and RF module transceiver. It provides constant monitoring and update of the status of
the traffic light at the intersections. In the simulation, a fault button is connected to the main
traffic control unit which when activated causes the traffic light to go off. The controller then
report fault to the base station controller via the wireless device. When the base station
receives the signal, it triggers an alarm and display the information on the LCD board. The
figure below shows the block diagram of the monitoring control unit
Figure 3. 4 Block Diagram of Monitoring Control Unit
27
3.3 Hardware Components Description
In this section the main components used in the design of the ITSS are described below. It
covers the circuit description and components used in the design of the power supply and
detailed description of the other components used in the entire circuit design of the ITSS.
3.3.1 Power Supply
The power supply section is very important for all electronic circuits. The 220V, 50Hz AC
mains is stepped down by a transformer TR1 to deliver a secondary output of 12V AC power
supply. The transformer output is rectified by a full-wave rectifier comprising of a bridge
rectifier BR1 into a DC voltage source. The pulsating DC voltage is filtered by a 1000μf
capacitor C1 and regulated by 7812 voltage regulator U1 to obtain a constant 12v DC supply.
To obtain an alternate +5v DC supply to power the PIC16F877A, the 12v is further regulated
by a 7805 voltage regulator to provide a constant +5v DC power supply. Capacitors C2, C3,
to C6 are used respectively to further eliminate ripples present in the regulated power supply.
An LED-red (D1) act as the power indicator and R1 limits the current through LED-red (D1).
Bridge rectifier
A rectifier convert AC signal to a pulsating DC signal. The output from the step down
transformer is fed into the bridge rectifier. It converts A.C. into pulsating D.C. The rectifier
may be a half wave or a full wave rectifier. A bridge rectifier is used because of its merits like
good stability and full wave rectification. (Electronic Tutorials, 2016)
Capacitor
Capacitive filter is used in power supply circuit. 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
28
received at this point changes. Therefore a regulator is applied at the output stage. (Electronic
Tutorials, 2016)
Voltage regulator
As the name itself implies, it regulates the input applied to it and gives a stable output. A
voltage regulator is an electrical regulator designed to automatically maintain a constant
voltage level. Power supply of 5V and 12V are required for Paper dispenser system. In order
to obtain these voltage levels, 7805 and 7812 voltage regulators are to be used. The first
number 78 represents positive supply and the numbers 05, 12 represent the required output
voltage levels. (Electronic Tutorials, 2016)
The circuit diagram of the power supply is displayed below;
Figure 3. 5 circuit diagram of the power supply
3.3.2 PIC 16F877A Microcontroller
PIC is a family of Harvard architecture microcontrollers made by microchip
technology, derived from the PIC1640 originally developed by general instrument’s
microelectronics division. PIC is popular due to their low cost, wide availability, large
user base, extensive collection of application notes, availability of low cost or free
29
development tools and serial programming (and re-programming with flash memory)
capability.
It is characterized by the following features: Separate code and data spaces (Harvard
architecture). A small number fixed length instructions which are simple cycle
execution (4 clock cycles) with single delay cycles upon branches and skips. A single
accumulator (W), the use of which (as source operand) is implied (i.e is not encoded
in the opcode). All RAM location function as registers as both source and/ or
destination of maths and other functions. A hardware stack for storing return
addresses. A fairly small amount of addressable data space (typically 256 bytes),
extended through banking, Data space mapped CPU, port and peripheral registers.
The program counter is also mapped into data space and writable( this is to implement
indirect) unlike most other CPU’s, there is no distinction “memory” and “register”
space because the RAM serves the job of both memory and registers and RAM is
usually just referred to as the register file or simply as the registers (Abinaya and
Uthira, 2014).
PIC 16F877 uses 14 bits for instructions which allows for all instructions to be one
word instructions. It is also typical for Harvard architecture to have fewer instructions to be
one word instructions. It is also typical for Harvard architecture to have fewer instructions
than Von Neumann’s and to have instructions to be executed in one cycle. The major
advantage with this architecture is that while an instruction is being executed the next
can be fetched. The execution speed is doubled. PIC uses Harvard architecture, so the size
of an instruction can be different from the size of the data. PIC 16F877A is one of the most
commonly used microcontrollers especially in automotive, industrial, appliances and
consumer applications. PIC16F877A is at the upper end of the mid-range series of the
microcontrollers developed by microchip Inc. It can be reprogrammed and erased up to about
30
100,000 times. Therefore it is very good for new product development phase. The memory of
PIC 16F877 chip is divided into three sections. They are; Program memory, Data memory
and Data EEPROM
Program memory: It contains the programs that are written by the user. The program counter
(PC) executes these stored commands one by one. Usually PIC16F877 devices have 13 bit
wide program counter that is capable of addressing 8K×14 bit program memory space. This
memory is primarily used for storing the programs that are written to be used by the PIC. The
PIC 16F877×A family has an 8-level deep × 13-bit wide hardware stack. The stack space is
not a part of either program or data space and the stack pointers are not readable or writable
(Vysakh, 2011).
Data memory: The data memory of PIC16F877 is separated into multiple banks which
contain the general purpose registers (GPR) and special function registers (SPR). The
PIC 16F877 chip has only four banks (BANK 0, BANK 1, BANK 2, and BANK 3).
Each holds 128 bytes of addressable memory.
Data EEPROM: The data EEPROM and flash program memory is readable and
writable during normal operation (over the full VDD range). This memory is not
directly mapped in the register file space; instead it is indirectly addressed through the
Special Function Registers. The EEPROM data memory allows single- byte read and
writes. The write operations automatically perform an erase before write on blocks of
four words. A byte write in data EEPROM memory automatically erases the location
and writes the new data (erase-before-write). The write time is controlled by on-chip
timer. The write/ erase voltages are generated by on-chip charge pump, rated to
operate over the voltage range of the device for byte or word operations (Vysakh,
2011).
31
Figure 3. 6 Pin Diagram of the PIC 16F877A (Vysakh, 2011)
Pin Description
VSS and VDD: These are power supply pins. VDD is the positive supply and VSS is
the negative supply or 0V. The maximum supply voltage that you can use is 6V and
the minimum is 2V.
MCLR: Master clear (reset) input. This pin is an active low to the device. This pin is
used to erase the memory locations inside the PIC (i.e. when we want to re-program
it). In normal use it is connected to the positive supply rail.
OSC1/CLK IN and OSC2/CLKOUT: These are oscillator crystal input and output.
These pins are where we connect an external clock, so that the microcontroller has
some kind of timing. These are connected to crystal or resonator in crystal oscillator
mode.
32
Table 3. 1 pin description of the PIC circuit
Pin Name Pin No. Description Application
VDD 11, 32 Positive
supply (+5V)
Positive supply
to chip
VSS 12, 31 Ground
Reference
Ground
Reference
OSC 13, 14 20MHz
quartz crystal
Basic clocking
to the
microcontroller
MCLR 1 Reset input Connected to +5v
3.3.3 The Radio Frequency (RF) Module
The RF module, as the name suggest, operates at Radio Frequency. The corresponding
frequency range varies between 30 KHz and 300 GHz. In this RF system, the digital data is
represented as variations in the amplitude of carrier wave. This kind of modulation is known
as Amplitude shift keying (ASK).
The module comprises of an RF transmitter and receiver. The transmitter/receiver pair
operates at a frequency of 434 MHz. An RF transmitter receives serial data and transmits it
wirelessly through its antenna connected at pin 4. The transmission occurs at the rate of
1Kbps to 10Kbps. The transmitted data is received by an RF receiver operating at the same
frequency as that of the transmitter. The RF module is often used along with a pair of
encoder/decoder. The encoder is used for encoding parallel data for transmission feed while
reception is decoded by a decoder (engineersgarage, 2015). Pin diagram of RF transmitter/
receiver is displayed by the figure below;
33
Figure 3. 7 pin diagram of RF transmitter and receiver (Source: engineersgarage, 2015)
Pin Description:
Table 3. 2 Pin description of RF transmitter
Pin Number Function Name
1 Ground (0v) Ground
2 Serial data input pin Data
3 Supply voltage (5v) Vcc
4 Antenna output pin ANT
Table 3. 3 Pin description of RF receiver
Pin number Function Name
1 Ground(0v) Ground
2 Serial data output pin Data
3 Linear output pin; nit
connected
NC
4 Supply voltage (5v) Vcc
5 Supply voltage (5v) Vcc
34
6 Ground (0v) Ground
7 Ground (0v) Ground
8 Antenna input pin ANT
3.3.4 Liquid crystal display (LCD)
A liquid crystal display (LCD) is a thin, flat display device made up of any number of colour
or monochrome pixels arrayed in front of a light source or reflector. It is utilized in battery-
powered electronic devices as it uses small amount of electric power. In this proposed
system, LCD 20×4 LCD display is used to display fault detection at the monitoring unit of
the ITSS and also display the connection status of the emergency vehicle to the main traffic
control unit.
Table 3. 4 Pin description of 20×4 LCD display
Pin number Symbol Function
1 VSS Ground
2 VDD Supply voltage for
logical circuit
3 VEE Supply voltage for
LCD driving
4 RS A signal for selecting
registers
5 R/W A signal for selecting
read or write actions
6 E Enable signal for
reading or writing
35
data
7 DB0-DB7 8 bit data bus
Figure 3. 8 Pin Diagram of 20×4 LCD Display
3.3.5 Global Positioning System (GPS)
The Global Positioning System (GPS) is a satellite- based navigation system consisting of a
network of 24 satellites located into orbit. The system provides essential information to
military, civil and commercial users around the world and it’s freely accessible to anyone
with a GPS receiver. GPS works in any weather circumstances at anywhere in the world. A
GPS receiver must be locked on to the signal of at least three satellites to estimate 2D
position (latitude and longitude) and track movement (Abinaya and Uthira, 2014). With four
or more satellites in sight, the receiver can determine other information like speed, distance to
destination and time. GPS receiver used for this research work is installed in the emergency
vehicle to detect vehicle location and provide information to the main traffic control unit
through the radio frequency (RF) device.
36
Figure 3. 9 GPS Module (Source: Riscin, 2015)
3.3.6 Buzzer
A Buzzer is a signalling device, which may be mechanical, electromechanical or
piezoelectric. It is typically used in alarm devices, automobiles, household appliances such as
a microwave oven etc. it mostly consists of a number of switches or sensors connected to a
control unit that determines if and which button was pulsed or a preset time has lapsed. It
sounds a warning in a form of continuous or intermittent buzzing or beeping sound (tinkbox,
2015).
Specifications:
On-board passive buzzer
On-board 8550 triode drive
Working voltage: 5v
Pin configuration:
1. VCC
2. Input
3. Ground
37
Figure 3. 10 schematic diagram of 5v buzzer module (Source: tinkbox, 2015)
3.3.7 Infrared Transmitter
An electro luminescent IR LED is a product which requires care in use. IR LEDs are
fabricated from narrow band hetero structures with energy gap from 0.25 to 0.4 eV. Infra-red
transmitter emits IR rays in planar wave front manner. Even though Infrared ray spreads in all
directions, it propagates along straight line in forward direction. IR rays have the
characteristics of producing secondary wavelets when it collides with any obstacles in its path
(engineersgarage, 2015). When IR rays gets emitted from LED, it moves in the direction it is
angled. When any obstacle interferes in the path, the IR rays get cut and it produces
secondary wavelets which propagates mostly in return direction or in a direction opposite to
that of the primary waves, which produces the net result like reflection of IR rays.
Figure 3. 11 circuit diagram of IR Transmitter
38
3.3.8 Infrared Receiver
Infrared photo receiver is a two terminal PN junction device, which operates in a reverse bias.
It has a small transparent window, which allows light to strike the PN junction. A photodiode
is a type of photo detector capable of converting light into either current or voltage,
depending upon the mode of operation. Most photodiodes will look similar to a light emitting
diode. They will have two leads, or wires, coming from the bottom. The shorter end of the
two is the cathode, while the longer end is the anode (engineersgarage, 2015).
A photodiode consists of PN junction or PIN structure. When a photon of sufficient energy
strikes the diode, it excites an electron thereby creating a mobile electron and a positively
charged electron hole. If the absorption occurs in the junction’s depletion region, or one
diffusion length away from it, these carriers are swept from the junction by the built-in field
of the depletion region. Thus holes move toward the anode, and electrons toward the cathode,
and a photocurrent is produced.
Figure 3.12 circuit diagram of IR receiver
39
3.4 Software Developing tools (description)
This section describes the software and the programming language used in the circuit design
and simulation of the ITSS. The ITSS was designed and simulated with Proteus ISIS 7
software. The instructions used for simulation was written using MikroC compiler which was
based on an algorithm in the flow chat shown in figure 3.14 below. The program was
compiled and the hex file generated from it was loaded unto PIC16F877A microcontroller.
3.4.1 Proteus ISIS 7
Proteus 7.0 is a virtual system modelling (VSM) that combines circuit simulation, animated
components and microprocessor models to co-simulate the complete microcontroller based
designs.
The tools for developing software and hardware for microcontroller based systems include
editors, assemblers, compilers, debuggers, simulators, emulators and device programmers. A
typical development cycle starts with writing the application program using a text editor. The
program is then translated into an executable code with the help of an assembler or compiler.
If the program has several modules, a linker is used to combine them into a single
application. Any syntax errors are detected by the assembler or compiler and must be
corrected before the executable code can be generated (Tomorrow Scientist, 2016). A
simulator is used to test the application program without the target hardware. Once the
program seems to be working, the executable code is loaded to the target microcontroller chip
using a device programmer and the system logic is tested. Debuggers and in-circuit emulators
analyse the program’s operation and display the variables and registers in real time with the
help of breakpoints set in the program. These software development tools are computer
programs that allow the programmer to create, modify, and test application programs (Ashok,
2014). The figure below shows the developing environment of Proteus ISIS 7.
40
Figure 3. 13 Proteus ISIS 7 development environment
3.4.2 MikroC
The mikroC PRO for PIC is a powerful, feature- rich development tool for PIC
microcontrollers. It is designed to provide the programmer with the easiest possible solution
to developing applications for embedded systems, without compromising performance or
control. PIC and C fit together well: PIC is the most popular 8-bit chip in the world, used in a
wide variety of applications and C, prized for its efficiency, is the natural choice for
developing embedded systems. MikroC PRO for PIC provides a successful match featuring
highly advanced IDE, ANSI compliant compiler, broad set of hardware libraries,
comprehensive documentation and plenty of ready- to- run examples (MikroElektronika,
2015).
42
CHAPTER FOUR
ANALYSIS AND RESULTS
4.1 Implementation of the Intelligent Traffic Signalling System (ITSS)
Figure 4. 1 schematic diagram of the ITSS
The figure above shows the schematic of the ITSS. The system is simulated for an
intersection consisting of lane one to lane four with each lane having an LED traffic light
mounted to control the flow of traffic. The sequence of the traffic light starts as green light at
lane one (L1) and red light for the other three lanes with each mode lasting for
3000milliseconds(ms). The light switches from green light to the amber for 500miliseconds.
Each lane also has two logic state indicators to represent IR sensors on the road. In this
simulation, 6000ms is assigned for high density whiles 3000ms is assigned for low density
respectively. The two logic state indicators are interfaced with the PIC16F887A which
switches to either 1 or 0 to indicate high or low density. Another indicator switch is
connected to the PIC16F887A to represent current sensors which can be toggled between 1
43
and 0 to introduce a fault in the LED traffic light. Upon activation, the PIC transmits signals
via the RF module TX to the RF module RX of the base controller unit. The LMO44L (20×4
LCD) displays the status of the system as ‘fault detection’ whiles a sound buzzer blows alarm
continuously. The emergency side is also made of a PIC16F887A which is interfaced with an
LM044L and a GPS module. It also has a logic toggle which upon activation triggers the PIC
to transmit GPS coordinates via the wireless RF module TX to the main traffic control unit.
4.2 Results for high density at lane two (L2)
Figure 4. 2 traffic light at lane two switched to green light for 6000ms
Figure 4.2 shows that when the two toggle switches at lane two were activated, the PIC
controller increased the green time allotted to lane two (L2) to 6000ms before switching to
the next lane.
44
4.3 Results for emergency override
Figure 4. 3 simulation of the emergency override
When the toggle switch was activated, the GPS coordinates received from the GPS module
was transmitted via the RF module to the main traffic controller. The controller overrode the
sequence of the traffic light and assigned green light to lane one (L1) based on the
coordinates received.
45
4.4 Results for system failure of the LED traffic light
Figure 4. 4 results for system failure of the LED traffic light
When the logic toggle was activated, the LED traffic light went off; this triggered the
controller to transmit signals via the RF module TX to the base controller. The LM044L at
the base station displays ‘fault’ and the buzzer blows alarm continuously.
46
4.5 Results for malfunctioning of a particular LED traffic light
Figure 4. 5 shows simulation results for malfunctioning of a particular LED traffic light
Considering the figure above, the main traffic control unit upon receiving GPS coordinates
from the emergency vehicle assigned green light to the respective lane (L3) even though the
two toggle switches at lane two (L2) were activated to indicate high density. The logic state
indicator for fault detection was activated to render the LED light at lane four inactive. This
triggered the controller to transmit signals via the RF module TX to the base station
controller. The buzzer blows alarm whiles the LM044L displays the status of the traffic light
as “fault”.
47
CHAPTER FIVE
Conclusion and Recommendations
5.1 Conclusion
The primary objective of this study was to design and simulate an intelligent traffic signalling
system to reduce traffic congestion, unwanted time delay, detect light malfunctioning and to
provide smooth access for emergency vehicles.
Proteus ISIS 7 was used together with MikroC in the design and simulation of the ITSS.
After the design and simulation of the system, the results show that the system was able to
change red and green times based on traffic density, detect malfunction of traffic light and
provide access for emergency vehicles.
However there were also many challenges that were met in the designing of the ITSS. The
simulation software (Proteus ISIS 7) used could not take into account certain parameters such
as behaviour of drivers and nature of roads. The limitation associated with this system is that
the RF module TX/RX which serves as the main communication medium in the simulation
cannot travel far.
5.2 Recommendations
The results obtained from this research can easily be implemented and integrated in the
existing system to help optimize traffic congestion in the city and the country at large. The
design of the ITSS can further be enhanced by replacing the infra-red sensors with imaging
systems/camera systems in other to have a wide range of detection capabilities.
Consequently the recommended future work may be oriented on studying the traffic variation
in Ghana so as to synchronize all the traffic junctions in the cities by establishing a network
among them. This will help provide useful information such as traffic situation on roads,
48
accident and vehicle tracking to motorist, security and other organisations to ensure safety
and at large reduce traffic congestion on roads in Ghana.
49
References
1. Abinaya, M. and Uthira, R., (2014), Intelligent Vehicle Control Using Wireless
Embedded System in Transportation System Based on GSM and GPS Technology,
International Journal of Computer Science and Mobile Computing (IJCSMC), Vol. 3
No. 9, PP. 244 – 258.
2. Arasan, T., (2012), Urban Transportation systems planning. Unpublished Hand Book
presented at Short Term Course organised by Kwame Nkrumah of Science and
Technology and Indian Institute of Technology Madras, Accra.
3. Ashwin, (2015), The Evolution of Traffic Lights. Science ABC blog,
http://www.scienceabc.com/throughtheyears/ready-steady-go-the-evolution-of-traffic-
lights.html [viewed on November 24, 2015 at 1:09pm].
4. Ashwini, B., Senhalata, D., Navitha, N., and Shruti, M., (2014), Vehicle Density
Sensor System to manage traffic, International Journal of Research in Engineering
and Technology (IJRET), Vol. 3 No. 3.
5. Adewoye, O., Ajibade, S. and Akin-Olayemi, T., (2014), Modelling of Fuzzy Traffic
Light Controller, International Journal of Research in Mechanical and Materials
Engineering. Vol. 1, No.1, PP. 6-14.
6. Akanegawa, M., Tanaka, Y., and Nakaga, M., (2001), Basic Study on traffic
information system using LED traffic lights, Intelligent Transportation Systems, IEEE
Transactions on Vol. 2, No. 4, PP. 197 – 203.
7. Ashok, K., (2014), Report on Traffic controller- part2(main content) , Accessed from:
http://www.slideshare.net/AshokNaidu/part-2-30424502 [viewed on February 12,
2016]
8. Baffour, R., (2010), Managing traffic congestion in Accra by overhauling the signal
timing procedures GhanaWeb. Accessed from:
50
http://www.ghanaweb.com/GhanaHompage/NewsArchive/artikel.php?ID=195642
[viewed on October 20, 2015 at 9:15am].
9. Bagheri, E., Feizi, M., Ensan, F. and Behnia, F., (2007), A novel fuzzel control model
of traffic light timing at an urban intersection. Department of Computer Science,
University of New Brunswick, Fredericton, Canada, Vol. 8.
10. David, L., (2014), Traffic Lights: There’s a better way, MIT Researchers develop an
improved system for timing of urban lights to minimize commuting times. MIT
News, http://news.mit.edu2014/traffic-lights-a-better-way-0707 . [viewed on October
15, 2015]
11. Dinesh, R. and Swapnili, K., (2012), Intelligent Traffic Signal Control System using
Embedded System, Innovative Systems Design And Engineering, Vol. 3, No. 5.
12. Electronicshub, (2015), PIC Microcontroller and its Architecture, Accessed from:
http://www.electronicshub.org/pic-microcontroller-architecture/ [viewed on
December 20, 2015]
13. Emad, A. and Aman, J., (2011), An Intelligent Traffic Light Monitor System using an
Adaptive Associative Memory, International Journal of Information Processing and
Management, Vol. 2, No. 2, PP. 23-39.
14. EngineersGarage, (2015), RF module (transmitter and receiver), Accessed from:
http://www.engineersgarage.com/electronic-components/rf-module-transmitter-
receiver [viewed on January 20, 2016]
15. Electronics Tutorials, (2016), Power Supply Accessed from: http://www.electronics-
tutorials.ws/blog/unregulated-power-supply.html [viewed on April 7, 2016].
51
16. Geetha, E., Viswannadha, V., Kavitha, G. (2014), Design of an Intelligent Auto
Traffic Signal Controller with Emergency Override, International Journal of
Engineering Science and Innovative Technology (IJESIT) Vol. 3, No. 4, PP. 670-674.
17. Hashim, N., Jaafar, A., Ali, N., Salahuddin, L., Mohamad, N., and Ibrahim, M.,
(2013), Traffic Light Control System for Emergency Vehicles Using Radio
Frequency. IOSR Journal of Engineering (IOSRJEN), Vol. 3, No. 7, PP. 43-52.
18. Ibrahim, D. and Beasley, M., (1998), The benefits of LED traffic lights in London and
the pilot test sites, Road Transport Information and control, 9th
international
conference, London, (conference public No. 454), PP. 172 – 176.
19. Kumasi Metropolitan Assembly, (2015), About the metropolis, Accessed from:
www.kma.ghanadistricts.gov.gh/ [viewed on October 16, 2015 at 1:30pm]
20. LM044L 20×4 LCD Display, Accessed from:
http://eeecb.com/up2//uploads/images/domain-db8665074e.jpg [viewed on March 15,
2016]
21. Madhavi, A. and Banga, V., (2012), Intelligent Traffic Light Control System using
Morphological Edge Detection and Fuzzy Logic, International Conference on
intelligent Computational System Vol. 7, No. 8, PP. 151-154.
22. Muhammad, A., (2011), PLC Based Intelligent Traffic Control System, International
Journal of Electrical and Computer Sciences IJECS-IJENS, Vol. 11, No. 6, PP. 69-73
23. MikroElektronika, (2015), Introduction to mikroC PRO for PIC, Accessed from:
http://www.mikroe.com/mikrobasic/overview/ [viewed on 25 January 2016]
24. Naeem, A., Muhammad, T. and Tabhir, M., (2013), Real Time Traffic Density Count
using Image processing, International Journal of Computer Applications, Vol.83, No.
9 PP.16-19.
52
25. Obiri-Yeboah, A., Amoah, A. and Acquah, P., (2013), Effect of Trotros on Saturation
Flow at Selected Signalized Intersections on the 24th
February Road, Kumasi, Ghana,
American Journal of Engineering Research (AJER). Vol. 2, No. 12, PP. 235-243.
26. Osborne, H., (2014), History of traffic lights: 100th
Anniversary of the First Electric
Traffic System, International Business Times UK (IBTimes UK) retrieved from:
http://www.ibtimes.co.uk/history-traffic-lights-100th-anniversary-first-electric-traffic-
system-1459680 [viewed on November 24, 2015 at 1:40pm].
27. PIC16F877A Microcontroller, Accessed from:
http://www.microchip.com/wwwproducts/en/PIC16F877A [viewed on November 20,
2015]
28. Proteus ISIS 7 Professional, Accessed from: http://proteus-7-professional-
software.informer.com/ [viewed on January 20, 2016]
29. Ravi, K., Abhishek, K., Pravin, K., and Nawjeet, K., (2012), Intelligent Ambulance
for Traffic City and Control Traffic Based on Its Density, undergraduate project work,
Prist University https://www.scribd.com ,[ viewed on October 10, 2015]
30. Riscin, (2015), GPS Module http://riscin.com/ [viewed on January 10, 2016]
31. Signalfan, (2015), Historical Signals: http://www.signalfan.com/history.html [viewed
on October 20, 2015].
32. Syed, A., Syed, M., Sheraz and Humera N., (2007), Fuzzy Rule Traffic Signal Control
System for Oversaturated Intersections, Master’s Thesis, Department of Computer
and Information Systems and Engineering, NED University of Engineering and
Technology, Karachi, Pakistan. Accessed
http://www.neduet.edu.pk/cise/docs/2009publication2.pdf [Viewed on November 20,
2015]
53
33. Sahar, Z., Balqees, A., Alaa, I. and Hussein, R., (2012), A wireless Mobile Phone
Approach to Traffic Signal Pre-emption for Faster Service of Emergency Vehicles.
International Journal of Computer Applications, Vol.46, No.3 PP. 35-41.
34. Sonja, K., (2012), Generating signals, moving in the right direction
http://compass.ptvgroup.com/tag/fixedtimesignalcontrol/?lang=en [viewed on
October 20, 2015 at 8:30pm]
35. Shruthi, K. and Vinodha, K., (2012), Priority Based Traffic Lights Controller Using
Wireless Sensor Networks, International Journal of Electronics Signal and Systems
(IJESS), Vol.1, No.4. PP. 58-61
36. Sarika, B. and Gajanan, P., (2013), Design of Intelligent Ambulance and Traffic
Control, International Journal of Innovative Technology and Exploring Engineering
(IJITEE), Vol.2, No.5, PP. 137-142.
37. Shanmugasundaram, M., Muthuselvi, G. and Sundar S., (2013), Implementation of
PIC16F877A Based Intelligent Smart Home System, International Journal of
Engineering and Technology (IJET), Vol. 5, No. 2, PP. 1608-1623.
38. Shweta, N. and Amit, W., (2014), Literature Survey on Density Based Signal
Management in Traffic System’, International Journal of Computer Applications and
International Conference of Quality Up-gradation in Engineering and Technology
Vol. 3, No. 5
39. Tomorrow Scientist (2016), PIC Programming And Simulation Using Proteus
Accessed from: http://tomorrowscientist.blogspot.com/2009/07/pic-programming-
and-simulations-using.html [viewed on April 8, 2016]
40. Tarun, A., (2013), Dynamic Road Traffic Signal Control System, retrieved from:
http://www.elprocus.com/dynamic-road-traffic-signal-control/ [viewed on January 3,
2016].
54
41. Traffic flow, (n.d), McGraw-Hill Dictionary of Scientific and Technical Terms, 6E.
(2003). Accessed from http://encyclopedia2.thefreedictionary.com/traffic+flow
[viewed on October 20, 2015]
42. The traffic signal museum, (2015), Eagle signal Model EF-70 Traffic controller,
Accessed from http://www.trafficsignalmuseum.com/pages/ef70html [viewed on
November 20, 2015]
43. Vikramaditya, D., Amol, P., Kshitij, P., and Rathod S., (2012), Image Processing
Based Intelligent Traffic Controller, Undergraduate Academic Research Journal
(UARJ), Vol. 1, No.1, PP. 1-17.
44. Vysakh, (2011), Architecture and Memory Organization of PIC 16F877
http://www.circuitstoday.com/pic-16f877-architecture-and-memory-organisation
[accessed on March 08, 2015 at 1:09pm]
45. William, L., (2015), the high level side event to the 70th session of the general
assembly strengthening cooperation on migration and refugee movements in the
perspective of the new development agenda retrieved from:
http://unobserver.iom.int/sites/default/files/Statement%20%20SG%20conference%20
v2_0.pdf [viewed on December 1, 2015 at 1:50pm].
46. Washington Department of Public Works Streets and Traffic Division (2015) LED
Traffic Signals: Saving Money and Energy
https://www.yakimawa.gov/services/streets/ledtrafficsignals/ [viewed on October 20,
2015 at 8:30pm]
47. Willis, L., (2015), Traffic Signal Collection, History of Traffic Signal Design
http://www.kbrhorse.net/signals/history01.html [viewed on November 15, 2015 at
2:10pm]
Appendix
Code for the main traffic unit
char started, count;
char command, value, ok;
int fault = 0;
int allow = 0;
void RF_Send(char command, char value)
{
char checksum = ~(char)(command + value);
UART1_Write(0xFF); //Start
delay_ms(10);
UART1_Write(command); //Comando
delay_ms(10);
UART1_Write(value); //Valor
delay_ms(10);
UART1_Write(checksum); //Checksum
delay_ms(10);
}
void RF_Read(char *Cmd, char *Val, char *Ok)
{
char buffer;
char checksum_byte;
*Ok = 0;
if(PIR1.RCIF)
{
buffer = UART1_Read();
if(started)
{
count++;
if(count == 1)
{
*Cmd = buffer;
}
if(count == 2)
{
*Val = buffer;
}
if(count == 3)
{
checksum_byte = buffer;
started = 0;
if(checksum_byte == ~(char)(*Cmd + *Val))
{
*Ok = 1;
}
}
}
else
{
if(buffer == 0xFF)
{
started = 1;
count = 0;
}
}
}
}
void Interrupt()
{
RF_Read(&command, &value, &ok);
if(ok == 1)
{
if(command == 'A')
{
allow = 1;
}
else
{
allow = 0;
}
}
if(INTCON.INTF)
{
fault = 1;
INTCON.INTF = 0;
//goto fault;
}
}
void RF_Init()
{
UART1_Init(9600);
Delay_ms(100);
}
void RF_Receive_Init()
{
RCIE_bit = 1;
GIE_Bit = 1;
PEIE_Bit = 1;
INTE_bit = 1;
}
void main()
{
TRISD = 0b11000000;
TRISB = 0b00000001;
TRISC = 0b10111111;
ADCON0 = 0x00;
ADCON1 = 0x0F;
PORTD = 0x00;
PORTB= 0x00;
RF_Receive_Init();
RF_Init();
SPBRG = 255;
BRGH_bit = 0;
fault = 0;
while(1)
{
//Lane 1
PORTD = 0b00001100;
PORTB = 0b00010010;
if(PORTD.F7 == 1 && PORTD.F6 == 1 )
delay_ms(6000);
else
delay_ms(3000);
PORTD = 0b00001010;
if(fault == 1 || allow == 1) goto faulting;
delay_ms(500);
//Lane 2
PORTD = 0b00100001;
PORTB = 0b00010010;
if(PORTC.F0 == 1 && PORTC.F1 == 1 )
delay_ms(6000);
else
delay_ms(3000);
PORTD = 0b00010001;
if(fault == 1 || allow == 1) goto faulting;
delay_ms(500);
//Lane 3
PORTD = 0b00001001;
PORTB = 0b00011000;
if(PORTC.F2 == 1 && PORTC.F3 == 1 )
delay_ms(6000);
else
delay_ms(3000);
PORTB = 0b00010100;
if(fault == 1 || allow == 1) goto faulting;
delay_ms(500);
//Lane 4
PORTD = 0b00001001;
PORTB = 0b01000010;
if(PORTC.F4 == 1 && PORTC.F5 == 1 )
delay_ms(6000);
else
delay_ms(3000);
PORTB = 0b00100010;
delay_ms(500);
faulting:
while(fault)
{
PORTB.F7 = 1;
PORTD = 0b00000000;
PORTB = 0b00000000;
delay_ms(500);
RF_Send( 'F', 1);
}
while(allow)
{
PORTD = 0b00001100;
PORTB = 0b00010010;
while(fault)
{
PORTD = 0b00001001;
PORTB = 0b00001001;
RF_Send( 'F', 1);
delay_ms(500);
}
delay_ms(500);
}
}
}
Code for the monitoring unit
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
char started, count;
short fault = 0;
void RF_Read(char *Cmd, char *Val, char *Ok)
{
char buffer;
char checksum_byte;
*Ok = 0;
if(PIR1.RCIF)
{
buffer = UART1_Read();
if(started)
{
count++;
if(count == 1)
{
*Cmd = buffer;
}
if(count == 2)
{
*Val = buffer;
}
if(count == 3)
{
checksum_byte = buffer;
started = 0;
if(checksum_byte == ~(char)(*Cmd + *Val))
{
*Ok = 1;
}
}
}
else
{
if(buffer == 0xFF)
{
started = 1;
count = 0;
}
}
}
}
char command, value, ok;
void Interrupt()
{
RF_Read(&command, &value, &ok);
if(ok == 1)
{
if(command == 'F')
fault = 1;
}
if(INTCON.INTF)
{
fault = 0;
INTCON.INTF = 0;
}
}
void RF_Init()
{
UART1_Init(9600);
Delay_ms(100);
}
void RF_Receive_Init()
{
RCIE_bit = 1;
GIE_Bit = 1;
PEIE_Bit = 1;
INTE_bit = 1;
}
void main()
{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,2,"Traffic Monitoring");
Lcd_Out(2,10,"By");
Lcd_Out(3,8,"Konadu");
delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,2,"Traffic Monitoring");
Lcd_Out(2,1,"--------------------");
Lcd_Out(3,1,"System: ACTIVE");
Lcd_Out(4,1,"Condition: Normal");
TRISB = 0x03;
TRISC = 0b10000000;
RF_Init();
SPBRG = 255;
BRGH_bit = 0;
RF_Receive_Init();
Sound_Init(&PORTC, 3);
Sound_Play(880, 1000); // Play sound at 880Hz for 1 second
while(1)
{
PORTB.F7 = 1;
delay_ms(500);
while(fault)
{
Lcd_Out(4,1,"Condition: Fault ");
Sound_Play(659, 250); // Frequency = 659Hz, duration = 250ms
Sound_Play(698, 250); // Frequency = 698Hz, duration = 250ms
Sound_Play(784, 250); // Frequency = 784Hz, duration = 250ms
delay_ms(100);
}
Lcd_Out(4,1,"Condition: Normal");
PORTB.F7 = 0;
delay_ms(500);
}
}
Code for the emergency unit
// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
char *Output;
char* codetxt_to_ramtxt(const char* ctxt){
static char txt[20];
char i;
for(i =0; txt[i] = ctxt[i]; i++);
return txt;
}
void RF_Send(char command, char value)
{
char checksum = ~(char)(command + value);
UART1_Write(0xFF); //Start
delay_ms(10);
UART1_Write(command); //Comando
delay_ms(10);
UART1_Write(value); //Valor
delay_ms(10);
UART1_Write(checksum); //Checksum
delay_ms(10);
}
void RF_Init()
{
UART1_Init(9600);
Delay_ms(100);
}
void main()
{
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,2,codetxt_to_ramtxt("Emergency Override"));
Lcd_Out(2,10,codetxt_to_ramtxt("By"));
Lcd_Out(3,8,codetxt_to_ramtxt("Konadu"));
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,2,codetxt_to_ramtxt("Emergency Override"));
Lcd_Out(2,2,codetxt_to_ramtxt("------------------"));
Lcd_Out(3,2,codetxt_to_ramtxt("System: ACTIVE"));
Lcd_Out(4,2,codetxt_to_ramtxt("Status: IDEAL"));
ADCON1 = 0x0F; //Desativa as portas analógicas(PORTA e PORTB)
TRISB = 3;
TRISD = 0x1F;
RF_Init();
SPBRG = 255;
BRGH_bit = 0;
while(1)
{
while(PORTD.F4 == 1)
{
//Lcd_Out(3,2,"Direction: NORTH");
Lcd_Out(3,2,codetxt_to_ramtxt("Sending: "));
Lcd_Out(4,2,codetxt_to_ramtxt("GPS Coordinates..."));
if (UART1_Data_Ready() == 1) { // if data is received
UART1_Read_Text(output, ",", 20); // reads text until 'OK' is found
UART1_Write_Text(output); // sends back text
}
RF_Send('A', 1);
}
Lcd_Out(3,2,codetxt_to_ramtxt("System: ACTIVE "));
Lcd_Out(4,2,codetxt_to_ramtxt("Status: IDEAL "));
RF_Send('B', 1);
delay_ms(500);
}
}